comparison src/share/vm/c1/c1_Instruction.hpp @ 1819:f02a8bbe6ed4

6986046: C1 valuestack cleanup Summary: fixes an historical oddity in C1 with inlining where all of the expression stacks are kept in the topmost ValueStack instead of being in their respective ValueStacks. Reviewed-by: never Contributed-by: Christian Wimmer <cwimmer@uci.edu>
author roland
date Tue, 29 Dec 2009 19:08:54 +0100
parents 3a294e483abc
children ad0638ff8ea4
comparison
equal deleted inserted replaced
1817:c40600e85311 1819:f02a8bbe6ed4
36 // All leaf classes in the class hierarchy are concrete classes 36 // All leaf classes in the class hierarchy are concrete classes
37 // (i.e., are instantiated). All other classes are abstract and 37 // (i.e., are instantiated). All other classes are abstract and
38 // serve factoring. 38 // serve factoring.
39 39
40 class Instruction; 40 class Instruction;
41 class HiWord;
42 class Phi; 41 class Phi;
43 class Local; 42 class Local;
44 class Constant; 43 class Constant;
45 class AccessField; 44 class AccessField;
46 class LoadField; 45 class LoadField;
147 // (e.g., printing, code generation) is factored out into a specialised 146 // (e.g., printing, code generation) is factored out into a specialised
148 // visitor instead of added to the Instruction classes itself. 147 // visitor instead of added to the Instruction classes itself.
149 148
150 class InstructionVisitor: public StackObj { 149 class InstructionVisitor: public StackObj {
151 public: 150 public:
152 void do_HiWord (HiWord* x) { ShouldNotReachHere(); }
153 virtual void do_Phi (Phi* x) = 0; 151 virtual void do_Phi (Phi* x) = 0;
154 virtual void do_Local (Local* x) = 0; 152 virtual void do_Local (Local* x) = 0;
155 virtual void do_Constant (Constant* x) = 0; 153 virtual void do_Constant (Constant* x) = 0;
156 virtual void do_LoadField (LoadField* x) = 0; 154 virtual void do_LoadField (LoadField* x) = 0;
157 virtual void do_StoreField (StoreField* x) = 0; 155 virtual void do_StoreField (StoreField* x) = 0;
270 // The mother of all instructions... 268 // The mother of all instructions...
271 269
272 class Instruction: public CompilationResourceObj { 270 class Instruction: public CompilationResourceObj {
273 private: 271 private:
274 int _id; // the unique instruction id 272 int _id; // the unique instruction id
275 int _bci; // the instruction bci 273 #ifndef PRODUCT
274 int _printable_bci; // the bci of the instruction for printing
275 #endif
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 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
277 int _pin_state; // set of PinReason describing the reason for pinning 277 int _pin_state; // set of PinReason describing the reason for pinning
278 ValueType* _type; // the instruction value type 278 ValueType* _type; // the instruction value type
279 Instruction* _next; // the next instruction if any (NULL for BlockEnd instructions) 279 Instruction* _next; // the next instruction if any (NULL for BlockEnd instructions)
280 Instruction* _subst; // the substitution instruction if any 280 Instruction* _subst; // the substitution instruction if any
281 LIR_Opr _operand; // LIR specific information 281 LIR_Opr _operand; // LIR specific information
282 unsigned int _flags; // Flag bits 282 unsigned int _flags; // Flag bits
283 283
284 ValueStack* _state_before; // Copy of state with input operands still on stack (or NULL)
285 ValueStack* _exception_state; // Copy of state for exception handling
284 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction 286 XHandlers* _exception_handlers; // Flat list of exception handlers covering this instruction
285
286 #ifdef ASSERT
287 HiWord* _hi_word;
288 #endif
289 287
290 friend class UseCountComputer; 288 friend class UseCountComputer;
291 friend class BlockBegin; 289 friend class BlockBegin;
292 290
291 void update_exception_state(ValueStack* state);
292
293 bool has_printable_bci() const { return NOT_PRODUCT(_printable_bci != -99) PRODUCT_ONLY(false); }
294
293 protected: 295 protected:
294 void set_bci(int bci) { assert(bci == SynchronizationEntryBCI || bci >= 0, "illegal bci"); _bci = bci; }
295 void set_type(ValueType* type) { 296 void set_type(ValueType* type) {
296 assert(type != NULL, "type must exist"); 297 assert(type != NULL, "type must exist");
297 _type = type; 298 _type = type;
298 } 299 }
299 300
323 TargetIsStrictfpFlag, 324 TargetIsStrictfpFlag,
324 UnorderedIsTrueFlag, 325 UnorderedIsTrueFlag,
325 NeedsPatchingFlag, 326 NeedsPatchingFlag,
326 ThrowIncompatibleClassChangeErrorFlag, 327 ThrowIncompatibleClassChangeErrorFlag,
327 ProfileMDOFlag, 328 ProfileMDOFlag,
329 IsLinkedInBlockFlag,
328 InstructionLastFlag 330 InstructionLastFlag
329 }; 331 };
330 332
331 public: 333 public:
332 bool check_flag(InstructionFlag id) const { return (_flags & (1 << id)) != 0; } 334 bool check_flag(InstructionFlag id) const { return (_flags & (1 << id)) != 0; }
354 static int number_of_instructions() { 356 static int number_of_instructions() {
355 return Compilation::current()->number_of_instructions(); 357 return Compilation::current()->number_of_instructions();
356 } 358 }
357 359
358 // creation 360 // creation
359 Instruction(ValueType* type, bool type_is_constant = false, bool create_hi = true) 361 Instruction(ValueType* type, ValueStack* state_before = NULL, bool type_is_constant = false, bool create_hi = true)
360 : _bci(-99) 362 : _use_count(0)
361 , _use_count(0) 363 #ifndef PRODUCT
364 , _printable_bci(-99)
365 #endif
362 , _pin_state(0) 366 , _pin_state(0)
363 , _type(type) 367 , _type(type)
364 , _next(NULL) 368 , _next(NULL)
365 , _subst(NULL) 369 , _subst(NULL)
366 , _flags(0) 370 , _flags(0)
367 , _operand(LIR_OprFact::illegalOpr) 371 , _operand(LIR_OprFact::illegalOpr)
372 , _state_before(state_before)
368 , _exception_handlers(NULL) 373 , _exception_handlers(NULL)
369 #ifdef ASSERT 374 {
370 , _hi_word(NULL) 375 check_state(state_before);
376 assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist");
377 update_exception_state(_state_before);
378 }
379
380 // accessors
381 int id() const { return _id; }
382 #ifndef PRODUCT
383 int printable_bci() const { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
384 void set_printable_bci(int bci) { NOT_PRODUCT(_printable_bci = bci;) }
371 #endif 385 #endif
372 {
373 assert(type != NULL && (!type->is_constant() || type_is_constant), "type must exist");
374 #ifdef ASSERT
375 if (create_hi && type->is_double_word()) {
376 create_hi_word();
377 }
378 #endif
379 }
380
381 // accessors
382 int id() const { return _id; }
383 int bci() const { return _bci; }
384 int use_count() const { return _use_count; } 386 int use_count() const { return _use_count; }
385 int pin_state() const { return _pin_state; } 387 int pin_state() const { return _pin_state; }
386 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; } 388 bool is_pinned() const { return _pin_state != 0 || PinAllInstructions; }
387 ValueType* type() const { return _type; } 389 ValueType* type() const { return _type; }
388 Instruction* prev(BlockBegin* block); // use carefully, expensive operation 390 Instruction* prev(BlockBegin* block); // use carefully, expensive operation
391 Instruction* subst() { return _subst == NULL ? this : _subst->subst(); } 393 Instruction* subst() { return _subst == NULL ? this : _subst->subst(); }
392 LIR_Opr operand() const { return _operand; } 394 LIR_Opr operand() const { return _operand; }
393 395
394 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); } 396 void set_needs_null_check(bool f) { set_flag(NeedsNullCheckFlag, f); }
395 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); } 397 bool needs_null_check() const { return check_flag(NeedsNullCheckFlag); }
398 bool is_linked() const { return check_flag(IsLinkedInBlockFlag); }
399 bool can_be_linked() { return as_Local() == NULL && as_Phi() == NULL; }
396 400
397 bool has_uses() const { return use_count() > 0; } 401 bool has_uses() const { return use_count() > 0; }
398 bool is_root() const { return is_pinned() || use_count() > 1; } 402 ValueStack* state_before() const { return _state_before; }
403 ValueStack* exception_state() const { return _exception_state; }
404 virtual bool needs_exception_state() const { return true; }
399 XHandlers* exception_handlers() const { return _exception_handlers; } 405 XHandlers* exception_handlers() const { return _exception_handlers; }
400 406
401 // manipulation 407 // manipulation
402 void pin(PinReason reason) { _pin_state |= reason; } 408 void pin(PinReason reason) { _pin_state |= reason; }
403 void pin() { _pin_state |= PinUnknown; } 409 void pin() { _pin_state |= PinUnknown; }
404 // DANGEROUS: only used by EliminateStores 410 // DANGEROUS: only used by EliminateStores
405 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; } 411 void unpin(PinReason reason) { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
406 virtual void set_lock_stack(ValueStack* l) { /* do nothing*/ } 412
407 virtual ValueStack* lock_stack() const { return NULL; } 413 Instruction* set_next(Instruction* next) {
408 414 assert(next->has_printable_bci(), "_printable_bci should have been set");
409 Instruction* set_next(Instruction* next, int bci) { 415 assert(next != NULL, "must not be NULL");
410 if (next != NULL) { 416 assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next");
411 assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next"); 417 assert(next->can_be_linked(), "shouldn't link these instructions into list");
412 assert(next->as_Phi() == NULL && next->as_Local() == NULL, "shouldn't link these instructions into list"); 418
413 next->set_bci(bci); 419 next->set_flag(Instruction::IsLinkedInBlockFlag, true);
414 }
415 _next = next; 420 _next = next;
416 return next; 421 return next;
422 }
423
424 Instruction* set_next(Instruction* next, int bci) {
425 #ifndef PRODUCT
426 next->set_printable_bci(bci);
427 #endif
428 return set_next(next);
417 } 429 }
418 430
419 void set_subst(Instruction* subst) { 431 void set_subst(Instruction* subst) {
420 assert(subst == NULL || 432 assert(subst == NULL ||
421 type()->base() == subst->type()->base() || 433 type()->base() == subst->type()->base() ||
422 subst->type()->base() == illegalType, "type can't change"); 434 subst->type()->base() == illegalType, "type can't change");
423 _subst = subst; 435 _subst = subst;
424 } 436 }
425 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; } 437 void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
426 438 void set_exception_state(ValueStack* s) { check_state(s); _exception_state = s; }
427 #ifdef ASSERT
428 // HiWord is used for debugging and is allocated early to avoid
429 // allocation at inconvenient points
430 HiWord* hi_word() { return _hi_word; }
431 void create_hi_word();
432 #endif
433
434 439
435 // machine-specifics 440 // machine-specifics
436 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; } 441 void set_operand(LIR_Opr operand) { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
437 void clear_operand() { _operand = LIR_OprFact::illegalOpr; } 442 void clear_operand() { _operand = LIR_OprFact::illegalOpr; }
438 443
439 // generic 444 // generic
440 virtual Instruction* as_Instruction() { return this; } // to satisfy HASHING1 macro 445 virtual Instruction* as_Instruction() { return this; } // to satisfy HASHING1 macro
441 virtual HiWord* as_HiWord() { return NULL; }
442 virtual Phi* as_Phi() { return NULL; } 446 virtual Phi* as_Phi() { return NULL; }
443 virtual Local* as_Local() { return NULL; } 447 virtual Local* as_Local() { return NULL; }
444 virtual Constant* as_Constant() { return NULL; } 448 virtual Constant* as_Constant() { return NULL; }
445 virtual AccessField* as_AccessField() { return NULL; } 449 virtual AccessField* as_AccessField() { return NULL; }
446 virtual LoadField* as_LoadField() { return NULL; } 450 virtual LoadField* as_LoadField() { return NULL; }
491 virtual void visit(InstructionVisitor* v) = 0; 495 virtual void visit(InstructionVisitor* v) = 0;
492 496
493 virtual bool can_trap() const { return false; } 497 virtual bool can_trap() const { return false; }
494 498
495 virtual void input_values_do(ValueVisitor* f) = 0; 499 virtual void input_values_do(ValueVisitor* f) = 0;
496 virtual void state_values_do(ValueVisitor* f) { /* usually no state - override on demand */ } 500 virtual void state_values_do(ValueVisitor* f);
497 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ } 501 virtual void other_values_do(ValueVisitor* f) { /* usually no other - override on demand */ }
498 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); } 502 void values_do(ValueVisitor* f) { input_values_do(f); state_values_do(f); other_values_do(f); }
499 503
500 virtual ciType* exact_type() const { return NULL; } 504 virtual ciType* exact_type() const { return NULL; }
501 virtual ciType* declared_type() const { return NULL; } 505 virtual ciType* declared_type() const { return NULL; }
503 // hashing 507 // hashing
504 virtual const char* name() const = 0; 508 virtual const char* name() const = 0;
505 HASHING1(Instruction, false, id()) // hashing disabled by default 509 HASHING1(Instruction, false, id()) // hashing disabled by default
506 510
507 // debugging 511 // debugging
512 static void check_state(ValueStack* state) PRODUCT_RETURN;
508 void print() PRODUCT_RETURN; 513 void print() PRODUCT_RETURN;
509 void print_line() PRODUCT_RETURN; 514 void print_line() PRODUCT_RETURN;
510 void print(InstructionPrinter& ip) PRODUCT_RETURN; 515 void print(InstructionPrinter& ip) PRODUCT_RETURN;
511 }; 516 };
512 517
537 }; 542 };
538 #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); } 543 #define ASSERT_VALUES { AssertValues assert_value; values_do(&assert_value); }
539 #else 544 #else
540 #define ASSERT_VALUES 545 #define ASSERT_VALUES
541 #endif // ASSERT 546 #endif // ASSERT
542
543
544 // A HiWord occupies the 'high word' of a 2-word
545 // expression stack entry. Hi & lo words must be
546 // paired on the expression stack (otherwise the
547 // bytecode sequence is illegal). Note that 'hi'
548 // refers to the IR expression stack format and
549 // does *not* imply a machine word ordering. No
550 // HiWords are used in optimized mode for speed,
551 // but NULL pointers are used instead.
552
553 LEAF(HiWord, Instruction)
554 private:
555 Value _lo_word;
556
557 public:
558 // creation
559 HiWord(Value lo_word)
560 : Instruction(illegalType, false, false),
561 _lo_word(lo_word) {
562 // hi-words are also allowed for illegal lo-words
563 assert(lo_word->type()->is_double_word() || lo_word->type()->is_illegal(),
564 "HiWord must be used for 2-word values only");
565 }
566
567 // accessors
568 Value lo_word() const { return _lo_word->subst(); }
569
570 // for invalidating of HiWords
571 void make_illegal() { set_type(illegalType); }
572
573 // generic
574 virtual void input_values_do(ValueVisitor* f) { ShouldNotReachHere(); }
575 };
576 547
577 548
578 // A Phi is a phi function in the sense of SSA form. It stands for 549 // A Phi is a phi function in the sense of SSA form. It stands for
579 // the value of a local variable at the beginning of a join block. 550 // the value of a local variable at the beginning of a join block.
580 // A Phi consists of n operands, one for every incoming branch. 551 // A Phi consists of n operands, one for every incoming branch.
654 virtual void input_values_do(ValueVisitor* f) { /* no values */ } 625 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
655 }; 626 };
656 627
657 628
658 LEAF(Constant, Instruction) 629 LEAF(Constant, Instruction)
659 ValueStack* _state;
660
661 public: 630 public:
662 // creation 631 // creation
663 Constant(ValueType* type): 632 Constant(ValueType* type):
664 Instruction(type, true) 633 Instruction(type, NULL, true)
665 , _state(NULL) { 634 {
666 assert(type->is_constant(), "must be a constant"); 635 assert(type->is_constant(), "must be a constant");
667 } 636 }
668 637
669 Constant(ValueType* type, ValueStack* state): 638 Constant(ValueType* type, ValueStack* state_before):
670 Instruction(type, true) 639 Instruction(type, state_before, true)
671 , _state(state) { 640 {
672 assert(state != NULL, "only used for constants which need patching"); 641 assert(state_before != NULL, "only used for constants which need patching");
673 assert(type->is_constant(), "must be a constant"); 642 assert(type->is_constant(), "must be a constant");
674 // since it's patching it needs to be pinned 643 // since it's patching it needs to be pinned
675 pin(); 644 pin();
676 } 645 }
677 646
678 ValueStack* state() const { return _state; } 647 virtual bool can_trap() const { return state_before() != NULL; }
679
680 // generic
681 virtual bool can_trap() const { return state() != NULL; }
682 virtual void input_values_do(ValueVisitor* f) { /* no values */ } 648 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
683 virtual void other_values_do(ValueVisitor* f);
684 649
685 virtual intx hash() const; 650 virtual intx hash() const;
686 virtual bool is_equal(Value v) const; 651 virtual bool is_equal(Value v) const;
687 652
688 virtual BlockBegin* compare(Instruction::Condition condition, Value right, 653 virtual BlockBegin* compare(Instruction::Condition condition, Value right,
693 BASE(AccessField, Instruction) 658 BASE(AccessField, Instruction)
694 private: 659 private:
695 Value _obj; 660 Value _obj;
696 int _offset; 661 int _offset;
697 ciField* _field; 662 ciField* _field;
698 ValueStack* _state_before; // state is set only for unloaded or uninitialized fields
699 ValueStack* _lock_stack; // contains lock and scope information
700 NullCheck* _explicit_null_check; // For explicit null check elimination 663 NullCheck* _explicit_null_check; // For explicit null check elimination
701 664
702 public: 665 public:
703 // creation 666 // creation
704 AccessField(Value obj, int offset, ciField* field, bool is_static, ValueStack* lock_stack, 667 AccessField(Value obj, int offset, ciField* field, bool is_static,
705 ValueStack* state_before, bool is_loaded, bool is_initialized) 668 ValueStack* state_before, bool is_loaded, bool is_initialized)
706 : Instruction(as_ValueType(field->type()->basic_type())) 669 : Instruction(as_ValueType(field->type()->basic_type()), state_before)
707 , _obj(obj) 670 , _obj(obj)
708 , _offset(offset) 671 , _offset(offset)
709 , _field(field) 672 , _field(field)
710 , _lock_stack(lock_stack)
711 , _state_before(state_before)
712 , _explicit_null_check(NULL) 673 , _explicit_null_check(NULL)
713 { 674 {
714 set_needs_null_check(!is_static); 675 set_needs_null_check(!is_static);
715 set_flag(IsLoadedFlag, is_loaded); 676 set_flag(IsLoadedFlag, is_loaded);
716 set_flag(IsInitializedFlag, is_initialized); 677 set_flag(IsInitializedFlag, is_initialized);
732 ciField* field() const { return _field; } 693 ciField* field() const { return _field; }
733 BasicType field_type() const { return _field->type()->basic_type(); } 694 BasicType field_type() const { return _field->type()->basic_type(); }
734 bool is_static() const { return check_flag(IsStaticFlag); } 695 bool is_static() const { return check_flag(IsStaticFlag); }
735 bool is_loaded() const { return check_flag(IsLoadedFlag); } 696 bool is_loaded() const { return check_flag(IsLoadedFlag); }
736 bool is_initialized() const { return check_flag(IsInitializedFlag); } 697 bool is_initialized() const { return check_flag(IsInitializedFlag); }
737 ValueStack* state_before() const { return _state_before; }
738 ValueStack* lock_stack() const { return _lock_stack; }
739 NullCheck* explicit_null_check() const { return _explicit_null_check; } 698 NullCheck* explicit_null_check() const { return _explicit_null_check; }
740 bool needs_patching() const { return check_flag(NeedsPatchingFlag); } 699 bool needs_patching() const { return check_flag(NeedsPatchingFlag); }
741 700
742 // manipulation 701 // manipulation
743 void set_lock_stack(ValueStack* l) { _lock_stack = l; } 702
744 // Under certain circumstances, if a previous NullCheck instruction 703 // Under certain circumstances, if a previous NullCheck instruction
745 // proved the target object non-null, we can eliminate the explicit 704 // proved the target object non-null, we can eliminate the explicit
746 // null check and do an implicit one, simply specifying the debug 705 // null check and do an implicit one, simply specifying the debug
747 // information from the NullCheck. This field should only be consulted 706 // information from the NullCheck. This field should only be consulted
748 // if needs_null_check() is true. 707 // if needs_null_check() is true.
749 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; } 708 void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
750 709
751 // generic 710 // generic
752 virtual bool can_trap() const { return needs_null_check() || needs_patching(); } 711 virtual bool can_trap() const { return needs_null_check() || needs_patching(); }
753 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } 712 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); }
754 virtual void other_values_do(ValueVisitor* f);
755 }; 713 };
756 714
757 715
758 LEAF(LoadField, AccessField) 716 LEAF(LoadField, AccessField)
759 public: 717 public:
760 // creation 718 // creation
761 LoadField(Value obj, int offset, ciField* field, bool is_static, ValueStack* lock_stack, 719 LoadField(Value obj, int offset, ciField* field, bool is_static,
762 ValueStack* state_before, bool is_loaded, bool is_initialized) 720 ValueStack* state_before, bool is_loaded, bool is_initialized)
763 : AccessField(obj, offset, field, is_static, lock_stack, state_before, is_loaded, is_initialized) 721 : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized)
764 {} 722 {}
765 723
766 ciType* declared_type() const; 724 ciType* declared_type() const;
767 ciType* exact_type() const; 725 ciType* exact_type() const;
768 726
775 private: 733 private:
776 Value _value; 734 Value _value;
777 735
778 public: 736 public:
779 // creation 737 // creation
780 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static, ValueStack* lock_stack, 738 StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
781 ValueStack* state_before, bool is_loaded, bool is_initialized) 739 ValueStack* state_before, bool is_loaded, bool is_initialized)
782 : AccessField(obj, offset, field, is_static, lock_stack, state_before, is_loaded, is_initialized) 740 : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized)
783 , _value(value) 741 , _value(value)
784 { 742 {
785 set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object()); 743 set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
786 ASSERT_VALUES 744 ASSERT_VALUES
787 pin(); 745 pin();
797 755
798 756
799 BASE(AccessArray, Instruction) 757 BASE(AccessArray, Instruction)
800 private: 758 private:
801 Value _array; 759 Value _array;
802 ValueStack* _lock_stack; 760
803 761 public:
804 public: 762 // creation
805 // creation 763 AccessArray(ValueType* type, Value array, ValueStack* state_before)
806 AccessArray(ValueType* type, Value array, ValueStack* lock_stack) 764 : Instruction(type, state_before)
807 : Instruction(type)
808 , _array(array) 765 , _array(array)
809 , _lock_stack(lock_stack) { 766 {
810 set_needs_null_check(true); 767 set_needs_null_check(true);
811 ASSERT_VALUES 768 ASSERT_VALUES
812 pin(); // instruction with side effect (null exception or range check throwing) 769 pin(); // instruction with side effect (null exception or range check throwing)
813 } 770 }
814 771
815 Value array() const { return _array; } 772 Value array() const { return _array; }
816 ValueStack* lock_stack() const { return _lock_stack; }
817
818 // setters
819 void set_lock_stack(ValueStack* l) { _lock_stack = l; }
820 773
821 // generic 774 // generic
822 virtual bool can_trap() const { return needs_null_check(); } 775 virtual bool can_trap() const { return needs_null_check(); }
823 virtual void input_values_do(ValueVisitor* f) { f->visit(&_array); } 776 virtual void input_values_do(ValueVisitor* f) { f->visit(&_array); }
824 virtual void other_values_do(ValueVisitor* f);
825 }; 777 };
826 778
827 779
828 LEAF(ArrayLength, AccessArray) 780 LEAF(ArrayLength, AccessArray)
829 private: 781 private:
830 NullCheck* _explicit_null_check; // For explicit null check elimination 782 NullCheck* _explicit_null_check; // For explicit null check elimination
831 783
832 public: 784 public:
833 // creation 785 // creation
834 ArrayLength(Value array, ValueStack* lock_stack) 786 ArrayLength(Value array, ValueStack* state_before)
835 : AccessArray(intType, array, lock_stack) 787 : AccessArray(intType, array, state_before)
836 , _explicit_null_check(NULL) {} 788 , _explicit_null_check(NULL) {}
837 789
838 // accessors 790 // accessors
839 NullCheck* explicit_null_check() const { return _explicit_null_check; } 791 NullCheck* explicit_null_check() const { return _explicit_null_check; }
840 792
853 Value _length; 805 Value _length;
854 BasicType _elt_type; 806 BasicType _elt_type;
855 807
856 public: 808 public:
857 // creation 809 // creation
858 AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* lock_stack) 810 AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before)
859 : AccessArray(as_ValueType(elt_type), array, lock_stack) 811 : AccessArray(as_ValueType(elt_type), array, state_before)
860 , _index(index) 812 , _index(index)
861 , _length(length) 813 , _length(length)
862 , _elt_type(elt_type) 814 , _elt_type(elt_type)
863 { 815 {
864 ASSERT_VALUES 816 ASSERT_VALUES
881 private: 833 private:
882 NullCheck* _explicit_null_check; // For explicit null check elimination 834 NullCheck* _explicit_null_check; // For explicit null check elimination
883 835
884 public: 836 public:
885 // creation 837 // creation
886 LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* lock_stack) 838 LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before)
887 : AccessIndexed(array, index, length, elt_type, lock_stack) 839 : AccessIndexed(array, index, length, elt_type, state_before)
888 , _explicit_null_check(NULL) {} 840 , _explicit_null_check(NULL) {}
889 841
890 // accessors 842 // accessors
891 NullCheck* explicit_null_check() const { return _explicit_null_check; } 843 NullCheck* explicit_null_check() const { return _explicit_null_check; }
892 844
908 860
909 ciMethod* _profiled_method; 861 ciMethod* _profiled_method;
910 int _profiled_bci; 862 int _profiled_bci;
911 public: 863 public:
912 // creation 864 // creation
913 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* lock_stack) 865 StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before)
914 : AccessIndexed(array, index, length, elt_type, lock_stack) 866 : AccessIndexed(array, index, length, elt_type, state_before)
915 , _value(value), _profiled_method(NULL), _profiled_bci(0) 867 , _value(value), _profiled_method(NULL), _profiled_bci(0)
916 { 868 {
917 set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object())); 869 set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
918 set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object())); 870 set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
919 ASSERT_VALUES 871 ASSERT_VALUES
920 pin(); 872 pin();
921 } 873 }
922 874
923 // accessors 875 // accessors
924 Value value() const { return _value; } 876 Value value() const { return _value; }
925 IRScope* scope() const; // the state's scope
926 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); } 877 bool needs_write_barrier() const { return check_flag(NeedsWriteBarrierFlag); }
927 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); } 878 bool needs_store_check() const { return check_flag(NeedsStoreCheckFlag); }
928 // Helpers for methodDataOop profiling 879 // Helpers for methodDataOop profiling
929 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } 880 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
930 void set_profiled_method(ciMethod* method) { _profiled_method = method; } 881 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
961 Value _x; 912 Value _x;
962 Value _y; 913 Value _y;
963 914
964 public: 915 public:
965 // creation 916 // creation
966 Op2(ValueType* type, Bytecodes::Code op, Value x, Value y) : Instruction(type), _op(op), _x(x), _y(y) { 917 Op2(ValueType* type, Bytecodes::Code op, Value x, Value y, ValueStack* state_before = NULL)
918 : Instruction(type, state_before)
919 , _op(op)
920 , _x(x)
921 , _y(y)
922 {
967 ASSERT_VALUES 923 ASSERT_VALUES
968 } 924 }
969 925
970 // accessors 926 // accessors
971 Bytecodes::Code op() const { return _op; } 927 Bytecodes::Code op() const { return _op; }
983 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); } 939 virtual void input_values_do(ValueVisitor* f) { f->visit(&_x); f->visit(&_y); }
984 }; 940 };
985 941
986 942
987 LEAF(ArithmeticOp, Op2) 943 LEAF(ArithmeticOp, Op2)
988 private: 944 public:
989 ValueStack* _lock_stack; // used only for division operations 945 // creation
990 public: 946 ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* state_before)
991 // creation 947 : Op2(x->type()->meet(y->type()), op, x, y, state_before)
992 ArithmeticOp(Bytecodes::Code op, Value x, Value y, bool is_strictfp, ValueStack* lock_stack) 948 {
993 : Op2(x->type()->meet(y->type()), op, x, y)
994 , _lock_stack(lock_stack) {
995 set_flag(IsStrictfpFlag, is_strictfp); 949 set_flag(IsStrictfpFlag, is_strictfp);
996 if (can_trap()) pin(); 950 if (can_trap()) pin();
997 } 951 }
998 952
999 // accessors 953 // accessors
1000 ValueStack* lock_stack() const { return _lock_stack; }
1001 bool is_strictfp() const { return check_flag(IsStrictfpFlag); } 954 bool is_strictfp() const { return check_flag(IsStrictfpFlag); }
1002
1003 // setters
1004 void set_lock_stack(ValueStack* l) { _lock_stack = l; }
1005 955
1006 // generic 956 // generic
1007 virtual bool is_commutative() const; 957 virtual bool is_commutative() const;
1008 virtual bool can_trap() const; 958 virtual bool can_trap() const;
1009 virtual void other_values_do(ValueVisitor* f);
1010 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) 959 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1011 }; 960 };
1012 961
1013 962
1014 LEAF(ShiftOp, Op2) 963 LEAF(ShiftOp, Op2)
1031 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) 980 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1032 }; 981 };
1033 982
1034 983
1035 LEAF(CompareOp, Op2) 984 LEAF(CompareOp, Op2)
1036 private:
1037 ValueStack* _state_before; // for deoptimization, when canonicalizing
1038 public: 985 public:
1039 // creation 986 // creation
1040 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before) 987 CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1041 : Op2(intType, op, x, y) 988 : Op2(intType, op, x, y, state_before)
1042 , _state_before(state_before)
1043 {} 989 {}
1044 990
1045 // accessors
1046 ValueStack* state_before() const { return _state_before; }
1047
1048 // generic 991 // generic
1049 HASHING3(Op2, true, op(), x()->subst(), y()->subst()) 992 HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1050 virtual void other_values_do(ValueVisitor* f);
1051 }; 993 };
1052 994
1053 995
1054 LEAF(IfOp, Op2) 996 LEAF(IfOp, Op2)
1055 private: 997 private:
1101 1043
1102 1044
1103 LEAF(NullCheck, Instruction) 1045 LEAF(NullCheck, Instruction)
1104 private: 1046 private:
1105 Value _obj; 1047 Value _obj;
1106 ValueStack* _lock_stack; 1048
1107 1049 public:
1108 public: 1050 // creation
1109 // creation 1051 NullCheck(Value obj, ValueStack* state_before)
1110 NullCheck(Value obj, ValueStack* lock_stack) : Instruction(obj->type()->base()), _obj(obj), _lock_stack(lock_stack) { 1052 : Instruction(obj->type()->base(), state_before)
1053 , _obj(obj)
1054 {
1111 ASSERT_VALUES 1055 ASSERT_VALUES
1112 set_can_trap(true); 1056 set_can_trap(true);
1113 assert(_obj->type()->is_object(), "null check must be applied to objects only"); 1057 assert(_obj->type()->is_object(), "null check must be applied to objects only");
1114 pin(Instruction::PinExplicitNullCheck); 1058 pin(Instruction::PinExplicitNullCheck);
1115 } 1059 }
1116 1060
1117 // accessors 1061 // accessors
1118 Value obj() const { return _obj; } 1062 Value obj() const { return _obj; }
1119 ValueStack* lock_stack() const { return _lock_stack; }
1120 1063
1121 // setters 1064 // setters
1122 void set_lock_stack(ValueStack* l) { _lock_stack = l; }
1123 void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); } 1065 void set_can_trap(bool can_trap) { set_flag(CanTrapFlag, can_trap); }
1124 1066
1125 // generic 1067 // generic
1126 virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ } 1068 virtual bool can_trap() const { return check_flag(CanTrapFlag); /* null-check elimination sets to false */ }
1127 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); } 1069 virtual void input_values_do(ValueVisitor* f) { f->visit(&_obj); }
1128 virtual void other_values_do(ValueVisitor* f);
1129 HASHING1(NullCheck, true, obj()->subst()) 1070 HASHING1(NullCheck, true, obj()->subst())
1130 }; 1071 };
1131 1072
1132 1073
1133 BASE(StateSplit, Instruction) 1074 BASE(StateSplit, Instruction)
1137 protected: 1078 protected:
1138 static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block); 1079 static void substitute(BlockList& list, BlockBegin* old_block, BlockBegin* new_block);
1139 1080
1140 public: 1081 public:
1141 // creation 1082 // creation
1142 StateSplit(ValueType* type) : Instruction(type), _state(NULL) { 1083 StateSplit(ValueType* type, ValueStack* state_before = NULL)
1084 : Instruction(type, state_before)
1085 , _state(NULL)
1086 {
1143 pin(PinStateSplitConstructor); 1087 pin(PinStateSplitConstructor);
1144 } 1088 }
1145 1089
1146 // accessors 1090 // accessors
1147 ValueStack* state() const { return _state; } 1091 ValueStack* state() const { return _state; }
1148 IRScope* scope() const; // the state's scope 1092 IRScope* scope() const; // the state's scope
1149 1093
1150 // manipulation 1094 // manipulation
1151 void set_state(ValueStack* state) { _state = state; } 1095 void set_state(ValueStack* state) { assert(_state == NULL, "overwriting existing state"); check_state(state); _state = state; }
1152 1096
1153 // generic 1097 // generic
1154 virtual void input_values_do(ValueVisitor* f) { /* no values */ } 1098 virtual void input_values_do(ValueVisitor* f) { /* no values */ }
1155 virtual void state_values_do(ValueVisitor* f); 1099 virtual void state_values_do(ValueVisitor* f);
1156 }; 1100 };
1162 Value _recv; 1106 Value _recv;
1163 Values* _args; 1107 Values* _args;
1164 BasicTypeList* _signature; 1108 BasicTypeList* _signature;
1165 int _vtable_index; 1109 int _vtable_index;
1166 ciMethod* _target; 1110 ciMethod* _target;
1167 ValueStack* _state_before; // Required for deoptimization.
1168 1111
1169 public: 1112 public:
1170 // creation 1113 // creation
1171 Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args, 1114 Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
1172 int vtable_index, ciMethod* target, ValueStack* state_before); 1115 int vtable_index, ciMethod* target, ValueStack* state_before);
1178 int number_of_arguments() const { return _args->length(); } 1121 int number_of_arguments() const { return _args->length(); }
1179 Value argument_at(int i) const { return _args->at(i); } 1122 Value argument_at(int i) const { return _args->at(i); }
1180 int vtable_index() const { return _vtable_index; } 1123 int vtable_index() const { return _vtable_index; }
1181 BasicTypeList* signature() const { return _signature; } 1124 BasicTypeList* signature() const { return _signature; }
1182 ciMethod* target() const { return _target; } 1125 ciMethod* target() const { return _target; }
1183 ValueStack* state_before() const { return _state_before; }
1184 1126
1185 // Returns false if target is not loaded 1127 // Returns false if target is not loaded
1186 bool target_is_final() const { return check_flag(TargetIsFinalFlag); } 1128 bool target_is_final() const { return check_flag(TargetIsFinalFlag); }
1187 bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); } 1129 bool target_is_loaded() const { return check_flag(TargetIsLoadedFlag); }
1188 // Returns false if target is not loaded 1130 // Returns false if target is not loaded
1189 bool target_is_strictfp() const { return check_flag(TargetIsStrictfpFlag); } 1131 bool target_is_strictfp() const { return check_flag(TargetIsStrictfpFlag); }
1190 1132
1191 // JSR 292 support 1133 // JSR 292 support
1192 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; } 1134 bool is_invokedynamic() const { return code() == Bytecodes::_invokedynamic; }
1193 1135
1136 virtual bool needs_exception_state() const { return false; }
1137
1194 // generic 1138 // generic
1195 virtual bool can_trap() const { return true; } 1139 virtual bool can_trap() const { return true; }
1196 virtual void input_values_do(ValueVisitor* f) { 1140 virtual void input_values_do(ValueVisitor* f) {
1197 StateSplit::input_values_do(f); 1141 StateSplit::input_values_do(f);
1198 if (has_receiver()) f->visit(&_recv); 1142 if (has_receiver()) f->visit(&_recv);
1206 private: 1150 private:
1207 ciInstanceKlass* _klass; 1151 ciInstanceKlass* _klass;
1208 1152
1209 public: 1153 public:
1210 // creation 1154 // creation
1211 NewInstance(ciInstanceKlass* klass) : StateSplit(instanceType), _klass(klass) {} 1155 NewInstance(ciInstanceKlass* klass, ValueStack* state_before)
1156 : StateSplit(instanceType, state_before)
1157 , _klass(klass)
1158 {}
1212 1159
1213 // accessors 1160 // accessors
1214 ciInstanceKlass* klass() const { return _klass; } 1161 ciInstanceKlass* klass() const { return _klass; }
1162
1163 virtual bool needs_exception_state() const { return false; }
1215 1164
1216 // generic 1165 // generic
1217 virtual bool can_trap() const { return true; } 1166 virtual bool can_trap() const { return true; }
1218 ciType* exact_type() const; 1167 ciType* exact_type() const;
1219 }; 1168 };
1220 1169
1221 1170
1222 BASE(NewArray, StateSplit) 1171 BASE(NewArray, StateSplit)
1223 private: 1172 private:
1224 Value _length; 1173 Value _length;
1225 ValueStack* _state_before; 1174
1226 1175 public:
1227 public: 1176 // creation
1228 // creation 1177 NewArray(Value length, ValueStack* state_before)
1229 NewArray(Value length, ValueStack* state_before) : StateSplit(objectType), _length(length), _state_before(state_before) { 1178 : StateSplit(objectType, state_before)
1179 , _length(length)
1180 {
1230 // Do not ASSERT_VALUES since length is NULL for NewMultiArray 1181 // Do not ASSERT_VALUES since length is NULL for NewMultiArray
1231 } 1182 }
1232 1183
1233 // accessors 1184 // accessors
1234 ValueStack* state_before() const { return _state_before; }
1235 Value length() const { return _length; } 1185 Value length() const { return _length; }
1186
1187 virtual bool needs_exception_state() const { return false; }
1236 1188
1237 // generic 1189 // generic
1238 virtual bool can_trap() const { return true; } 1190 virtual bool can_trap() const { return true; }
1239 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); } 1191 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_length); }
1240 virtual void other_values_do(ValueVisitor* f);
1241 }; 1192 };
1242 1193
1243 1194
1244 LEAF(NewTypeArray, NewArray) 1195 LEAF(NewTypeArray, NewArray)
1245 private: 1196 private:
1246 BasicType _elt_type; 1197 BasicType _elt_type;
1247 1198
1248 public: 1199 public:
1249 // creation 1200 // creation
1250 NewTypeArray(Value length, BasicType elt_type) : NewArray(length, NULL), _elt_type(elt_type) {} 1201 NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before)
1202 : NewArray(length, state_before)
1203 , _elt_type(elt_type)
1204 {}
1251 1205
1252 // accessors 1206 // accessors
1253 BasicType elt_type() const { return _elt_type; } 1207 BasicType elt_type() const { return _elt_type; }
1254 ciType* exact_type() const; 1208 ciType* exact_type() const;
1255 }; 1209 };
1301 1255
1302 BASE(TypeCheck, StateSplit) 1256 BASE(TypeCheck, StateSplit)
1303 private: 1257 private:
1304 ciKlass* _klass; 1258 ciKlass* _klass;
1305 Value _obj; 1259 Value _obj;
1306 ValueStack* _state_before;
1307 1260
1308 ciMethod* _profiled_method; 1261 ciMethod* _profiled_method;
1309 int _profiled_bci; 1262 int _profiled_bci;
1310 1263
1311 public: 1264 public:
1312 // creation 1265 // creation
1313 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before) 1266 TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1314 : StateSplit(type), _klass(klass), _obj(obj), _state_before(state_before), 1267 : StateSplit(type, state_before), _klass(klass), _obj(obj),
1315 _profiled_method(NULL), _profiled_bci(0) { 1268 _profiled_method(NULL), _profiled_bci(0) {
1316 ASSERT_VALUES 1269 ASSERT_VALUES
1317 set_direct_compare(false); 1270 set_direct_compare(false);
1318 } 1271 }
1319 1272
1320 // accessors 1273 // accessors
1321 ValueStack* state_before() const { return _state_before; }
1322 ciKlass* klass() const { return _klass; } 1274 ciKlass* klass() const { return _klass; }
1323 Value obj() const { return _obj; } 1275 Value obj() const { return _obj; }
1324 bool is_loaded() const { return klass() != NULL; } 1276 bool is_loaded() const { return klass() != NULL; }
1325 bool direct_compare() const { return check_flag(DirectCompareFlag); } 1277 bool direct_compare() const { return check_flag(DirectCompareFlag); }
1326 1278
1328 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); } 1280 void set_direct_compare(bool flag) { set_flag(DirectCompareFlag, flag); }
1329 1281
1330 // generic 1282 // generic
1331 virtual bool can_trap() const { return true; } 1283 virtual bool can_trap() const { return true; }
1332 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } 1284 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1333 virtual void other_values_do(ValueVisitor* f);
1334 1285
1335 // Helpers for methodDataOop profiling 1286 // Helpers for methodDataOop profiling
1336 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); } 1287 void set_should_profile(bool value) { set_flag(ProfileMDOFlag, value); }
1337 void set_profiled_method(ciMethod* method) { _profiled_method = method; } 1288 void set_profiled_method(ciMethod* method) { _profiled_method = method; }
1338 void set_profiled_bci(int bci) { _profiled_bci = bci; } 1289 void set_profiled_bci(int bci) { _profiled_bci = bci; }
1362 1313
1363 LEAF(InstanceOf, TypeCheck) 1314 LEAF(InstanceOf, TypeCheck)
1364 public: 1315 public:
1365 // creation 1316 // creation
1366 InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {} 1317 InstanceOf(ciKlass* klass, Value obj, ValueStack* state_before) : TypeCheck(klass, obj, intType, state_before) {}
1318
1319 virtual bool needs_exception_state() const { return false; }
1367 }; 1320 };
1368 1321
1369 1322
1370 BASE(AccessMonitor, StateSplit) 1323 BASE(AccessMonitor, StateSplit)
1371 private: 1324 private:
1372 Value _obj; 1325 Value _obj;
1373 int _monitor_no; 1326 int _monitor_no;
1374 1327
1375 public: 1328 public:
1376 // creation 1329 // creation
1377 AccessMonitor(Value obj, int monitor_no) 1330 AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = NULL)
1378 : StateSplit(illegalType) 1331 : StateSplit(illegalType, state_before)
1379 , _obj(obj) 1332 , _obj(obj)
1380 , _monitor_no(monitor_no) 1333 , _monitor_no(monitor_no)
1381 { 1334 {
1382 set_needs_null_check(true); 1335 set_needs_null_check(true);
1383 ASSERT_VALUES 1336 ASSERT_VALUES
1391 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); } 1344 virtual void input_values_do(ValueVisitor* f) { StateSplit::input_values_do(f); f->visit(&_obj); }
1392 }; 1345 };
1393 1346
1394 1347
1395 LEAF(MonitorEnter, AccessMonitor) 1348 LEAF(MonitorEnter, AccessMonitor)
1396 private: 1349 public:
1397 ValueStack* _lock_stack_before; 1350 // creation
1398 1351 MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1399 public: 1352 : AccessMonitor(obj, monitor_no, state_before)
1400 // creation 1353 {
1401 MonitorEnter(Value obj, int monitor_no, ValueStack* lock_stack_before) 1354 ASSERT_VALUES
1402 : AccessMonitor(obj, monitor_no) 1355 }
1403 , _lock_stack_before(lock_stack_before)
1404 {
1405 ASSERT_VALUES
1406 }
1407
1408 // accessors
1409 ValueStack* lock_stack_before() const { return _lock_stack_before; }
1410 virtual void state_values_do(ValueVisitor* f);
1411 1356
1412 // generic 1357 // generic
1413 virtual bool can_trap() const { return true; } 1358 virtual bool can_trap() const { return true; }
1414 }; 1359 };
1415 1360
1416 1361
1417 LEAF(MonitorExit, AccessMonitor) 1362 LEAF(MonitorExit, AccessMonitor)
1418 public: 1363 public:
1419 // creation 1364 // creation
1420 MonitorExit(Value obj, int monitor_no) : AccessMonitor(obj, monitor_no) {} 1365 MonitorExit(Value obj, int monitor_no)
1366 : AccessMonitor(obj, monitor_no, NULL)
1367 {
1368 ASSERT_VALUES
1369 }
1421 }; 1370 };
1422 1371
1423 1372
1424 LEAF(Intrinsic, StateSplit) 1373 LEAF(Intrinsic, StateSplit)
1425 private: 1374 private:
1426 vmIntrinsics::ID _id; 1375 vmIntrinsics::ID _id;
1427 Values* _args; 1376 Values* _args;
1428 ValueStack* _lock_stack;
1429 Value _recv; 1377 Value _recv;
1430 1378
1431 public: 1379 public:
1432 // preserves_state can be set to true for Intrinsics 1380 // preserves_state can be set to true for Intrinsics
1433 // which are guaranteed to preserve register state across any slow 1381 // which are guaranteed to preserve register state across any slow
1438 // performed across the Intrinsic. The default value is false. 1386 // performed across the Intrinsic. The default value is false.
1439 Intrinsic(ValueType* type, 1387 Intrinsic(ValueType* type,
1440 vmIntrinsics::ID id, 1388 vmIntrinsics::ID id,
1441 Values* args, 1389 Values* args,
1442 bool has_receiver, 1390 bool has_receiver,
1443 ValueStack* lock_stack, 1391 ValueStack* state_before,
1444 bool preserves_state, 1392 bool preserves_state,
1445 bool cantrap = true) 1393 bool cantrap = true)
1446 : StateSplit(type) 1394 : StateSplit(type, state_before)
1447 , _id(id) 1395 , _id(id)
1448 , _args(args) 1396 , _args(args)
1449 , _lock_stack(lock_stack)
1450 , _recv(NULL) 1397 , _recv(NULL)
1451 { 1398 {
1452 assert(args != NULL, "args must exist"); 1399 assert(args != NULL, "args must exist");
1453 ASSERT_VALUES 1400 ASSERT_VALUES
1454 set_flag(PreservesStateFlag, preserves_state); 1401 set_flag(PreservesStateFlag, preserves_state);
1466 1413
1467 // accessors 1414 // accessors
1468 vmIntrinsics::ID id() const { return _id; } 1415 vmIntrinsics::ID id() const { return _id; }
1469 int number_of_arguments() const { return _args->length(); } 1416 int number_of_arguments() const { return _args->length(); }
1470 Value argument_at(int i) const { return _args->at(i); } 1417 Value argument_at(int i) const { return _args->at(i); }
1471 ValueStack* lock_stack() const { return _lock_stack; }
1472 1418
1473 bool has_receiver() const { return (_recv != NULL); } 1419 bool has_receiver() const { return (_recv != NULL); }
1474 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; } 1420 Value receiver() const { assert(has_receiver(), "must have receiver"); return _recv; }
1475 bool preserves_state() const { return check_flag(PreservesStateFlag); } 1421 bool preserves_state() const { return check_flag(PreservesStateFlag); }
1476 1422
1478 virtual bool can_trap() const { return check_flag(CanTrapFlag); } 1424 virtual bool can_trap() const { return check_flag(CanTrapFlag); }
1479 virtual void input_values_do(ValueVisitor* f) { 1425 virtual void input_values_do(ValueVisitor* f) {
1480 StateSplit::input_values_do(f); 1426 StateSplit::input_values_do(f);
1481 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i)); 1427 for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1482 } 1428 }
1483 virtual void state_values_do(ValueVisitor* f);
1484
1485 }; 1429 };
1486 1430
1487 1431
1488 class LIR_List; 1432 class LIR_List;
1489 1433
1490 LEAF(BlockBegin, StateSplit) 1434 LEAF(BlockBegin, StateSplit)
1491 private: 1435 private:
1492 int _block_id; // the unique block id 1436 int _block_id; // the unique block id
1437 int _bci; // start-bci of block
1493 int _depth_first_number; // number of this block in a depth-first ordering 1438 int _depth_first_number; // number of this block in a depth-first ordering
1494 int _linear_scan_number; // number of this block in linear-scan ordering 1439 int _linear_scan_number; // number of this block in linear-scan ordering
1495 int _loop_depth; // the loop nesting level of this block 1440 int _loop_depth; // the loop nesting level of this block
1496 int _loop_index; // number of the innermost loop of this block 1441 int _loop_index; // number of the innermost loop of this block
1497 int _flags; // the flags associated with this block 1442 int _flags; // the flags associated with this block
1544 } 1489 }
1545 1490
1546 // creation 1491 // creation
1547 BlockBegin(int bci) 1492 BlockBegin(int bci)
1548 : StateSplit(illegalType) 1493 : StateSplit(illegalType)
1494 , _bci(bci)
1549 , _depth_first_number(-1) 1495 , _depth_first_number(-1)
1550 , _linear_scan_number(-1) 1496 , _linear_scan_number(-1)
1551 , _loop_depth(0) 1497 , _loop_depth(0)
1552 , _flags(0) 1498 , _flags(0)
1553 , _dominator(NULL) 1499 , _dominator(NULL)
1568 , _first_lir_instruction_id(-1) 1514 , _first_lir_instruction_id(-1)
1569 , _last_lir_instruction_id(-1) 1515 , _last_lir_instruction_id(-1)
1570 , _total_preds(0) 1516 , _total_preds(0)
1571 , _stores_to_locals() 1517 , _stores_to_locals()
1572 { 1518 {
1573 set_bci(bci); 1519 #ifndef PRODUCT
1520 set_printable_bci(bci);
1521 #endif
1574 } 1522 }
1575 1523
1576 // accessors 1524 // accessors
1577 int block_id() const { return _block_id; } 1525 int block_id() const { return _block_id; }
1526 int bci() const { return _bci; }
1578 BlockList* successors() { return &_successors; } 1527 BlockList* successors() { return &_successors; }
1579 BlockBegin* dominator() const { return _dominator; } 1528 BlockBegin* dominator() const { return _dominator; }
1580 int loop_depth() const { return _loop_depth; } 1529 int loop_depth() const { return _loop_depth; }
1581 int depth_first_number() const { return _depth_first_number; } 1530 int depth_first_number() const { return _depth_first_number; }
1582 int linear_scan_number() const { return _linear_scan_number; } 1531 int linear_scan_number() const { return _linear_scan_number; }
1594 int last_lir_instruction_id() const { return _last_lir_instruction_id; } 1543 int last_lir_instruction_id() const { return _last_lir_instruction_id; }
1595 int total_preds() const { return _total_preds; } 1544 int total_preds() const { return _total_preds; }
1596 BitMap& stores_to_locals() { return _stores_to_locals; } 1545 BitMap& stores_to_locals() { return _stores_to_locals; }
1597 1546
1598 // manipulation 1547 // manipulation
1599 void set_bci(int bci) { Instruction::set_bci(bci); }
1600 void set_dominator(BlockBegin* dom) { _dominator = dom; } 1548 void set_dominator(BlockBegin* dom) { _dominator = dom; }
1601 void set_loop_depth(int d) { _loop_depth = d; } 1549 void set_loop_depth(int d) { _loop_depth = d; }
1602 void set_depth_first_number(int dfn) { _depth_first_number = dfn; } 1550 void set_depth_first_number(int dfn) { _depth_first_number = dfn; }
1603 void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; } 1551 void set_linear_scan_number(int lsn) { _linear_scan_number = lsn; }
1604 void set_end(BlockEnd* end); 1552 void set_end(BlockEnd* end);
1692 1640
1693 BASE(BlockEnd, StateSplit) 1641 BASE(BlockEnd, StateSplit)
1694 private: 1642 private:
1695 BlockBegin* _begin; 1643 BlockBegin* _begin;
1696 BlockList* _sux; 1644 BlockList* _sux;
1697 ValueStack* _state_before;
1698 1645
1699 protected: 1646 protected:
1700 BlockList* sux() const { return _sux; } 1647 BlockList* sux() const { return _sux; }
1701 1648
1702 void set_sux(BlockList* sux) { 1649 void set_sux(BlockList* sux) {
1708 } 1655 }
1709 1656
1710 public: 1657 public:
1711 // creation 1658 // creation
1712 BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint) 1659 BlockEnd(ValueType* type, ValueStack* state_before, bool is_safepoint)
1713 : StateSplit(type) 1660 : StateSplit(type, state_before)
1714 , _begin(NULL) 1661 , _begin(NULL)
1715 , _sux(NULL) 1662 , _sux(NULL)
1716 , _state_before(state_before) { 1663 {
1717 set_flag(IsSafepointFlag, is_safepoint); 1664 set_flag(IsSafepointFlag, is_safepoint);
1718 } 1665 }
1719 1666
1720 // accessors 1667 // accessors
1721 ValueStack* state_before() const { return _state_before; }
1722 bool is_safepoint() const { return check_flag(IsSafepointFlag); } 1668 bool is_safepoint() const { return check_flag(IsSafepointFlag); }
1723 BlockBegin* begin() const { return _begin; } 1669 BlockBegin* begin() const { return _begin; }
1724 1670
1725 // manipulation 1671 // manipulation
1726 void set_begin(BlockBegin* begin); 1672 void set_begin(BlockBegin* begin);
1727
1728 // generic
1729 virtual void other_values_do(ValueVisitor* f);
1730 1673
1731 // successors 1674 // successors
1732 int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; } 1675 int number_of_sux() const { return _sux != NULL ? _sux->length() : 0; }
1733 BlockBegin* sux_at(int i) const { return _sux->at(i); } 1676 BlockBegin* sux_at(int i) const { return _sux->at(i); }
1734 BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); } 1677 BlockBegin* default_sux() const { return sux_at(number_of_sux() - 1); }
1917 1860
1918 // accessors 1861 // accessors
1919 Value tag() const { return _tag; } 1862 Value tag() const { return _tag; }
1920 int length() const { return number_of_sux() - 1; } 1863 int length() const { return number_of_sux() - 1; }
1921 1864
1865 virtual bool needs_exception_state() const { return false; }
1866
1922 // generic 1867 // generic
1923 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_tag); } 1868 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_tag); }
1924 }; 1869 };
1925 1870
1926 1871
1994 Value exception() const { return _exception; } 1939 Value exception() const { return _exception; }
1995 1940
1996 // generic 1941 // generic
1997 virtual bool can_trap() const { return true; } 1942 virtual bool can_trap() const { return true; }
1998 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_exception); } 1943 virtual void input_values_do(ValueVisitor* f) { BlockEnd::input_values_do(f); f->visit(&_exception); }
1999 virtual void state_values_do(ValueVisitor* f);
2000 }; 1944 };
2001 1945
2002 1946
2003 LEAF(Base, BlockEnd) 1947 LEAF(Base, BlockEnd)
2004 public: 1948 public:
2089 // accessors 2033 // accessors
2090 BasicType basic_type() { return _basic_type; } 2034 BasicType basic_type() { return _basic_type; }
2091 2035
2092 // generic 2036 // generic
2093 virtual void input_values_do(ValueVisitor* f) { } 2037 virtual void input_values_do(ValueVisitor* f) { }
2094 virtual void other_values_do(ValueVisitor* f) { }
2095 }; 2038 };
2096 2039
2097 2040
2098 BASE(UnsafeRawOp, UnsafeOp) 2041 BASE(UnsafeRawOp, UnsafeOp)
2099 private: 2042 private: