< prev index next >

src/hotspot/share/c1/c1_ValueStack.hpp

Print this page

 37     // Exception states for an instruction.
 38     // Dead stack items or locals may be invalidated or cleared/removed.
 39     // Locals are retained if needed for JVMTI.
 40     // "empty" exception states are used when there is no handler,
 41     // and invalidate the locals.
 42     // "leaf" exception states clear the stack.
 43     // "caller" exception states are used for the parent/caller,
 44     // and invalidate the stack.
 45     ExceptionState,      // Exception state for leaf with handler, stack cleared
 46     EmptyExceptionState, // Exception state for leaf w/o handler, stack cleared, locals invalidated
 47     CallerExceptionState, // Exception state for parent with handler, stack invalidated
 48     CallerEmptyExceptionState, // Exception state for parent w/o handler, stack+locals invalidated
 49     BlockBeginState      // State of BlockBegin instruction with phi functions of this block
 50   };
 51 
 52  private:
 53   IRScope* _scope;                               // the enclosing scope
 54   ValueStack* _caller_state;
 55   int      _bci;
 56   Kind     _kind;

 57 
 58   Values   _locals;                              // the locals
 59   Values   _stack;                               // the expression stack
 60   Values*  _locks;                               // the monitor stack (holding the locked values)
 61   bool     _force_reexecute;                     // force the reexecute flag on, used for patching stub
 62 
 63   Value check(ValueTag tag, Value t) {
 64     assert(tag == t->type()->tag() || (tag == objectTag && t->type()->tag() == addressTag), "types must correspond");
 65     return t;
 66   }
 67 
 68   Value check(ValueTag tag, Value t, Value h) {
 69     assert(h == nullptr, "hi-word of doubleword value must be null");
 70     return check(tag, t);
 71   }
 72 
 73   // helper routine
 74   static void apply(const Values& list, ValueVisitor* f);
 75 
 76   // for simplified copying
 77   ValueStack(ValueStack* copy_from, Kind kind, int bci);
 78 
 79   int locals_size_for_copy(Kind kind) const;
 80   int stack_size_for_copy(Kind kind) const;
 81  public:
 82   // creation
 83   ValueStack(IRScope* scope, ValueStack* caller_state);
 84 
 85   ValueStack* copy()                             { return new ValueStack(this, _kind, _bci); }
 86   ValueStack* copy(Kind new_kind, int new_bci)   { return new ValueStack(this, new_kind, new_bci); }
 87   ValueStack* copy_for_parsing()                 { return new ValueStack(this, Parsing, -99); }
 88 
 89   // Used when no exception handler is found
 90   static Kind empty_exception_kind(bool caller = false) {
 91     return Compilation::current()->env()->should_retain_local_variables() ?
 92       (caller ? CallerExceptionState : ExceptionState) : // retain locals
 93       (caller ? CallerEmptyExceptionState : EmptyExceptionState);   // clear locals
 94   }
 95 
 96   void set_caller_state(ValueStack* s)           {
 97     assert(kind() == empty_exception_kind(false) || kind() == empty_exception_kind(true),
 98            "only empty exception states can be modified");
 99     _caller_state = s;
100   }
101 
102   bool is_same(ValueStack* s);                   // returns true if this & s's types match (w/o checking locals)
103 
104   // accessors
105   IRScope* scope() const                         { return _scope; }
106   ValueStack* caller_state() const               { return _caller_state; }
107   int bci() const                                { return _bci; }
108   Kind kind() const                              { return _kind; }


109 
110   int locals_size() const                        { return _locals.length(); }
111   int stack_size() const                         { return _stack.length(); }
112   int locks_size() const                         { return _locks == nullptr ? 0 : _locks->length(); }
113   bool stack_is_empty() const                    { return _stack.is_empty(); }
114   bool no_active_locks() const                   { return _locks == nullptr || _locks->is_empty(); }
115   int total_locks_size() const;
116 
117   // locals access
118   void clear_locals();                           // sets all locals to null;
119 
120   void invalidate_local(int i) {
121     assert(!_locals.at(i)->type()->is_double_word() ||
122            _locals.at(i + 1) == nullptr, "hi-word of doubleword value must be null");
123     _locals.at_put(i, nullptr);
124   }
125 
126   Value local_at(int i) const {
127     Value x = _locals.at(i);
128     assert(x == nullptr || !x->type()->is_double_word() ||

 37     // Exception states for an instruction.
 38     // Dead stack items or locals may be invalidated or cleared/removed.
 39     // Locals are retained if needed for JVMTI.
 40     // "empty" exception states are used when there is no handler,
 41     // and invalidate the locals.
 42     // "leaf" exception states clear the stack.
 43     // "caller" exception states are used for the parent/caller,
 44     // and invalidate the stack.
 45     ExceptionState,      // Exception state for leaf with handler, stack cleared
 46     EmptyExceptionState, // Exception state for leaf w/o handler, stack cleared, locals invalidated
 47     CallerExceptionState, // Exception state for parent with handler, stack invalidated
 48     CallerEmptyExceptionState, // Exception state for parent w/o handler, stack+locals invalidated
 49     BlockBeginState      // State of BlockBegin instruction with phi functions of this block
 50   };
 51 
 52  private:
 53   IRScope* _scope;                               // the enclosing scope
 54   ValueStack* _caller_state;
 55   int      _bci;
 56   Kind     _kind;
 57   bool     _should_reexecute;
 58 
 59   Values   _locals;                              // the locals
 60   Values   _stack;                               // the expression stack
 61   Values*  _locks;                               // the monitor stack (holding the locked values)
 62   bool     _force_reexecute;                     // force the reexecute flag on, used for patching stub
 63 
 64   Value check(ValueTag tag, Value t) {
 65     assert(tag == t->type()->tag() || (tag == objectTag && t->type()->tag() == addressTag), "types must correspond");
 66     return t;
 67   }
 68 
 69   Value check(ValueTag tag, Value t, Value h) {
 70     assert(h == nullptr, "hi-word of doubleword value must be null");
 71     return check(tag, t);
 72   }
 73 
 74   // helper routine
 75   static void apply(const Values& list, ValueVisitor* f);
 76 
 77   // for simplified copying
 78   ValueStack(ValueStack* copy_from, Kind kind, int bci, bool reexecute);
 79 
 80   int locals_size_for_copy(Kind kind) const;
 81   int stack_size_for_copy(Kind kind) const;
 82  public:
 83   // creation
 84   ValueStack(IRScope* scope, ValueStack* caller_state);
 85 
 86   ValueStack* copy()                             { return new ValueStack(this, _kind, _bci, _should_reexecute); }
 87   ValueStack* copy(Kind new_kind, int new_bci)   { return new ValueStack(this, new_kind, new_bci, _should_reexecute); }
 88   ValueStack* copy_for_parsing()                 { return new ValueStack(this, Parsing, -99, false); }
 89 
 90   // Used when no exception handler is found
 91   static Kind empty_exception_kind(bool caller = false) {
 92     return Compilation::current()->env()->should_retain_local_variables() ?
 93       (caller ? CallerExceptionState : ExceptionState) : // retain locals
 94       (caller ? CallerEmptyExceptionState : EmptyExceptionState);   // clear locals
 95   }
 96 
 97   void set_caller_state(ValueStack* s)           {
 98     assert(kind() == empty_exception_kind(false) || kind() == empty_exception_kind(true),
 99            "only empty exception states can be modified");
100     _caller_state = s;
101   }
102 
103   bool is_same(ValueStack* s);                   // returns true if this & s's types match (w/o checking locals)
104 
105   // accessors
106   IRScope* scope() const                         { return _scope; }
107   ValueStack* caller_state() const               { return _caller_state; }
108   int bci() const                                { return _bci; }
109   Kind kind() const                              { return _kind; }
110   bool should_reexecute() const                  { return _should_reexecute; }
111   void set_should_reexecute(bool reexec)         { _should_reexecute = reexec; }
112 
113   int locals_size() const                        { return _locals.length(); }
114   int stack_size() const                         { return _stack.length(); }
115   int locks_size() const                         { return _locks == nullptr ? 0 : _locks->length(); }
116   bool stack_is_empty() const                    { return _stack.is_empty(); }
117   bool no_active_locks() const                   { return _locks == nullptr || _locks->is_empty(); }
118   int total_locks_size() const;
119 
120   // locals access
121   void clear_locals();                           // sets all locals to null;
122 
123   void invalidate_local(int i) {
124     assert(!_locals.at(i)->type()->is_double_word() ||
125            _locals.at(i + 1) == nullptr, "hi-word of doubleword value must be null");
126     _locals.at_put(i, nullptr);
127   }
128 
129   Value local_at(int i) const {
130     Value x = _locals.at(i);
131     assert(x == nullptr || !x->type()->is_double_word() ||
< prev index next >