57 class StoreIndexed;
58 class NegateOp;
59 class Op2;
60 class ArithmeticOp;
61 class ShiftOp;
62 class LogicOp;
63 class CompareOp;
64 class IfOp;
65 class Convert;
66 class NullCheck;
67 class TypeCast;
68 class OsrEntry;
69 class ExceptionObject;
70 class StateSplit;
71 class Invoke;
72 class NewInstance;
73 class NewArray;
74 class NewTypeArray;
75 class NewObjectArray;
76 class NewMultiArray;
77 class TypeCheck;
78 class CheckCast;
79 class InstanceOf;
80 class AccessMonitor;
81 class MonitorEnter;
82 class MonitorExit;
83 class Intrinsic;
84 class BlockBegin;
85 class BlockEnd;
86 class Goto;
87 class If;
88 class Switch;
89 class TableSwitch;
90 class LookupSwitch;
91 class Return;
92 class Throw;
93 class Base;
94 class RoundFP;
95 class UnsafeOp;
96 class UnsafeGet;
97 class UnsafePut;
98 class UnsafeGetAndSet;
99 class ProfileCall;
100 class ProfileReturnType;
101 class ProfileInvoke;
102 class RuntimeCall;
103 class MemBar;
104 class RangeCheckPredicate;
105 #ifdef ASSERT
106 class Assert;
107 #endif
108
109 // A Value is a reference to the instruction creating the value
110 typedef Instruction* Value;
111 typedef GrowableArray<Value> Values;
112 typedef GrowableArray<ValueStack*> ValueStackStack;
113
114 // BlockClosure is the base class for block traversal/iteration.
115
116 class BlockClosure: public CompilationResourceObj {
117 public:
118 virtual void block_do(BlockBegin* block) = 0;
119 };
120
176 virtual void do_InstanceOf (InstanceOf* x) = 0;
177 virtual void do_MonitorEnter (MonitorEnter* x) = 0;
178 virtual void do_MonitorExit (MonitorExit* x) = 0;
179 virtual void do_Intrinsic (Intrinsic* x) = 0;
180 virtual void do_BlockBegin (BlockBegin* x) = 0;
181 virtual void do_Goto (Goto* x) = 0;
182 virtual void do_If (If* x) = 0;
183 virtual void do_TableSwitch (TableSwitch* x) = 0;
184 virtual void do_LookupSwitch (LookupSwitch* x) = 0;
185 virtual void do_Return (Return* x) = 0;
186 virtual void do_Throw (Throw* x) = 0;
187 virtual void do_Base (Base* x) = 0;
188 virtual void do_OsrEntry (OsrEntry* x) = 0;
189 virtual void do_ExceptionObject(ExceptionObject* x) = 0;
190 virtual void do_RoundFP (RoundFP* x) = 0;
191 virtual void do_UnsafeGet (UnsafeGet* x) = 0;
192 virtual void do_UnsafePut (UnsafePut* x) = 0;
193 virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x) = 0;
194 virtual void do_ProfileCall (ProfileCall* x) = 0;
195 virtual void do_ProfileReturnType (ProfileReturnType* x) = 0;
196 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
197 virtual void do_RuntimeCall (RuntimeCall* x) = 0;
198 virtual void do_MemBar (MemBar* x) = 0;
199 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
200 #ifdef ASSERT
201 virtual void do_Assert (Assert* x) = 0;
202 #endif
203 };
204
205
206 // Hashing support
207 //
208 // Note: This hash functions affect the performance
209 // of ValueMap - make changes carefully!
210
211 #define HASH1(x1 ) ((intx)(x1))
212 #define HASH2(x1, x2 ) ((HASH1(x1 ) << 7) ^ HASH1(x2))
213 #define HASH3(x1, x2, x3 ) ((HASH2(x1, x2 ) << 7) ^ HASH1(x3))
214 #define HASH4(x1, x2, x3, x4) ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4))
215
216
217 // The following macros are used to implement instruction-specific hashing.
218 // By default, each instruction implements hash() and is_equal(Value), used
219 // for value numbering/common subexpression elimination. The default imple-
220 // mentation disables value numbering. Each instruction which can be value-
221 // numbered, should define corresponding hash() and is_equal(Value) functions
222 // via the macros below. The f arguments specify all the values/op codes, etc.
223 // that need to be identical for two instructions to be identical.
224 //
225 // Note: The default implementation of hash() returns 0 in order to indicate
226 // that the instruction should not be considered for value numbering.
227 // The currently used hash functions do not guarantee that never a 0
228 // is produced. While this is still correct, it may be a performance
229 // bug (no value numbering for that node). However, this situation is
230 // so unlikely, that we are not going to handle it specially.
231
232 #define HASHING1(class_name, enabled, f1) \
233 virtual intx hash() const { \
234 return (enabled) ? HASH2(name(), f1) : 0; \
253 if (f1 != _v->f1) return false; \
254 if (f2 != _v->f2) return false; \
255 return true; \
256 } \
257
258
259 #define HASHING3(class_name, enabled, f1, f2, f3) \
260 virtual intx hash() const { \
261 return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
262 } \
263 virtual bool is_equal(Value v) const { \
264 if (!(enabled) ) return false; \
265 class_name* _v = v->as_##class_name(); \
266 if (_v == nullptr) return false; \
267 if (f1 != _v->f1) return false; \
268 if (f2 != _v->f2) return false; \
269 if (f3 != _v->f3) return false; \
270 return true; \
271 } \
272
273
274 // The mother of all instructions...
275
276 class Instruction: public CompilationResourceObj {
277 private:
278 int _id; // the unique instruction id
279 #ifndef PRODUCT
280 int _printable_bci; // the bci of the instruction for printing
281 #endif
282 int _use_count; // the number of instructions referring to this value (w/o prev/next); only roots can have use count = 0 or > 1
283 int _pin_state; // set of PinReason describing the reason for pinning
284 ValueType* _type; // the instruction value type
285 Instruction* _next; // the next instruction if any (null for BlockEnd instructions)
286 Instruction* _subst; // the substitution instruction if any
287 LIR_Opr _operand; // LIR specific information
288 unsigned int _flags; // Flag bits
289
290 ValueStack* _state_before; // Copy of state with input operands still on stack (or null)
291 ValueStack* _exception_state; // Copy of state for exception handling
292 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction
293
294 friend class UseCountComputer;
295
296 void update_exception_state(ValueStack* state);
297
298 protected:
299 BlockBegin* _block; // Block that contains this instruction
300
301 void set_type(ValueType* type) {
302 assert(type != nullptr, "type must exist");
303 _type = type;
304 }
305
306 // Helper class to keep track of which arguments need a null check
307 class ArgsNonNullState {
308 private:
309 int _nonnull_state; // mask identifying which args are nonnull
310 public:
311 ArgsNonNullState()
312 : _nonnull_state(AllBits) {}
313
314 // Does argument number i needs a null check?
327 if (check) {
328 _nonnull_state |= (int)nth_bit(i);
329 } else {
330 _nonnull_state &= (int)~(nth_bit(i));
331 }
332 }
333 }
334 };
335
336 public:
337 void* operator new(size_t size) throw() {
338 Compilation* c = Compilation::current();
339 void* res = c->arena()->Amalloc(size);
340 return res;
341 }
342
343 static const int no_bci = -99;
344
345 enum InstructionFlag {
346 NeedsNullCheckFlag = 0,
347 CanTrapFlag,
348 DirectCompareFlag,
349 IsEliminatedFlag,
350 IsSafepointFlag,
351 IsStaticFlag,
352 NeedsStoreCheckFlag,
353 NeedsWriteBarrierFlag,
354 PreservesStateFlag,
355 TargetIsFinalFlag,
356 TargetIsLoadedFlag,
357 UnorderedIsTrueFlag,
358 NeedsPatchingFlag,
359 ThrowIncompatibleClassChangeErrorFlag,
360 InvokeSpecialReceiverCheckFlag,
361 ProfileMDOFlag,
362 IsLinkedInBlockFlag,
363 NeedsRangeCheckFlag,
364 InWorkListFlag,
365 DeoptimizeOnException,
366 KillsMemoryFlag,
420 int id() const { return _id; }
421 #ifndef PRODUCT
422 bool has_printable_bci() const { return _printable_bci != -99; }
423 int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
424 void set_printable_bci(int bci) { _printable_bci = bci; }
425 #endif
426 int dominator_depth();
427 int use_count() const { return _use_count; }
428 int pin_state() const { return _pin_state; }
429 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; }
430 ValueType* type() const { return _type; }
431 BlockBegin *block() const { return _block; }
432 Instruction* prev(); // use carefully, expensive operation
433 Instruction* next() const { return _next; }
434 bool has_subst() const { return _subst != nullptr; }
435 Instruction* subst() { return _subst == nullptr ? this : _subst->subst(); }
436 LIR_Opr operand() const { return _operand; }
437
438 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); }
439 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); }
440 bool is_linked() const { return check_flag(IsLinkedInBlockFlag); }
441 bool can_be_linked() { return as_Local() == nullptr && as_Phi() == nullptr; }
442
443 bool is_null_obj() { return as_Constant() != nullptr && type()->as_ObjectType()->constant_value()->is_null_object(); }
444
445 bool has_uses() const { return use_count() > 0; }
446 ValueStack* state_before() const { return _state_before; }
447 ValueStack* exception_state() const { return _exception_state; }
448 virtual bool needs_exception_state() const { return true; }
449 XHandlers* exception_handlers() const { return _exception_handlers; }
450
451 // manipulation
452 void pin(PinReason reason) { _pin_state |= reason; }
453 void pin() { _pin_state |= PinUnknown; }
454 // DANGEROUS: only used by EliminateStores
455 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
456
457 Instruction* set_next(Instruction* next) {
458 assert(next->has_printable_bci(), "_printable_bci should have been set");
459 assert(next != nullptr, "must not be null");
460 assert(as_BlockEnd() == nullptr, "BlockEnd instructions must have no next");
461 assert(next->can_be_linked(), "shouldn't link these instructions into list");
462
463 BlockBegin *block = this->block();
464 next->_block = block;
465
466 next->set_flag(Instruction::IsLinkedInBlockFlag, true);
467 _next = next;
468 return next;
469 }
474 #endif
475 return set_next(next);
476 }
477
478 // when blocks are merged
479 void fixup_block_pointers() {
480 Instruction *cur = next()->next(); // next()'s block is set in set_next
481 while (cur && cur->_block != block()) {
482 cur->_block = block();
483 cur = cur->next();
484 }
485 }
486
487 Instruction *insert_after(Instruction *i) {
488 Instruction* n = _next;
489 set_next(i);
490 i->set_next(n);
491 return _next;
492 }
493
494 Instruction *insert_after_same_bci(Instruction *i) {
495 #ifndef PRODUCT
496 i->set_printable_bci(printable_bci());
497 #endif
498 return insert_after(i);
499 }
500
501 void set_subst(Instruction* subst) {
502 assert(subst == nullptr ||
503 type()->base() == subst->type()->base() ||
504 subst->type()->base() == illegalType, "type can't change");
505 _subst = subst;
506 }
507 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
508 void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; }
509 void set_state_before(ValueStack* s) { check_state(s); _state_before = s; }
510
511 // machine-specifics
512 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
513 void clear_operand() { _operand = LIR_OprFact::illegalOpr; }
673 }
674
675 bool is_illegal() const {
676 return type()->is_illegal();
677 }
678
679 // generic
680 virtual void input_values_do(ValueVisitor* f) {
681 }
682 };
683
684
685 // A local is a placeholder for an incoming argument to a function call.
686 LEAF(Local, Instruction)
687 private:
688 int _java_index; // the local index within the method to which the local belongs
689 bool _is_receiver; // if local variable holds the receiver: "this" for non-static methods
690 ciType* _declared_type;
691 public:
692 // creation
693 Local(ciType* declared, ValueType* type, int index, bool receiver)
694 : Instruction(type)
695 , _java_index(index)
696 , _is_receiver(receiver)
697 , _declared_type(declared)
698 {
699 NOT_PRODUCT(set_printable_bci(-1));
700 }
701
702 // accessors
703 int java_index() const { return _java_index; }
704 bool is_receiver() const { return _is_receiver; }
705
706 virtual ciType* declared_type() const { return _declared_type; }
707
708 // generic
709 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
710 };
711
712
713 LEAF(Constant, Instruction)
714 public:
715 // creation
716 Constant(ValueType* type):
717 Instruction(type, nullptr, /*type_is_constant*/ true)
718 {
800
801 // manipulation
802
803 // Under certain circumstances, if a previous NullCheck instruction
804 // proved the target object non-null, we can eliminate the explicit
805 // null check and do an implicit one, simply specifying the debug
806 // information from the NullCheck. This field should only be consulted
807 // if needs_null_check() is true.
808 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
809
810 // generic
811 virtual bool can_trap() const { return needs_null_check() || needs_patching(); }
812 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); }
813 };
814
815
816 LEAF(LoadField, AccessField)
817 public:
818 // creation
819 LoadField(Value obj, int offset, ciField* field, bool is_static,
820 ValueStack* state_before, bool needs_patching)
821 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
822 {}
823
824 ciType* declared_type() const;
825
826 // generic; cannot be eliminated if needs patching or if volatile.
827 HASHING3(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset(), declared_type())
828 };
829
830
831 LEAF(StoreField, AccessField)
832 private:
833 Value _value;
834
835 public:
836 // creation
837 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
838 ValueStack* state_before, bool needs_patching)
839 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
840 , _value(value)
841 {
842 set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
843 ASSERT_VALUES
844 pin();
845 }
846
847 // accessors
848 Value value() const { return _value; }
849 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); }
850
851 // generic
852 virtual void input_values_do(ValueVisitor* f) { AccessField::input_values_do(f); f->visit(&_value); }
853 };
854
855
856 BASE(AccessArray, Instruction)
857 private:
858 Value _array;
859
860 public:
861 // creation
862 AccessArray(ValueType* type, Value array, ValueStack* state_before)
863 : Instruction(type, state_before)
864 , _array(array)
865 {
866 set_needs_null_check(true);
867 ASSERT_VALUES
868 pin(); // instruction with side effect (null exception or range check throwing)
869 }
887 , _explicit_null_check(nullptr) {}
888
889 // accessors
890 NullCheck* explicit_null_check() const { return _explicit_null_check; }
891
892 // setters
893 // See LoadField::set_explicit_null_check for documentation
894 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
895
896 // generic
897 HASHING1(ArrayLength, true, array()->subst())
898 };
899
900
901 BASE(AccessIndexed, AccessArray)
902 private:
903 Value _index;
904 Value _length;
905 BasicType _elt_type;
906 bool _mismatched;
907
908 public:
909 // creation
910 AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
911 : AccessArray(as_ValueType(elt_type), array, state_before)
912 , _index(index)
913 , _length(length)
914 , _elt_type(elt_type)
915 , _mismatched(mismatched)
916 {
917 set_flag(Instruction::NeedsRangeCheckFlag, true);
918 ASSERT_VALUES
919 }
920
921 // accessors
922 Value index() const { return _index; }
923 Value length() const { return _length; }
924 BasicType elt_type() const { return _elt_type; }
925 bool mismatched() const { return _mismatched; }
926
927 void clear_length() { _length = nullptr; }
928 // perform elimination of range checks involving constants
929 bool compute_needs_range_check();
930
931 // generic
932 virtual void input_values_do(ValueVisitor* f) { AccessArray::input_values_do(f); f->visit(&_index); if (_length != nullptr) f->visit(&_length); }
933 };
934
935
936 LEAF(LoadIndexed, AccessIndexed)
937 private:
938 NullCheck* _explicit_null_check; // For explicit null check elimination
939
940 public:
941 // creation
942 LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
943 : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
944 , _explicit_null_check(nullptr) {}
945
946 // accessors
947 NullCheck* explicit_null_check() const { return _explicit_null_check; }
948
949 // setters
950 // See LoadField::set_explicit_null_check for documentation
951 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
952
953 ciType* exact_type() const;
954 ciType* declared_type() const;
955
956 // generic;
957 HASHING3(LoadIndexed, true, elt_type(), array()->subst(), index()->subst())
958 };
959
960
961 LEAF(StoreIndexed, AccessIndexed)
962 private:
963 Value _value;
964
965 ciMethod* _profiled_method;
966 int _profiled_bci;
967 bool _check_boolean;
968
969 public:
970 // creation
971 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
972 bool check_boolean, bool mismatched = false)
973 : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
974 , _value(value), _profiled_method(nullptr), _profiled_bci(0), _check_boolean(check_boolean)
975 {
976 set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
977 set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
978 ASSERT_VALUES
979 pin();
980 }
981
982 // accessors
983 Value value() const { return _value; }
984 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); }
985 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); }
986 bool check_boolean() const { return _check_boolean; }
987 // Helpers for MethodData* profiling
988 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
989 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
990 void set_profiled_bci(int bci) { _profiled_bci = bci; }
991 bool should_profile() const { return check_flag(ProfileMDOFlag); }
992 ciMethod* profiled_method() const { return _profiled_method; }
993 int profiled_bci() const { return _profiled_bci; }
994 // generic
995 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); }
996 };
997
998
999 LEAF(NegateOp, Instruction)
1000 private:
1001 Value _x;
1002
1003 public:
1004 // creation
1005 NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1006 ASSERT_VALUES
1007 }
1008
1009 // accessors
1010 Value x() const { return _x; }
1011
1012 // generic
1013 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); }
1084 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1085 };
1086
1087
1088 LEAF(CompareOp, Op2)
1089 public:
1090 // creation
1091 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1092 : Op2(intType, op, x, y, state_before)
1093 {}
1094
1095 // generic
1096 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1097 };
1098
1099
1100 LEAF(IfOp, Op2)
1101 private:
1102 Value _tval;
1103 Value _fval;
1104
1105 public:
1106 // creation
1107 IfOp(Value x, Condition cond, Value y, Value tval, Value fval)
1108 : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1109 , _tval(tval)
1110 , _fval(fval)
1111 {
1112 ASSERT_VALUES
1113 assert(tval->type()->tag() == fval->type()->tag(), "types must match");
1114 }
1115
1116 // accessors
1117 virtual bool is_commutative() const;
1118 Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; }
1119 Condition cond() const { return (Condition)Op2::op(); }
1120 Value tval() const { return _tval; }
1121 Value fval() const { return _fval; }
1122
1123 // generic
1124 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1125 };
1126
1127
1128 LEAF(Convert, Instruction)
1129 private:
1130 Bytecodes::Code _op;
1131 Value _value;
1132
1133 public:
1134 // creation
1135 Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1136 ASSERT_VALUES
1137 }
1138
1139 // accessors
1140 Bytecodes::Code op() const { return _op; }
1141 Value value() const { return _value; }
1142
1259 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; }
1260 bool is_method_handle_intrinsic() const { return target()->is_method_handle_intrinsic(); }
1261
1262 virtual bool needs_exception_state() const { return false; }
1263
1264 // generic
1265 virtual bool can_trap() const { return true; }
1266 virtual void input_values_do(ValueVisitor* f) {
1267 StateSplit::input_values_do(f);
1268 if (has_receiver()) f->visit(&_recv);
1269 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1270 }
1271 virtual void state_values_do(ValueVisitor *f);
1272 };
1273
1274
1275 LEAF(NewInstance, StateSplit)
1276 private:
1277 ciInstanceKlass* _klass;
1278 bool _is_unresolved;
1279
1280 public:
1281 // creation
1282 NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
1283 : StateSplit(instanceType, state_before)
1284 , _klass(klass), _is_unresolved(is_unresolved)
1285 {}
1286
1287 // accessors
1288 ciInstanceKlass* klass() const { return _klass; }
1289 bool is_unresolved() const { return _is_unresolved; }
1290
1291 virtual bool needs_exception_state() const { return false; }
1292
1293 // generic
1294 virtual bool can_trap() const { return true; }
1295 ciType* exact_type() const;
1296 ciType* declared_type() const;
1297 };
1298
1299
1300 BASE(NewArray, StateSplit)
1301 private:
1302 Value _length;
1303
1304 public:
1305 // creation
1306 NewArray(Value length, ValueStack* state_before)
1307 : StateSplit(objectType, state_before)
1308 , _length(length)
1309 {
1310 // Do not ASSERT_VALUES since length is null for NewMultiArray
1311 }
1312
1313 // accessors
1314 Value length() const { return _length; }
1315
1316 virtual bool needs_exception_state() const { return false; }
1317
1318 ciType* exact_type() const { return nullptr; }
1319 ciType* declared_type() const;
1330
1331 public:
1332 // creation
1333 NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before)
1334 : NewArray(length, state_before)
1335 , _elt_type(elt_type)
1336 {}
1337
1338 // accessors
1339 BasicType elt_type() const { return _elt_type; }
1340 ciType* exact_type() const;
1341 };
1342
1343
1344 LEAF(NewObjectArray, NewArray)
1345 private:
1346 ciKlass* _klass;
1347
1348 public:
1349 // creation
1350 NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {}
1351
1352 // accessors
1353 ciKlass* klass() const { return _klass; }
1354 ciType* exact_type() const;
1355 };
1356
1357
1358 LEAF(NewMultiArray, NewArray)
1359 private:
1360 ciKlass* _klass;
1361 Values* _dims;
1362
1363 public:
1364 // creation
1365 NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(nullptr, state_before), _klass(klass), _dims(dims) {
1366 ASSERT_VALUES
1367 }
1368
1369 // accessors
1370 ciKlass* klass() const { return _klass; }
1371 Values* dims() const { return _dims; }
1372 int rank() const { return dims()->length(); }
1373
1374 // generic
1375 virtual void input_values_do(ValueVisitor* f) {
1376 // NOTE: we do not call NewArray::input_values_do since "length"
1377 // is meaningless for a multi-dimensional array; passing the
1378 // zeroth element down to NewArray as its length is a bad idea
1379 // since there will be a copy in the "dims" array which doesn't
1380 // get updated, and the value must not be traversed twice. Was bug
1381 // - kbr 4/10/2001
1382 StateSplit::input_values_do(f);
1383 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1384 }
1385 };
1386
1387
1388 BASE(TypeCheck, StateSplit)
1389 private:
1390 ciKlass* _klass;
1391 Value _obj;
1392
1393 ciMethod* _profiled_method;
1394 int _profiled_bci;
1395
1396 public:
1397 // creation
1398 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1399 : StateSplit(type, state_before), _klass(klass), _obj(obj),
1400 _profiled_method(nullptr), _profiled_bci(0) {
1401 ASSERT_VALUES
1402 set_direct_compare(false);
1403 }
1404
1412 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); }
1413
1414 // generic
1415 virtual bool can_trap() const { return true; }
1416 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1417
1418 // Helpers for MethodData* profiling
1419 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
1420 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
1421 void set_profiled_bci(int bci) { _profiled_bci = bci; }
1422 bool should_profile() const { return check_flag(ProfileMDOFlag); }
1423 ciMethod* profiled_method() const { return _profiled_method; }
1424 int profiled_bci() const { return _profiled_bci; }
1425 };
1426
1427
1428 LEAF(CheckCast, TypeCheck)
1429 public:
1430 // creation
1431 CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
1432 : TypeCheck(klass, obj, objectType, state_before) {}
1433
1434 void set_incompatible_class_change_check() {
1435 set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
1436 }
1437 bool is_incompatible_class_change_check() const {
1438 return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1439 }
1440 void set_invokespecial_receiver_check() {
1441 set_flag(InvokeSpecialReceiverCheckFlag, true);
1442 }
1443 bool is_invokespecial_receiver_check() const {
1444 return check_flag(InvokeSpecialReceiverCheckFlag);
1445 }
1446
1447 virtual bool needs_exception_state() const {
1448 return !is_invokespecial_receiver_check();
1449 }
1450
1451 ciType* declared_type() const;
1452 };
1470 // creation
1471 AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1472 : StateSplit(illegalType, state_before)
1473 , _obj(obj)
1474 , _monitor_no(monitor_no)
1475 {
1476 set_needs_null_check(true);
1477 ASSERT_VALUES
1478 }
1479
1480 // accessors
1481 Value obj() const { return _obj; }
1482 int monitor_no() const { return _monitor_no; }
1483
1484 // generic
1485 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1486 };
1487
1488
1489 LEAF(MonitorEnter, AccessMonitor)
1490 public:
1491 // creation
1492 MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1493 : AccessMonitor(obj, monitor_no, state_before)
1494 {
1495 ASSERT_VALUES
1496 }
1497
1498 // generic
1499 virtual bool can_trap() const { return true; }
1500 };
1501
1502
1503 LEAF(MonitorExit, AccessMonitor)
1504 public:
1505 // creation
1506 MonitorExit(Value obj, int monitor_no)
1507 : AccessMonitor(obj, monitor_no, nullptr)
1508 {
1509 ASSERT_VALUES
1510 }
1511 };
1512
1513
1514 LEAF(Intrinsic, StateSplit)
1515 private:
1516 vmIntrinsics::ID _id;
1517 Values* _args;
1937 Condition cond() const { return _cond; }
1938 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
1939 Value y() const { return _y; }
1940
1941 void always_fail() { _x = _y = nullptr; }
1942
1943 // generic
1944 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1945 HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
1946 };
1947
1948 LEAF(If, BlockEnd)
1949 private:
1950 Value _x;
1951 Condition _cond;
1952 Value _y;
1953 ciMethod* _profiled_method;
1954 int _profiled_bci; // Canonicalizer may alter bci of If node
1955 bool _swapped; // Is the order reversed with respect to the original If in the
1956 // bytecode stream?
1957 public:
1958 // creation
1959 // unordered_is_true is valid for float/double compares only
1960 If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint)
1961 : BlockEnd(illegalType, state_before, is_safepoint)
1962 , _x(x)
1963 , _cond(cond)
1964 , _y(y)
1965 , _profiled_method(nullptr)
1966 , _profiled_bci(0)
1967 , _swapped(false)
1968 {
1969 ASSERT_VALUES
1970 set_flag(UnorderedIsTrueFlag, unordered_is_true);
1971 assert(x->type()->tag() == y->type()->tag(), "types must match");
1972 BlockList* s = new BlockList(2);
1973 s->append(tsux);
1974 s->append(fsux);
1975 set_sux(s);
1976 }
1977
1978 // accessors
1979 Value x() const { return _x; }
1980 Condition cond() const { return _cond; }
1981 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
1982 Value y() const { return _y; }
1983 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); }
1984 BlockBegin* tsux() const { return sux_for(true); }
1985 BlockBegin* fsux() const { return sux_for(false); }
1986 BlockBegin* usux() const { return sux_for(unordered_is_true()); }
1987 bool should_profile() const { return check_flag(ProfileMDOFlag); }
1988 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches
1989 int profiled_bci() const { return _profiled_bci; } // set for profiled branches and tiered
1990 bool is_swapped() const { return _swapped; }
1991
1992 // manipulation
1993 void swap_operands() {
1994 Value t = _x; _x = _y; _y = t;
1995 _cond = mirror(_cond);
1996 }
1997
1998 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
1999 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
2000 void set_profiled_bci(int bci) { _profiled_bci = bci; }
2001 void set_swapped(bool value) { _swapped = value; }
2002 // generic
2003 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2004 };
2005
2006
2007 BASE(Switch, BlockEnd)
2008 private:
2009 Value _tag;
2010
2011 public:
2012 // creation
2013 Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2014 : BlockEnd(illegalType, state_before, is_safepoint)
2015 , _tag(tag) {
2016 ASSERT_VALUES
2017 set_sux(sux);
2018 }
2019
2020 // accessors
2021 Value tag() const { return _tag; }
2316 }
2317 }
2318 };
2319
2320 LEAF(ProfileReturnType, Instruction)
2321 private:
2322 ciMethod* _method;
2323 ciMethod* _callee;
2324 int _bci_of_invoke;
2325 Value _ret;
2326
2327 public:
2328 ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2329 : Instruction(voidType)
2330 , _method(method)
2331 , _callee(callee)
2332 , _bci_of_invoke(bci)
2333 , _ret(ret)
2334 {
2335 set_needs_null_check(true);
2336 // The ProfileType has side-effects and must occur precisely where located
2337 pin();
2338 }
2339
2340 ciMethod* method() const { return _method; }
2341 ciMethod* callee() const { return _callee; }
2342 int bci_of_invoke() const { return _bci_of_invoke; }
2343 Value ret() const { return _ret; }
2344
2345 virtual void input_values_do(ValueVisitor* f) {
2346 if (_ret != nullptr) {
2347 f->visit(&_ret);
2348 }
2349 }
2350 };
2351
2352 // Call some C runtime function that doesn't safepoint,
2353 // optionally passing the current thread as the first argument.
2354 LEAF(RuntimeCall, Instruction)
2355 private:
2356 const char* _entry_name;
2357 address _entry;
2358 Values* _args;
2359 bool _pass_thread; // Pass the JavaThread* as an implicit first argument
2360
2361 public:
2362 RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2363 : Instruction(type)
2364 , _entry_name(entry_name)
2365 , _entry(entry)
2366 , _args(args)
2367 , _pass_thread(pass_thread) {
2368 ASSERT_VALUES
2369 pin();
2370 }
2371
|
57 class StoreIndexed;
58 class NegateOp;
59 class Op2;
60 class ArithmeticOp;
61 class ShiftOp;
62 class LogicOp;
63 class CompareOp;
64 class IfOp;
65 class Convert;
66 class NullCheck;
67 class TypeCast;
68 class OsrEntry;
69 class ExceptionObject;
70 class StateSplit;
71 class Invoke;
72 class NewInstance;
73 class NewArray;
74 class NewTypeArray;
75 class NewObjectArray;
76 class NewMultiArray;
77 class Deoptimize;
78 class TypeCheck;
79 class CheckCast;
80 class InstanceOf;
81 class AccessMonitor;
82 class MonitorEnter;
83 class MonitorExit;
84 class Intrinsic;
85 class BlockBegin;
86 class BlockEnd;
87 class Goto;
88 class If;
89 class Switch;
90 class TableSwitch;
91 class LookupSwitch;
92 class Return;
93 class Throw;
94 class Base;
95 class RoundFP;
96 class UnsafeOp;
97 class UnsafeGet;
98 class UnsafePut;
99 class UnsafeGetAndSet;
100 class ProfileCall;
101 class ProfileReturnType;
102 class ProfileACmpTypes;
103 class ProfileInvoke;
104 class RuntimeCall;
105 class MemBar;
106 class RangeCheckPredicate;
107 #ifdef ASSERT
108 class Assert;
109 #endif
110
111 // A Value is a reference to the instruction creating the value
112 typedef Instruction* Value;
113 typedef GrowableArray<Value> Values;
114 typedef GrowableArray<ValueStack*> ValueStackStack;
115
116 // BlockClosure is the base class for block traversal/iteration.
117
118 class BlockClosure: public CompilationResourceObj {
119 public:
120 virtual void block_do(BlockBegin* block) = 0;
121 };
122
178 virtual void do_InstanceOf (InstanceOf* x) = 0;
179 virtual void do_MonitorEnter (MonitorEnter* x) = 0;
180 virtual void do_MonitorExit (MonitorExit* x) = 0;
181 virtual void do_Intrinsic (Intrinsic* x) = 0;
182 virtual void do_BlockBegin (BlockBegin* x) = 0;
183 virtual void do_Goto (Goto* x) = 0;
184 virtual void do_If (If* x) = 0;
185 virtual void do_TableSwitch (TableSwitch* x) = 0;
186 virtual void do_LookupSwitch (LookupSwitch* x) = 0;
187 virtual void do_Return (Return* x) = 0;
188 virtual void do_Throw (Throw* x) = 0;
189 virtual void do_Base (Base* x) = 0;
190 virtual void do_OsrEntry (OsrEntry* x) = 0;
191 virtual void do_ExceptionObject(ExceptionObject* x) = 0;
192 virtual void do_RoundFP (RoundFP* x) = 0;
193 virtual void do_UnsafeGet (UnsafeGet* x) = 0;
194 virtual void do_UnsafePut (UnsafePut* x) = 0;
195 virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x) = 0;
196 virtual void do_ProfileCall (ProfileCall* x) = 0;
197 virtual void do_ProfileReturnType (ProfileReturnType* x) = 0;
198 virtual void do_ProfileACmpTypes(ProfileACmpTypes* x) = 0;
199 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
200 virtual void do_RuntimeCall (RuntimeCall* x) = 0;
201 virtual void do_MemBar (MemBar* x) = 0;
202 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
203 #ifdef ASSERT
204 virtual void do_Assert (Assert* x) = 0;
205 #endif
206 };
207
208
209 // Hashing support
210 //
211 // Note: This hash functions affect the performance
212 // of ValueMap - make changes carefully!
213
214 #define HASH1(x1 ) ((intx)(x1))
215 #define HASH2(x1, x2 ) ((HASH1(x1 ) << 7) ^ HASH1(x2))
216 #define HASH3(x1, x2, x3 ) ((HASH2(x1, x2 ) << 7) ^ HASH1(x3))
217 #define HASH4(x1, x2, x3, x4) ((HASH3(x1, x2, x3 ) << 7) ^ HASH1(x4))
218 #define HASH5(x1, x2, x3, x4, x5) ((HASH4(x1, x2, x3, x4) << 7) ^ HASH1(x5))
219
220
221 // The following macros are used to implement instruction-specific hashing.
222 // By default, each instruction implements hash() and is_equal(Value), used
223 // for value numbering/common subexpression elimination. The default imple-
224 // mentation disables value numbering. Each instruction which can be value-
225 // numbered, should define corresponding hash() and is_equal(Value) functions
226 // via the macros below. The f arguments specify all the values/op codes, etc.
227 // that need to be identical for two instructions to be identical.
228 //
229 // Note: The default implementation of hash() returns 0 in order to indicate
230 // that the instruction should not be considered for value numbering.
231 // The currently used hash functions do not guarantee that never a 0
232 // is produced. While this is still correct, it may be a performance
233 // bug (no value numbering for that node). However, this situation is
234 // so unlikely, that we are not going to handle it specially.
235
236 #define HASHING1(class_name, enabled, f1) \
237 virtual intx hash() const { \
238 return (enabled) ? HASH2(name(), f1) : 0; \
257 if (f1 != _v->f1) return false; \
258 if (f2 != _v->f2) return false; \
259 return true; \
260 } \
261
262
263 #define HASHING3(class_name, enabled, f1, f2, f3) \
264 virtual intx hash() const { \
265 return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
266 } \
267 virtual bool is_equal(Value v) const { \
268 if (!(enabled) ) return false; \
269 class_name* _v = v->as_##class_name(); \
270 if (_v == nullptr) return false; \
271 if (f1 != _v->f1) return false; \
272 if (f2 != _v->f2) return false; \
273 if (f3 != _v->f3) return false; \
274 return true; \
275 } \
276
277 #define HASHING4(class_name, enabled, f1, f2, f3, f4) \
278 virtual intx hash() const { \
279 return (enabled) ? HASH5(name(), f1, f2, f3, f4) : 0; \
280 } \
281 virtual bool is_equal(Value v) const { \
282 if (!(enabled) ) return false; \
283 class_name* _v = v->as_##class_name(); \
284 if (_v == nullptr ) return false; \
285 if (f1 != _v->f1) return false; \
286 if (f2 != _v->f2) return false; \
287 if (f3 != _v->f3) return false; \
288 if (f4 != _v->f4) return false; \
289 return true; \
290 } \
291
292
293 // The mother of all instructions...
294
295 class Instruction: public CompilationResourceObj {
296 private:
297 int _id; // the unique instruction id
298 #ifndef PRODUCT
299 int _printable_bci; // the bci of the instruction for printing
300 #endif
301 int _use_count; // the number of instructions referring to this value (w/o prev/next); only roots can have use count = 0 or > 1
302 int _pin_state; // set of PinReason describing the reason for pinning
303 ValueType* _type; // the instruction value type
304 Instruction* _next; // the next instruction if any (null for BlockEnd instructions)
305 Instruction* _subst; // the substitution instruction if any
306 LIR_Opr _operand; // LIR specific information
307 unsigned int _flags; // Flag bits
308
309 ValueStack* _state_before; // Copy of state with input operands still on stack (or null)
310 ValueStack* _exception_state; // Copy of state for exception handling
311 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction
312
313 friend class UseCountComputer;
314 friend class GraphBuilder;
315
316 void update_exception_state(ValueStack* state);
317
318 protected:
319 BlockBegin* _block; // Block that contains this instruction
320
321 void set_type(ValueType* type) {
322 assert(type != nullptr, "type must exist");
323 _type = type;
324 }
325
326 // Helper class to keep track of which arguments need a null check
327 class ArgsNonNullState {
328 private:
329 int _nonnull_state; // mask identifying which args are nonnull
330 public:
331 ArgsNonNullState()
332 : _nonnull_state(AllBits) {}
333
334 // Does argument number i needs a null check?
347 if (check) {
348 _nonnull_state |= (int)nth_bit(i);
349 } else {
350 _nonnull_state &= (int)~(nth_bit(i));
351 }
352 }
353 }
354 };
355
356 public:
357 void* operator new(size_t size) throw() {
358 Compilation* c = Compilation::current();
359 void* res = c->arena()->Amalloc(size);
360 return res;
361 }
362
363 static const int no_bci = -99;
364
365 enum InstructionFlag {
366 NeedsNullCheckFlag = 0,
367 NeverNullFlag, // For "Q" signatures
368 CanTrapFlag,
369 DirectCompareFlag,
370 IsEliminatedFlag,
371 IsSafepointFlag,
372 IsStaticFlag,
373 NeedsStoreCheckFlag,
374 NeedsWriteBarrierFlag,
375 PreservesStateFlag,
376 TargetIsFinalFlag,
377 TargetIsLoadedFlag,
378 UnorderedIsTrueFlag,
379 NeedsPatchingFlag,
380 ThrowIncompatibleClassChangeErrorFlag,
381 InvokeSpecialReceiverCheckFlag,
382 ProfileMDOFlag,
383 IsLinkedInBlockFlag,
384 NeedsRangeCheckFlag,
385 InWorkListFlag,
386 DeoptimizeOnException,
387 KillsMemoryFlag,
441 int id() const { return _id; }
442 #ifndef PRODUCT
443 bool has_printable_bci() const { return _printable_bci != -99; }
444 int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
445 void set_printable_bci(int bci) { _printable_bci = bci; }
446 #endif
447 int dominator_depth();
448 int use_count() const { return _use_count; }
449 int pin_state() const { return _pin_state; }
450 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; }
451 ValueType* type() const { return _type; }
452 BlockBegin *block() const { return _block; }
453 Instruction* prev(); // use carefully, expensive operation
454 Instruction* next() const { return _next; }
455 bool has_subst() const { return _subst != nullptr; }
456 Instruction* subst() { return _subst == nullptr ? this : _subst->subst(); }
457 LIR_Opr operand() const { return _operand; }
458
459 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); }
460 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); }
461 void set_null_free(bool f) { set_flag(NeverNullFlag, f); }
462 bool is_null_free() const { return check_flag(NeverNullFlag); }
463 bool is_linked() const { return check_flag(IsLinkedInBlockFlag); }
464 bool can_be_linked() { return as_Local() == nullptr && as_Phi() == nullptr; }
465
466 bool is_null_obj() { return as_Constant() != nullptr && type()->as_ObjectType()->constant_value()->is_null_object(); }
467
468 bool has_uses() const { return use_count() > 0; }
469 ValueStack* state_before() const { return _state_before; }
470 ValueStack* exception_state() const { return _exception_state; }
471 virtual bool needs_exception_state() const { return true; }
472 XHandlers* exception_handlers() const { return _exception_handlers; }
473 ciKlass* as_loaded_klass_or_null() const;
474
475 // manipulation
476 void pin(PinReason reason) { _pin_state |= reason; }
477 void pin() { _pin_state |= PinUnknown; }
478 // DANGEROUS: only used by EliminateStores
479 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
480
481 Instruction* set_next(Instruction* next) {
482 assert(next->has_printable_bci(), "_printable_bci should have been set");
483 assert(next != nullptr, "must not be null");
484 assert(as_BlockEnd() == nullptr, "BlockEnd instructions must have no next");
485 assert(next->can_be_linked(), "shouldn't link these instructions into list");
486
487 BlockBegin *block = this->block();
488 next->_block = block;
489
490 next->set_flag(Instruction::IsLinkedInBlockFlag, true);
491 _next = next;
492 return next;
493 }
498 #endif
499 return set_next(next);
500 }
501
502 // when blocks are merged
503 void fixup_block_pointers() {
504 Instruction *cur = next()->next(); // next()'s block is set in set_next
505 while (cur && cur->_block != block()) {
506 cur->_block = block();
507 cur = cur->next();
508 }
509 }
510
511 Instruction *insert_after(Instruction *i) {
512 Instruction* n = _next;
513 set_next(i);
514 i->set_next(n);
515 return _next;
516 }
517
518 bool is_loaded_flat_array() const;
519 bool maybe_flat_array();
520 bool maybe_null_free_array();
521
522 Instruction *insert_after_same_bci(Instruction *i) {
523 #ifndef PRODUCT
524 i->set_printable_bci(printable_bci());
525 #endif
526 return insert_after(i);
527 }
528
529 void set_subst(Instruction* subst) {
530 assert(subst == nullptr ||
531 type()->base() == subst->type()->base() ||
532 subst->type()->base() == illegalType, "type can't change");
533 _subst = subst;
534 }
535 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
536 void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; }
537 void set_state_before(ValueStack* s) { check_state(s); _state_before = s; }
538
539 // machine-specifics
540 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
541 void clear_operand() { _operand = LIR_OprFact::illegalOpr; }
701 }
702
703 bool is_illegal() const {
704 return type()->is_illegal();
705 }
706
707 // generic
708 virtual void input_values_do(ValueVisitor* f) {
709 }
710 };
711
712
713 // A local is a placeholder for an incoming argument to a function call.
714 LEAF(Local, Instruction)
715 private:
716 int _java_index; // the local index within the method to which the local belongs
717 bool _is_receiver; // if local variable holds the receiver: "this" for non-static methods
718 ciType* _declared_type;
719 public:
720 // creation
721 Local(ciType* declared, ValueType* type, int index, bool receiver, bool null_free)
722 : Instruction(type)
723 , _java_index(index)
724 , _is_receiver(receiver)
725 , _declared_type(declared)
726 {
727 set_null_free(null_free);
728 NOT_PRODUCT(set_printable_bci(-1));
729 }
730
731 // accessors
732 int java_index() const { return _java_index; }
733 bool is_receiver() const { return _is_receiver; }
734
735 virtual ciType* declared_type() const { return _declared_type; }
736
737 // generic
738 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
739 };
740
741
742 LEAF(Constant, Instruction)
743 public:
744 // creation
745 Constant(ValueType* type):
746 Instruction(type, nullptr, /*type_is_constant*/ true)
747 {
829
830 // manipulation
831
832 // Under certain circumstances, if a previous NullCheck instruction
833 // proved the target object non-null, we can eliminate the explicit
834 // null check and do an implicit one, simply specifying the debug
835 // information from the NullCheck. This field should only be consulted
836 // if needs_null_check() is true.
837 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
838
839 // generic
840 virtual bool can_trap() const { return needs_null_check() || needs_patching(); }
841 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); }
842 };
843
844
845 LEAF(LoadField, AccessField)
846 public:
847 // creation
848 LoadField(Value obj, int offset, ciField* field, bool is_static,
849 ValueStack* state_before, bool needs_patching,
850 ciInlineKlass* inline_klass = nullptr, Value default_value = nullptr )
851 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
852 {
853 set_null_free(field->is_null_free());
854 }
855
856 ciType* declared_type() const;
857
858 // generic; cannot be eliminated if needs patching or if volatile.
859 HASHING3(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset(), declared_type())
860 };
861
862
863 LEAF(StoreField, AccessField)
864 private:
865 Value _value;
866 ciField* _enclosing_field; // enclosing field (the flat one) for nested fields
867
868 public:
869 // creation
870 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
871 ValueStack* state_before, bool needs_patching);
872
873 // accessors
874 Value value() const { return _value; }
875 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); }
876 ciField* enclosing_field() const { return _enclosing_field; }
877 void set_enclosing_field(ciField* field) { _enclosing_field = field; }
878
879 // generic
880 virtual void input_values_do(ValueVisitor* f) { AccessField::input_values_do(f); f->visit(&_value); }
881 };
882
883
884 BASE(AccessArray, Instruction)
885 private:
886 Value _array;
887
888 public:
889 // creation
890 AccessArray(ValueType* type, Value array, ValueStack* state_before)
891 : Instruction(type, state_before)
892 , _array(array)
893 {
894 set_needs_null_check(true);
895 ASSERT_VALUES
896 pin(); // instruction with side effect (null exception or range check throwing)
897 }
915 , _explicit_null_check(nullptr) {}
916
917 // accessors
918 NullCheck* explicit_null_check() const { return _explicit_null_check; }
919
920 // setters
921 // See LoadField::set_explicit_null_check for documentation
922 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
923
924 // generic
925 HASHING1(ArrayLength, true, array()->subst())
926 };
927
928
929 BASE(AccessIndexed, AccessArray)
930 private:
931 Value _index;
932 Value _length;
933 BasicType _elt_type;
934 bool _mismatched;
935 ciMethod* _profiled_method;
936 int _profiled_bci;
937
938 public:
939 // creation
940 AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
941 : AccessArray(as_ValueType(elt_type), array, state_before)
942 , _index(index)
943 , _length(length)
944 , _elt_type(elt_type)
945 , _mismatched(mismatched)
946 , _profiled_method(nullptr), _profiled_bci(0)
947 {
948 set_flag(Instruction::NeedsRangeCheckFlag, true);
949 ASSERT_VALUES
950 }
951
952 // accessors
953 Value index() const { return _index; }
954 Value length() const { return _length; }
955 BasicType elt_type() const { return _elt_type; }
956 bool mismatched() const { return _mismatched; }
957
958 void clear_length() { _length = nullptr; }
959 // perform elimination of range checks involving constants
960 bool compute_needs_range_check();
961
962 // Helpers for MethodData* profiling
963 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
964 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
965 void set_profiled_bci(int bci) { _profiled_bci = bci; }
966 bool should_profile() const { return check_flag(ProfileMDOFlag); }
967 ciMethod* profiled_method() const { return _profiled_method; }
968 int profiled_bci() const { return _profiled_bci; }
969
970
971 // generic
972 virtual void input_values_do(ValueVisitor* f) { AccessArray::input_values_do(f); f->visit(&_index); if (_length != nullptr) f->visit(&_length); }
973 };
974
975 class DelayedLoadIndexed;
976
977 LEAF(LoadIndexed, AccessIndexed)
978 private:
979 NullCheck* _explicit_null_check; // For explicit null check elimination
980 NewInstance* _vt;
981 DelayedLoadIndexed* _delayed;
982
983 public:
984 // creation
985 LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
986 : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
987 , _explicit_null_check(nullptr), _vt(nullptr), _delayed(nullptr) {}
988
989 // accessors
990 NullCheck* explicit_null_check() const { return _explicit_null_check; }
991
992 // setters
993 // See LoadField::set_explicit_null_check for documentation
994 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
995
996 ciType* exact_type() const;
997 ciType* declared_type() const;
998
999 NewInstance* vt() const { return _vt; }
1000 void set_vt(NewInstance* vt) { _vt = vt; }
1001
1002 DelayedLoadIndexed* delayed() const { return _delayed; }
1003 void set_delayed(DelayedLoadIndexed* delayed) { _delayed = delayed; }
1004
1005 // generic;
1006 HASHING4(LoadIndexed, delayed() == nullptr && !should_profile(), elt_type(), array()->subst(), index()->subst(), vt())
1007 };
1008
1009 class DelayedLoadIndexed : public CompilationResourceObj {
1010 private:
1011 LoadIndexed* _load_instr;
1012 ValueStack* _state_before;
1013 ciField* _field;
1014 int _offset;
1015 public:
1016 DelayedLoadIndexed(LoadIndexed* load, ValueStack* state_before)
1017 : _load_instr(load)
1018 , _state_before(state_before)
1019 , _field(nullptr)
1020 , _offset(0) { }
1021
1022 void update(ciField* field, int offset) {
1023 _field = field;
1024 _offset += offset;
1025 }
1026
1027 LoadIndexed* load_instr() const { return _load_instr; }
1028 ValueStack* state_before() const { return _state_before; }
1029 ciField* field() const { return _field; }
1030 int offset() const { return _offset; }
1031 };
1032
1033 LEAF(StoreIndexed, AccessIndexed)
1034 private:
1035 Value _value;
1036
1037 bool _check_boolean;
1038
1039 public:
1040 // creation
1041 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
1042 bool check_boolean, bool mismatched = false);
1043
1044 // accessors
1045 Value value() const { return _value; }
1046 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); }
1047 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); }
1048 bool check_boolean() const { return _check_boolean; }
1049
1050 // Flattened array support
1051 bool is_exact_flat_array_store() const;
1052 // generic
1053 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); }
1054 };
1055
1056
1057 LEAF(NegateOp, Instruction)
1058 private:
1059 Value _x;
1060
1061 public:
1062 // creation
1063 NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1064 ASSERT_VALUES
1065 }
1066
1067 // accessors
1068 Value x() const { return _x; }
1069
1070 // generic
1071 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); }
1142 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1143 };
1144
1145
1146 LEAF(CompareOp, Op2)
1147 public:
1148 // creation
1149 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1150 : Op2(intType, op, x, y, state_before)
1151 {}
1152
1153 // generic
1154 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1155 };
1156
1157
1158 LEAF(IfOp, Op2)
1159 private:
1160 Value _tval;
1161 Value _fval;
1162 bool _substitutability_check;
1163
1164 public:
1165 // creation
1166 IfOp(Value x, Condition cond, Value y, Value tval, Value fval, ValueStack* state_before, bool substitutability_check)
1167 : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1168 , _tval(tval)
1169 , _fval(fval)
1170 , _substitutability_check(substitutability_check)
1171 {
1172 ASSERT_VALUES
1173 assert(tval->type()->tag() == fval->type()->tag(), "types must match");
1174 set_state_before(state_before);
1175 }
1176
1177 // accessors
1178 virtual bool is_commutative() const;
1179 Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; }
1180 Condition cond() const { return (Condition)Op2::op(); }
1181 Value tval() const { return _tval; }
1182 Value fval() const { return _fval; }
1183 bool substitutability_check() const { return _substitutability_check; }
1184 // generic
1185 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1186 };
1187
1188
1189 LEAF(Convert, Instruction)
1190 private:
1191 Bytecodes::Code _op;
1192 Value _value;
1193
1194 public:
1195 // creation
1196 Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1197 ASSERT_VALUES
1198 }
1199
1200 // accessors
1201 Bytecodes::Code op() const { return _op; }
1202 Value value() const { return _value; }
1203
1320 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; }
1321 bool is_method_handle_intrinsic() const { return target()->is_method_handle_intrinsic(); }
1322
1323 virtual bool needs_exception_state() const { return false; }
1324
1325 // generic
1326 virtual bool can_trap() const { return true; }
1327 virtual void input_values_do(ValueVisitor* f) {
1328 StateSplit::input_values_do(f);
1329 if (has_receiver()) f->visit(&_recv);
1330 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1331 }
1332 virtual void state_values_do(ValueVisitor *f);
1333 };
1334
1335
1336 LEAF(NewInstance, StateSplit)
1337 private:
1338 ciInstanceKlass* _klass;
1339 bool _is_unresolved;
1340 bool _needs_state_before;
1341
1342 public:
1343 // creation
1344 NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved, bool needs_state_before)
1345 : StateSplit(instanceType, state_before)
1346 , _klass(klass), _is_unresolved(is_unresolved), _needs_state_before(needs_state_before)
1347 {}
1348
1349 // accessors
1350 ciInstanceKlass* klass() const { return _klass; }
1351 bool is_unresolved() const { return _is_unresolved; }
1352 bool needs_state_before() const { return _needs_state_before; }
1353
1354 virtual bool needs_exception_state() const { return false; }
1355
1356 // generic
1357 virtual bool can_trap() const { return true; }
1358 ciType* exact_type() const;
1359 ciType* declared_type() const;
1360 };
1361
1362 BASE(NewArray, StateSplit)
1363 private:
1364 Value _length;
1365
1366 public:
1367 // creation
1368 NewArray(Value length, ValueStack* state_before)
1369 : StateSplit(objectType, state_before)
1370 , _length(length)
1371 {
1372 // Do not ASSERT_VALUES since length is null for NewMultiArray
1373 }
1374
1375 // accessors
1376 Value length() const { return _length; }
1377
1378 virtual bool needs_exception_state() const { return false; }
1379
1380 ciType* exact_type() const { return nullptr; }
1381 ciType* declared_type() const;
1392
1393 public:
1394 // creation
1395 NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before)
1396 : NewArray(length, state_before)
1397 , _elt_type(elt_type)
1398 {}
1399
1400 // accessors
1401 BasicType elt_type() const { return _elt_type; }
1402 ciType* exact_type() const;
1403 };
1404
1405
1406 LEAF(NewObjectArray, NewArray)
1407 private:
1408 ciKlass* _klass;
1409
1410 public:
1411 // creation
1412 NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before)
1413 : NewArray(length, state_before), _klass(klass) { }
1414
1415 // accessors
1416 ciKlass* klass() const { return _klass; }
1417 ciType* exact_type() const;
1418 };
1419
1420
1421 LEAF(NewMultiArray, NewArray)
1422 private:
1423 ciKlass* _klass;
1424 Values* _dims;
1425
1426 public:
1427 // creation
1428 NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(nullptr, state_before), _klass(klass), _dims(dims) {
1429 ASSERT_VALUES
1430 }
1431
1432 // accessors
1433 ciKlass* klass() const { return _klass; }
1434 Values* dims() const { return _dims; }
1435 int rank() const { return dims()->length(); }
1436
1437 // generic
1438 virtual void input_values_do(ValueVisitor* f) {
1439 // NOTE: we do not call NewArray::input_values_do since "length"
1440 // is meaningless for a multi-dimensional array; passing the
1441 // zeroth element down to NewArray as its length is a bad idea
1442 // since there will be a copy in the "dims" array which doesn't
1443 // get updated, and the value must not be traversed twice. Was bug
1444 // - kbr 4/10/2001
1445 StateSplit::input_values_do(f);
1446 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1447 }
1448
1449 ciType* exact_type() const;
1450 };
1451
1452
1453 BASE(TypeCheck, StateSplit)
1454 private:
1455 ciKlass* _klass;
1456 Value _obj;
1457
1458 ciMethod* _profiled_method;
1459 int _profiled_bci;
1460
1461 public:
1462 // creation
1463 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1464 : StateSplit(type, state_before), _klass(klass), _obj(obj),
1465 _profiled_method(nullptr), _profiled_bci(0) {
1466 ASSERT_VALUES
1467 set_direct_compare(false);
1468 }
1469
1477 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); }
1478
1479 // generic
1480 virtual bool can_trap() const { return true; }
1481 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1482
1483 // Helpers for MethodData* profiling
1484 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
1485 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
1486 void set_profiled_bci(int bci) { _profiled_bci = bci; }
1487 bool should_profile() const { return check_flag(ProfileMDOFlag); }
1488 ciMethod* profiled_method() const { return _profiled_method; }
1489 int profiled_bci() const { return _profiled_bci; }
1490 };
1491
1492
1493 LEAF(CheckCast, TypeCheck)
1494 public:
1495 // creation
1496 CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
1497 : TypeCheck(klass, obj, objectType, state_before) { }
1498
1499 void set_incompatible_class_change_check() {
1500 set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
1501 }
1502 bool is_incompatible_class_change_check() const {
1503 return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1504 }
1505 void set_invokespecial_receiver_check() {
1506 set_flag(InvokeSpecialReceiverCheckFlag, true);
1507 }
1508 bool is_invokespecial_receiver_check() const {
1509 return check_flag(InvokeSpecialReceiverCheckFlag);
1510 }
1511
1512 virtual bool needs_exception_state() const {
1513 return !is_invokespecial_receiver_check();
1514 }
1515
1516 ciType* declared_type() const;
1517 };
1535 // creation
1536 AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1537 : StateSplit(illegalType, state_before)
1538 , _obj(obj)
1539 , _monitor_no(monitor_no)
1540 {
1541 set_needs_null_check(true);
1542 ASSERT_VALUES
1543 }
1544
1545 // accessors
1546 Value obj() const { return _obj; }
1547 int monitor_no() const { return _monitor_no; }
1548
1549 // generic
1550 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1551 };
1552
1553
1554 LEAF(MonitorEnter, AccessMonitor)
1555 bool _maybe_inlinetype;
1556 public:
1557 // creation
1558 MonitorEnter(Value obj, int monitor_no, ValueStack* state_before, bool maybe_inlinetype)
1559 : AccessMonitor(obj, monitor_no, state_before)
1560 , _maybe_inlinetype(maybe_inlinetype)
1561 {
1562 ASSERT_VALUES
1563 }
1564
1565 // accessors
1566 bool maybe_inlinetype() const { return _maybe_inlinetype; }
1567
1568 // generic
1569 virtual bool can_trap() const { return true; }
1570 };
1571
1572
1573 LEAF(MonitorExit, AccessMonitor)
1574 public:
1575 // creation
1576 MonitorExit(Value obj, int monitor_no)
1577 : AccessMonitor(obj, monitor_no, nullptr)
1578 {
1579 ASSERT_VALUES
1580 }
1581 };
1582
1583
1584 LEAF(Intrinsic, StateSplit)
1585 private:
1586 vmIntrinsics::ID _id;
1587 Values* _args;
2007 Condition cond() const { return _cond; }
2008 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
2009 Value y() const { return _y; }
2010
2011 void always_fail() { _x = _y = nullptr; }
2012
2013 // generic
2014 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2015 HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
2016 };
2017
2018 LEAF(If, BlockEnd)
2019 private:
2020 Value _x;
2021 Condition _cond;
2022 Value _y;
2023 ciMethod* _profiled_method;
2024 int _profiled_bci; // Canonicalizer may alter bci of If node
2025 bool _swapped; // Is the order reversed with respect to the original If in the
2026 // bytecode stream?
2027 bool _substitutability_check;
2028 public:
2029 // creation
2030 // unordered_is_true is valid for float/double compares only
2031 If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint, bool substitutability_check=false)
2032 : BlockEnd(illegalType, state_before, is_safepoint)
2033 , _x(x)
2034 , _cond(cond)
2035 , _y(y)
2036 , _profiled_method(nullptr)
2037 , _profiled_bci(0)
2038 , _swapped(false)
2039 , _substitutability_check(substitutability_check)
2040 {
2041 ASSERT_VALUES
2042 set_flag(UnorderedIsTrueFlag, unordered_is_true);
2043 assert(x->type()->tag() == y->type()->tag(), "types must match");
2044 BlockList* s = new BlockList(2);
2045 s->append(tsux);
2046 s->append(fsux);
2047 set_sux(s);
2048 }
2049
2050 // accessors
2051 Value x() const { return _x; }
2052 Condition cond() const { return _cond; }
2053 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
2054 Value y() const { return _y; }
2055 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); }
2056 BlockBegin* tsux() const { return sux_for(true); }
2057 BlockBegin* fsux() const { return sux_for(false); }
2058 BlockBegin* usux() const { return sux_for(unordered_is_true()); }
2059 bool should_profile() const { return check_flag(ProfileMDOFlag); }
2060 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches
2061 int profiled_bci() const { return _profiled_bci; } // set for profiled branches and tiered
2062 bool is_swapped() const { return _swapped; }
2063
2064 // manipulation
2065 void swap_operands() {
2066 Value t = _x; _x = _y; _y = t;
2067 _cond = mirror(_cond);
2068 }
2069
2070 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
2071 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
2072 void set_profiled_bci(int bci) { _profiled_bci = bci; }
2073 void set_swapped(bool value) { _swapped = value; }
2074 bool substitutability_check() const { return _substitutability_check; }
2075 // generic
2076 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2077 };
2078
2079
2080 BASE(Switch, BlockEnd)
2081 private:
2082 Value _tag;
2083
2084 public:
2085 // creation
2086 Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2087 : BlockEnd(illegalType, state_before, is_safepoint)
2088 , _tag(tag) {
2089 ASSERT_VALUES
2090 set_sux(sux);
2091 }
2092
2093 // accessors
2094 Value tag() const { return _tag; }
2389 }
2390 }
2391 };
2392
2393 LEAF(ProfileReturnType, Instruction)
2394 private:
2395 ciMethod* _method;
2396 ciMethod* _callee;
2397 int _bci_of_invoke;
2398 Value _ret;
2399
2400 public:
2401 ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2402 : Instruction(voidType)
2403 , _method(method)
2404 , _callee(callee)
2405 , _bci_of_invoke(bci)
2406 , _ret(ret)
2407 {
2408 set_needs_null_check(true);
2409 // The ProfileReturnType has side-effects and must occur precisely where located
2410 pin();
2411 }
2412
2413 ciMethod* method() const { return _method; }
2414 ciMethod* callee() const { return _callee; }
2415 int bci_of_invoke() const { return _bci_of_invoke; }
2416 Value ret() const { return _ret; }
2417
2418 virtual void input_values_do(ValueVisitor* f) {
2419 if (_ret != nullptr) {
2420 f->visit(&_ret);
2421 }
2422 }
2423 };
2424
2425 LEAF(ProfileACmpTypes, Instruction)
2426 private:
2427 ciMethod* _method;
2428 int _bci;
2429 Value _left;
2430 Value _right;
2431 bool _left_maybe_null;
2432 bool _right_maybe_null;
2433
2434 public:
2435 ProfileACmpTypes(ciMethod* method, int bci, Value left, Value right)
2436 : Instruction(voidType)
2437 , _method(method)
2438 , _bci(bci)
2439 , _left(left)
2440 , _right(right)
2441 {
2442 // The ProfileACmp has side-effects and must occur precisely where located
2443 pin();
2444 _left_maybe_null = true;
2445 _right_maybe_null = true;
2446 }
2447
2448 ciMethod* method() const { return _method; }
2449 int bci() const { return _bci; }
2450 Value left() const { return _left; }
2451 Value right() const { return _right; }
2452 bool left_maybe_null() const { return _left_maybe_null; }
2453 bool right_maybe_null() const { return _right_maybe_null; }
2454 void set_left_maybe_null(bool v) { _left_maybe_null = v; }
2455 void set_right_maybe_null(bool v) { _right_maybe_null = v; }
2456
2457 virtual void input_values_do(ValueVisitor* f) {
2458 if (_left != nullptr) {
2459 f->visit(&_left);
2460 }
2461 if (_right != nullptr) {
2462 f->visit(&_right);
2463 }
2464 }
2465 };
2466
2467 // Call some C runtime function that doesn't safepoint,
2468 // optionally passing the current thread as the first argument.
2469 LEAF(RuntimeCall, Instruction)
2470 private:
2471 const char* _entry_name;
2472 address _entry;
2473 Values* _args;
2474 bool _pass_thread; // Pass the JavaThread* as an implicit first argument
2475
2476 public:
2477 RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2478 : Instruction(type)
2479 , _entry_name(entry_name)
2480 , _entry(entry)
2481 , _args(args)
2482 , _pass_thread(pass_thread) {
2483 ASSERT_VALUES
2484 pin();
2485 }
2486
|