duke@435: /* never@2486: * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_C1_C1_INSTRUCTION_HPP stefank@2314: #define SHARE_VM_C1_C1_INSTRUCTION_HPP stefank@2314: stefank@2314: #include "c1/c1_Compilation.hpp" stefank@2314: #include "c1/c1_LIR.hpp" stefank@2314: #include "c1/c1_ValueType.hpp" stefank@2314: #include "ci/ciField.hpp" stefank@2314: duke@435: // Predefined classes duke@435: class ciField; duke@435: class ValueStack; duke@435: class InstructionPrinter; duke@435: class IRScope; duke@435: class LIR_OprDesc; duke@435: typedef LIR_OprDesc* LIR_Opr; duke@435: duke@435: duke@435: // Instruction class hierarchy duke@435: // duke@435: // All leaf classes in the class hierarchy are concrete classes duke@435: // (i.e., are instantiated). All other classes are abstract and duke@435: // serve factoring. duke@435: duke@435: class Instruction; duke@435: class Phi; duke@435: class Local; duke@435: class Constant; duke@435: class AccessField; duke@435: class LoadField; duke@435: class StoreField; duke@435: class AccessArray; duke@435: class ArrayLength; duke@435: class AccessIndexed; duke@435: class LoadIndexed; duke@435: class StoreIndexed; duke@435: class NegateOp; duke@435: class Op2; duke@435: class ArithmeticOp; duke@435: class ShiftOp; duke@435: class LogicOp; duke@435: class CompareOp; duke@435: class IfOp; duke@435: class Convert; duke@435: class NullCheck; duke@435: class OsrEntry; duke@435: class ExceptionObject; duke@435: class StateSplit; duke@435: class Invoke; duke@435: class NewInstance; duke@435: class NewArray; duke@435: class NewTypeArray; duke@435: class NewObjectArray; duke@435: class NewMultiArray; duke@435: class TypeCheck; duke@435: class CheckCast; duke@435: class InstanceOf; duke@435: class AccessMonitor; duke@435: class MonitorEnter; duke@435: class MonitorExit; duke@435: class Intrinsic; duke@435: class BlockBegin; duke@435: class BlockEnd; duke@435: class Goto; duke@435: class If; duke@435: class IfInstanceOf; duke@435: class Switch; duke@435: class TableSwitch; duke@435: class LookupSwitch; duke@435: class Return; duke@435: class Throw; duke@435: class Base; duke@435: class RoundFP; duke@435: class UnsafeOp; duke@435: class UnsafeRawOp; duke@435: class UnsafeGetRaw; duke@435: class UnsafePutRaw; duke@435: class UnsafeObjectOp; duke@435: class UnsafeGetObject; duke@435: class UnsafePutObject; duke@435: class UnsafePrefetch; duke@435: class UnsafePrefetchRead; duke@435: class UnsafePrefetchWrite; duke@435: class ProfileCall; iveresov@2138: class ProfileInvoke; never@2486: class RuntimeCall; duke@435: duke@435: // A Value is a reference to the instruction creating the value duke@435: typedef Instruction* Value; duke@435: define_array(ValueArray, Value) duke@435: define_stack(Values, ValueArray) duke@435: duke@435: define_array(ValueStackArray, ValueStack*) duke@435: define_stack(ValueStackStack, ValueStackArray) duke@435: duke@435: // BlockClosure is the base class for block traversal/iteration. duke@435: duke@435: class BlockClosure: public CompilationResourceObj { duke@435: public: duke@435: virtual void block_do(BlockBegin* block) = 0; duke@435: }; duke@435: duke@435: iveresov@1939: // A simple closure class for visiting the values of an Instruction iveresov@1939: class ValueVisitor: public StackObj { iveresov@1939: public: iveresov@1939: virtual void visit(Value* v) = 0; iveresov@1939: }; iveresov@1939: iveresov@1939: duke@435: // Some array and list classes duke@435: define_array(BlockBeginArray, BlockBegin*) duke@435: define_stack(_BlockList, BlockBeginArray) duke@435: duke@435: class BlockList: public _BlockList { duke@435: public: duke@435: BlockList(): _BlockList() {} duke@435: BlockList(const int size): _BlockList(size) {} duke@435: BlockList(const int size, BlockBegin* init): _BlockList(size, init) {} duke@435: duke@435: void iterate_forward(BlockClosure* closure); duke@435: void iterate_backward(BlockClosure* closure); duke@435: void blocks_do(void f(BlockBegin*)); iveresov@1939: void values_do(ValueVisitor* f); duke@435: void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN; duke@435: }; duke@435: duke@435: duke@435: // InstructionVisitors provide type-based dispatch for instructions. duke@435: // For each concrete Instruction class X, a virtual function do_X is duke@435: // provided. Functionality that needs to be implemented for all classes duke@435: // (e.g., printing, code generation) is factored out into a specialised duke@435: // visitor instead of added to the Instruction classes itself. duke@435: duke@435: class InstructionVisitor: public StackObj { duke@435: public: duke@435: virtual void do_Phi (Phi* x) = 0; duke@435: virtual void do_Local (Local* x) = 0; duke@435: virtual void do_Constant (Constant* x) = 0; duke@435: virtual void do_LoadField (LoadField* x) = 0; duke@435: virtual void do_StoreField (StoreField* x) = 0; duke@435: virtual void do_ArrayLength (ArrayLength* x) = 0; duke@435: virtual void do_LoadIndexed (LoadIndexed* x) = 0; duke@435: virtual void do_StoreIndexed (StoreIndexed* x) = 0; duke@435: virtual void do_NegateOp (NegateOp* x) = 0; duke@435: virtual void do_ArithmeticOp (ArithmeticOp* x) = 0; duke@435: virtual void do_ShiftOp (ShiftOp* x) = 0; duke@435: virtual void do_LogicOp (LogicOp* x) = 0; duke@435: virtual void do_CompareOp (CompareOp* x) = 0; duke@435: virtual void do_IfOp (IfOp* x) = 0; duke@435: virtual void do_Convert (Convert* x) = 0; duke@435: virtual void do_NullCheck (NullCheck* x) = 0; duke@435: virtual void do_Invoke (Invoke* x) = 0; duke@435: virtual void do_NewInstance (NewInstance* x) = 0; duke@435: virtual void do_NewTypeArray (NewTypeArray* x) = 0; duke@435: virtual void do_NewObjectArray (NewObjectArray* x) = 0; duke@435: virtual void do_NewMultiArray (NewMultiArray* x) = 0; duke@435: virtual void do_CheckCast (CheckCast* x) = 0; duke@435: virtual void do_InstanceOf (InstanceOf* x) = 0; duke@435: virtual void do_MonitorEnter (MonitorEnter* x) = 0; duke@435: virtual void do_MonitorExit (MonitorExit* x) = 0; duke@435: virtual void do_Intrinsic (Intrinsic* x) = 0; duke@435: virtual void do_BlockBegin (BlockBegin* x) = 0; duke@435: virtual void do_Goto (Goto* x) = 0; duke@435: virtual void do_If (If* x) = 0; duke@435: virtual void do_IfInstanceOf (IfInstanceOf* x) = 0; duke@435: virtual void do_TableSwitch (TableSwitch* x) = 0; duke@435: virtual void do_LookupSwitch (LookupSwitch* x) = 0; duke@435: virtual void do_Return (Return* x) = 0; duke@435: virtual void do_Throw (Throw* x) = 0; duke@435: virtual void do_Base (Base* x) = 0; duke@435: virtual void do_OsrEntry (OsrEntry* x) = 0; duke@435: virtual void do_ExceptionObject(ExceptionObject* x) = 0; duke@435: virtual void do_RoundFP (RoundFP* x) = 0; duke@435: virtual void do_UnsafeGetRaw (UnsafeGetRaw* x) = 0; duke@435: virtual void do_UnsafePutRaw (UnsafePutRaw* x) = 0; duke@435: virtual void do_UnsafeGetObject(UnsafeGetObject* x) = 0; duke@435: virtual void do_UnsafePutObject(UnsafePutObject* x) = 0; duke@435: virtual void do_UnsafePrefetchRead (UnsafePrefetchRead* x) = 0; duke@435: virtual void do_UnsafePrefetchWrite(UnsafePrefetchWrite* x) = 0; duke@435: virtual void do_ProfileCall (ProfileCall* x) = 0; iveresov@2138: virtual void do_ProfileInvoke (ProfileInvoke* x) = 0; never@2486: virtual void do_RuntimeCall (RuntimeCall* x) = 0; duke@435: }; duke@435: duke@435: duke@435: // Hashing support duke@435: // duke@435: // Note: This hash functions affect the performance duke@435: // of ValueMap - make changes carefully! duke@435: duke@435: #define HASH1(x1 ) ((intx)(x1)) duke@435: #define HASH2(x1, x2 ) ((HASH1(x1 ) << 7) ^ HASH1(x2)) duke@435: #define HASH3(x1, x2, x3 ) ((HASH2(x1, x2 ) << 7) ^ HASH1(x3)) duke@435: #define HASH4(x1, x2, x3, x4) ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4)) duke@435: duke@435: duke@435: // The following macros are used to implement instruction-specific hashing. duke@435: // By default, each instruction implements hash() and is_equal(Value), used duke@435: // for value numbering/common subexpression elimination. The default imple- duke@435: // mentation disables value numbering. Each instruction which can be value- duke@435: // numbered, should define corresponding hash() and is_equal(Value) functions duke@435: // via the macros below. The f arguments specify all the values/op codes, etc. duke@435: // that need to be identical for two instructions to be identical. duke@435: // duke@435: // Note: The default implementation of hash() returns 0 in order to indicate duke@435: // that the instruction should not be considered for value numbering. duke@435: // The currently used hash functions do not guarantee that never a 0 duke@435: // is produced. While this is still correct, it may be a performance duke@435: // bug (no value numbering for that node). However, this situation is duke@435: // so unlikely, that we are not going to handle it specially. duke@435: duke@435: #define HASHING1(class_name, enabled, f1) \ duke@435: virtual intx hash() const { \ duke@435: return (enabled) ? HASH2(name(), f1) : 0; \ duke@435: } \ duke@435: virtual bool is_equal(Value v) const { \ duke@435: if (!(enabled) ) return false; \ duke@435: class_name* _v = v->as_##class_name(); \ duke@435: if (_v == NULL ) return false; \ duke@435: if (f1 != _v->f1) return false; \ duke@435: return true; \ duke@435: } \ duke@435: duke@435: duke@435: #define HASHING2(class_name, enabled, f1, f2) \ duke@435: virtual intx hash() const { \ duke@435: return (enabled) ? HASH3(name(), f1, f2) : 0; \ duke@435: } \ duke@435: virtual bool is_equal(Value v) const { \ duke@435: if (!(enabled) ) return false; \ duke@435: class_name* _v = v->as_##class_name(); \ duke@435: if (_v == NULL ) return false; \ duke@435: if (f1 != _v->f1) return false; \ duke@435: if (f2 != _v->f2) return false; \ duke@435: return true; \ duke@435: } \ duke@435: duke@435: duke@435: #define HASHING3(class_name, enabled, f1, f2, f3) \ duke@435: virtual intx hash() const { \ duke@435: return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \ duke@435: } \ duke@435: virtual bool is_equal(Value v) const { \ duke@435: if (!(enabled) ) return false; \ duke@435: class_name* _v = v->as_##class_name(); \ duke@435: if (_v == NULL ) return false; \ duke@435: if (f1 != _v->f1) return false; \ duke@435: if (f2 != _v->f2) return false; \ duke@435: if (f3 != _v->f3) return false; \ duke@435: return true; \ duke@435: } \ duke@435: duke@435: duke@435: // The mother of all instructions... duke@435: duke@435: class Instruction: public CompilationResourceObj { duke@435: private: duke@435: int _id; // the unique instruction id roland@2174: #ifndef PRODUCT roland@2174: int _printable_bci; // the bci of the instruction for printing roland@2174: #endif duke@435: int _use_count; // the number of instructions refering to this value (w/o prev/next); only roots can have use count = 0 or > 1 duke@435: int _pin_state; // set of PinReason describing the reason for pinning duke@435: ValueType* _type; // the instruction value type duke@435: Instruction* _next; // the next instruction if any (NULL for BlockEnd instructions) duke@435: Instruction* _subst; // the substitution instruction if any duke@435: LIR_Opr _operand; // LIR specific information duke@435: unsigned int _flags; // Flag bits duke@435: roland@2174: ValueStack* _state_before; // Copy of state with input operands still on stack (or NULL) roland@2174: ValueStack* _exception_state; // Copy of state for exception handling duke@435: XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction duke@435: duke@435: friend class UseCountComputer; iveresov@1939: friend class BlockBegin; duke@435: roland@2174: void update_exception_state(ValueStack* state); roland@2174: roland@2174: bool has_printable_bci() const { return NOT_PRODUCT(_printable_bci != -99) PRODUCT_ONLY(false); } roland@2174: duke@435: protected: duke@435: void set_type(ValueType* type) { duke@435: assert(type != NULL, "type must exist"); duke@435: _type = type; duke@435: } duke@435: duke@435: public: iveresov@1939: void* operator new(size_t size) { iveresov@1939: Compilation* c = Compilation::current(); iveresov@1939: void* res = c->arena()->Amalloc(size); iveresov@1939: ((Instruction*)res)->_id = c->get_next_id(); iveresov@1939: return res; iveresov@1939: } iveresov@1939: bobv@2508: static const int no_bci = -99; bobv@2508: duke@435: enum InstructionFlag { duke@435: NeedsNullCheckFlag = 0, duke@435: CanTrapFlag, duke@435: DirectCompareFlag, duke@435: IsEliminatedFlag, duke@435: IsInitializedFlag, duke@435: IsLoadedFlag, duke@435: IsSafepointFlag, duke@435: IsStaticFlag, duke@435: IsStrictfpFlag, duke@435: NeedsStoreCheckFlag, duke@435: NeedsWriteBarrierFlag, duke@435: PreservesStateFlag, duke@435: TargetIsFinalFlag, duke@435: TargetIsLoadedFlag, duke@435: TargetIsStrictfpFlag, duke@435: UnorderedIsTrueFlag, duke@435: NeedsPatchingFlag, duke@435: ThrowIncompatibleClassChangeErrorFlag, duke@435: ProfileMDOFlag, roland@2174: IsLinkedInBlockFlag, duke@435: InstructionLastFlag duke@435: }; duke@435: duke@435: public: duke@435: bool check_flag(InstructionFlag id) const { return (_flags & (1 << id)) != 0; } duke@435: void set_flag(InstructionFlag id, bool f) { _flags = f ? (_flags | (1 << id)) : (_flags & ~(1 << id)); }; duke@435: duke@435: // 'globally' used condition values duke@435: enum Condition { duke@435: eql, neq, lss, leq, gtr, geq duke@435: }; duke@435: duke@435: // Instructions may be pinned for many reasons and under certain conditions duke@435: // with enough knowledge it's possible to safely unpin them. duke@435: enum PinReason { duke@435: PinUnknown = 1 << 0 duke@435: , PinExplicitNullCheck = 1 << 3 duke@435: , PinStackForStateSplit= 1 << 12 duke@435: , PinStateSplitConstructor= 1 << 13 duke@435: , PinGlobalValueNumbering= 1 << 14 duke@435: }; duke@435: duke@435: static Condition mirror(Condition cond); duke@435: static Condition negate(Condition cond); duke@435: duke@435: // initialization iveresov@1939: static int number_of_instructions() { iveresov@1939: return Compilation::current()->number_of_instructions(); iveresov@1939: } duke@435: duke@435: // creation roland@2179: Instruction(ValueType* type, ValueStack* state_before = NULL, bool type_is_constant = false) roland@2174: : _use_count(0) roland@2174: #ifndef PRODUCT roland@2174: , _printable_bci(-99) roland@2174: #endif duke@435: , _pin_state(0) duke@435: , _type(type) duke@435: , _next(NULL) duke@435: , _subst(NULL) duke@435: , _flags(0) duke@435: , _operand(LIR_OprFact::illegalOpr) roland@2174: , _state_before(state_before) duke@435: , _exception_handlers(NULL) duke@435: { roland@2174: check_state(state_before); duke@435: assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist"); roland@2174: update_exception_state(_state_before); duke@435: } duke@435: duke@435: // accessors duke@435: int id() const { return _id; } roland@2174: #ifndef PRODUCT roland@2174: int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; } roland@2174: void set_printable_bci(int bci) { NOT_PRODUCT(_printable_bci = bci;) } roland@2174: #endif duke@435: int use_count() const { return _use_count; } duke@435: int pin_state() const { return _pin_state; } duke@435: bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; } duke@435: ValueType* type() const { return _type; } duke@435: Instruction* prev(BlockBegin* block); // use carefully, expensive operation duke@435: Instruction* next() const { return _next; } duke@435: bool has_subst() const { return _subst != NULL; } duke@435: Instruction* subst() { return _subst == NULL ? this : _subst->subst(); } duke@435: LIR_Opr operand() const { return _operand; } duke@435: duke@435: void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); } duke@435: bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); } roland@2174: bool is_linked() const { return check_flag(IsLinkedInBlockFlag); } roland@2174: bool can_be_linked() { return as_Local() == NULL && as_Phi() == NULL; } duke@435: duke@435: bool has_uses() const { return use_count() > 0; } roland@2174: ValueStack* state_before() const { return _state_before; } roland@2174: ValueStack* exception_state() const { return _exception_state; } roland@2174: virtual bool needs_exception_state() const { return true; } duke@435: XHandlers* exception_handlers() const { return _exception_handlers; } duke@435: duke@435: // manipulation duke@435: void pin(PinReason reason) { _pin_state |= reason; } duke@435: void pin() { _pin_state |= PinUnknown; } duke@435: // DANGEROUS: only used by EliminateStores duke@435: void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; } roland@2174: roland@2174: Instruction* set_next(Instruction* next) { roland@2174: assert(next->has_printable_bci(), "_printable_bci should have been set"); roland@2174: assert(next != NULL, "must not be NULL"); roland@2174: assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next"); roland@2174: assert(next->can_be_linked(), "shouldn't link these instructions into list"); roland@2174: roland@2174: next->set_flag(Instruction::IsLinkedInBlockFlag, true); roland@2174: _next = next; roland@2174: return next; roland@2174: } duke@435: duke@435: Instruction* set_next(Instruction* next, int bci) { roland@2174: #ifndef PRODUCT roland@2174: next->set_printable_bci(bci); roland@2174: #endif roland@2174: return set_next(next); duke@435: } duke@435: duke@435: void set_subst(Instruction* subst) { duke@435: assert(subst == NULL || duke@435: type()->base() == subst->type()->base() || duke@435: subst->type()->base() == illegalType, "type can't change"); duke@435: _subst = subst; duke@435: } duke@435: void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; } roland@2174: void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; } duke@435: duke@435: // machine-specifics duke@435: void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; } duke@435: void clear_operand() { _operand = LIR_OprFact::illegalOpr; } duke@435: duke@435: // generic duke@435: virtual Instruction* as_Instruction() { return this; } // to satisfy HASHING1 macro roland@2254: virtual Phi* as_Phi() { return NULL; } duke@435: virtual Local* as_Local() { return NULL; } duke@435: virtual Constant* as_Constant() { return NULL; } duke@435: virtual AccessField* as_AccessField() { return NULL; } duke@435: virtual LoadField* as_LoadField() { return NULL; } duke@435: virtual StoreField* as_StoreField() { return NULL; } duke@435: virtual AccessArray* as_AccessArray() { return NULL; } duke@435: virtual ArrayLength* as_ArrayLength() { return NULL; } duke@435: virtual AccessIndexed* as_AccessIndexed() { return NULL; } duke@435: virtual LoadIndexed* as_LoadIndexed() { return NULL; } duke@435: virtual StoreIndexed* as_StoreIndexed() { return NULL; } duke@435: virtual NegateOp* as_NegateOp() { return NULL; } duke@435: virtual Op2* as_Op2() { return NULL; } duke@435: virtual ArithmeticOp* as_ArithmeticOp() { return NULL; } duke@435: virtual ShiftOp* as_ShiftOp() { return NULL; } duke@435: virtual LogicOp* as_LogicOp() { return NULL; } duke@435: virtual CompareOp* as_CompareOp() { return NULL; } duke@435: virtual IfOp* as_IfOp() { return NULL; } duke@435: virtual Convert* as_Convert() { return NULL; } duke@435: virtual NullCheck* as_NullCheck() { return NULL; } duke@435: virtual OsrEntry* as_OsrEntry() { return NULL; } duke@435: virtual StateSplit* as_StateSplit() { return NULL; } duke@435: virtual Invoke* as_Invoke() { return NULL; } duke@435: virtual NewInstance* as_NewInstance() { return NULL; } duke@435: virtual NewArray* as_NewArray() { return NULL; } duke@435: virtual NewTypeArray* as_NewTypeArray() { return NULL; } duke@435: virtual NewObjectArray* as_NewObjectArray() { return NULL; } duke@435: virtual NewMultiArray* as_NewMultiArray() { return NULL; } duke@435: virtual TypeCheck* as_TypeCheck() { return NULL; } duke@435: virtual CheckCast* as_CheckCast() { return NULL; } duke@435: virtual InstanceOf* as_InstanceOf() { return NULL; } duke@435: virtual AccessMonitor* as_AccessMonitor() { return NULL; } duke@435: virtual MonitorEnter* as_MonitorEnter() { return NULL; } duke@435: virtual MonitorExit* as_MonitorExit() { return NULL; } duke@435: virtual Intrinsic* as_Intrinsic() { return NULL; } duke@435: virtual BlockBegin* as_BlockBegin() { return NULL; } duke@435: virtual BlockEnd* as_BlockEnd() { return NULL; } duke@435: virtual Goto* as_Goto() { return NULL; } duke@435: virtual If* as_If() { return NULL; } duke@435: virtual IfInstanceOf* as_IfInstanceOf() { return NULL; } duke@435: virtual TableSwitch* as_TableSwitch() { return NULL; } duke@435: virtual LookupSwitch* as_LookupSwitch() { return NULL; } duke@435: virtual Return* as_Return() { return NULL; } duke@435: virtual Throw* as_Throw() { return NULL; } duke@435: virtual Base* as_Base() { return NULL; } duke@435: virtual RoundFP* as_RoundFP() { return NULL; } duke@435: virtual ExceptionObject* as_ExceptionObject() { return NULL; } duke@435: virtual UnsafeOp* as_UnsafeOp() { return NULL; } duke@435: duke@435: virtual void visit(InstructionVisitor* v) = 0; duke@435: duke@435: virtual bool can_trap() const { return false; } duke@435: iveresov@1939: virtual void input_values_do(ValueVisitor* f) = 0; roland@2174: virtual void state_values_do(ValueVisitor* f); iveresov@1939: virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ } iveresov@1939: void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); } duke@435: duke@435: virtual ciType* exact_type() const { return NULL; } duke@435: virtual ciType* declared_type() const { return NULL; } duke@435: duke@435: // hashing duke@435: virtual const char* name() const = 0; duke@435: HASHING1(Instruction, false, id()) // hashing disabled by default duke@435: duke@435: // debugging roland@2174: static void check_state(ValueStack* state) PRODUCT_RETURN; duke@435: void print() PRODUCT_RETURN; duke@435: void print_line() PRODUCT_RETURN; duke@435: void print(InstructionPrinter& ip) PRODUCT_RETURN; duke@435: }; duke@435: duke@435: duke@435: // The following macros are used to define base (i.e., non-leaf) duke@435: // and leaf instruction classes. They define class-name related duke@435: // generic functionality in one place. duke@435: duke@435: #define BASE(class_name, super_class_name) \ duke@435: class class_name: public super_class_name { \ duke@435: public: \ duke@435: virtual class_name* as_##class_name() { return this; } \ duke@435: duke@435: duke@435: #define LEAF(class_name, super_class_name) \ duke@435: BASE(class_name, super_class_name) \ duke@435: public: \ duke@435: virtual const char* name() const { return #class_name; } \ duke@435: virtual void visit(InstructionVisitor* v) { v->do_##class_name(this); } \ duke@435: duke@435: duke@435: // Debugging support duke@435: iveresov@1939: duke@435: #ifdef ASSERT iveresov@1939: class AssertValues: public ValueVisitor { iveresov@1939: void visit(Value* x) { assert((*x) != NULL, "value must exist"); } iveresov@1939: }; iveresov@1939: #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); } duke@435: #else duke@435: #define ASSERT_VALUES duke@435: #endif // ASSERT duke@435: duke@435: duke@435: // A Phi is a phi function in the sense of SSA form. It stands for duke@435: // the value of a local variable at the beginning of a join block. duke@435: // A Phi consists of n operands, one for every incoming branch. duke@435: duke@435: LEAF(Phi, Instruction) duke@435: private: duke@435: BlockBegin* _block; // the block to which the phi function belongs duke@435: int _pf_flags; // the flags of the phi function duke@435: int _index; // to value on operand stack (index < 0) or to local duke@435: public: duke@435: // creation duke@435: Phi(ValueType* type, BlockBegin* b, int index) duke@435: : Instruction(type->base()) duke@435: , _pf_flags(0) duke@435: , _block(b) duke@435: , _index(index) duke@435: { duke@435: if (type->is_illegal()) { duke@435: make_illegal(); duke@435: } duke@435: } duke@435: duke@435: // flags duke@435: enum Flag { duke@435: no_flag = 0, duke@435: visited = 1 << 0, duke@435: cannot_simplify = 1 << 1 duke@435: }; duke@435: duke@435: // accessors duke@435: bool is_local() const { return _index >= 0; } duke@435: bool is_on_stack() const { return !is_local(); } duke@435: int local_index() const { assert(is_local(), ""); return _index; } duke@435: int stack_index() const { assert(is_on_stack(), ""); return -(_index+1); } duke@435: duke@435: Value operand_at(int i) const; duke@435: int operand_count() const; duke@435: duke@435: BlockBegin* block() const { return _block; } duke@435: duke@435: void set(Flag f) { _pf_flags |= f; } duke@435: void clear(Flag f) { _pf_flags &= ~f; } duke@435: bool is_set(Flag f) const { return (_pf_flags & f) != 0; } duke@435: duke@435: // Invalidates phis corresponding to merges of locals of two different types duke@435: // (these should never be referenced, otherwise the bytecodes are illegal) duke@435: void make_illegal() { duke@435: set(cannot_simplify); duke@435: set_type(illegalType); duke@435: } duke@435: duke@435: bool is_illegal() const { duke@435: return type()->is_illegal(); duke@435: } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { duke@435: } duke@435: }; duke@435: duke@435: duke@435: // A local is a placeholder for an incoming argument to a function call. duke@435: LEAF(Local, Instruction) duke@435: private: duke@435: int _java_index; // the local index within the method to which the local belongs duke@435: public: duke@435: // creation duke@435: Local(ValueType* type, int index) duke@435: : Instruction(type) duke@435: , _java_index(index) duke@435: {} duke@435: duke@435: // accessors duke@435: int java_index() const { return _java_index; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { /* no values */ } duke@435: }; duke@435: duke@435: duke@435: LEAF(Constant, Instruction) duke@435: public: duke@435: // creation duke@435: Constant(ValueType* type): roland@2174: Instruction(type, NULL, true) roland@2174: { duke@435: assert(type->is_constant(), "must be a constant"); duke@435: } duke@435: roland@2174: Constant(ValueType* type, ValueStack* state_before): roland@2174: Instruction(type, state_before, true) roland@2174: { roland@2174: assert(state_before != NULL, "only used for constants which need patching"); duke@435: assert(type->is_constant(), "must be a constant"); duke@435: // since it's patching it needs to be pinned duke@435: pin(); duke@435: } duke@435: roland@2174: virtual bool can_trap() const { return state_before() != NULL; } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { /* no values */ } duke@435: duke@435: virtual intx hash() const; duke@435: virtual bool is_equal(Value v) const; duke@435: roland@2254: roland@2254: enum CompareResult { not_comparable = -1, cond_false, cond_true }; roland@2254: roland@2254: virtual CompareResult compare(Instruction::Condition condition, Value right) const; roland@2254: BlockBegin* compare(Instruction::Condition cond, Value right, roland@2254: BlockBegin* true_sux, BlockBegin* false_sux) const { roland@2254: switch (compare(cond, right)) { roland@2254: case not_comparable: roland@2254: return NULL; roland@2254: case cond_false: roland@2254: return false_sux; roland@2254: case cond_true: roland@2254: return true_sux; roland@2254: default: roland@2254: ShouldNotReachHere(); roland@2254: return NULL; roland@2254: } roland@2254: } duke@435: }; duke@435: duke@435: duke@435: BASE(AccessField, Instruction) duke@435: private: duke@435: Value _obj; duke@435: int _offset; duke@435: ciField* _field; duke@435: NullCheck* _explicit_null_check; // For explicit null check elimination duke@435: duke@435: public: duke@435: // creation roland@2174: AccessField(Value obj, int offset, ciField* field, bool is_static, duke@435: ValueStack* state_before, bool is_loaded, bool is_initialized) roland@2174: : Instruction(as_ValueType(field->type()->basic_type()), state_before) duke@435: , _obj(obj) duke@435: , _offset(offset) duke@435: , _field(field) duke@435: , _explicit_null_check(NULL) duke@435: { duke@435: set_needs_null_check(!is_static); duke@435: set_flag(IsLoadedFlag, is_loaded); duke@435: set_flag(IsInitializedFlag, is_initialized); duke@435: set_flag(IsStaticFlag, is_static); duke@435: ASSERT_VALUES duke@435: if (!is_loaded || (PatchALot && !field->is_volatile())) { duke@435: // need to patch if the holder wasn't loaded or we're testing duke@435: // using PatchALot. Don't allow PatchALot for fields which are duke@435: // known to be volatile they aren't patchable. duke@435: set_flag(NeedsPatchingFlag, true); duke@435: } duke@435: // pin of all instructions with memory access duke@435: pin(); duke@435: } duke@435: duke@435: // accessors duke@435: Value obj() const { return _obj; } duke@435: int offset() const { return _offset; } duke@435: ciField* field() const { return _field; } duke@435: BasicType field_type() const { return _field->type()->basic_type(); } duke@435: bool is_static() const { return check_flag(IsStaticFlag); } duke@435: bool is_loaded() const { return check_flag(IsLoadedFlag); } duke@435: bool is_initialized() const { return check_flag(IsInitializedFlag); } duke@435: NullCheck* explicit_null_check() const { return _explicit_null_check; } duke@435: bool needs_patching() const { return check_flag(NeedsPatchingFlag); } duke@435: duke@435: // manipulation roland@2174: duke@435: // Under certain circumstances, if a previous NullCheck instruction duke@435: // proved the target object non-null, we can eliminate the explicit duke@435: // null check and do an implicit one, simply specifying the debug duke@435: // information from the NullCheck. This field should only be consulted duke@435: // if needs_null_check() is true. duke@435: void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return needs_null_check() || needs_patching(); } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } duke@435: }; duke@435: duke@435: duke@435: LEAF(LoadField, AccessField) duke@435: public: duke@435: // creation roland@2174: LoadField(Value obj, int offset, ciField* field, bool is_static, duke@435: ValueStack* state_before, bool is_loaded, bool is_initialized) roland@2174: : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized) duke@435: {} duke@435: duke@435: ciType* declared_type() const; duke@435: ciType* exact_type() const; duke@435: duke@435: // generic duke@435: HASHING2(LoadField, is_loaded() && !field()->is_volatile(), obj()->subst(), offset()) // cannot be eliminated if not yet loaded or if volatile duke@435: }; duke@435: duke@435: duke@435: LEAF(StoreField, AccessField) duke@435: private: duke@435: Value _value; duke@435: duke@435: public: duke@435: // creation roland@2174: StoreField(Value obj, int offset, ciField* field, Value value, bool is_static, duke@435: ValueStack* state_before, bool is_loaded, bool is_initialized) roland@2174: : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized) duke@435: , _value(value) duke@435: { duke@435: set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object()); duke@435: ASSERT_VALUES duke@435: pin(); duke@435: } duke@435: duke@435: // accessors duke@435: Value value() const { return _value; } duke@435: bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { AccessField::input_values_do(f); f->visit(&_value); } duke@435: }; duke@435: duke@435: duke@435: BASE(AccessArray, Instruction) duke@435: private: duke@435: Value _array; duke@435: duke@435: public: duke@435: // creation roland@2174: AccessArray(ValueType* type, Value array, ValueStack* state_before) roland@2174: : Instruction(type, state_before) duke@435: , _array(array) roland@2174: { duke@435: set_needs_null_check(true); duke@435: ASSERT_VALUES duke@435: pin(); // instruction with side effect (null exception or range check throwing) duke@435: } duke@435: duke@435: Value array() const { return _array; } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return needs_null_check(); } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_array); } duke@435: }; duke@435: duke@435: duke@435: LEAF(ArrayLength, AccessArray) duke@435: private: duke@435: NullCheck* _explicit_null_check; // For explicit null check elimination duke@435: duke@435: public: duke@435: // creation roland@2174: ArrayLength(Value array, ValueStack* state_before) roland@2174: : AccessArray(intType, array, state_before) duke@435: , _explicit_null_check(NULL) {} duke@435: duke@435: // accessors duke@435: NullCheck* explicit_null_check() const { return _explicit_null_check; } duke@435: duke@435: // setters duke@435: // See LoadField::set_explicit_null_check for documentation duke@435: void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } duke@435: duke@435: // generic duke@435: HASHING1(ArrayLength, true, array()->subst()) duke@435: }; duke@435: duke@435: duke@435: BASE(AccessIndexed, AccessArray) duke@435: private: duke@435: Value _index; duke@435: Value _length; duke@435: BasicType _elt_type; duke@435: duke@435: public: duke@435: // creation roland@2174: AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before) roland@2174: : AccessArray(as_ValueType(elt_type), array, state_before) duke@435: , _index(index) duke@435: , _length(length) duke@435: , _elt_type(elt_type) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value index() const { return _index; } duke@435: Value length() const { return _length; } duke@435: BasicType elt_type() const { return _elt_type; } duke@435: duke@435: // perform elimination of range checks involving constants duke@435: bool compute_needs_range_check(); duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { AccessArray::input_values_do(f); f->visit(&_index); if (_length != NULL) f->visit(&_length); } duke@435: }; duke@435: duke@435: duke@435: LEAF(LoadIndexed, AccessIndexed) duke@435: private: duke@435: NullCheck* _explicit_null_check; // For explicit null check elimination duke@435: duke@435: public: duke@435: // creation roland@2174: LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before) roland@2174: : AccessIndexed(array, index, length, elt_type, state_before) duke@435: , _explicit_null_check(NULL) {} duke@435: duke@435: // accessors duke@435: NullCheck* explicit_null_check() const { return _explicit_null_check; } duke@435: duke@435: // setters duke@435: // See LoadField::set_explicit_null_check for documentation duke@435: void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } duke@435: duke@435: ciType* exact_type() const; duke@435: ciType* declared_type() const; duke@435: duke@435: // generic duke@435: HASHING2(LoadIndexed, true, array()->subst(), index()->subst()) duke@435: }; duke@435: duke@435: duke@435: LEAF(StoreIndexed, AccessIndexed) duke@435: private: duke@435: Value _value; duke@435: iveresov@2146: ciMethod* _profiled_method; iveresov@2146: int _profiled_bci; duke@435: public: duke@435: // creation roland@2174: StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before) roland@2174: : AccessIndexed(array, index, length, elt_type, state_before) iveresov@2146: , _value(value), _profiled_method(NULL), _profiled_bci(0) duke@435: { duke@435: set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object())); duke@435: set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object())); duke@435: ASSERT_VALUES duke@435: pin(); duke@435: } duke@435: duke@435: // accessors duke@435: Value value() const { return _value; } duke@435: bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } duke@435: bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); } iveresov@2146: // Helpers for methodDataOop profiling iveresov@2146: void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } iveresov@2146: void set_profiled_method(ciMethod* method) { _profiled_method = method; } iveresov@2146: void set_profiled_bci(int bci) { _profiled_bci = bci; } iveresov@2146: bool should_profile() const { return check_flag(ProfileMDOFlag); } iveresov@2146: ciMethod* profiled_method() const { return _profiled_method; } iveresov@2146: int profiled_bci() const { return _profiled_bci; } duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); } duke@435: }; duke@435: duke@435: duke@435: LEAF(NegateOp, Instruction) duke@435: private: duke@435: Value _x; duke@435: duke@435: public: duke@435: // creation duke@435: NegateOp(Value x) : Instruction(x->type()->base()), _x(x) { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value x() const { return _x; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); } duke@435: }; duke@435: duke@435: duke@435: BASE(Op2, Instruction) duke@435: private: duke@435: Bytecodes::Code _op; duke@435: Value _x; duke@435: Value _y; duke@435: duke@435: public: duke@435: // creation roland@2174: Op2(ValueType* type, Bytecodes::Code op, Value x, Value y, ValueStack* state_before = NULL) roland@2174: : Instruction(type, state_before) roland@2174: , _op(op) roland@2174: , _x(x) roland@2174: , _y(y) roland@2174: { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Bytecodes::Code op() const { return _op; } duke@435: Value x() const { return _x; } duke@435: Value y() const { return _y; } duke@435: duke@435: // manipulators duke@435: void swap_operands() { duke@435: assert(is_commutative(), "operation must be commutative"); duke@435: Value t = _x; _x = _y; _y = t; duke@435: } duke@435: duke@435: // generic duke@435: virtual bool is_commutative() const { return false; } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); } duke@435: }; duke@435: duke@435: duke@435: LEAF(ArithmeticOp, Op2) duke@435: public: duke@435: // creation roland@2174: ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* state_before) roland@2174: : Op2(x->type()->meet(y->type()), op, x, y, state_before) roland@2174: { duke@435: set_flag(IsStrictfpFlag, is_strictfp); duke@435: if (can_trap()) pin(); duke@435: } duke@435: duke@435: // accessors duke@435: bool is_strictfp() const { return check_flag(IsStrictfpFlag); } duke@435: duke@435: // generic duke@435: virtual bool is_commutative() const; duke@435: virtual bool can_trap() const; duke@435: HASHING3(Op2, true, op(), x()->subst(), y()->subst()) duke@435: }; duke@435: duke@435: duke@435: LEAF(ShiftOp, Op2) duke@435: public: duke@435: // creation duke@435: ShiftOp(Bytecodes::Code op, Value x, Value s) : Op2(x->type()->base(), op, x, s) {} duke@435: duke@435: // generic duke@435: HASHING3(Op2, true, op(), x()->subst(), y()->subst()) duke@435: }; duke@435: duke@435: duke@435: LEAF(LogicOp, Op2) duke@435: public: duke@435: // creation duke@435: LogicOp(Bytecodes::Code op, Value x, Value y) : Op2(x->type()->meet(y->type()), op, x, y) {} duke@435: duke@435: // generic duke@435: virtual bool is_commutative() const; duke@435: HASHING3(Op2, true, op(), x()->subst(), y()->subst()) duke@435: }; duke@435: duke@435: duke@435: LEAF(CompareOp, Op2) duke@435: public: duke@435: // creation duke@435: CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before) roland@2174: : Op2(intType, op, x, y, state_before) duke@435: {} duke@435: duke@435: // generic duke@435: HASHING3(Op2, true, op(), x()->subst(), y()->subst()) duke@435: }; duke@435: duke@435: duke@435: LEAF(IfOp, Op2) duke@435: private: duke@435: Value _tval; duke@435: Value _fval; duke@435: duke@435: public: duke@435: // creation duke@435: IfOp(Value x, Condition cond, Value y, Value tval, Value fval) duke@435: : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y) duke@435: , _tval(tval) duke@435: , _fval(fval) duke@435: { duke@435: ASSERT_VALUES duke@435: assert(tval->type()->tag() == fval->type()->tag(), "types must match"); duke@435: } duke@435: duke@435: // accessors duke@435: virtual bool is_commutative() const; duke@435: Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; } duke@435: Condition cond() const { return (Condition)Op2::op(); } duke@435: Value tval() const { return _tval; } duke@435: Value fval() const { return _fval; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); } duke@435: }; duke@435: duke@435: duke@435: LEAF(Convert, Instruction) duke@435: private: duke@435: Bytecodes::Code _op; duke@435: Value _value; duke@435: duke@435: public: duke@435: // creation duke@435: Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Bytecodes::Code op() const { return _op; } duke@435: Value value() const { return _value; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_value); } duke@435: HASHING2(Convert, true, op(), value()->subst()) duke@435: }; duke@435: duke@435: duke@435: LEAF(NullCheck, Instruction) duke@435: private: duke@435: Value _obj; duke@435: duke@435: public: duke@435: // creation roland@2174: NullCheck(Value obj, ValueStack* state_before) roland@2174: : Instruction(obj->type()->base(), state_before) roland@2174: , _obj(obj) roland@2174: { duke@435: ASSERT_VALUES duke@435: set_can_trap(true); duke@435: assert(_obj->type()->is_object(), "null check must be applied to objects only"); duke@435: pin(Instruction::PinExplicitNullCheck); duke@435: } duke@435: duke@435: // accessors duke@435: Value obj() const { return _obj; } duke@435: duke@435: // setters duke@435: void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } duke@435: HASHING1(NullCheck, true, obj()->subst()) duke@435: }; duke@435: duke@435: duke@435: BASE(StateSplit, Instruction) duke@435: private: duke@435: ValueStack* _state; duke@435: duke@435: protected: duke@435: static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block); duke@435: duke@435: public: duke@435: // creation roland@2174: StateSplit(ValueType* type, ValueStack* state_before = NULL) roland@2174: : Instruction(type, state_before) roland@2174: , _state(NULL) roland@2174: { duke@435: pin(PinStateSplitConstructor); duke@435: } duke@435: duke@435: // accessors duke@435: ValueStack* state() const { return _state; } duke@435: IRScope* scope() const; // the state's scope duke@435: duke@435: // manipulation roland@2174: void set_state(ValueStack* state) { assert(_state == NULL, "overwriting existing state"); check_state(state); _state = state; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { /* no values */ } iveresov@1939: virtual void state_values_do(ValueVisitor* f); duke@435: }; duke@435: duke@435: duke@435: LEAF(Invoke, StateSplit) duke@435: private: twisti@1730: Bytecodes::Code _code; twisti@1730: Value _recv; twisti@1730: Values* _args; twisti@1730: BasicTypeList* _signature; twisti@1730: int _vtable_index; twisti@1730: ciMethod* _target; duke@435: duke@435: public: duke@435: // creation duke@435: Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args, twisti@1730: int vtable_index, ciMethod* target, ValueStack* state_before); duke@435: duke@435: // accessors duke@435: Bytecodes::Code code() const { return _code; } duke@435: Value receiver() const { return _recv; } duke@435: bool has_receiver() const { return receiver() != NULL; } duke@435: int number_of_arguments() const { return _args->length(); } duke@435: Value argument_at(int i) const { return _args->at(i); } duke@435: int vtable_index() const { return _vtable_index; } duke@435: BasicTypeList* signature() const { return _signature; } duke@435: ciMethod* target() const { return _target; } duke@435: duke@435: // Returns false if target is not loaded duke@435: bool target_is_final() const { return check_flag(TargetIsFinalFlag); } duke@435: bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); } duke@435: // Returns false if target is not loaded duke@435: bool target_is_strictfp() const { return check_flag(TargetIsStrictfpFlag); } duke@435: twisti@1730: // JSR 292 support twisti@1730: bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } twisti@1730: roland@2174: virtual bool needs_exception_state() const { return false; } roland@2174: duke@435: // generic duke@435: virtual bool can_trap() const { return true; } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { duke@435: StateSplit::input_values_do(f); iveresov@1939: if (has_receiver()) f->visit(&_recv); iveresov@1939: for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); duke@435: } iveresov@1939: virtual void state_values_do(ValueVisitor *f); duke@435: }; duke@435: duke@435: duke@435: LEAF(NewInstance, StateSplit) duke@435: private: duke@435: ciInstanceKlass* _klass; duke@435: duke@435: public: duke@435: // creation roland@2174: NewInstance(ciInstanceKlass* klass, ValueStack* state_before) roland@2174: : StateSplit(instanceType, state_before) roland@2174: , _klass(klass) roland@2174: {} duke@435: duke@435: // accessors duke@435: ciInstanceKlass* klass() const { return _klass; } duke@435: roland@2174: virtual bool needs_exception_state() const { return false; } roland@2174: duke@435: // generic duke@435: virtual bool can_trap() const { return true; } duke@435: ciType* exact_type() const; duke@435: }; duke@435: duke@435: duke@435: BASE(NewArray, StateSplit) duke@435: private: duke@435: Value _length; duke@435: duke@435: public: duke@435: // creation roland@2174: NewArray(Value length, ValueStack* state_before) roland@2174: : StateSplit(objectType, state_before) roland@2174: , _length(length) roland@2174: { duke@435: // Do not ASSERT_VALUES since length is NULL for NewMultiArray duke@435: } duke@435: duke@435: // accessors duke@435: Value length() const { return _length; } duke@435: roland@2174: virtual bool needs_exception_state() const { return false; } roland@2174: duke@435: // generic duke@435: virtual bool can_trap() const { return true; } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); } duke@435: }; duke@435: duke@435: duke@435: LEAF(NewTypeArray, NewArray) duke@435: private: duke@435: BasicType _elt_type; duke@435: duke@435: public: duke@435: // creation roland@2174: NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before) roland@2174: : NewArray(length, state_before) roland@2174: , _elt_type(elt_type) roland@2174: {} duke@435: duke@435: // accessors duke@435: BasicType elt_type() const { return _elt_type; } duke@435: ciType* exact_type() const; duke@435: }; duke@435: duke@435: duke@435: LEAF(NewObjectArray, NewArray) duke@435: private: duke@435: ciKlass* _klass; duke@435: duke@435: public: duke@435: // creation duke@435: NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {} duke@435: duke@435: // accessors duke@435: ciKlass* klass() const { return _klass; } duke@435: ciType* exact_type() const; duke@435: }; duke@435: duke@435: duke@435: LEAF(NewMultiArray, NewArray) duke@435: private: duke@435: ciKlass* _klass; duke@435: Values* _dims; duke@435: duke@435: public: duke@435: // creation duke@435: NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: ciKlass* klass() const { return _klass; } duke@435: Values* dims() const { return _dims; } duke@435: int rank() const { return dims()->length(); } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { duke@435: // NOTE: we do not call NewArray::input_values_do since "length" duke@435: // is meaningless for a multi-dimensional array; passing the duke@435: // zeroth element down to NewArray as its length is a bad idea duke@435: // since there will be a copy in the "dims" array which doesn't duke@435: // get updated, and the value must not be traversed twice. Was bug duke@435: // - kbr 4/10/2001 duke@435: StateSplit::input_values_do(f); iveresov@1939: for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i)); duke@435: } duke@435: }; duke@435: duke@435: duke@435: BASE(TypeCheck, StateSplit) duke@435: private: duke@435: ciKlass* _klass; duke@435: Value _obj; duke@435: iveresov@2146: ciMethod* _profiled_method; iveresov@2146: int _profiled_bci; iveresov@2146: duke@435: public: duke@435: // creation iveresov@2146: TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before) roland@2174: : StateSplit(type, state_before), _klass(klass), _obj(obj), iveresov@2146: _profiled_method(NULL), _profiled_bci(0) { duke@435: ASSERT_VALUES duke@435: set_direct_compare(false); duke@435: } duke@435: duke@435: // accessors duke@435: ciKlass* klass() const { return _klass; } duke@435: Value obj() const { return _obj; } duke@435: bool is_loaded() const { return klass() != NULL; } duke@435: bool direct_compare() const { return check_flag(DirectCompareFlag); } duke@435: duke@435: // manipulation duke@435: void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return true; } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } iveresov@2146: iveresov@2146: // Helpers for methodDataOop profiling iveresov@2146: void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } iveresov@2146: void set_profiled_method(ciMethod* method) { _profiled_method = method; } iveresov@2146: void set_profiled_bci(int bci) { _profiled_bci = bci; } iveresov@2146: bool should_profile() const { return check_flag(ProfileMDOFlag); } iveresov@2146: ciMethod* profiled_method() const { return _profiled_method; } iveresov@2146: int profiled_bci() const { return _profiled_bci; } duke@435: }; duke@435: duke@435: duke@435: LEAF(CheckCast, TypeCheck) duke@435: public: duke@435: // creation duke@435: CheckCast(ciKlass* klass, Value obj, ValueStack* state_before) iveresov@2146: : TypeCheck(klass, obj, objectType, state_before) {} duke@435: duke@435: void set_incompatible_class_change_check() { duke@435: set_flag(ThrowIncompatibleClassChangeErrorFlag, true); duke@435: } duke@435: bool is_incompatible_class_change_check() const { duke@435: return check_flag(ThrowIncompatibleClassChangeErrorFlag); duke@435: } duke@435: duke@435: ciType* declared_type() const; duke@435: ciType* exact_type() const; duke@435: }; duke@435: duke@435: duke@435: LEAF(InstanceOf, TypeCheck) duke@435: public: duke@435: // creation duke@435: InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {} roland@2174: roland@2174: virtual bool needs_exception_state() const { return false; } duke@435: }; duke@435: duke@435: duke@435: BASE(AccessMonitor, StateSplit) duke@435: private: duke@435: Value _obj; duke@435: int _monitor_no; duke@435: duke@435: public: duke@435: // creation roland@2174: AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = NULL) roland@2174: : StateSplit(illegalType, state_before) duke@435: , _obj(obj) duke@435: , _monitor_no(monitor_no) duke@435: { duke@435: set_needs_null_check(true); duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value obj() const { return _obj; } duke@435: int monitor_no() const { return _monitor_no; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } duke@435: }; duke@435: duke@435: duke@435: LEAF(MonitorEnter, AccessMonitor) duke@435: public: duke@435: // creation roland@2174: MonitorEnter(Value obj, int monitor_no, ValueStack* state_before) roland@2174: : AccessMonitor(obj, monitor_no, state_before) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return true; } duke@435: }; duke@435: duke@435: duke@435: LEAF(MonitorExit, AccessMonitor) duke@435: public: duke@435: // creation roland@2174: MonitorExit(Value obj, int monitor_no) roland@2174: : AccessMonitor(obj, monitor_no, NULL) roland@2174: { roland@2174: ASSERT_VALUES roland@2174: } duke@435: }; duke@435: duke@435: duke@435: LEAF(Intrinsic, StateSplit) duke@435: private: duke@435: vmIntrinsics::ID _id; duke@435: Values* _args; duke@435: Value _recv; duke@435: duke@435: public: duke@435: // preserves_state can be set to true for Intrinsics duke@435: // which are guaranteed to preserve register state across any slow duke@435: // cases; setting it to true does not mean that the Intrinsic can duke@435: // not trap, only that if we continue execution in the same basic duke@435: // block after the Intrinsic, all of the registers are intact. This duke@435: // allows load elimination and common expression elimination to be duke@435: // performed across the Intrinsic. The default value is false. duke@435: Intrinsic(ValueType* type, duke@435: vmIntrinsics::ID id, duke@435: Values* args, duke@435: bool has_receiver, roland@2174: ValueStack* state_before, duke@435: bool preserves_state, duke@435: bool cantrap = true) roland@2174: : StateSplit(type, state_before) duke@435: , _id(id) duke@435: , _args(args) duke@435: , _recv(NULL) duke@435: { duke@435: assert(args != NULL, "args must exist"); duke@435: ASSERT_VALUES duke@435: set_flag(PreservesStateFlag, preserves_state); duke@435: set_flag(CanTrapFlag, cantrap); duke@435: if (has_receiver) { duke@435: _recv = argument_at(0); duke@435: } duke@435: set_needs_null_check(has_receiver); duke@435: duke@435: // some intrinsics can't trap, so don't force them to be pinned duke@435: if (!can_trap()) { duke@435: unpin(PinStateSplitConstructor); duke@435: } duke@435: } duke@435: duke@435: // accessors duke@435: vmIntrinsics::ID id() const { return _id; } duke@435: int number_of_arguments() const { return _args->length(); } duke@435: Value argument_at(int i) const { return _args->at(i); } duke@435: duke@435: bool has_receiver() const { return (_recv != NULL); } duke@435: Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } duke@435: bool preserves_state() const { return check_flag(PreservesStateFlag); } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return check_flag(CanTrapFlag); } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { duke@435: StateSplit::input_values_do(f); iveresov@1939: for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); duke@435: } duke@435: }; duke@435: duke@435: duke@435: class LIR_List; duke@435: duke@435: LEAF(BlockBegin, StateSplit) duke@435: private: duke@435: int _block_id; // the unique block id roland@2174: int _bci; // start-bci of block duke@435: int _depth_first_number; // number of this block in a depth-first ordering duke@435: int _linear_scan_number; // number of this block in linear-scan ordering duke@435: int _loop_depth; // the loop nesting level of this block duke@435: int _loop_index; // number of the innermost loop of this block duke@435: int _flags; // the flags associated with this block duke@435: duke@435: // fields used by BlockListBuilder duke@435: int _total_preds; // number of predecessors found by BlockListBuilder duke@435: BitMap _stores_to_locals; // bit is set when a local variable is stored in the block duke@435: duke@435: // SSA specific fields: (factor out later) duke@435: BlockList _successors; // the successors of this block duke@435: BlockList _predecessors; // the predecessors of this block duke@435: BlockBegin* _dominator; // the dominator of this block duke@435: // SSA specific ends duke@435: BlockEnd* _end; // the last instruction of this block duke@435: BlockList _exception_handlers; // the exception handlers potentially invoked by this block duke@435: ValueStackStack* _exception_states; // only for xhandler entries: states of all instructions that have an edge to this xhandler duke@435: int _exception_handler_pco; // if this block is the start of an exception handler, duke@435: // this records the PC offset in the assembly code of the duke@435: // first instruction in this block duke@435: Label _label; // the label associated with this block duke@435: LIR_List* _lir; // the low level intermediate representation for this block duke@435: duke@435: BitMap _live_in; // set of live LIR_Opr registers at entry to this block duke@435: BitMap _live_out; // set of live LIR_Opr registers at exit from this block duke@435: BitMap _live_gen; // set of registers used before any redefinition in this block duke@435: BitMap _live_kill; // set of registers defined in this block duke@435: duke@435: BitMap _fpu_register_usage; duke@435: intArray* _fpu_stack_state; // For x86 FPU code generation with UseLinearScan duke@435: int _first_lir_instruction_id; // ID of first LIR instruction in this block duke@435: int _last_lir_instruction_id; // ID of last LIR instruction in this block duke@435: duke@435: void iterate_preorder (boolArray& mark, BlockClosure* closure); duke@435: void iterate_postorder(boolArray& mark, BlockClosure* closure); duke@435: duke@435: friend class SuxAndWeightAdjuster; duke@435: duke@435: public: iveresov@1939: void* operator new(size_t size) { iveresov@1939: Compilation* c = Compilation::current(); iveresov@1939: void* res = c->arena()->Amalloc(size); iveresov@1939: ((BlockBegin*)res)->_id = c->get_next_id(); iveresov@1939: ((BlockBegin*)res)->_block_id = c->get_next_block_id(); iveresov@1939: return res; iveresov@1939: } iveresov@1939: duke@435: // initialization/counting iveresov@1939: static int number_of_blocks() { iveresov@1939: return Compilation::current()->number_of_blocks(); iveresov@1939: } duke@435: duke@435: // creation duke@435: BlockBegin(int bci) duke@435: : StateSplit(illegalType) roland@2174: , _bci(bci) duke@435: , _depth_first_number(-1) duke@435: , _linear_scan_number(-1) duke@435: , _loop_depth(0) duke@435: , _flags(0) duke@435: , _dominator(NULL) duke@435: , _end(NULL) duke@435: , _predecessors(2) duke@435: , _successors(2) duke@435: , _exception_handlers(1) duke@435: , _exception_states(NULL) duke@435: , _exception_handler_pco(-1) duke@435: , _lir(NULL) duke@435: , _loop_index(-1) duke@435: , _live_in() duke@435: , _live_out() duke@435: , _live_gen() duke@435: , _live_kill() duke@435: , _fpu_register_usage() duke@435: , _fpu_stack_state(NULL) duke@435: , _first_lir_instruction_id(-1) duke@435: , _last_lir_instruction_id(-1) duke@435: , _total_preds(0) duke@435: , _stores_to_locals() duke@435: { roland@2174: #ifndef PRODUCT roland@2174: set_printable_bci(bci); roland@2174: #endif duke@435: } duke@435: duke@435: // accessors duke@435: int block_id() const { return _block_id; } roland@2174: int bci() const { return _bci; } duke@435: BlockList* successors() { return &_successors; } duke@435: BlockBegin* dominator() const { return _dominator; } duke@435: int loop_depth() const { return _loop_depth; } duke@435: int depth_first_number() const { return _depth_first_number; } duke@435: int linear_scan_number() const { return _linear_scan_number; } duke@435: BlockEnd* end() const { return _end; } duke@435: Label* label() { return &_label; } duke@435: LIR_List* lir() const { return _lir; } duke@435: int exception_handler_pco() const { return _exception_handler_pco; } duke@435: BitMap& live_in() { return _live_in; } duke@435: BitMap& live_out() { return _live_out; } duke@435: BitMap& live_gen() { return _live_gen; } duke@435: BitMap& live_kill() { return _live_kill; } duke@435: BitMap& fpu_register_usage() { return _fpu_register_usage; } duke@435: intArray* fpu_stack_state() const { return _fpu_stack_state; } duke@435: int first_lir_instruction_id() const { return _first_lir_instruction_id; } duke@435: int last_lir_instruction_id() const { return _last_lir_instruction_id; } duke@435: int total_preds() const { return _total_preds; } duke@435: BitMap& stores_to_locals() { return _stores_to_locals; } duke@435: duke@435: // manipulation duke@435: void set_dominator(BlockBegin* dom) { _dominator = dom; } duke@435: void set_loop_depth(int d) { _loop_depth = d; } duke@435: void set_depth_first_number(int dfn) { _depth_first_number = dfn; } duke@435: void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; } duke@435: void set_end(BlockEnd* end); duke@435: void disconnect_from_graph(); duke@435: static void disconnect_edge(BlockBegin* from, BlockBegin* to); duke@435: BlockBegin* insert_block_between(BlockBegin* sux); duke@435: void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); duke@435: void set_lir(LIR_List* lir) { _lir = lir; } duke@435: void set_exception_handler_pco(int pco) { _exception_handler_pco = pco; } duke@435: void set_live_in (BitMap map) { _live_in = map; } duke@435: void set_live_out (BitMap map) { _live_out = map; } duke@435: void set_live_gen (BitMap map) { _live_gen = map; } duke@435: void set_live_kill (BitMap map) { _live_kill = map; } duke@435: void set_fpu_register_usage(BitMap map) { _fpu_register_usage = map; } duke@435: void set_fpu_stack_state(intArray* state) { _fpu_stack_state = state; } duke@435: void set_first_lir_instruction_id(int id) { _first_lir_instruction_id = id; } duke@435: void set_last_lir_instruction_id(int id) { _last_lir_instruction_id = id; } duke@435: void increment_total_preds(int n = 1) { _total_preds += n; } duke@435: void init_stores_to_locals(int locals_count) { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); } duke@435: duke@435: // generic iveresov@1939: virtual void state_values_do(ValueVisitor* f); duke@435: duke@435: // successors and predecessors duke@435: int number_of_sux() const; duke@435: BlockBegin* sux_at(int i) const; duke@435: void add_successor(BlockBegin* sux); duke@435: void remove_successor(BlockBegin* pred); duke@435: bool is_successor(BlockBegin* sux) const { return _successors.contains(sux); } duke@435: duke@435: void add_predecessor(BlockBegin* pred); duke@435: void remove_predecessor(BlockBegin* pred); duke@435: bool is_predecessor(BlockBegin* pred) const { return _predecessors.contains(pred); } duke@435: int number_of_preds() const { return _predecessors.length(); } duke@435: BlockBegin* pred_at(int i) const { return _predecessors[i]; } duke@435: duke@435: // exception handlers potentially invoked by this block duke@435: void add_exception_handler(BlockBegin* b); duke@435: bool is_exception_handler(BlockBegin* b) const { return _exception_handlers.contains(b); } duke@435: int number_of_exception_handlers() const { return _exception_handlers.length(); } duke@435: BlockBegin* exception_handler_at(int i) const { return _exception_handlers.at(i); } duke@435: duke@435: // states of the instructions that have an edge to this exception handler duke@435: int number_of_exception_states() { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states == NULL ? 0 : _exception_states->length(); } duke@435: ValueStack* exception_state_at(int idx) const { assert(is_set(exception_entry_flag), "only for xhandlers"); return _exception_states->at(idx); } duke@435: int add_exception_state(ValueStack* state); duke@435: duke@435: // flags duke@435: enum Flag { duke@435: no_flag = 0, duke@435: std_entry_flag = 1 << 0, duke@435: osr_entry_flag = 1 << 1, duke@435: exception_entry_flag = 1 << 2, duke@435: subroutine_entry_flag = 1 << 3, duke@435: backward_branch_target_flag = 1 << 4, duke@435: is_on_work_list_flag = 1 << 5, duke@435: was_visited_flag = 1 << 6, never@1813: parser_loop_header_flag = 1 << 7, // set by parser to identify blocks where phi functions can not be created on demand never@1813: critical_edge_split_flag = 1 << 8, // set for all blocks that are introduced when critical edges are split never@1813: linear_scan_loop_header_flag = 1 << 9, // set during loop-detection for LinearScan never@1813: linear_scan_loop_end_flag = 1 << 10 // set during loop-detection for LinearScan duke@435: }; duke@435: duke@435: void set(Flag f) { _flags |= f; } duke@435: void clear(Flag f) { _flags &= ~f; } duke@435: bool is_set(Flag f) const { return (_flags & f) != 0; } duke@435: bool is_entry_block() const { duke@435: const int entry_mask = std_entry_flag | osr_entry_flag | exception_entry_flag; duke@435: return (_flags & entry_mask) != 0; duke@435: } duke@435: duke@435: // iteration duke@435: void iterate_preorder (BlockClosure* closure); duke@435: void iterate_postorder (BlockClosure* closure); duke@435: iveresov@1939: void block_values_do(ValueVisitor* f); duke@435: duke@435: // loops duke@435: void set_loop_index(int ix) { _loop_index = ix; } duke@435: int loop_index() const { return _loop_index; } duke@435: duke@435: // merging duke@435: bool try_merge(ValueStack* state); // try to merge states at block begin duke@435: void merge(ValueStack* state) { bool b = try_merge(state); assert(b, "merge failed"); } duke@435: duke@435: // debugging duke@435: void print_block() PRODUCT_RETURN; duke@435: void print_block(InstructionPrinter& ip, bool live_only = false) PRODUCT_RETURN; duke@435: }; duke@435: duke@435: duke@435: BASE(BlockEnd, StateSplit) duke@435: private: duke@435: BlockBegin* _begin; duke@435: BlockList* _sux; duke@435: duke@435: protected: duke@435: BlockList* sux() const { return _sux; } duke@435: duke@435: void set_sux(BlockList* sux) { duke@435: #ifdef ASSERT duke@435: assert(sux != NULL, "sux must exist"); duke@435: for (int i = sux->length() - 1; i >= 0; i--) assert(sux->at(i) != NULL, "sux must exist"); duke@435: #endif duke@435: _sux = sux; duke@435: } duke@435: duke@435: public: duke@435: // creation duke@435: BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint) roland@2174: : StateSplit(type, state_before) duke@435: , _begin(NULL) duke@435: , _sux(NULL) roland@2174: { duke@435: set_flag(IsSafepointFlag, is_safepoint); duke@435: } duke@435: duke@435: // accessors duke@435: bool is_safepoint() const { return check_flag(IsSafepointFlag); } duke@435: BlockBegin* begin() const { return _begin; } duke@435: duke@435: // manipulation duke@435: void set_begin(BlockBegin* begin); duke@435: duke@435: // successors duke@435: int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; } duke@435: BlockBegin* sux_at(int i) const { return _sux->at(i); } duke@435: BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); } duke@435: BlockBegin** addr_sux_at(int i) const { return _sux->adr_at(i); } duke@435: int sux_index(BlockBegin* sux) const { return _sux->find(sux); } duke@435: void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); duke@435: }; duke@435: duke@435: duke@435: LEAF(Goto, BlockEnd) duke@435: public: iveresov@2138: enum Direction { iveresov@2138: none, // Just a regular goto iveresov@2138: taken, not_taken // Goto produced from If iveresov@2138: }; iveresov@2138: private: iveresov@2138: ciMethod* _profiled_method; iveresov@2138: int _profiled_bci; iveresov@2138: Direction _direction; iveresov@2138: public: duke@435: // creation iveresov@2138: Goto(BlockBegin* sux, ValueStack* state_before, bool is_safepoint = false) iveresov@2138: : BlockEnd(illegalType, state_before, is_safepoint) iveresov@2138: , _direction(none) iveresov@2138: , _profiled_method(NULL) iveresov@2138: , _profiled_bci(0) { duke@435: BlockList* s = new BlockList(1); duke@435: s->append(sux); duke@435: set_sux(s); duke@435: } duke@435: iveresov@2138: Goto(BlockBegin* sux, bool is_safepoint) : BlockEnd(illegalType, NULL, is_safepoint) iveresov@2138: , _direction(none) iveresov@2138: , _profiled_method(NULL) iveresov@2138: , _profiled_bci(0) { duke@435: BlockList* s = new BlockList(1); duke@435: s->append(sux); duke@435: set_sux(s); duke@435: } duke@435: iveresov@2138: bool should_profile() const { return check_flag(ProfileMDOFlag); } iveresov@2138: ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches iveresov@2138: int profiled_bci() const { return _profiled_bci; } iveresov@2138: Direction direction() const { return _direction; } iveresov@2138: iveresov@2138: void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } iveresov@2138: void set_profiled_method(ciMethod* method) { _profiled_method = method; } iveresov@2138: void set_profiled_bci(int bci) { _profiled_bci = bci; } iveresov@2138: void set_direction(Direction d) { _direction = d; } duke@435: }; duke@435: duke@435: duke@435: LEAF(If, BlockEnd) duke@435: private: duke@435: Value _x; duke@435: Condition _cond; duke@435: Value _y; duke@435: ciMethod* _profiled_method; duke@435: int _profiled_bci; // Canonicalizer may alter bci of If node iveresov@2138: bool _swapped; // Is the order reversed with respect to the original If in the iveresov@2138: // bytecode stream? duke@435: public: duke@435: // creation duke@435: // unordered_is_true is valid for float/double compares only duke@435: If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint) duke@435: : BlockEnd(illegalType, state_before, is_safepoint) duke@435: , _x(x) duke@435: , _cond(cond) duke@435: , _y(y) duke@435: , _profiled_method(NULL) duke@435: , _profiled_bci(0) iveresov@2138: , _swapped(false) duke@435: { duke@435: ASSERT_VALUES duke@435: set_flag(UnorderedIsTrueFlag, unordered_is_true); duke@435: assert(x->type()->tag() == y->type()->tag(), "types must match"); duke@435: BlockList* s = new BlockList(2); duke@435: s->append(tsux); duke@435: s->append(fsux); duke@435: set_sux(s); duke@435: } duke@435: duke@435: // accessors duke@435: Value x() const { return _x; } duke@435: Condition cond() const { return _cond; } duke@435: bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); } duke@435: Value y() const { return _y; } duke@435: BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); } duke@435: BlockBegin* tsux() const { return sux_for(true); } duke@435: BlockBegin* fsux() const { return sux_for(false); } duke@435: BlockBegin* usux() const { return sux_for(unordered_is_true()); } duke@435: bool should_profile() const { return check_flag(ProfileMDOFlag); } duke@435: ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches iveresov@2138: int profiled_bci() const { return _profiled_bci; } // set for profiled branches and tiered iveresov@2138: bool is_swapped() const { return _swapped; } duke@435: duke@435: // manipulation duke@435: void swap_operands() { duke@435: Value t = _x; _x = _y; _y = t; duke@435: _cond = mirror(_cond); duke@435: } duke@435: duke@435: void swap_sux() { duke@435: assert(number_of_sux() == 2, "wrong number of successors"); duke@435: BlockList* s = sux(); duke@435: BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); duke@435: _cond = negate(_cond); duke@435: set_flag(UnorderedIsTrueFlag, !check_flag(UnorderedIsTrueFlag)); duke@435: } duke@435: duke@435: void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } duke@435: void set_profiled_method(ciMethod* method) { _profiled_method = method; } duke@435: void set_profiled_bci(int bci) { _profiled_bci = bci; } iveresov@2138: void set_swapped(bool value) { _swapped = value; } duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); } duke@435: }; duke@435: duke@435: duke@435: LEAF(IfInstanceOf, BlockEnd) duke@435: private: duke@435: ciKlass* _klass; duke@435: Value _obj; duke@435: bool _test_is_instance; // jump if instance duke@435: int _instanceof_bci; duke@435: duke@435: public: duke@435: IfInstanceOf(ciKlass* klass, Value obj, bool test_is_instance, int instanceof_bci, BlockBegin* tsux, BlockBegin* fsux) duke@435: : BlockEnd(illegalType, NULL, false) // temporary set to false duke@435: , _klass(klass) duke@435: , _obj(obj) duke@435: , _test_is_instance(test_is_instance) duke@435: , _instanceof_bci(instanceof_bci) duke@435: { duke@435: ASSERT_VALUES duke@435: assert(instanceof_bci >= 0, "illegal bci"); duke@435: BlockList* s = new BlockList(2); duke@435: s->append(tsux); duke@435: s->append(fsux); duke@435: set_sux(s); duke@435: } duke@435: duke@435: // accessors duke@435: // duke@435: // Note 1: If test_is_instance() is true, IfInstanceOf tests if obj *is* an duke@435: // instance of klass; otherwise it tests if it is *not* and instance duke@435: // of klass. duke@435: // duke@435: // Note 2: IfInstanceOf instructions are created by combining an InstanceOf duke@435: // and an If instruction. The IfInstanceOf bci() corresponds to the duke@435: // bci that the If would have had; the (this->) instanceof_bci() is duke@435: // the bci of the original InstanceOf instruction. duke@435: ciKlass* klass() const { return _klass; } duke@435: Value obj() const { return _obj; } duke@435: int instanceof_bci() const { return _instanceof_bci; } duke@435: bool test_is_instance() const { return _test_is_instance; } duke@435: BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); } duke@435: BlockBegin* tsux() const { return sux_for(true); } duke@435: BlockBegin* fsux() const { return sux_for(false); } duke@435: duke@435: // manipulation duke@435: void swap_sux() { duke@435: assert(number_of_sux() == 2, "wrong number of successors"); duke@435: BlockList* s = sux(); duke@435: BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); duke@435: _test_is_instance = !_test_is_instance; duke@435: } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_obj); } duke@435: }; duke@435: duke@435: duke@435: BASE(Switch, BlockEnd) duke@435: private: duke@435: Value _tag; duke@435: duke@435: public: duke@435: // creation duke@435: Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint) duke@435: : BlockEnd(illegalType, state_before, is_safepoint) duke@435: , _tag(tag) { duke@435: ASSERT_VALUES duke@435: set_sux(sux); duke@435: } duke@435: duke@435: // accessors duke@435: Value tag() const { return _tag; } duke@435: int length() const { return number_of_sux() - 1; } duke@435: roland@2174: virtual bool needs_exception_state() const { return false; } roland@2174: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_tag); } duke@435: }; duke@435: duke@435: duke@435: LEAF(TableSwitch, Switch) duke@435: private: duke@435: int _lo_key; duke@435: duke@435: public: duke@435: // creation duke@435: TableSwitch(Value tag, BlockList* sux, int lo_key, ValueStack* state_before, bool is_safepoint) duke@435: : Switch(tag, sux, state_before, is_safepoint) duke@435: , _lo_key(lo_key) {} duke@435: duke@435: // accessors duke@435: int lo_key() const { return _lo_key; } duke@435: int hi_key() const { return _lo_key + length() - 1; } duke@435: }; duke@435: duke@435: duke@435: LEAF(LookupSwitch, Switch) duke@435: private: duke@435: intArray* _keys; duke@435: duke@435: public: duke@435: // creation duke@435: LookupSwitch(Value tag, BlockList* sux, intArray* keys, ValueStack* state_before, bool is_safepoint) duke@435: : Switch(tag, sux, state_before, is_safepoint) duke@435: , _keys(keys) { duke@435: assert(keys != NULL, "keys must exist"); duke@435: assert(keys->length() == length(), "sux & keys have incompatible lengths"); duke@435: } duke@435: duke@435: // accessors duke@435: int key_at(int i) const { return _keys->at(i); } duke@435: }; duke@435: duke@435: duke@435: LEAF(Return, BlockEnd) duke@435: private: duke@435: Value _result; duke@435: duke@435: public: duke@435: // creation duke@435: Return(Value result) : duke@435: BlockEnd(result == NULL ? voidType : result->type()->base(), NULL, true), duke@435: _result(result) {} duke@435: duke@435: // accessors duke@435: Value result() const { return _result; } duke@435: bool has_result() const { return result() != NULL; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { duke@435: BlockEnd::input_values_do(f); iveresov@1939: if (has_result()) f->visit(&_result); duke@435: } duke@435: }; duke@435: duke@435: duke@435: LEAF(Throw, BlockEnd) duke@435: private: duke@435: Value _exception; duke@435: duke@435: public: duke@435: // creation duke@435: Throw(Value exception, ValueStack* state_before) : BlockEnd(illegalType, state_before, true), _exception(exception) { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value exception() const { return _exception; } duke@435: duke@435: // generic duke@435: virtual bool can_trap() const { return true; } iveresov@1939: virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_exception); } duke@435: }; duke@435: duke@435: duke@435: LEAF(Base, BlockEnd) duke@435: public: duke@435: // creation duke@435: Base(BlockBegin* std_entry, BlockBegin* osr_entry) : BlockEnd(illegalType, NULL, false) { duke@435: assert(std_entry->is_set(BlockBegin::std_entry_flag), "std entry must be flagged"); duke@435: assert(osr_entry == NULL || osr_entry->is_set(BlockBegin::osr_entry_flag), "osr entry must be flagged"); duke@435: BlockList* s = new BlockList(2); duke@435: if (osr_entry != NULL) s->append(osr_entry); duke@435: s->append(std_entry); // must be default sux! duke@435: set_sux(s); duke@435: } duke@435: duke@435: // accessors duke@435: BlockBegin* std_entry() const { return default_sux(); } duke@435: BlockBegin* osr_entry() const { return number_of_sux() < 2 ? NULL : sux_at(0); } duke@435: }; duke@435: duke@435: duke@435: LEAF(OsrEntry, Instruction) duke@435: public: duke@435: // creation duke@435: #ifdef _LP64 roland@2179: OsrEntry() : Instruction(longType) { pin(); } duke@435: #else roland@2179: OsrEntry() : Instruction(intType) { pin(); } duke@435: #endif duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { } duke@435: }; duke@435: duke@435: duke@435: // Models the incoming exception at a catch site duke@435: LEAF(ExceptionObject, Instruction) duke@435: public: duke@435: // creation roland@2179: ExceptionObject() : Instruction(objectType) { duke@435: pin(); duke@435: } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { } duke@435: }; duke@435: duke@435: duke@435: // Models needed rounding for floating-point values on Intel. duke@435: // Currently only used to represent rounding of double-precision duke@435: // values stored into local variables, but could be used to model duke@435: // intermediate rounding of single-precision values as well. duke@435: LEAF(RoundFP, Instruction) duke@435: private: duke@435: Value _input; // floating-point value to be rounded duke@435: duke@435: public: duke@435: RoundFP(Value input) duke@435: : Instruction(input->type()) // Note: should not be used for constants duke@435: , _input(input) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value input() const { return _input; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { f->visit(&_input); } duke@435: }; duke@435: duke@435: duke@435: BASE(UnsafeOp, Instruction) duke@435: private: duke@435: BasicType _basic_type; // ValueType can not express byte-sized integers duke@435: duke@435: protected: duke@435: // creation duke@435: UnsafeOp(BasicType basic_type, bool is_put) duke@435: : Instruction(is_put ? voidType : as_ValueType(basic_type)) duke@435: , _basic_type(basic_type) duke@435: { duke@435: //Note: Unsafe ops are not not guaranteed to throw NPE. duke@435: // Convservatively, Unsafe operations must be pinned though we could be duke@435: // looser about this if we wanted to.. duke@435: pin(); duke@435: } duke@435: duke@435: public: duke@435: // accessors duke@435: BasicType basic_type() { return _basic_type; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { } duke@435: }; duke@435: duke@435: duke@435: BASE(UnsafeRawOp, UnsafeOp) duke@435: private: duke@435: Value _base; // Base address (a Java long) duke@435: Value _index; // Index if computed by optimizer; initialized to NULL duke@435: int _log2_scale; // Scale factor: 0, 1, 2, or 3. duke@435: // Indicates log2 of number of bytes (1, 2, 4, or 8) duke@435: // to scale index by. duke@435: duke@435: protected: duke@435: UnsafeRawOp(BasicType basic_type, Value addr, bool is_put) duke@435: : UnsafeOp(basic_type, is_put) duke@435: , _base(addr) duke@435: , _index(NULL) duke@435: , _log2_scale(0) duke@435: { duke@435: // Can not use ASSERT_VALUES because index may be NULL duke@435: assert(addr != NULL && addr->type()->is_long(), "just checking"); duke@435: } duke@435: duke@435: UnsafeRawOp(BasicType basic_type, Value base, Value index, int log2_scale, bool is_put) duke@435: : UnsafeOp(basic_type, is_put) duke@435: , _base(base) duke@435: , _index(index) duke@435: , _log2_scale(log2_scale) duke@435: { duke@435: } duke@435: duke@435: public: duke@435: // accessors duke@435: Value base() { return _base; } duke@435: Value index() { return _index; } duke@435: bool has_index() { return (_index != NULL); } duke@435: int log2_scale() { return _log2_scale; } duke@435: duke@435: // setters duke@435: void set_base (Value base) { _base = base; } duke@435: void set_index(Value index) { _index = index; } duke@435: void set_log2_scale(int log2_scale) { _log2_scale = log2_scale; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); iveresov@1939: f->visit(&_base); iveresov@1939: if (has_index()) f->visit(&_index); } duke@435: }; duke@435: duke@435: duke@435: LEAF(UnsafeGetRaw, UnsafeRawOp) duke@435: private: iveresov@2344: bool _may_be_unaligned, _is_wide; // For OSREntry duke@435: duke@435: public: iveresov@2344: UnsafeGetRaw(BasicType basic_type, Value addr, bool may_be_unaligned, bool is_wide = false) duke@435: : UnsafeRawOp(basic_type, addr, false) { duke@435: _may_be_unaligned = may_be_unaligned; iveresov@2344: _is_wide = is_wide; duke@435: } duke@435: iveresov@2344: UnsafeGetRaw(BasicType basic_type, Value base, Value index, int log2_scale, bool may_be_unaligned, bool is_wide = false) duke@435: : UnsafeRawOp(basic_type, base, index, log2_scale, false) { duke@435: _may_be_unaligned = may_be_unaligned; iveresov@2344: _is_wide = is_wide; duke@435: } duke@435: iveresov@2344: bool may_be_unaligned() { return _may_be_unaligned; } iveresov@2344: bool is_wide() { return _is_wide; } duke@435: }; duke@435: duke@435: duke@435: LEAF(UnsafePutRaw, UnsafeRawOp) duke@435: private: duke@435: Value _value; // Value to be stored duke@435: duke@435: public: duke@435: UnsafePutRaw(BasicType basic_type, Value addr, Value value) duke@435: : UnsafeRawOp(basic_type, addr, true) duke@435: , _value(value) duke@435: { duke@435: assert(value != NULL, "just checking"); duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: UnsafePutRaw(BasicType basic_type, Value base, Value index, int log2_scale, Value value) duke@435: : UnsafeRawOp(basic_type, base, index, log2_scale, true) duke@435: , _value(value) duke@435: { duke@435: assert(value != NULL, "just checking"); duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value value() { return _value; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { UnsafeRawOp::input_values_do(f); iveresov@1939: f->visit(&_value); } duke@435: }; duke@435: duke@435: duke@435: BASE(UnsafeObjectOp, UnsafeOp) duke@435: private: duke@435: Value _object; // Object to be fetched from or mutated duke@435: Value _offset; // Offset within object duke@435: bool _is_volatile; // true if volatile - dl/JSR166 duke@435: public: duke@435: UnsafeObjectOp(BasicType basic_type, Value object, Value offset, bool is_put, bool is_volatile) duke@435: : UnsafeOp(basic_type, is_put), _object(object), _offset(offset), _is_volatile(is_volatile) duke@435: { duke@435: } duke@435: duke@435: // accessors duke@435: Value object() { return _object; } duke@435: Value offset() { return _offset; } duke@435: bool is_volatile() { return _is_volatile; } duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); iveresov@1939: f->visit(&_object); iveresov@1939: f->visit(&_offset); } duke@435: }; duke@435: duke@435: duke@435: LEAF(UnsafeGetObject, UnsafeObjectOp) duke@435: public: duke@435: UnsafeGetObject(BasicType basic_type, Value object, Value offset, bool is_volatile) duke@435: : UnsafeObjectOp(basic_type, object, offset, false, is_volatile) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: }; duke@435: duke@435: duke@435: LEAF(UnsafePutObject, UnsafeObjectOp) duke@435: private: duke@435: Value _value; // Value to be stored duke@435: public: duke@435: UnsafePutObject(BasicType basic_type, Value object, Value offset, Value value, bool is_volatile) duke@435: : UnsafeObjectOp(basic_type, object, offset, true, is_volatile) duke@435: , _value(value) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: duke@435: // accessors duke@435: Value value() { return _value; } duke@435: duke@435: // generic iveresov@1939: virtual void input_values_do(ValueVisitor* f) { UnsafeObjectOp::input_values_do(f); iveresov@1939: f->visit(&_value); } duke@435: }; duke@435: duke@435: duke@435: BASE(UnsafePrefetch, UnsafeObjectOp) duke@435: public: duke@435: UnsafePrefetch(Value object, Value offset) duke@435: : UnsafeObjectOp(T_VOID, object, offset, false, false) duke@435: { duke@435: } duke@435: }; duke@435: duke@435: duke@435: LEAF(UnsafePrefetchRead, UnsafePrefetch) duke@435: public: duke@435: UnsafePrefetchRead(Value object, Value offset) duke@435: : UnsafePrefetch(object, offset) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: }; duke@435: duke@435: duke@435: LEAF(UnsafePrefetchWrite, UnsafePrefetch) duke@435: public: duke@435: UnsafePrefetchWrite(Value object, Value offset) duke@435: : UnsafePrefetch(object, offset) duke@435: { duke@435: ASSERT_VALUES duke@435: } duke@435: }; duke@435: duke@435: LEAF(ProfileCall, Instruction) duke@435: private: duke@435: ciMethod* _method; duke@435: int _bci_of_invoke; duke@435: Value _recv; duke@435: ciKlass* _known_holder; duke@435: duke@435: public: duke@435: ProfileCall(ciMethod* method, int bci, Value recv, ciKlass* known_holder) duke@435: : Instruction(voidType) duke@435: , _method(method) duke@435: , _bci_of_invoke(bci) duke@435: , _recv(recv) duke@435: , _known_holder(known_holder) duke@435: { duke@435: // The ProfileCall has side-effects and must occur precisely where located duke@435: pin(); duke@435: } duke@435: duke@435: ciMethod* method() { return _method; } duke@435: int bci_of_invoke() { return _bci_of_invoke; } duke@435: Value recv() { return _recv; } duke@435: ciKlass* known_holder() { return _known_holder; } duke@435: iveresov@1939: virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } duke@435: }; duke@435: never@2486: never@2486: // Call some C runtime function that doesn't safepoint, never@2486: // optionally passing the current thread as the first argument. never@2486: LEAF(RuntimeCall, Instruction) never@2486: private: never@2486: const char* _entry_name; never@2486: address _entry; never@2486: Values* _args; never@2486: bool _pass_thread; // Pass the JavaThread* as an implicit first argument never@2486: never@2486: public: never@2486: RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true) never@2486: : Instruction(type) never@2486: , _entry(entry) never@2486: , _args(args) never@2486: , _entry_name(entry_name) never@2486: , _pass_thread(pass_thread) { never@2486: ASSERT_VALUES never@2486: pin(); never@2486: } never@2486: never@2486: const char* entry_name() const { return _entry_name; } never@2486: address entry() const { return _entry; } never@2486: int number_of_arguments() const { return _args->length(); } never@2486: Value argument_at(int i) const { return _args->at(i); } never@2486: bool pass_thread() const { return _pass_thread; } never@2486: never@2486: virtual void input_values_do(ValueVisitor* f) { never@2486: for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); never@2486: } never@2486: }; never@2486: iveresov@2138: // Use to trip invocation counter of an inlined method duke@435: iveresov@2138: LEAF(ProfileInvoke, Instruction) duke@435: private: iveresov@2138: ciMethod* _inlinee; iveresov@2138: ValueStack* _state; duke@435: duke@435: public: iveresov@2180: ProfileInvoke(ciMethod* inlinee, ValueStack* state) duke@435: : Instruction(voidType) iveresov@2138: , _inlinee(inlinee) iveresov@2138: , _state(state) duke@435: { iveresov@2138: // The ProfileInvoke has side-effects and must occur precisely where located QQQ??? duke@435: pin(); duke@435: } duke@435: iveresov@2138: ciMethod* inlinee() { return _inlinee; } iveresov@2138: ValueStack* state() { return _state; } iveresov@2138: virtual void input_values_do(ValueVisitor*) {} iveresov@2138: virtual void state_values_do(ValueVisitor*); duke@435: }; duke@435: duke@435: class BlockPair: public CompilationResourceObj { duke@435: private: duke@435: BlockBegin* _from; duke@435: BlockBegin* _to; duke@435: public: duke@435: BlockPair(BlockBegin* from, BlockBegin* to): _from(from), _to(to) {} duke@435: BlockBegin* from() const { return _from; } duke@435: BlockBegin* to() const { return _to; } duke@435: bool is_same(BlockBegin* from, BlockBegin* to) const { return _from == from && _to == to; } duke@435: bool is_same(BlockPair* p) const { return _from == p->from() && _to == p->to(); } duke@435: void set_to(BlockBegin* b) { _to = b; } duke@435: void set_from(BlockBegin* b) { _from = b; } duke@435: }; duke@435: duke@435: duke@435: define_array(BlockPairArray, BlockPair*) duke@435: define_stack(BlockPairList, BlockPairArray) duke@435: duke@435: duke@435: inline int BlockBegin::number_of_sux() const { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); } duke@435: inline BlockBegin* BlockBegin::sux_at(int i) const { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch"); return _successors.at(i); } duke@435: inline void BlockBegin::add_successor(BlockBegin* sux) { assert(_end == NULL, "Would create mismatch with successors of BlockEnd"); _successors.append(sux); } duke@435: duke@435: #undef ASSERT_VALUES stefank@2314: stefank@2314: #endif // SHARE_VM_C1_C1_INSTRUCTION_HPP