/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. * */ #ifndef SHARE_VM_OPTO_VALUETYPENODE_HPP #define SHARE_VM_OPTO_VALUETYPENODE_HPP #include "opto/node.hpp" #include "opto/connode.hpp" class GraphKit; //------------------------------ValueTypeNode------------------------------------- // Node representing a value type in C2 IR class ValueTypeNode : public TypeNode { private: ValueTypeNode(const TypeValueType* t, Node* oop) : TypeNode(t, Values + t->value_klass()->param_count()) { init_class_id(Class_ValueType); init_req(Oop, oop); } // Get the klass defining the field layout of the value type ciValueKlass* get_value_klass() const { return type()->is_valuetype()->value_klass(); } // Initialize the value type by loading its field values from memory void load_values(PhaseGVN& gvn, Node* mem, ciInstanceKlass* holder, Node* base, int base_offset = 0); // Store the field values to memory void store_values(GraphKit* kit, ciInstanceKlass* holder, Node* base, int base_offset = 0) const; enum { Control, // Control input Oop, // Oop of TypeValueTypePtr Values // Nodes corresponding to field values }; public: // Create a new ValueTypeNode with uninitialized values static ValueTypeNode* make(PhaseGVN& gvn, ciValueKlass* klass); // Create a new ValueTypeNode and load its values from an oop static Node* make(PhaseGVN& gvn, Node* mem, Node* oop); // Create a new ValueTypeNode and load its values from a flattened value type field static Node* make(PhaseGVN& gvn, ciValueKlass* klass, Node* mem, ciInstanceKlass* holder, Node* obj, int field_offset); // Support for control flow merges ValueTypeNode* clone_with_phis(PhaseGVN& gvn, Node* region); Node* merge_with(GraphKit* kit, const ValueTypeNode* other, int pnum); // Store the value type to memory if not yet allocated and returns the oop Node* store_to_memory(GraphKit* kit); // Store the value type in a field of an object void store_to_field(GraphKit* kit, ciInstanceKlass* holder, Node* obj, int field_offset) const; // Get oop for heap allocated value type (may be TypePtr::NULL_PTR) Node* get_oop() const { return in(Oop); } void set_oop(Node* oop) { set_req(Oop, oop); } // Value type fields uint field_count() const { return req() - Values; } Node* get_field_value(uint index) const; Node* get_field_value_by_offset(int offset, bool recursive = false) const; void set_field_value(uint index, Node* value); int get_field_offset(uint index) const; ciType* get_field_type(uint index) const; // Replace ValueTypeNodes in debug info at safepoints with SafePointScalarObjectNodes void make_scalar_in_safepoints(Compile* C); uint set_arguments_for_java_call(CallJavaNode* call, int base_input, const GraphKit& kit, ciValueKlass* base_vk = NULL, int base_offset = 0); virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); virtual int Opcode() const; #ifndef PRODUCT virtual void dump_spec(outputStream* st) const; #endif }; #endif // SHARE_VM_OPTO_VALUETYPENODE_HPP