1 /*
2 * Copyright (c) 1999, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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 UnsafeOp;
95 class UnsafeGet;
96 class UnsafePut;
97 class UnsafeGetAndSet;
98 class ProfileCall;
99 class ProfileReturnType;
100 class ProfileInvoke;
101 class RuntimeCall;
102 class MemBar;
103 class RangeCheckPredicate;
104 #ifdef ASSERT
105 class Assert;
106 #endif
107
108 // A Value is a reference to the instruction creating the value
109 typedef Instruction* Value;
110 typedef GrowableArray<Value> Values;
111 typedef GrowableArray<ValueStack*> ValueStackStack;
112
113 // BlockClosure is the base class for block traversal/iteration.
114
115 class BlockClosure: public CompilationResourceObj {
116 public:
117 virtual void block_do(BlockBegin* block) = 0;
118 };
119
174 virtual void do_CheckCast (CheckCast* x) = 0;
175 virtual void do_InstanceOf (InstanceOf* x) = 0;
176 virtual void do_MonitorEnter (MonitorEnter* x) = 0;
177 virtual void do_MonitorExit (MonitorExit* x) = 0;
178 virtual void do_Intrinsic (Intrinsic* x) = 0;
179 virtual void do_BlockBegin (BlockBegin* x) = 0;
180 virtual void do_Goto (Goto* x) = 0;
181 virtual void do_If (If* x) = 0;
182 virtual void do_TableSwitch (TableSwitch* x) = 0;
183 virtual void do_LookupSwitch (LookupSwitch* x) = 0;
184 virtual void do_Return (Return* x) = 0;
185 virtual void do_Throw (Throw* x) = 0;
186 virtual void do_Base (Base* x) = 0;
187 virtual void do_OsrEntry (OsrEntry* x) = 0;
188 virtual void do_ExceptionObject(ExceptionObject* x) = 0;
189 virtual void do_UnsafeGet (UnsafeGet* x) = 0;
190 virtual void do_UnsafePut (UnsafePut* x) = 0;
191 virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x) = 0;
192 virtual void do_ProfileCall (ProfileCall* x) = 0;
193 virtual void do_ProfileReturnType (ProfileReturnType* x) = 0;
194 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
195 virtual void do_RuntimeCall (RuntimeCall* x) = 0;
196 virtual void do_MemBar (MemBar* x) = 0;
197 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
198 #ifdef ASSERT
199 virtual void do_Assert (Assert* x) = 0;
200 #endif
201 };
202
203
204 // Hashing support
205 //
206 // Note: This hash functions affect the performance
207 // of ValueMap - make changes carefully!
208
209 #define HASH1(x1 ) ((intx)(x1))
210 #define HASH2(x1, x2 ) ((HASH1(x1 ) << 7) ^ HASH1(x2))
211 #define HASH3(x1, x2, x3 ) ((HASH2(x1, x2 ) << 7) ^ HASH1(x3))
212 #define HASH4(x1, x2, x3, x4) ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4))
213
214
215 // The following macros are used to implement instruction-specific hashing.
216 // By default, each instruction implements hash() and is_equal(Value), used
217 // for value numbering/common subexpression elimination. The default imple-
218 // mentation disables value numbering. Each instruction which can be value-
219 // numbered, should define corresponding hash() and is_equal(Value) functions
220 // via the macros below. The f arguments specify all the values/op codes, etc.
221 // that need to be identical for two instructions to be identical.
222 //
223 // Note: The default implementation of hash() returns 0 in order to indicate
224 // that the instruction should not be considered for value numbering.
225 // The currently used hash functions do not guarantee that never a 0
226 // is produced. While this is still correct, it may be a performance
227 // bug (no value numbering for that node). However, this situation is
228 // so unlikely, that we are not going to handle it specially.
229
230 #define HASHING1(class_name, enabled, f1) \
231 virtual intx hash() const { \
232 return (enabled) ? HASH2(name(), f1) : 0; \
251 if (f1 != _v->f1) return false; \
252 if (f2 != _v->f2) return false; \
253 return true; \
254 } \
255
256
257 #define HASHING3(class_name, enabled, f1, f2, f3) \
258 virtual intx hash() const { \
259 return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
260 } \
261 virtual bool is_equal(Value v) const { \
262 if (!(enabled) ) return false; \
263 class_name* _v = v->as_##class_name(); \
264 if (_v == nullptr) return false; \
265 if (f1 != _v->f1) return false; \
266 if (f2 != _v->f2) return false; \
267 if (f3 != _v->f3) return false; \
268 return true; \
269 } \
270
271
272 // The mother of all instructions...
273
274 class Instruction: public CompilationResourceObj {
275 private:
276 int _id; // the unique instruction id
277 #ifndef PRODUCT
278 int _printable_bci; // the bci of the instruction for printing
279 #endif
280 int _use_count; // the number of instructions referring to this value (w/o prev/next); only roots can have use count = 0 or > 1
281 int _pin_state; // set of PinReason describing the reason for pinning
282 unsigned int _flags; // Flag bits
283 ValueType* _type; // the instruction value type
284 Instruction* _next; // the next instruction if any (null for BlockEnd instructions)
285 Instruction* _subst; // the substitution instruction if any
286 LIR_Opr _operand; // LIR specific information
287
288 ValueStack* _state_before; // Copy of state with input operands still on stack (or null)
289 ValueStack* _exception_state; // Copy of state for exception handling
290 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction
291
292 friend class UseCountComputer;
293
294 void update_exception_state(ValueStack* state);
295
296 protected:
297 BlockBegin* _block; // Block that contains this instruction
298
299 void set_type(ValueType* type) {
300 assert(type != nullptr, "type must exist");
301 _type = type;
302 }
303
304 // Helper class to keep track of which arguments need a null check
305 class ArgsNonNullState {
306 private:
307 int _nonnull_state; // mask identifying which args are nonnull
308 public:
309 ArgsNonNullState()
310 : _nonnull_state(AllBits) {}
311
312 // Does argument number i needs a null check?
325 if (check) {
326 _nonnull_state |= (int)nth_bit(i);
327 } else {
328 _nonnull_state &= (int)~(nth_bit(i));
329 }
330 }
331 }
332 };
333
334 public:
335 void* operator new(size_t size) throw() {
336 Compilation* c = Compilation::current();
337 void* res = c->arena()->Amalloc(size);
338 return res;
339 }
340
341 static const int no_bci = -99;
342
343 enum InstructionFlag {
344 NeedsNullCheckFlag = 0,
345 CanTrapFlag,
346 DirectCompareFlag,
347 IsSafepointFlag,
348 IsStaticFlag,
349 PreservesStateFlag,
350 TargetIsFinalFlag,
351 TargetIsLoadedFlag,
352 UnorderedIsTrueFlag,
353 NeedsPatchingFlag,
354 ThrowIncompatibleClassChangeErrorFlag,
355 InvokeSpecialReceiverCheckFlag,
356 ProfileMDOFlag,
357 IsLinkedInBlockFlag,
358 NeedsRangeCheckFlag,
359 DeoptimizeOnException,
360 KillsMemoryFlag,
361 OmitChecksFlag,
362 InstructionLastFlag
363 };
364
415 int id() const { return _id; }
416 #ifndef PRODUCT
417 bool has_printable_bci() const { return _printable_bci != -99; }
418 int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
419 void set_printable_bci(int bci) { _printable_bci = bci; }
420 #endif
421 int dominator_depth();
422 int use_count() const { return _use_count; }
423 int pin_state() const { return _pin_state; }
424 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; }
425 ValueType* type() const { return _type; }
426 BlockBegin *block() const { return _block; }
427 Instruction* prev(); // use carefully, expensive operation
428 Instruction* next() const { return _next; }
429 bool has_subst() const { return _subst != nullptr; }
430 Instruction* subst() { return _subst == nullptr ? this : _subst->subst(); }
431 LIR_Opr operand() const { return _operand; }
432
433 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); }
434 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); }
435 bool is_linked() const { return check_flag(IsLinkedInBlockFlag); }
436 bool can_be_linked() { return as_Local() == nullptr && as_Phi() == nullptr; }
437
438 bool is_null_obj() { return as_Constant() != nullptr && type()->as_ObjectType()->constant_value()->is_null_object(); }
439
440 bool has_uses() const { return use_count() > 0; }
441 ValueStack* state_before() const { return _state_before; }
442 ValueStack* exception_state() const { return _exception_state; }
443 virtual bool needs_exception_state() const { return true; }
444 XHandlers* exception_handlers() const { return _exception_handlers; }
445
446 // manipulation
447 void pin(PinReason reason) { _pin_state |= reason; }
448 void pin() { _pin_state |= PinUnknown; }
449 // DANGEROUS: only used by EliminateStores
450 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
451
452 Instruction* set_next(Instruction* next) {
453 assert(next->has_printable_bci(), "_printable_bci should have been set");
454 assert(next != nullptr, "must not be null");
455 assert(as_BlockEnd() == nullptr, "BlockEnd instructions must have no next");
456 assert(next->can_be_linked(), "shouldn't link these instructions into list");
457
458 BlockBegin *block = this->block();
459 next->_block = block;
460
461 next->set_flag(Instruction::IsLinkedInBlockFlag, true);
462 _next = next;
463 return next;
464 }
469 #endif
470 return set_next(next);
471 }
472
473 // when blocks are merged
474 void fixup_block_pointers() {
475 Instruction *cur = next()->next(); // next()'s block is set in set_next
476 while (cur && cur->_block != block()) {
477 cur->_block = block();
478 cur = cur->next();
479 }
480 }
481
482 Instruction *insert_after(Instruction *i) {
483 Instruction* n = _next;
484 set_next(i);
485 i->set_next(n);
486 return _next;
487 }
488
489 Instruction *insert_after_same_bci(Instruction *i) {
490 #ifndef PRODUCT
491 i->set_printable_bci(printable_bci());
492 #endif
493 return insert_after(i);
494 }
495
496 void set_subst(Instruction* subst) {
497 assert(subst == nullptr ||
498 type()->base() == subst->type()->base() ||
499 subst->type()->base() == illegalType, "type can't change");
500 _subst = subst;
501 }
502 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
503 void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; }
504 void set_state_before(ValueStack* s) { check_state(s); _state_before = s; }
505
506 // machine-specifics
507 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
508 void clear_operand() { _operand = LIR_OprFact::illegalOpr; }
796
797 // Under certain circumstances, if a previous NullCheck instruction
798 // proved the target object non-null, we can eliminate the explicit
799 // null check and do an implicit one, simply specifying the debug
800 // information from the NullCheck. This field should only be consulted
801 // if needs_null_check() is true.
802 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
803
804 // generic
805 virtual bool can_trap() const { return needs_null_check() || needs_patching(); }
806 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); }
807 };
808
809
810 LEAF(LoadField, AccessField)
811 public:
812 // creation
813 LoadField(Value obj, int offset, ciField* field, bool is_static,
814 ValueStack* state_before, bool needs_patching)
815 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
816 {}
817
818 ciType* declared_type() const;
819
820 // generic; cannot be eliminated if needs patching or if volatile.
821 HASHING3(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset(), declared_type())
822 };
823
824
825 LEAF(StoreField, AccessField)
826 private:
827 Value _value;
828
829 public:
830 // creation
831 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
832 ValueStack* state_before, bool needs_patching)
833 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
834 , _value(value)
835 {
836 ASSERT_VALUES
837 pin();
838 }
839
840 // accessors
841 Value value() const { return _value; }
842
843 // generic
844 virtual void input_values_do(ValueVisitor* f) { AccessField::input_values_do(f); f->visit(&_value); }
845 };
846
847
848 BASE(AccessArray, Instruction)
849 private:
850 Value _array;
851
852 public:
853 // creation
854 AccessArray(ValueType* type, Value array, ValueStack* state_before)
855 : Instruction(type, state_before)
856 , _array(array)
857 {
858 set_needs_null_check(true);
859 ASSERT_VALUES
860 pin(); // instruction with side effect (null exception or range check throwing)
861 }
879 , _explicit_null_check(nullptr) {}
880
881 // accessors
882 NullCheck* explicit_null_check() const { return _explicit_null_check; }
883
884 // setters
885 // See LoadField::set_explicit_null_check for documentation
886 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
887
888 // generic
889 HASHING1(ArrayLength, true, array()->subst())
890 };
891
892
893 BASE(AccessIndexed, AccessArray)
894 private:
895 Value _index;
896 Value _length;
897 BasicType _elt_type;
898 bool _mismatched;
899
900 public:
901 // creation
902 AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
903 : AccessArray(as_ValueType(elt_type), array, state_before)
904 , _index(index)
905 , _length(length)
906 , _elt_type(elt_type)
907 , _mismatched(mismatched)
908 {
909 set_flag(Instruction::NeedsRangeCheckFlag, true);
910 ASSERT_VALUES
911 }
912
913 // accessors
914 Value index() const { return _index; }
915 Value length() const { return _length; }
916 BasicType elt_type() const { return _elt_type; }
917 bool mismatched() const { return _mismatched; }
918
919 void clear_length() { _length = nullptr; }
920 // perform elimination of range checks involving constants
921 bool compute_needs_range_check();
922
923 // generic
924 virtual void input_values_do(ValueVisitor* f) { AccessArray::input_values_do(f); f->visit(&_index); if (_length != nullptr) f->visit(&_length); }
925 };
926
927
928 LEAF(LoadIndexed, AccessIndexed)
929 private:
930 NullCheck* _explicit_null_check; // For explicit null check elimination
931
932 public:
933 // creation
934 LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
935 : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
936 , _explicit_null_check(nullptr) {}
937
938 // accessors
939 NullCheck* explicit_null_check() const { return _explicit_null_check; }
940
941 // setters
942 // See LoadField::set_explicit_null_check for documentation
943 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
944
945 ciType* exact_type() const;
946 ciType* declared_type() const;
947
948 // generic;
949 HASHING3(LoadIndexed, true, elt_type(), array()->subst(), index()->subst())
950 };
951
952
953 LEAF(StoreIndexed, AccessIndexed)
954 private:
955 Value _value;
956
957 ciMethod* _profiled_method;
958 int _profiled_bci;
959 bool _check_boolean;
960
961 public:
962 // creation
963 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
964 bool check_boolean, bool mismatched = false)
965 : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
966 , _value(value), _profiled_method(nullptr), _profiled_bci(0), _check_boolean(check_boolean)
967 {
968 ASSERT_VALUES
969 pin();
970 }
971
972 // accessors
973 Value value() const { return _value; }
974 bool check_boolean() const { return _check_boolean; }
975 // Helpers for MethodData* profiling
976 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
977 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
978 void set_profiled_bci(int bci) { _profiled_bci = bci; }
979 bool should_profile() const { return check_flag(ProfileMDOFlag); }
980 ciMethod* profiled_method() const { return _profiled_method; }
981 int profiled_bci() const { return _profiled_bci; }
982 // generic
983 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); }
984 };
985
986
987 LEAF(NegateOp, Instruction)
988 private:
989 Value _x;
990
991 public:
992 // creation
993 NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
994 ASSERT_VALUES
995 }
996
997 // accessors
998 Value x() const { return _x; }
999
1000 // generic
1001 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); }
1072 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1073 };
1074
1075
1076 LEAF(CompareOp, Op2)
1077 public:
1078 // creation
1079 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1080 : Op2(intType, op, x, y, state_before)
1081 {}
1082
1083 // generic
1084 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1085 };
1086
1087
1088 LEAF(IfOp, Op2)
1089 private:
1090 Value _tval;
1091 Value _fval;
1092
1093 public:
1094 // creation
1095 IfOp(Value x, Condition cond, Value y, Value tval, Value fval)
1096 : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1097 , _tval(tval)
1098 , _fval(fval)
1099 {
1100 ASSERT_VALUES
1101 assert(tval->type()->tag() == fval->type()->tag(), "types must match");
1102 }
1103
1104 // accessors
1105 virtual bool is_commutative() const;
1106 Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; }
1107 Condition cond() const { return (Condition)Op2::op(); }
1108 Value tval() const { return _tval; }
1109 Value fval() const { return _fval; }
1110
1111 // generic
1112 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1113 };
1114
1115
1116 LEAF(Convert, Instruction)
1117 private:
1118 Bytecodes::Code _op;
1119 Value _value;
1120
1121 public:
1122 // creation
1123 Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1124 ASSERT_VALUES
1125 }
1126
1127 // accessors
1128 Bytecodes::Code op() const { return _op; }
1129 Value value() const { return _value; }
1130
1205 // accessors
1206 ValueStack* state() const { return _state; }
1207 IRScope* scope() const; // the state's scope
1208
1209 // manipulation
1210 void set_state(ValueStack* state) { assert(_state == nullptr, "overwriting existing state"); check_state(state); _state = state; }
1211
1212 // generic
1213 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
1214 virtual void state_values_do(ValueVisitor* f);
1215 };
1216
1217
1218 LEAF(Invoke, StateSplit)
1219 private:
1220 Bytecodes::Code _code;
1221 Value _recv;
1222 Values* _args;
1223 BasicTypeList* _signature;
1224 ciMethod* _target;
1225
1226 public:
1227 // creation
1228 Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
1229 ciMethod* target, ValueStack* state_before);
1230
1231 // accessors
1232 Bytecodes::Code code() const { return _code; }
1233 Value receiver() const { return _recv; }
1234 bool has_receiver() const { return receiver() != nullptr; }
1235 int number_of_arguments() const { return _args->length(); }
1236 Value argument_at(int i) const { return _args->at(i); }
1237 BasicTypeList* signature() const { return _signature; }
1238 ciMethod* target() const { return _target; }
1239
1240 ciType* declared_type() const;
1241
1242 // Returns false if target is not loaded
1243 bool target_is_final() const { return check_flag(TargetIsFinalFlag); }
1244 bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); }
1245
1246 // JSR 292 support
1247 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; }
1248 bool is_method_handle_intrinsic() const { return target()->is_method_handle_intrinsic(); }
1249
1250 virtual bool needs_exception_state() const { return false; }
1251
1252 // generic
1253 virtual bool can_trap() const { return true; }
1254 virtual void input_values_do(ValueVisitor* f) {
1255 StateSplit::input_values_do(f);
1256 if (has_receiver()) f->visit(&_recv);
1257 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1258 }
1259 virtual void state_values_do(ValueVisitor *f);
1260 };
1261
1262
1263 LEAF(NewInstance, StateSplit)
1264 private:
1265 ciInstanceKlass* _klass;
1266 bool _is_unresolved;
1267
1268 public:
1269 // creation
1270 NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
1271 : StateSplit(instanceType, state_before)
1272 , _klass(klass), _is_unresolved(is_unresolved)
1273 {}
1274
1275 // accessors
1276 ciInstanceKlass* klass() const { return _klass; }
1277 bool is_unresolved() const { return _is_unresolved; }
1278
1279 virtual bool needs_exception_state() const { return false; }
1280
1281 // generic
1282 virtual bool can_trap() const { return true; }
1283 ciType* exact_type() const;
1284 ciType* declared_type() const;
1285 };
1286
1287
1288 BASE(NewArray, StateSplit)
1289 private:
1290 Value _length;
1291
1292 public:
1293 // creation
1294 NewArray(Value length, ValueStack* state_before)
1295 : StateSplit(objectType, state_before)
1296 , _length(length)
1297 {
1298 // Do not ASSERT_VALUES since length is null for NewMultiArray
1299 }
1300
1301 // accessors
1302 Value length() const { return _length; }
1303
1304 virtual bool needs_exception_state() const { return false; }
1305
1306 ciType* exact_type() const { return nullptr; }
1307 ciType* declared_type() const;
1321 // creation
1322 NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before, bool zero_array)
1323 : NewArray(length, state_before)
1324 , _elt_type(elt_type)
1325 , _zero_array(zero_array)
1326 {}
1327
1328 // accessors
1329 BasicType elt_type() const { return _elt_type; }
1330 bool zero_array() const { return _zero_array; }
1331 ciType* exact_type() const;
1332 };
1333
1334
1335 LEAF(NewObjectArray, NewArray)
1336 private:
1337 ciKlass* _klass;
1338
1339 public:
1340 // creation
1341 NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {}
1342
1343 // accessors
1344 ciKlass* klass() const { return _klass; }
1345 ciType* exact_type() const;
1346 };
1347
1348
1349 LEAF(NewMultiArray, NewArray)
1350 private:
1351 ciKlass* _klass;
1352 Values* _dims;
1353
1354 public:
1355 // creation
1356 NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(nullptr, state_before), _klass(klass), _dims(dims) {
1357 ASSERT_VALUES
1358 }
1359
1360 // accessors
1361 ciKlass* klass() const { return _klass; }
1362 Values* dims() const { return _dims; }
1363 int rank() const { return dims()->length(); }
1364
1365 // generic
1366 virtual void input_values_do(ValueVisitor* f) {
1367 // NOTE: we do not call NewArray::input_values_do since "length"
1368 // is meaningless for a multi-dimensional array; passing the
1369 // zeroth element down to NewArray as its length is a bad idea
1370 // since there will be a copy in the "dims" array which doesn't
1371 // get updated, and the value must not be traversed twice. Was bug
1372 // - kbr 4/10/2001
1373 StateSplit::input_values_do(f);
1374 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1375 }
1376 };
1377
1378
1379 BASE(TypeCheck, StateSplit)
1380 private:
1381 ciKlass* _klass;
1382 Value _obj;
1383
1384 ciMethod* _profiled_method;
1385 int _profiled_bci;
1386
1387 public:
1388 // creation
1389 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1390 : StateSplit(type, state_before), _klass(klass), _obj(obj),
1391 _profiled_method(nullptr), _profiled_bci(0) {
1392 ASSERT_VALUES
1393 set_direct_compare(false);
1394 }
1395
1461 // creation
1462 AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1463 : StateSplit(illegalType, state_before)
1464 , _obj(obj)
1465 , _monitor_no(monitor_no)
1466 {
1467 set_needs_null_check(true);
1468 ASSERT_VALUES
1469 }
1470
1471 // accessors
1472 Value obj() const { return _obj; }
1473 int monitor_no() const { return _monitor_no; }
1474
1475 // generic
1476 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1477 };
1478
1479
1480 LEAF(MonitorEnter, AccessMonitor)
1481 public:
1482 // creation
1483 MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1484 : AccessMonitor(obj, monitor_no, state_before)
1485 {
1486 ASSERT_VALUES
1487 }
1488
1489 // generic
1490 virtual bool can_trap() const { return true; }
1491 };
1492
1493
1494 LEAF(MonitorExit, AccessMonitor)
1495 public:
1496 // creation
1497 MonitorExit(Value obj, int monitor_no)
1498 : AccessMonitor(obj, monitor_no, nullptr)
1499 {
1500 ASSERT_VALUES
1501 }
1502 };
1503
1504
1505 LEAF(Intrinsic, StateSplit)
1506 private:
1507 vmIntrinsics::ID _id;
1508 ArgsNonNullState _nonnull_state;
1924 Condition cond() const { return _cond; }
1925 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
1926 Value y() const { return _y; }
1927
1928 void always_fail() { _x = _y = nullptr; }
1929
1930 // generic
1931 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1932 HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
1933 };
1934
1935 LEAF(If, BlockEnd)
1936 private:
1937 Value _x;
1938 Condition _cond;
1939 Value _y;
1940 ciMethod* _profiled_method;
1941 int _profiled_bci; // Canonicalizer may alter bci of If node
1942 bool _swapped; // Is the order reversed with respect to the original If in the
1943 // bytecode stream?
1944 public:
1945 // creation
1946 // unordered_is_true is valid for float/double compares only
1947 If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint)
1948 : BlockEnd(illegalType, state_before, is_safepoint)
1949 , _x(x)
1950 , _cond(cond)
1951 , _y(y)
1952 , _profiled_method(nullptr)
1953 , _profiled_bci(0)
1954 , _swapped(false)
1955 {
1956 ASSERT_VALUES
1957 set_flag(UnorderedIsTrueFlag, unordered_is_true);
1958 assert(x->type()->tag() == y->type()->tag(), "types must match");
1959 BlockList* s = new BlockList(2);
1960 s->append(tsux);
1961 s->append(fsux);
1962 set_sux(s);
1963 }
1964
1965 // accessors
1966 Value x() const { return _x; }
1967 Condition cond() const { return _cond; }
1968 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
1969 Value y() const { return _y; }
1970 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); }
1971 BlockBegin* tsux() const { return sux_for(true); }
1972 BlockBegin* fsux() const { return sux_for(false); }
1973 BlockBegin* usux() const { return sux_for(unordered_is_true()); }
1974 bool should_profile() const { return check_flag(ProfileMDOFlag); }
1975 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches
1976 int profiled_bci() const { return _profiled_bci; } // set for profiled branches and tiered
1977 bool is_swapped() const { return _swapped; }
1978
1979 // manipulation
1980 void swap_operands() {
1981 Value t = _x; _x = _y; _y = t;
1982 _cond = mirror(_cond);
1983 }
1984
1985 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
1986 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
1987 void set_profiled_bci(int bci) { _profiled_bci = bci; }
1988 void set_swapped(bool value) { _swapped = value; }
1989 // generic
1990 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1991 };
1992
1993
1994 BASE(Switch, BlockEnd)
1995 private:
1996 Value _tag;
1997
1998 public:
1999 // creation
2000 Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2001 : BlockEnd(illegalType, state_before, is_safepoint)
2002 , _tag(tag) {
2003 ASSERT_VALUES
2004 set_sux(sux);
2005 }
2006
2007 // accessors
2008 Value tag() const { return _tag; }
2279 }
2280 }
2281 };
2282
2283 LEAF(ProfileReturnType, Instruction)
2284 private:
2285 ciMethod* _method;
2286 ciMethod* _callee;
2287 int _bci_of_invoke;
2288 Value _ret;
2289
2290 public:
2291 ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2292 : Instruction(voidType)
2293 , _method(method)
2294 , _callee(callee)
2295 , _bci_of_invoke(bci)
2296 , _ret(ret)
2297 {
2298 set_needs_null_check(true);
2299 // The ProfileType has side-effects and must occur precisely where located
2300 pin();
2301 }
2302
2303 ciMethod* method() const { return _method; }
2304 ciMethod* callee() const { return _callee; }
2305 int bci_of_invoke() const { return _bci_of_invoke; }
2306 Value ret() const { return _ret; }
2307
2308 virtual void input_values_do(ValueVisitor* f) {
2309 if (_ret != nullptr) {
2310 f->visit(&_ret);
2311 }
2312 }
2313 };
2314
2315 // Call some C runtime function that doesn't safepoint,
2316 // optionally passing the current thread as the first argument.
2317 LEAF(RuntimeCall, Instruction)
2318 private:
2319 const char* _entry_name;
2320 address _entry;
2321 Values* _args;
2322 bool _pass_thread; // Pass the JavaThread* as an implicit first argument
2323
2324 public:
2325 RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2326 : Instruction(type)
2327 , _entry_name(entry_name)
2328 , _entry(entry)
2329 , _args(args)
2330 , _pass_thread(pass_thread) {
2331 ASSERT_VALUES
2332 pin();
2333 }
2334
|
1 /*
2 * Copyright (c) 1999, 2026, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
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 UnsafeOp;
96 class UnsafeGet;
97 class UnsafePut;
98 class UnsafeGetAndSet;
99 class ProfileCall;
100 class ProfileReturnType;
101 class ProfileACmpTypes;
102 class ProfileInvoke;
103 class RuntimeCall;
104 class MemBar;
105 class RangeCheckPredicate;
106 #ifdef ASSERT
107 class Assert;
108 #endif
109
110 // A Value is a reference to the instruction creating the value
111 typedef Instruction* Value;
112 typedef GrowableArray<Value> Values;
113 typedef GrowableArray<ValueStack*> ValueStackStack;
114
115 // BlockClosure is the base class for block traversal/iteration.
116
117 class BlockClosure: public CompilationResourceObj {
118 public:
119 virtual void block_do(BlockBegin* block) = 0;
120 };
121
176 virtual void do_CheckCast (CheckCast* x) = 0;
177 virtual void do_InstanceOf (InstanceOf* x) = 0;
178 virtual void do_MonitorEnter (MonitorEnter* x) = 0;
179 virtual void do_MonitorExit (MonitorExit* x) = 0;
180 virtual void do_Intrinsic (Intrinsic* x) = 0;
181 virtual void do_BlockBegin (BlockBegin* x) = 0;
182 virtual void do_Goto (Goto* x) = 0;
183 virtual void do_If (If* x) = 0;
184 virtual void do_TableSwitch (TableSwitch* x) = 0;
185 virtual void do_LookupSwitch (LookupSwitch* x) = 0;
186 virtual void do_Return (Return* x) = 0;
187 virtual void do_Throw (Throw* x) = 0;
188 virtual void do_Base (Base* x) = 0;
189 virtual void do_OsrEntry (OsrEntry* x) = 0;
190 virtual void do_ExceptionObject(ExceptionObject* 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_ProfileACmpTypes(ProfileACmpTypes* x) = 0;
197 virtual void do_ProfileInvoke (ProfileInvoke* x) = 0;
198 virtual void do_RuntimeCall (RuntimeCall* x) = 0;
199 virtual void do_MemBar (MemBar* x) = 0;
200 virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
201 #ifdef ASSERT
202 virtual void do_Assert (Assert* x) = 0;
203 #endif
204 };
205
206
207 // Hashing support
208 //
209 // Note: This hash functions affect the performance
210 // of ValueMap - make changes carefully!
211
212 #define HASH1(x1 ) ((intx)(x1))
213 #define HASH2(x1, x2 ) ((HASH1(x1 ) << 7) ^ HASH1(x2))
214 #define HASH3(x1, x2, x3 ) ((HASH2(x1, x2 ) << 7) ^ HASH1(x3))
215 #define HASH4(x1, x2, x3, x4) ((HASH3(x1, x2, x3 ) << 7) ^ HASH1(x4))
216 #define HASH5(x1, x2, x3, x4, x5) ((HASH4(x1, x2, x3, x4) << 7) ^ HASH1(x5))
217
218
219 // The following macros are used to implement instruction-specific hashing.
220 // By default, each instruction implements hash() and is_equal(Value), used
221 // for value numbering/common subexpression elimination. The default imple-
222 // mentation disables value numbering. Each instruction which can be value-
223 // numbered, should define corresponding hash() and is_equal(Value) functions
224 // via the macros below. The f arguments specify all the values/op codes, etc.
225 // that need to be identical for two instructions to be identical.
226 //
227 // Note: The default implementation of hash() returns 0 in order to indicate
228 // that the instruction should not be considered for value numbering.
229 // The currently used hash functions do not guarantee that never a 0
230 // is produced. While this is still correct, it may be a performance
231 // bug (no value numbering for that node). However, this situation is
232 // so unlikely, that we are not going to handle it specially.
233
234 #define HASHING1(class_name, enabled, f1) \
235 virtual intx hash() const { \
236 return (enabled) ? HASH2(name(), f1) : 0; \
255 if (f1 != _v->f1) return false; \
256 if (f2 != _v->f2) return false; \
257 return true; \
258 } \
259
260
261 #define HASHING3(class_name, enabled, f1, f2, f3) \
262 virtual intx hash() const { \
263 return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
264 } \
265 virtual bool is_equal(Value v) const { \
266 if (!(enabled) ) return false; \
267 class_name* _v = v->as_##class_name(); \
268 if (_v == nullptr) return false; \
269 if (f1 != _v->f1) return false; \
270 if (f2 != _v->f2) return false; \
271 if (f3 != _v->f3) return false; \
272 return true; \
273 } \
274
275 #define HASHING4(class_name, enabled, f1, f2, f3, f4) \
276 virtual intx hash() const { \
277 return (enabled) ? HASH5(name(), f1, f2, f3, f4) : 0; \
278 } \
279 virtual bool is_equal(Value v) const { \
280 if (!(enabled)) return false; \
281 class_name* _v = v->as_##class_name(); \
282 if (_v == nullptr) return false; \
283 if (f1 != _v->f1) return false; \
284 if (f2 != _v->f2) return false; \
285 if (f3 != _v->f3) return false; \
286 if (f4 != _v->f4) return false; \
287 return true; \
288 } \
289
290
291 // The mother of all instructions...
292
293 class Instruction: public CompilationResourceObj {
294 private:
295 int _id; // the unique instruction id
296 #ifndef PRODUCT
297 int _printable_bci; // the bci of the instruction for printing
298 #endif
299 int _use_count; // the number of instructions referring to this value (w/o prev/next); only roots can have use count = 0 or > 1
300 int _pin_state; // set of PinReason describing the reason for pinning
301 unsigned int _flags; // Flag bits
302 ValueType* _type; // the instruction value type
303 Instruction* _next; // the next instruction if any (null for BlockEnd instructions)
304 Instruction* _subst; // the substitution instruction if any
305 LIR_Opr _operand; // LIR specific information
306
307 ValueStack* _state_before; // Copy of state with input operands still on stack (or null)
308 ValueStack* _exception_state; // Copy of state for exception handling
309 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction
310
311 friend class UseCountComputer;
312 friend class GraphBuilder;
313
314 void update_exception_state(ValueStack* state);
315
316 protected:
317 BlockBegin* _block; // Block that contains this instruction
318
319 void set_type(ValueType* type) {
320 assert(type != nullptr, "type must exist");
321 _type = type;
322 }
323
324 // Helper class to keep track of which arguments need a null check
325 class ArgsNonNullState {
326 private:
327 int _nonnull_state; // mask identifying which args are nonnull
328 public:
329 ArgsNonNullState()
330 : _nonnull_state(AllBits) {}
331
332 // Does argument number i needs a null check?
345 if (check) {
346 _nonnull_state |= (int)nth_bit(i);
347 } else {
348 _nonnull_state &= (int)~(nth_bit(i));
349 }
350 }
351 }
352 };
353
354 public:
355 void* operator new(size_t size) throw() {
356 Compilation* c = Compilation::current();
357 void* res = c->arena()->Amalloc(size);
358 return res;
359 }
360
361 static const int no_bci = -99;
362
363 enum InstructionFlag {
364 NeedsNullCheckFlag = 0,
365 NeverNullFlag,
366 CanTrapFlag,
367 DirectCompareFlag,
368 IsSafepointFlag,
369 IsStaticFlag,
370 PreservesStateFlag,
371 TargetIsFinalFlag,
372 TargetIsLoadedFlag,
373 UnorderedIsTrueFlag,
374 NeedsPatchingFlag,
375 ThrowIncompatibleClassChangeErrorFlag,
376 InvokeSpecialReceiverCheckFlag,
377 ProfileMDOFlag,
378 IsLinkedInBlockFlag,
379 NeedsRangeCheckFlag,
380 DeoptimizeOnException,
381 KillsMemoryFlag,
382 OmitChecksFlag,
383 InstructionLastFlag
384 };
385
436 int id() const { return _id; }
437 #ifndef PRODUCT
438 bool has_printable_bci() const { return _printable_bci != -99; }
439 int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
440 void set_printable_bci(int bci) { _printable_bci = bci; }
441 #endif
442 int dominator_depth();
443 int use_count() const { return _use_count; }
444 int pin_state() const { return _pin_state; }
445 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; }
446 ValueType* type() const { return _type; }
447 BlockBegin *block() const { return _block; }
448 Instruction* prev(); // use carefully, expensive operation
449 Instruction* next() const { return _next; }
450 bool has_subst() const { return _subst != nullptr; }
451 Instruction* subst() { return _subst == nullptr ? this : _subst->subst(); }
452 LIR_Opr operand() const { return _operand; }
453
454 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); }
455 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); }
456 void set_null_free(bool f) { set_flag(NeverNullFlag, f); }
457 bool is_null_free() const { return check_flag(NeverNullFlag); }
458 bool is_linked() const { return check_flag(IsLinkedInBlockFlag); }
459 bool can_be_linked() { return as_Local() == nullptr && as_Phi() == nullptr; }
460
461 bool is_null_obj() { return as_Constant() != nullptr && type()->as_ObjectType()->constant_value()->is_null_object(); }
462
463 bool has_uses() const { return use_count() > 0; }
464 ValueStack* state_before() const { return _state_before; }
465 ValueStack* exception_state() const { return _exception_state; }
466 virtual bool needs_exception_state() const { return true; }
467 XHandlers* exception_handlers() const { return _exception_handlers; }
468 ciKlass* as_loaded_klass_or_null() const;
469
470 // manipulation
471 void pin(PinReason reason) { _pin_state |= reason; }
472 void pin() { _pin_state |= PinUnknown; }
473 // DANGEROUS: only used by EliminateStores
474 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
475
476 Instruction* set_next(Instruction* next) {
477 assert(next->has_printable_bci(), "_printable_bci should have been set");
478 assert(next != nullptr, "must not be null");
479 assert(as_BlockEnd() == nullptr, "BlockEnd instructions must have no next");
480 assert(next->can_be_linked(), "shouldn't link these instructions into list");
481
482 BlockBegin *block = this->block();
483 next->_block = block;
484
485 next->set_flag(Instruction::IsLinkedInBlockFlag, true);
486 _next = next;
487 return next;
488 }
493 #endif
494 return set_next(next);
495 }
496
497 // when blocks are merged
498 void fixup_block_pointers() {
499 Instruction *cur = next()->next(); // next()'s block is set in set_next
500 while (cur && cur->_block != block()) {
501 cur->_block = block();
502 cur = cur->next();
503 }
504 }
505
506 Instruction *insert_after(Instruction *i) {
507 Instruction* n = _next;
508 set_next(i);
509 i->set_next(n);
510 return _next;
511 }
512
513 bool is_loaded_flat_array() const;
514 bool maybe_flat_array() const;
515 bool maybe_null_free_array() const;
516
517 Instruction *insert_after_same_bci(Instruction *i) {
518 #ifndef PRODUCT
519 i->set_printable_bci(printable_bci());
520 #endif
521 return insert_after(i);
522 }
523
524 void set_subst(Instruction* subst) {
525 assert(subst == nullptr ||
526 type()->base() == subst->type()->base() ||
527 subst->type()->base() == illegalType, "type can't change");
528 _subst = subst;
529 }
530 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
531 void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; }
532 void set_state_before(ValueStack* s) { check_state(s); _state_before = s; }
533
534 // machine-specifics
535 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
536 void clear_operand() { _operand = LIR_OprFact::illegalOpr; }
824
825 // Under certain circumstances, if a previous NullCheck instruction
826 // proved the target object non-null, we can eliminate the explicit
827 // null check and do an implicit one, simply specifying the debug
828 // information from the NullCheck. This field should only be consulted
829 // if needs_null_check() is true.
830 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
831
832 // generic
833 virtual bool can_trap() const { return needs_null_check() || needs_patching(); }
834 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); }
835 };
836
837
838 LEAF(LoadField, AccessField)
839 public:
840 // creation
841 LoadField(Value obj, int offset, ciField* field, bool is_static,
842 ValueStack* state_before, bool needs_patching)
843 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
844 {
845 set_null_free(field->is_null_free());
846 }
847
848 ciType* declared_type() const;
849
850 // generic; cannot be eliminated if needs patching or if volatile.
851 HASHING3(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset(), declared_type())
852 };
853
854
855 LEAF(StoreField, AccessField)
856 private:
857 Value _value;
858 ciField* _enclosing_field; // enclosing field (the flat one) for nested fields
859
860 public:
861 // creation
862 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
863 ValueStack* state_before, bool needs_patching)
864 : AccessField(obj, offset, field, is_static, state_before, needs_patching)
865 , _value(value)
866 , _enclosing_field(nullptr) {
867 #ifdef ASSERT
868 AssertValues assert_value;
869 values_do(&assert_value);
870 #endif
871 pin();
872 }
873
874 // accessors
875 Value value() const { return _value; }
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)
947 , _profiled_bci(0)
948 {
949 set_flag(Instruction::NeedsRangeCheckFlag, true);
950 ASSERT_VALUES
951 }
952
953 // accessors
954 Value index() const { return _index; }
955 Value length() const { return _length; }
956 BasicType elt_type() const { return _elt_type; }
957 bool mismatched() const { return _mismatched; }
958
959 void clear_length() { _length = nullptr; }
960 // perform elimination of range checks involving constants
961 bool compute_needs_range_check();
962
963 // Helpers for MethodData* profiling
964 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
965 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
966 void set_profiled_bci(int bci) { _profiled_bci = bci; }
967 bool should_profile() const { return check_flag(ProfileMDOFlag); }
968 ciMethod* profiled_method() const { return _profiled_method; }
969 int profiled_bci() const { return _profiled_bci; }
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 Value _buffer; // Buffer for load from flat arrays
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), _buffer(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 Value buffer() const { return _buffer; }
1000
1001 void set_buffer(Value buffer) {
1002 assert(buffer == nullptr || buffer->as_NewInstance() != nullptr, "LoadIndexed flat array buffer must be a NewInstance");
1003 _buffer = buffer;
1004 }
1005
1006 DelayedLoadIndexed* delayed() const { return _delayed; }
1007 void set_delayed(DelayedLoadIndexed* delayed) { _delayed = delayed; }
1008
1009 virtual void input_values_do(ValueVisitor* f) {
1010 AccessIndexed::input_values_do(f);
1011 if (_buffer != nullptr) {
1012 f->visit(&_buffer);
1013 assert(_buffer->as_NewInstance() != nullptr, "LoadIndexed flat array buffer must stay a NewInstance");
1014 }
1015 }
1016
1017 // generic;
1018 HASHING4(LoadIndexed, delayed() == nullptr && !should_profile(), elt_type(), array()->subst(), index()->subst(), buffer())
1019 };
1020
1021 // Records a flat-array LoadIndexed while following getfield bytecodes are parsed.
1022 // This allows LIR generation to access the selected field directly, without first
1023 // buffering the enclosing flat-array element.
1024 class DelayedLoadIndexed : public CompilationResourceObj {
1025 private:
1026 LoadIndexed* _load_instr;
1027 ValueStack* _state_before;
1028 ciField* _field;
1029 size_t _offset;
1030 public:
1031 DelayedLoadIndexed(LoadIndexed* load, ValueStack* state_before)
1032 : _load_instr(load)
1033 , _state_before(state_before)
1034 , _field(nullptr)
1035 , _offset(0) { }
1036
1037 void update(ciField* field, int offset) {
1038 assert(offset >= 0, "must be");
1039 _field = field;
1040 _offset += offset;
1041 }
1042
1043 LoadIndexed* load_instr() const { return _load_instr; }
1044 ValueStack* state_before() const { return _state_before; }
1045 ciField* field() const { return _field; }
1046 size_t offset() const { return _offset; }
1047 };
1048
1049 LEAF(StoreIndexed, AccessIndexed)
1050 private:
1051 Value _value;
1052
1053 bool _check_boolean;
1054
1055 public:
1056 // creation
1057 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value,
1058 ValueStack* state_before, bool check_boolean, bool mismatched = false)
1059 : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
1060 , _value(value), _check_boolean(check_boolean) {
1061 #ifdef ASSERT
1062 AssertValues assert_value;
1063 values_do(&assert_value);
1064 #endif
1065 pin();
1066 }
1067
1068
1069 // accessors
1070 Value value() const { return _value; }
1071 bool check_boolean() const { return _check_boolean; }
1072
1073 // Flattened array support
1074 bool is_exact_flat_array_store() const;
1075 // generic
1076 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); }
1077 };
1078
1079
1080 LEAF(NegateOp, Instruction)
1081 private:
1082 Value _x;
1083
1084 public:
1085 // creation
1086 NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1087 ASSERT_VALUES
1088 }
1089
1090 // accessors
1091 Value x() const { return _x; }
1092
1093 // generic
1094 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); }
1165 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1166 };
1167
1168
1169 LEAF(CompareOp, Op2)
1170 public:
1171 // creation
1172 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1173 : Op2(intType, op, x, y, state_before)
1174 {}
1175
1176 // generic
1177 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1178 };
1179
1180
1181 LEAF(IfOp, Op2)
1182 private:
1183 Value _tval;
1184 Value _fval;
1185 bool _substitutability_check;
1186
1187 public:
1188 // creation
1189 IfOp(Value x, Condition cond, Value y, Value tval, Value fval, ValueStack* state_before, bool substitutability_check)
1190 : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1191 , _tval(tval)
1192 , _fval(fval)
1193 , _substitutability_check(substitutability_check)
1194 {
1195 ASSERT_VALUES
1196 assert(tval->type()->tag() == fval->type()->tag(), "types must match");
1197 set_state_before(state_before);
1198 }
1199
1200 // accessors
1201 virtual bool is_commutative() const;
1202 Bytecodes::Code op() const { ShouldNotCallThis(); return Bytecodes::_illegal; }
1203 Condition cond() const { return (Condition)Op2::op(); }
1204 Value tval() const { return _tval; }
1205 Value fval() const { return _fval; }
1206 bool substitutability_check() const { return _substitutability_check; }
1207 // generic
1208 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1209 };
1210
1211
1212 LEAF(Convert, Instruction)
1213 private:
1214 Bytecodes::Code _op;
1215 Value _value;
1216
1217 public:
1218 // creation
1219 Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1220 ASSERT_VALUES
1221 }
1222
1223 // accessors
1224 Bytecodes::Code op() const { return _op; }
1225 Value value() const { return _value; }
1226
1301 // accessors
1302 ValueStack* state() const { return _state; }
1303 IRScope* scope() const; // the state's scope
1304
1305 // manipulation
1306 void set_state(ValueStack* state) { assert(_state == nullptr, "overwriting existing state"); check_state(state); _state = state; }
1307
1308 // generic
1309 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
1310 virtual void state_values_do(ValueVisitor* f);
1311 };
1312
1313
1314 LEAF(Invoke, StateSplit)
1315 private:
1316 Bytecodes::Code _code;
1317 Value _recv;
1318 Values* _args;
1319 BasicTypeList* _signature;
1320 ciMethod* _target;
1321 ciType* _return_type;
1322
1323 public:
1324 // creation
1325 Invoke(Bytecodes::Code code, ciType* return_type, Value recv, Values* args,
1326 ciMethod* target, ValueStack* state_before);
1327
1328 // accessors
1329 Bytecodes::Code code() const { return _code; }
1330 Value receiver() const { return _recv; }
1331 bool has_receiver() const { return receiver() != nullptr; }
1332 int number_of_arguments() const { return _args->length(); }
1333 Value argument_at(int i) const { return _args->at(i); }
1334 BasicTypeList* signature() const { return _signature; }
1335 ciMethod* target() const { return _target; }
1336
1337 ciType* declared_type() const;
1338
1339 // Returns false if target is not loaded
1340 bool target_is_final() const { return check_flag(TargetIsFinalFlag); }
1341 bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); }
1342
1343 // JSR 292 support
1344 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; }
1345 bool is_method_handle_intrinsic() const { return target()->is_method_handle_intrinsic(); }
1346
1347 virtual bool needs_exception_state() const { return false; }
1348
1349 // generic
1350 virtual bool can_trap() const { return true; }
1351 virtual void input_values_do(ValueVisitor* f) {
1352 StateSplit::input_values_do(f);
1353 if (has_receiver()) f->visit(&_recv);
1354 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1355 }
1356 virtual void state_values_do(ValueVisitor *f);
1357 };
1358
1359
1360 LEAF(NewInstance, StateSplit)
1361 private:
1362 ciInstanceKlass* _klass;
1363 bool _is_unresolved;
1364 bool _needs_state_before;
1365
1366 public:
1367 // creation
1368 NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved, bool needs_state_before)
1369 : StateSplit(instanceType, state_before)
1370 , _klass(klass), _is_unresolved(is_unresolved), _needs_state_before(needs_state_before)
1371 {}
1372
1373 // accessors
1374 ciInstanceKlass* klass() const { return _klass; }
1375 bool is_unresolved() const { return _is_unresolved; }
1376 bool needs_state_before() const { return _needs_state_before; }
1377
1378 virtual bool needs_exception_state() const { return false; }
1379
1380 // generic
1381 virtual bool can_trap() const { return true; }
1382 ciType* exact_type() const;
1383 ciType* declared_type() const;
1384 };
1385
1386 BASE(NewArray, StateSplit)
1387 private:
1388 Value _length;
1389
1390 public:
1391 // creation
1392 NewArray(Value length, ValueStack* state_before)
1393 : StateSplit(objectType, state_before)
1394 , _length(length)
1395 {
1396 // Do not ASSERT_VALUES since length is null for NewMultiArray
1397 }
1398
1399 // accessors
1400 Value length() const { return _length; }
1401
1402 virtual bool needs_exception_state() const { return false; }
1403
1404 ciType* exact_type() const { return nullptr; }
1405 ciType* declared_type() const;
1419 // creation
1420 NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before, bool zero_array)
1421 : NewArray(length, state_before)
1422 , _elt_type(elt_type)
1423 , _zero_array(zero_array)
1424 {}
1425
1426 // accessors
1427 BasicType elt_type() const { return _elt_type; }
1428 bool zero_array() const { return _zero_array; }
1429 ciType* exact_type() const;
1430 };
1431
1432
1433 LEAF(NewObjectArray, NewArray)
1434 private:
1435 ciKlass* _klass;
1436
1437 public:
1438 // creation
1439 NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before)
1440 : NewArray(length, state_before), _klass(klass) { }
1441
1442 // accessors
1443 ciKlass* klass() const { return _klass; }
1444 ciType* exact_type() const;
1445 };
1446
1447
1448 LEAF(NewMultiArray, NewArray)
1449 private:
1450 ciKlass* _klass;
1451 Values* _dims;
1452
1453 public:
1454 // creation
1455 NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(nullptr, state_before), _klass(klass), _dims(dims) {
1456 ASSERT_VALUES
1457 }
1458
1459 // accessors
1460 ciKlass* klass() const { return _klass; }
1461 Values* dims() const { return _dims; }
1462 int rank() const { return dims()->length(); }
1463
1464 // generic
1465 virtual void input_values_do(ValueVisitor* f) {
1466 // NOTE: we do not call NewArray::input_values_do since "length"
1467 // is meaningless for a multi-dimensional array; passing the
1468 // zeroth element down to NewArray as its length is a bad idea
1469 // since there will be a copy in the "dims" array which doesn't
1470 // get updated, and the value must not be traversed twice. Was bug
1471 // - kbr 4/10/2001
1472 StateSplit::input_values_do(f);
1473 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1474 }
1475
1476 ciType* exact_type() const;
1477 };
1478
1479
1480 BASE(TypeCheck, StateSplit)
1481 private:
1482 ciKlass* _klass;
1483 Value _obj;
1484
1485 ciMethod* _profiled_method;
1486 int _profiled_bci;
1487
1488 public:
1489 // creation
1490 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1491 : StateSplit(type, state_before), _klass(klass), _obj(obj),
1492 _profiled_method(nullptr), _profiled_bci(0) {
1493 ASSERT_VALUES
1494 set_direct_compare(false);
1495 }
1496
1562 // creation
1563 AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1564 : StateSplit(illegalType, state_before)
1565 , _obj(obj)
1566 , _monitor_no(monitor_no)
1567 {
1568 set_needs_null_check(true);
1569 ASSERT_VALUES
1570 }
1571
1572 // accessors
1573 Value obj() const { return _obj; }
1574 int monitor_no() const { return _monitor_no; }
1575
1576 // generic
1577 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1578 };
1579
1580
1581 LEAF(MonitorEnter, AccessMonitor)
1582 bool _maybe_inlinetype;
1583 public:
1584 // creation
1585 MonitorEnter(Value obj, int monitor_no, ValueStack* state_before, bool maybe_inlinetype)
1586 : AccessMonitor(obj, monitor_no, state_before)
1587 , _maybe_inlinetype(maybe_inlinetype)
1588 {
1589 ASSERT_VALUES
1590 }
1591
1592 // accessors
1593 bool maybe_inlinetype() const { return _maybe_inlinetype; }
1594
1595 // generic
1596 virtual bool can_trap() const { return true; }
1597 };
1598
1599
1600 LEAF(MonitorExit, AccessMonitor)
1601 public:
1602 // creation
1603 MonitorExit(Value obj, int monitor_no)
1604 : AccessMonitor(obj, monitor_no, nullptr)
1605 {
1606 ASSERT_VALUES
1607 }
1608 };
1609
1610
1611 LEAF(Intrinsic, StateSplit)
1612 private:
1613 vmIntrinsics::ID _id;
1614 ArgsNonNullState _nonnull_state;
2030 Condition cond() const { return _cond; }
2031 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
2032 Value y() const { return _y; }
2033
2034 void always_fail() { _x = _y = nullptr; }
2035
2036 // generic
2037 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2038 HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
2039 };
2040
2041 LEAF(If, BlockEnd)
2042 private:
2043 Value _x;
2044 Condition _cond;
2045 Value _y;
2046 ciMethod* _profiled_method;
2047 int _profiled_bci; // Canonicalizer may alter bci of If node
2048 bool _swapped; // Is the order reversed with respect to the original If in the
2049 // bytecode stream?
2050 bool _substitutability_check;
2051 public:
2052 // creation
2053 // unordered_is_true is valid for float/double compares only
2054 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)
2055 : BlockEnd(illegalType, state_before, is_safepoint)
2056 , _x(x)
2057 , _cond(cond)
2058 , _y(y)
2059 , _profiled_method(nullptr)
2060 , _profiled_bci(0)
2061 , _swapped(false)
2062 , _substitutability_check(substitutability_check)
2063 {
2064 ASSERT_VALUES
2065 set_flag(UnorderedIsTrueFlag, unordered_is_true);
2066 assert(x->type()->tag() == y->type()->tag(), "types must match");
2067 BlockList* s = new BlockList(2);
2068 s->append(tsux);
2069 s->append(fsux);
2070 set_sux(s);
2071 }
2072
2073 // accessors
2074 Value x() const { return _x; }
2075 Condition cond() const { return _cond; }
2076 bool unordered_is_true() const { return check_flag(UnorderedIsTrueFlag); }
2077 Value y() const { return _y; }
2078 BlockBegin* sux_for(bool is_true) const { return sux_at(is_true ? 0 : 1); }
2079 BlockBegin* tsux() const { return sux_for(true); }
2080 BlockBegin* fsux() const { return sux_for(false); }
2081 BlockBegin* usux() const { return sux_for(unordered_is_true()); }
2082 bool should_profile() const { return check_flag(ProfileMDOFlag); }
2083 ciMethod* profiled_method() const { return _profiled_method; } // set only for profiled branches
2084 int profiled_bci() const { return _profiled_bci; } // set for profiled branches and tiered
2085 bool is_swapped() const { return _swapped; }
2086
2087 // manipulation
2088 void swap_operands() {
2089 Value t = _x; _x = _y; _y = t;
2090 _cond = mirror(_cond);
2091 }
2092
2093 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
2094 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
2095 void set_profiled_bci(int bci) { _profiled_bci = bci; }
2096 void set_swapped(bool value) { _swapped = value; }
2097 bool substitutability_check() const { return _substitutability_check; }
2098 // generic
2099 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2100 };
2101
2102
2103 BASE(Switch, BlockEnd)
2104 private:
2105 Value _tag;
2106
2107 public:
2108 // creation
2109 Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2110 : BlockEnd(illegalType, state_before, is_safepoint)
2111 , _tag(tag) {
2112 ASSERT_VALUES
2113 set_sux(sux);
2114 }
2115
2116 // accessors
2117 Value tag() const { return _tag; }
2388 }
2389 }
2390 };
2391
2392 LEAF(ProfileReturnType, Instruction)
2393 private:
2394 ciMethod* _method;
2395 ciMethod* _callee;
2396 int _bci_of_invoke;
2397 Value _ret;
2398
2399 public:
2400 ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2401 : Instruction(voidType)
2402 , _method(method)
2403 , _callee(callee)
2404 , _bci_of_invoke(bci)
2405 , _ret(ret)
2406 {
2407 set_needs_null_check(true);
2408 // The ProfileReturnType has side-effects and must occur precisely where located
2409 pin();
2410 }
2411
2412 ciMethod* method() const { return _method; }
2413 ciMethod* callee() const { return _callee; }
2414 int bci_of_invoke() const { return _bci_of_invoke; }
2415 Value ret() const { return _ret; }
2416
2417 virtual void input_values_do(ValueVisitor* f) {
2418 if (_ret != nullptr) {
2419 f->visit(&_ret);
2420 }
2421 }
2422 };
2423
2424 LEAF(ProfileACmpTypes, Instruction)
2425 private:
2426 ciMethod* _method;
2427 int _bci;
2428 Value _left;
2429 Value _right;
2430 bool _left_maybe_null;
2431 bool _right_maybe_null;
2432
2433 public:
2434 ProfileACmpTypes(ciMethod* method, int bci, Value left, Value right)
2435 : Instruction(voidType)
2436 , _method(method)
2437 , _bci(bci)
2438 , _left(left)
2439 , _right(right)
2440 {
2441 // The ProfileACmp has side-effects and must occur precisely where located
2442 pin();
2443 _left_maybe_null = true;
2444 _right_maybe_null = true;
2445 }
2446
2447 ciMethod* method() const { return _method; }
2448 int bci() const { return _bci; }
2449 Value left() const { return _left; }
2450 Value right() const { return _right; }
2451 bool left_maybe_null() const { return _left_maybe_null; }
2452 bool right_maybe_null() const { return _right_maybe_null; }
2453 void set_left_maybe_null(bool v) { _left_maybe_null = v; }
2454 void set_right_maybe_null(bool v) { _right_maybe_null = v; }
2455
2456 virtual void input_values_do(ValueVisitor* f) {
2457 if (_left != nullptr) {
2458 f->visit(&_left);
2459 }
2460 if (_right != nullptr) {
2461 f->visit(&_right);
2462 }
2463 }
2464 };
2465
2466 // Call some C runtime function that doesn't safepoint,
2467 // optionally passing the current thread as the first argument.
2468 LEAF(RuntimeCall, Instruction)
2469 private:
2470 const char* _entry_name;
2471 address _entry;
2472 Values* _args;
2473 bool _pass_thread; // Pass the JavaThread* as an implicit first argument
2474
2475 public:
2476 RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2477 : Instruction(type)
2478 , _entry_name(entry_name)
2479 , _entry(entry)
2480 , _args(args)
2481 , _pass_thread(pass_thread) {
2482 ASSERT_VALUES
2483 pin();
2484 }
2485
|