114 public: |
114 public: |
115 virtual void block_do(BlockBegin* block) = 0; |
115 virtual void block_do(BlockBegin* block) = 0; |
116 }; |
116 }; |
117 |
117 |
118 |
118 |
|
119 // A simple closure class for visiting the values of an Instruction |
|
120 class ValueVisitor: public StackObj { |
|
121 public: |
|
122 virtual void visit(Value* v) = 0; |
|
123 }; |
|
124 |
|
125 |
119 // Some array and list classes |
126 // Some array and list classes |
120 define_array(BlockBeginArray, BlockBegin*) |
127 define_array(BlockBeginArray, BlockBegin*) |
121 define_stack(_BlockList, BlockBeginArray) |
128 define_stack(_BlockList, BlockBeginArray) |
122 |
129 |
123 class BlockList: public _BlockList { |
130 class BlockList: public _BlockList { |
127 BlockList(const int size, BlockBegin* init): _BlockList(size, init) {} |
134 BlockList(const int size, BlockBegin* init): _BlockList(size, init) {} |
128 |
135 |
129 void iterate_forward(BlockClosure* closure); |
136 void iterate_forward(BlockClosure* closure); |
130 void iterate_backward(BlockClosure* closure); |
137 void iterate_backward(BlockClosure* closure); |
131 void blocks_do(void f(BlockBegin*)); |
138 void blocks_do(void f(BlockBegin*)); |
132 void values_do(void f(Value*)); |
139 void values_do(ValueVisitor* f); |
133 void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN; |
140 void print(bool cfg_only = false, bool live_only = false) PRODUCT_RETURN; |
134 }; |
141 }; |
135 |
142 |
136 |
143 |
137 // InstructionVisitors provide type-based dispatch for instructions. |
144 // InstructionVisitors provide type-based dispatch for instructions. |
262 |
269 |
263 // The mother of all instructions... |
270 // The mother of all instructions... |
264 |
271 |
265 class Instruction: public CompilationResourceObj { |
272 class Instruction: public CompilationResourceObj { |
266 private: |
273 private: |
267 static int _next_id; // the node counter |
|
268 |
|
269 int _id; // the unique instruction id |
274 int _id; // the unique instruction id |
270 int _bci; // the instruction bci |
275 int _bci; // the instruction bci |
271 int _use_count; // the number of instructions refering to this value (w/o prev/next); only roots can have use count = 0 or > 1 |
276 int _use_count; // the number of instructions refering to this value (w/o prev/next); only roots can have use count = 0 or > 1 |
272 int _pin_state; // set of PinReason describing the reason for pinning |
277 int _pin_state; // set of PinReason describing the reason for pinning |
273 ValueType* _type; // the instruction value type |
278 ValueType* _type; // the instruction value type |
281 #ifdef ASSERT |
286 #ifdef ASSERT |
282 HiWord* _hi_word; |
287 HiWord* _hi_word; |
283 #endif |
288 #endif |
284 |
289 |
285 friend class UseCountComputer; |
290 friend class UseCountComputer; |
|
291 friend class BlockBegin; |
286 |
292 |
287 protected: |
293 protected: |
288 void set_bci(int bci) { assert(bci == SynchronizationEntryBCI || bci >= 0, "illegal bci"); _bci = bci; } |
294 void set_bci(int bci) { assert(bci == SynchronizationEntryBCI || bci >= 0, "illegal bci"); _bci = bci; } |
289 void set_type(ValueType* type) { |
295 void set_type(ValueType* type) { |
290 assert(type != NULL, "type must exist"); |
296 assert(type != NULL, "type must exist"); |
291 _type = type; |
297 _type = type; |
292 } |
298 } |
293 |
299 |
294 public: |
300 public: |
|
301 void* operator new(size_t size) { |
|
302 Compilation* c = Compilation::current(); |
|
303 void* res = c->arena()->Amalloc(size); |
|
304 ((Instruction*)res)->_id = c->get_next_id(); |
|
305 return res; |
|
306 } |
|
307 |
295 enum InstructionFlag { |
308 enum InstructionFlag { |
296 NeedsNullCheckFlag = 0, |
309 NeedsNullCheckFlag = 0, |
297 CanTrapFlag, |
310 CanTrapFlag, |
298 DirectCompareFlag, |
311 DirectCompareFlag, |
299 IsEliminatedFlag, |
312 IsEliminatedFlag, |
336 |
349 |
337 static Condition mirror(Condition cond); |
350 static Condition mirror(Condition cond); |
338 static Condition negate(Condition cond); |
351 static Condition negate(Condition cond); |
339 |
352 |
340 // initialization |
353 // initialization |
341 static void initialize() { _next_id = 0; } |
354 static int number_of_instructions() { |
342 static int number_of_instructions() { return _next_id; } |
355 return Compilation::current()->number_of_instructions(); |
|
356 } |
343 |
357 |
344 // creation |
358 // creation |
345 Instruction(ValueType* type, bool type_is_constant = false, bool create_hi = true) |
359 Instruction(ValueType* type, bool type_is_constant = false, bool create_hi = true) |
346 : _id(_next_id++) |
360 : _bci(-99) |
347 , _bci(-99) |
|
348 , _use_count(0) |
361 , _use_count(0) |
349 , _pin_state(0) |
362 , _pin_state(0) |
350 , _type(type) |
363 , _type(type) |
351 , _next(NULL) |
364 , _next(NULL) |
352 , _subst(NULL) |
365 , _subst(NULL) |
477 |
490 |
478 virtual void visit(InstructionVisitor* v) = 0; |
491 virtual void visit(InstructionVisitor* v) = 0; |
479 |
492 |
480 virtual bool can_trap() const { return false; } |
493 virtual bool can_trap() const { return false; } |
481 |
494 |
482 virtual void input_values_do(void f(Value*)) = 0; |
495 virtual void input_values_do(ValueVisitor* f) = 0; |
483 virtual void state_values_do(void f(Value*)) { /* usually no state - override on demand */ } |
496 virtual void state_values_do(ValueVisitor* f) { /* usually no state - override on demand */ } |
484 virtual void other_values_do(void f(Value*)) { /* usually no other - override on demand */ } |
497 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ } |
485 void values_do(void f(Value*)) { input_values_do(f); state_values_do(f); other_values_do(f); } |
498 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); } |
486 |
499 |
487 virtual ciType* exact_type() const { return NULL; } |
500 virtual ciType* exact_type() const { return NULL; } |
488 virtual ciType* declared_type() const { return NULL; } |
501 virtual ciType* declared_type() const { return NULL; } |
489 |
502 |
490 // hashing |
503 // hashing |
515 virtual void visit(InstructionVisitor* v) { v->do_##class_name(this); } \ |
528 virtual void visit(InstructionVisitor* v) { v->do_##class_name(this); } \ |
516 |
529 |
517 |
530 |
518 // Debugging support |
531 // Debugging support |
519 |
532 |
|
533 |
520 #ifdef ASSERT |
534 #ifdef ASSERT |
521 static void assert_value(Value* x) { assert((*x) != NULL, "value must exist"); } |
535 class AssertValues: public ValueVisitor { |
522 #define ASSERT_VALUES values_do(assert_value); |
536 void visit(Value* x) { assert((*x) != NULL, "value must exist"); } |
|
537 }; |
|
538 #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); } |
523 #else |
539 #else |
524 #define ASSERT_VALUES |
540 #define ASSERT_VALUES |
525 #endif // ASSERT |
541 #endif // ASSERT |
526 |
542 |
527 |
543 |
553 |
569 |
554 // for invalidating of HiWords |
570 // for invalidating of HiWords |
555 void make_illegal() { set_type(illegalType); } |
571 void make_illegal() { set_type(illegalType); } |
556 |
572 |
557 // generic |
573 // generic |
558 virtual void input_values_do(void f(Value*)) { ShouldNotReachHere(); } |
574 virtual void input_values_do(ValueVisitor* f) { ShouldNotReachHere(); } |
559 }; |
575 }; |
560 |
576 |
561 |
577 |
562 // A Phi is a phi function in the sense of SSA form. It stands for |
578 // A Phi is a phi function in the sense of SSA form. It stands for |
563 // the value of a local variable at the beginning of a join block. |
579 // the value of a local variable at the beginning of a join block. |
661 |
677 |
662 ValueStack* state() const { return _state; } |
678 ValueStack* state() const { return _state; } |
663 |
679 |
664 // generic |
680 // generic |
665 virtual bool can_trap() const { return state() != NULL; } |
681 virtual bool can_trap() const { return state() != NULL; } |
666 virtual void input_values_do(void f(Value*)) { /* no values */ } |
682 virtual void input_values_do(ValueVisitor* f) { /* no values */ } |
667 virtual void other_values_do(void f(Value*)); |
683 virtual void other_values_do(ValueVisitor* f); |
668 |
684 |
669 virtual intx hash() const; |
685 virtual intx hash() const; |
670 virtual bool is_equal(Value v) const; |
686 virtual bool is_equal(Value v) const; |
671 |
687 |
672 virtual BlockBegin* compare(Instruction::Condition condition, Value right, |
688 virtual BlockBegin* compare(Instruction::Condition condition, Value right, |
732 // if needs_null_check() is true. |
748 // if needs_null_check() is true. |
733 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } |
749 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } |
734 |
750 |
735 // generic |
751 // generic |
736 virtual bool can_trap() const { return needs_null_check() || needs_patching(); } |
752 virtual bool can_trap() const { return needs_null_check() || needs_patching(); } |
737 virtual void input_values_do(void f(Value*)) { f(&_obj); } |
753 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } |
738 virtual void other_values_do(void f(Value*)); |
754 virtual void other_values_do(ValueVisitor* f); |
739 }; |
755 }; |
740 |
756 |
741 |
757 |
742 LEAF(LoadField, AccessField) |
758 LEAF(LoadField, AccessField) |
743 public: |
759 public: |
774 // accessors |
790 // accessors |
775 Value value() const { return _value; } |
791 Value value() const { return _value; } |
776 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } |
792 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } |
777 |
793 |
778 // generic |
794 // generic |
779 virtual void input_values_do(void f(Value*)) { AccessField::input_values_do(f); f(&_value); } |
795 virtual void input_values_do(ValueVisitor* f) { AccessField::input_values_do(f); f->visit(&_value); } |
780 }; |
796 }; |
781 |
797 |
782 |
798 |
783 BASE(AccessArray, Instruction) |
799 BASE(AccessArray, Instruction) |
784 private: |
800 private: |
802 // setters |
818 // setters |
803 void set_lock_stack(ValueStack* l) { _lock_stack = l; } |
819 void set_lock_stack(ValueStack* l) { _lock_stack = l; } |
804 |
820 |
805 // generic |
821 // generic |
806 virtual bool can_trap() const { return needs_null_check(); } |
822 virtual bool can_trap() const { return needs_null_check(); } |
807 virtual void input_values_do(void f(Value*)) { f(&_array); } |
823 virtual void input_values_do(ValueVisitor* f) { f->visit(&_array); } |
808 virtual void other_values_do(void f(Value*)); |
824 virtual void other_values_do(ValueVisitor* f); |
809 }; |
825 }; |
810 |
826 |
811 |
827 |
812 LEAF(ArrayLength, AccessArray) |
828 LEAF(ArrayLength, AccessArray) |
813 private: |
829 private: |
855 |
871 |
856 // perform elimination of range checks involving constants |
872 // perform elimination of range checks involving constants |
857 bool compute_needs_range_check(); |
873 bool compute_needs_range_check(); |
858 |
874 |
859 // generic |
875 // generic |
860 virtual void input_values_do(void f(Value*)) { AccessArray::input_values_do(f); f(&_index); if (_length != NULL) f(&_length); } |
876 virtual void input_values_do(ValueVisitor* f) { AccessArray::input_values_do(f); f->visit(&_index); if (_length != NULL) f->visit(&_length); } |
861 }; |
877 }; |
862 |
878 |
863 |
879 |
864 LEAF(LoadIndexed, AccessIndexed) |
880 LEAF(LoadIndexed, AccessIndexed) |
865 private: |
881 private: |
907 IRScope* scope() const; // the state's scope |
923 IRScope* scope() const; // the state's scope |
908 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } |
924 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } |
909 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); } |
925 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); } |
910 |
926 |
911 // generic |
927 // generic |
912 virtual void input_values_do(void f(Value*)) { AccessIndexed::input_values_do(f); f(&_value); } |
928 virtual void input_values_do(ValueVisitor* f) { AccessIndexed::input_values_do(f); f->visit(&_value); } |
913 }; |
929 }; |
914 |
930 |
915 |
931 |
916 LEAF(NegateOp, Instruction) |
932 LEAF(NegateOp, Instruction) |
917 private: |
933 private: |
980 void set_lock_stack(ValueStack* l) { _lock_stack = l; } |
996 void set_lock_stack(ValueStack* l) { _lock_stack = l; } |
981 |
997 |
982 // generic |
998 // generic |
983 virtual bool is_commutative() const; |
999 virtual bool is_commutative() const; |
984 virtual bool can_trap() const; |
1000 virtual bool can_trap() const; |
985 virtual void other_values_do(void f(Value*)); |
1001 virtual void other_values_do(ValueVisitor* f); |
986 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) |
1002 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) |
987 }; |
1003 }; |
988 |
1004 |
989 |
1005 |
990 LEAF(ShiftOp, Op2) |
1006 LEAF(ShiftOp, Op2) |
1049 Condition cond() const { return (Condition)Op2::op(); } |
1065 Condition cond() const { return (Condition)Op2::op(); } |
1050 Value tval() const { return _tval; } |
1066 Value tval() const { return _tval; } |
1051 Value fval() const { return _fval; } |
1067 Value fval() const { return _fval; } |
1052 |
1068 |
1053 // generic |
1069 // generic |
1054 virtual void input_values_do(void f(Value*)) { Op2::input_values_do(f); f(&_tval); f(&_fval); } |
1070 virtual void input_values_do(ValueVisitor* f) { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); } |
1055 }; |
1071 }; |
1056 |
1072 |
1057 |
1073 |
1058 LEAF(Convert, Instruction) |
1074 LEAF(Convert, Instruction) |
1059 private: |
1075 private: |
1069 // accessors |
1085 // accessors |
1070 Bytecodes::Code op() const { return _op; } |
1086 Bytecodes::Code op() const { return _op; } |
1071 Value value() const { return _value; } |
1087 Value value() const { return _value; } |
1072 |
1088 |
1073 // generic |
1089 // generic |
1074 virtual void input_values_do(void f(Value*)) { f(&_value); } |
1090 virtual void input_values_do(ValueVisitor* f) { f->visit(&_value); } |
1075 HASHING2(Convert, true, op(), value()->subst()) |
1091 HASHING2(Convert, true, op(), value()->subst()) |
1076 }; |
1092 }; |
1077 |
1093 |
1078 |
1094 |
1079 LEAF(NullCheck, Instruction) |
1095 LEAF(NullCheck, Instruction) |
1098 void set_lock_stack(ValueStack* l) { _lock_stack = l; } |
1114 void set_lock_stack(ValueStack* l) { _lock_stack = l; } |
1099 void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); } |
1115 void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); } |
1100 |
1116 |
1101 // generic |
1117 // generic |
1102 virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ } |
1118 virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ } |
1103 virtual void input_values_do(void f(Value*)) { f(&_obj); } |
1119 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } |
1104 virtual void other_values_do(void f(Value*)); |
1120 virtual void other_values_do(ValueVisitor* f); |
1105 HASHING1(NullCheck, true, obj()->subst()) |
1121 HASHING1(NullCheck, true, obj()->subst()) |
1106 }; |
1122 }; |
1107 |
1123 |
1108 |
1124 |
1109 BASE(StateSplit, Instruction) |
1125 BASE(StateSplit, Instruction) |
1167 // JSR 292 support |
1183 // JSR 292 support |
1168 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } |
1184 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } |
1169 |
1185 |
1170 // generic |
1186 // generic |
1171 virtual bool can_trap() const { return true; } |
1187 virtual bool can_trap() const { return true; } |
1172 virtual void input_values_do(void f(Value*)) { |
1188 virtual void input_values_do(ValueVisitor* f) { |
1173 StateSplit::input_values_do(f); |
1189 StateSplit::input_values_do(f); |
1174 if (has_receiver()) f(&_recv); |
1190 if (has_receiver()) f->visit(&_recv); |
1175 for (int i = 0; i < _args->length(); i++) f(_args->adr_at(i)); |
1191 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); |
1176 } |
1192 } |
1177 virtual void state_values_do(void f(Value*)); |
1193 virtual void state_values_do(ValueVisitor *f); |
1178 }; |
1194 }; |
1179 |
1195 |
1180 |
1196 |
1181 LEAF(NewInstance, StateSplit) |
1197 LEAF(NewInstance, StateSplit) |
1182 private: |
1198 private: |
1210 ValueStack* state_before() const { return _state_before; } |
1226 ValueStack* state_before() const { return _state_before; } |
1211 Value length() const { return _length; } |
1227 Value length() const { return _length; } |
1212 |
1228 |
1213 // generic |
1229 // generic |
1214 virtual bool can_trap() const { return true; } |
1230 virtual bool can_trap() const { return true; } |
1215 virtual void input_values_do(void f(Value*)) { StateSplit::input_values_do(f); f(&_length); } |
1231 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); } |
1216 virtual void other_values_do(void f(Value*)); |
1232 virtual void other_values_do(ValueVisitor* f); |
1217 }; |
1233 }; |
1218 |
1234 |
1219 |
1235 |
1220 LEAF(NewTypeArray, NewArray) |
1236 LEAF(NewTypeArray, NewArray) |
1221 private: |
1237 private: |
1260 ciKlass* klass() const { return _klass; } |
1276 ciKlass* klass() const { return _klass; } |
1261 Values* dims() const { return _dims; } |
1277 Values* dims() const { return _dims; } |
1262 int rank() const { return dims()->length(); } |
1278 int rank() const { return dims()->length(); } |
1263 |
1279 |
1264 // generic |
1280 // generic |
1265 virtual void input_values_do(void f(Value*)) { |
1281 virtual void input_values_do(ValueVisitor* f) { |
1266 // NOTE: we do not call NewArray::input_values_do since "length" |
1282 // NOTE: we do not call NewArray::input_values_do since "length" |
1267 // is meaningless for a multi-dimensional array; passing the |
1283 // is meaningless for a multi-dimensional array; passing the |
1268 // zeroth element down to NewArray as its length is a bad idea |
1284 // zeroth element down to NewArray as its length is a bad idea |
1269 // since there will be a copy in the "dims" array which doesn't |
1285 // since there will be a copy in the "dims" array which doesn't |
1270 // get updated, and the value must not be traversed twice. Was bug |
1286 // get updated, and the value must not be traversed twice. Was bug |
1271 // - kbr 4/10/2001 |
1287 // - kbr 4/10/2001 |
1272 StateSplit::input_values_do(f); |
1288 StateSplit::input_values_do(f); |
1273 for (int i = 0; i < _dims->length(); i++) f(_dims->adr_at(i)); |
1289 for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i)); |
1274 } |
1290 } |
1275 }; |
1291 }; |
1276 |
1292 |
1277 |
1293 |
1278 BASE(TypeCheck, StateSplit) |
1294 BASE(TypeCheck, StateSplit) |
1298 // manipulation |
1314 // manipulation |
1299 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); } |
1315 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); } |
1300 |
1316 |
1301 // generic |
1317 // generic |
1302 virtual bool can_trap() const { return true; } |
1318 virtual bool can_trap() const { return true; } |
1303 virtual void input_values_do(void f(Value*)) { StateSplit::input_values_do(f); f(&_obj); } |
1319 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } |
1304 virtual void other_values_do(void f(Value*)); |
1320 virtual void other_values_do(ValueVisitor* f); |
1305 }; |
1321 }; |
1306 |
1322 |
1307 |
1323 |
1308 LEAF(CheckCast, TypeCheck) |
1324 LEAF(CheckCast, TypeCheck) |
1309 private: |
1325 private: |
1452 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } |
1468 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } |
1453 bool preserves_state() const { return check_flag(PreservesStateFlag); } |
1469 bool preserves_state() const { return check_flag(PreservesStateFlag); } |
1454 |
1470 |
1455 // generic |
1471 // generic |
1456 virtual bool can_trap() const { return check_flag(CanTrapFlag); } |
1472 virtual bool can_trap() const { return check_flag(CanTrapFlag); } |
1457 virtual void input_values_do(void f(Value*)) { |
1473 virtual void input_values_do(ValueVisitor* f) { |
1458 StateSplit::input_values_do(f); |
1474 StateSplit::input_values_do(f); |
1459 for (int i = 0; i < _args->length(); i++) f(_args->adr_at(i)); |
1475 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); |
1460 } |
1476 } |
1461 virtual void state_values_do(void f(Value*)); |
1477 virtual void state_values_do(ValueVisitor* f); |
1462 |
1478 |
1463 }; |
1479 }; |
1464 |
1480 |
1465 |
1481 |
1466 class LIR_List; |
1482 class LIR_List; |
1467 |
1483 |
1468 LEAF(BlockBegin, StateSplit) |
1484 LEAF(BlockBegin, StateSplit) |
1469 private: |
1485 private: |
1470 static int _next_block_id; // the block counter |
|
1471 |
|
1472 int _block_id; // the unique block id |
1486 int _block_id; // the unique block id |
1473 int _depth_first_number; // number of this block in a depth-first ordering |
1487 int _depth_first_number; // number of this block in a depth-first ordering |
1474 int _linear_scan_number; // number of this block in linear-scan ordering |
1488 int _linear_scan_number; // number of this block in linear-scan ordering |
1475 int _loop_depth; // the loop nesting level of this block |
1489 int _loop_depth; // the loop nesting level of this block |
1476 int _loop_index; // number of the innermost loop of this block |
1490 int _loop_index; // number of the innermost loop of this block |
1508 void iterate_postorder(boolArray& mark, BlockClosure* closure); |
1522 void iterate_postorder(boolArray& mark, BlockClosure* closure); |
1509 |
1523 |
1510 friend class SuxAndWeightAdjuster; |
1524 friend class SuxAndWeightAdjuster; |
1511 |
1525 |
1512 public: |
1526 public: |
|
1527 void* operator new(size_t size) { |
|
1528 Compilation* c = Compilation::current(); |
|
1529 void* res = c->arena()->Amalloc(size); |
|
1530 ((BlockBegin*)res)->_id = c->get_next_id(); |
|
1531 ((BlockBegin*)res)->_block_id = c->get_next_block_id(); |
|
1532 return res; |
|
1533 } |
|
1534 |
1513 // initialization/counting |
1535 // initialization/counting |
1514 static void initialize() { _next_block_id = 0; } |
1536 static int number_of_blocks() { |
1515 static int number_of_blocks() { return _next_block_id; } |
1537 return Compilation::current()->number_of_blocks(); |
|
1538 } |
1516 |
1539 |
1517 // creation |
1540 // creation |
1518 BlockBegin(int bci) |
1541 BlockBegin(int bci) |
1519 : StateSplit(illegalType) |
1542 : StateSplit(illegalType) |
1520 , _block_id(_next_block_id++) |
|
1521 , _depth_first_number(-1) |
1543 , _depth_first_number(-1) |
1522 , _linear_scan_number(-1) |
1544 , _linear_scan_number(-1) |
1523 , _loop_depth(0) |
1545 , _loop_depth(0) |
1524 , _flags(0) |
1546 , _flags(0) |
1525 , _dominator(NULL) |
1547 , _dominator(NULL) |
1590 void set_last_lir_instruction_id(int id) { _last_lir_instruction_id = id; } |
1612 void set_last_lir_instruction_id(int id) { _last_lir_instruction_id = id; } |
1591 void increment_total_preds(int n = 1) { _total_preds += n; } |
1613 void increment_total_preds(int n = 1) { _total_preds += n; } |
1592 void init_stores_to_locals(int locals_count) { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); } |
1614 void init_stores_to_locals(int locals_count) { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); } |
1593 |
1615 |
1594 // generic |
1616 // generic |
1595 virtual void state_values_do(void f(Value*)); |
1617 virtual void state_values_do(ValueVisitor* f); |
1596 |
1618 |
1597 // successors and predecessors |
1619 // successors and predecessors |
1598 int number_of_sux() const; |
1620 int number_of_sux() const; |
1599 BlockBegin* sux_at(int i) const; |
1621 BlockBegin* sux_at(int i) const; |
1600 void add_successor(BlockBegin* sux); |
1622 void add_successor(BlockBegin* sux); |
1644 |
1666 |
1645 // iteration |
1667 // iteration |
1646 void iterate_preorder (BlockClosure* closure); |
1668 void iterate_preorder (BlockClosure* closure); |
1647 void iterate_postorder (BlockClosure* closure); |
1669 void iterate_postorder (BlockClosure* closure); |
1648 |
1670 |
1649 void block_values_do(void f(Value*)); |
1671 void block_values_do(ValueVisitor* f); |
1650 |
1672 |
1651 // loops |
1673 // loops |
1652 void set_loop_index(int ix) { _loop_index = ix; } |
1674 void set_loop_index(int ix) { _loop_index = ix; } |
1653 int loop_index() const { return _loop_index; } |
1675 int loop_index() const { return _loop_index; } |
1654 |
1676 |
1696 |
1718 |
1697 // manipulation |
1719 // manipulation |
1698 void set_begin(BlockBegin* begin); |
1720 void set_begin(BlockBegin* begin); |
1699 |
1721 |
1700 // generic |
1722 // generic |
1701 virtual void other_values_do(void f(Value*)); |
1723 virtual void other_values_do(ValueVisitor* f); |
1702 |
1724 |
1703 // successors |
1725 // successors |
1704 int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; } |
1726 int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; } |
1705 BlockBegin* sux_at(int i) const { return _sux->at(i); } |
1727 BlockBegin* sux_at(int i) const { return _sux->at(i); } |
1706 BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); } |
1728 BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); } |
1785 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } |
1807 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } |
1786 void set_profiled_method(ciMethod* method) { _profiled_method = method; } |
1808 void set_profiled_method(ciMethod* method) { _profiled_method = method; } |
1787 void set_profiled_bci(int bci) { _profiled_bci = bci; } |
1809 void set_profiled_bci(int bci) { _profiled_bci = bci; } |
1788 |
1810 |
1789 // generic |
1811 // generic |
1790 virtual void input_values_do(void f(Value*)) { BlockEnd::input_values_do(f); f(&_x); f(&_y); } |
1812 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); } |
1791 }; |
1813 }; |
1792 |
1814 |
1793 |
1815 |
1794 LEAF(IfInstanceOf, BlockEnd) |
1816 LEAF(IfInstanceOf, BlockEnd) |
1795 private: |
1817 private: |
1839 BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); |
1861 BlockBegin* t = s->at(0); s->at_put(0, s->at(1)); s->at_put(1, t); |
1840 _test_is_instance = !_test_is_instance; |
1862 _test_is_instance = !_test_is_instance; |
1841 } |
1863 } |
1842 |
1864 |
1843 // generic |
1865 // generic |
1844 virtual void input_values_do(void f(Value*)) { BlockEnd::input_values_do(f); f(&_obj); } |
1866 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_obj); } |
1845 }; |
1867 }; |
1846 |
1868 |
1847 |
1869 |
1848 BASE(Switch, BlockEnd) |
1870 BASE(Switch, BlockEnd) |
1849 private: |
1871 private: |
1914 // accessors |
1936 // accessors |
1915 Value result() const { return _result; } |
1937 Value result() const { return _result; } |
1916 bool has_result() const { return result() != NULL; } |
1938 bool has_result() const { return result() != NULL; } |
1917 |
1939 |
1918 // generic |
1940 // generic |
1919 virtual void input_values_do(void f(Value*)) { |
1941 virtual void input_values_do(ValueVisitor* f) { |
1920 BlockEnd::input_values_do(f); |
1942 BlockEnd::input_values_do(f); |
1921 if (has_result()) f(&_result); |
1943 if (has_result()) f->visit(&_result); |
1922 } |
1944 } |
1923 }; |
1945 }; |
1924 |
1946 |
1925 |
1947 |
1926 LEAF(Throw, BlockEnd) |
1948 LEAF(Throw, BlockEnd) |
1936 // accessors |
1958 // accessors |
1937 Value exception() const { return _exception; } |
1959 Value exception() const { return _exception; } |
1938 |
1960 |
1939 // generic |
1961 // generic |
1940 virtual bool can_trap() const { return true; } |
1962 virtual bool can_trap() const { return true; } |
1941 virtual void input_values_do(void f(Value*)) { BlockEnd::input_values_do(f); f(&_exception); } |
1963 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_exception); } |
1942 virtual void state_values_do(void f(Value*)); |
1964 virtual void state_values_do(ValueVisitor* f); |
1943 }; |
1965 }; |
1944 |
1966 |
1945 |
1967 |
1946 LEAF(Base, BlockEnd) |
1968 LEAF(Base, BlockEnd) |
1947 public: |
1969 public: |
1969 #else |
1991 #else |
1970 OsrEntry() : Instruction(intType, false) { pin(); } |
1992 OsrEntry() : Instruction(intType, false) { pin(); } |
1971 #endif |
1993 #endif |
1972 |
1994 |
1973 // generic |
1995 // generic |
1974 virtual void input_values_do(void f(Value*)) { } |
1996 virtual void input_values_do(ValueVisitor* f) { } |
1975 }; |
1997 }; |
1976 |
1998 |
1977 |
1999 |
1978 // Models the incoming exception at a catch site |
2000 // Models the incoming exception at a catch site |
1979 LEAF(ExceptionObject, Instruction) |
2001 LEAF(ExceptionObject, Instruction) |
2076 void set_base (Value base) { _base = base; } |
2098 void set_base (Value base) { _base = base; } |
2077 void set_index(Value index) { _index = index; } |
2099 void set_index(Value index) { _index = index; } |
2078 void set_log2_scale(int log2_scale) { _log2_scale = log2_scale; } |
2100 void set_log2_scale(int log2_scale) { _log2_scale = log2_scale; } |
2079 |
2101 |
2080 // generic |
2102 // generic |
2081 virtual void input_values_do(void f(Value*)) { UnsafeOp::input_values_do(f); |
2103 virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); |
2082 f(&_base); |
2104 f->visit(&_base); |
2083 if (has_index()) f(&_index); } |
2105 if (has_index()) f->visit(&_index); } |
2084 }; |
2106 }; |
2085 |
2107 |
2086 |
2108 |
2087 LEAF(UnsafeGetRaw, UnsafeRawOp) |
2109 LEAF(UnsafeGetRaw, UnsafeRawOp) |
2088 private: |
2110 private: |
2147 // accessors |
2169 // accessors |
2148 Value object() { return _object; } |
2170 Value object() { return _object; } |
2149 Value offset() { return _offset; } |
2171 Value offset() { return _offset; } |
2150 bool is_volatile() { return _is_volatile; } |
2172 bool is_volatile() { return _is_volatile; } |
2151 // generic |
2173 // generic |
2152 virtual void input_values_do(void f(Value*)) { UnsafeOp::input_values_do(f); |
2174 virtual void input_values_do(ValueVisitor* f) { UnsafeOp::input_values_do(f); |
2153 f(&_object); |
2175 f->visit(&_object); |
2154 f(&_offset); } |
2176 f->visit(&_offset); } |
2155 }; |
2177 }; |
2156 |
2178 |
2157 |
2179 |
2158 LEAF(UnsafeGetObject, UnsafeObjectOp) |
2180 LEAF(UnsafeGetObject, UnsafeObjectOp) |
2159 public: |
2181 public: |
2236 ciMethod* method() { return _method; } |
2258 ciMethod* method() { return _method; } |
2237 int bci_of_invoke() { return _bci_of_invoke; } |
2259 int bci_of_invoke() { return _bci_of_invoke; } |
2238 Value recv() { return _recv; } |
2260 Value recv() { return _recv; } |
2239 ciKlass* known_holder() { return _known_holder; } |
2261 ciKlass* known_holder() { return _known_holder; } |
2240 |
2262 |
2241 virtual void input_values_do(void f(Value*)) { if (_recv != NULL) f(&_recv); } |
2263 virtual void input_values_do(ValueVisitor* f) { if (_recv != NULL) f->visit(&_recv); } |
2242 }; |
2264 }; |
2243 |
2265 |
2244 |
2266 |
2245 // |
2267 // |
2246 // Simple node representing a counter update generally used for updating MDOs |
2268 // Simple node representing a counter update generally used for updating MDOs |
2264 |
2286 |
2265 Value mdo() { return _mdo; } |
2287 Value mdo() { return _mdo; } |
2266 int offset() { return _offset; } |
2288 int offset() { return _offset; } |
2267 int increment() { return _increment; } |
2289 int increment() { return _increment; } |
2268 |
2290 |
2269 virtual void input_values_do(void f(Value*)) { f(&_mdo); } |
2291 virtual void input_values_do(ValueVisitor* f) { f->visit(&_mdo); } |
2270 }; |
2292 }; |
2271 |
2293 |
2272 |
2294 |
2273 class BlockPair: public CompilationResourceObj { |
2295 class BlockPair: public CompilationResourceObj { |
2274 private: |
2296 private: |