< prev index next >

src/hotspot/share/c1/c1_ValueStack.hpp

Print this page

 27 
 28 #include "c1/c1_Instruction.hpp"
 29 
 30 class ValueStack: public CompilationResourceObj {
 31  public:
 32   enum Kind {
 33     Parsing,             // During abstract interpretation in GraphBuilder
 34     CallerState,         // Caller state when inlining
 35     StateBefore,         // Before before execution of instruction
 36     StateAfter,          // After execution of instruction
 37     ExceptionState,      // Exception handling of instruction
 38     EmptyExceptionState, // Exception handling of instructions not covered by an xhandler
 39     BlockBeginState      // State of BlockBegin instruction with phi functions of this block
 40   };
 41 
 42  private:
 43   IRScope* _scope;                               // the enclosing scope
 44   ValueStack* _caller_state;
 45   int      _bci;
 46   Kind     _kind;

 47 
 48   Values   _locals;                              // the locals
 49   Values   _stack;                               // the expression stack
 50   Values*  _locks;                               // the monitor stack (holding the locked values)
 51 
 52   Value check(ValueTag tag, Value t) {
 53     assert(tag == t->type()->tag() || tag == objectTag && t->type()->tag() == addressTag, "types must correspond");
 54     return t;
 55   }
 56 
 57   Value check(ValueTag tag, Value t, Value h) {
 58     assert(h == NULL, "hi-word of doubleword value must be NULL");
 59     return check(tag, t);
 60   }
 61 
 62   // helper routine
 63   static void apply(const Values& list, ValueVisitor* f);
 64 
 65   // for simplified copying
 66   ValueStack(ValueStack* copy_from, Kind kind, int bci);
 67 
 68   int locals_size_for_copy(Kind kind) const;
 69   int stack_size_for_copy(Kind kind) const;
 70  public:
 71   // creation
 72   ValueStack(IRScope* scope, ValueStack* caller_state);
 73 
 74   ValueStack* copy()                             { return new ValueStack(this, _kind, _bci); }
 75   ValueStack* copy(Kind new_kind, int new_bci)   { return new ValueStack(this, new_kind, new_bci); }
 76   ValueStack* copy_for_parsing()                 { return new ValueStack(this, Parsing, -99); }
 77 
 78   void set_caller_state(ValueStack* s)           {
 79     assert(kind() == EmptyExceptionState ||
 80            (Compilation::current()->env()->should_retain_local_variables() && kind() == ExceptionState),
 81            "only EmptyExceptionStates can be modified");
 82     _caller_state = s;
 83   }
 84 
 85   bool is_same(ValueStack* s);                   // returns true if this & s's types match (w/o checking locals)
 86 
 87   // accessors
 88   IRScope* scope() const                         { return _scope; }
 89   ValueStack* caller_state() const               { return _caller_state; }
 90   int bci() const                                { return _bci; }
 91   Kind kind() const                              { return _kind; }


 92 
 93   int locals_size() const                        { return _locals.length(); }
 94   int stack_size() const                         { return _stack.length(); }
 95   int locks_size() const                         { return _locks == NULL ? 0 : _locks->length(); }
 96   bool stack_is_empty() const                    { return _stack.is_empty(); }
 97   bool no_active_locks() const                   { return _locks == NULL || _locks->is_empty(); }
 98   int total_locks_size() const;
 99 
100   // locals access
101   void clear_locals();                           // sets all locals to NULL;
102 
103   void invalidate_local(int i) {
104     assert(!_locals.at(i)->type()->is_double_word() ||
105            _locals.at(i + 1) == NULL, "hi-word of doubleword value must be NULL");
106     _locals.at_put(i, NULL);
107   }
108 
109   Value local_at(int i) const {
110     Value x = _locals.at(i);
111     assert(x == NULL || !x->type()->is_double_word() ||

 27 
 28 #include "c1/c1_Instruction.hpp"
 29 
 30 class ValueStack: public CompilationResourceObj {
 31  public:
 32   enum Kind {
 33     Parsing,             // During abstract interpretation in GraphBuilder
 34     CallerState,         // Caller state when inlining
 35     StateBefore,         // Before before execution of instruction
 36     StateAfter,          // After execution of instruction
 37     ExceptionState,      // Exception handling of instruction
 38     EmptyExceptionState, // Exception handling of instructions not covered by an xhandler
 39     BlockBeginState      // State of BlockBegin instruction with phi functions of this block
 40   };
 41 
 42  private:
 43   IRScope* _scope;                               // the enclosing scope
 44   ValueStack* _caller_state;
 45   int      _bci;
 46   Kind     _kind;
 47   bool     _should_reexecute;
 48 
 49   Values   _locals;                              // the locals
 50   Values   _stack;                               // the expression stack
 51   Values*  _locks;                               // the monitor stack (holding the locked values)
 52 
 53   Value check(ValueTag tag, Value t) {
 54     assert(tag == t->type()->tag() || tag == objectTag && t->type()->tag() == addressTag, "types must correspond");
 55     return t;
 56   }
 57 
 58   Value check(ValueTag tag, Value t, Value h) {
 59     assert(h == NULL, "hi-word of doubleword value must be NULL");
 60     return check(tag, t);
 61   }
 62 
 63   // helper routine
 64   static void apply(const Values& list, ValueVisitor* f);
 65 
 66   // for simplified copying
 67   ValueStack(ValueStack* copy_from, Kind kind, int bci, bool reexecute);
 68 
 69   int locals_size_for_copy(Kind kind) const;
 70   int stack_size_for_copy(Kind kind) const;
 71  public:
 72   // creation
 73   ValueStack(IRScope* scope, ValueStack* caller_state);
 74 
 75   ValueStack* copy()                             { return new ValueStack(this, _kind, _bci, _should_reexecute); }
 76   ValueStack* copy(Kind new_kind, int new_bci)   { return new ValueStack(this, new_kind, new_bci, _should_reexecute); }
 77   ValueStack* copy_for_parsing()                 { return new ValueStack(this, Parsing, -99, false); }
 78 
 79   void set_caller_state(ValueStack* s)           {
 80     assert(kind() == EmptyExceptionState ||
 81            (Compilation::current()->env()->should_retain_local_variables() && kind() == ExceptionState),
 82            "only EmptyExceptionStates can be modified");
 83     _caller_state = s;
 84   }
 85 
 86   bool is_same(ValueStack* s);                   // returns true if this & s's types match (w/o checking locals)
 87 
 88   // accessors
 89   IRScope* scope() const                         { return _scope; }
 90   ValueStack* caller_state() const               { return _caller_state; }
 91   int bci() const                                { return _bci; }
 92   Kind kind() const                              { return _kind; }
 93   bool should_reexecute() const                  { return _should_reexecute; }
 94   void set_should_reexecute(bool reexec)         { _should_reexecute = reexec; }
 95 
 96   int locals_size() const                        { return _locals.length(); }
 97   int stack_size() const                         { return _stack.length(); }
 98   int locks_size() const                         { return _locks == NULL ? 0 : _locks->length(); }
 99   bool stack_is_empty() const                    { return _stack.is_empty(); }
100   bool no_active_locks() const                   { return _locks == NULL || _locks->is_empty(); }
101   int total_locks_size() const;
102 
103   // locals access
104   void clear_locals();                           // sets all locals to NULL;
105 
106   void invalidate_local(int i) {
107     assert(!_locals.at(i)->type()->is_double_word() ||
108            _locals.at(i + 1) == NULL, "hi-word of doubleword value must be NULL");
109     _locals.at_put(i, NULL);
110   }
111 
112   Value local_at(int i) const {
113     Value x = _locals.at(i);
114     assert(x == NULL || !x->type()->is_double_word() ||
< prev index next >