< prev index next >

src/hotspot/share/c1/c1_ValueStack.cpp

Print this page

 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "c1/c1_IR.hpp"
 27 #include "c1/c1_InstructionPrinter.hpp"
 28 #include "c1/c1_ValueStack.hpp"
 29 
 30 
 31 // Implementation of ValueStack
 32 
 33 ValueStack::ValueStack(IRScope* scope, ValueStack* caller_state)
 34 : _scope(scope)
 35 , _caller_state(caller_state)
 36 , _bci(-99)
 37 , _kind(Parsing)

 38 , _locals(scope->method()->max_locals(), scope->method()->max_locals(), nullptr)
 39 , _stack(scope->method()->max_stack())
 40 , _locks(nullptr)
 41 , _force_reexecute(false)
 42 {
 43   verify();
 44 }
 45 
 46 ValueStack::ValueStack(ValueStack* copy_from, Kind kind, int bci)
 47   : _scope(copy_from->scope())
 48   , _caller_state(copy_from->caller_state())
 49   , _bci(bci)
 50   , _kind(kind)

 51   , _locals(copy_from->locals_size_for_copy(kind))
 52   , _stack(copy_from->stack_size_for_copy(kind))
 53   , _locks(copy_from->locks_size() == 0 ? nullptr : new Values(copy_from->locks_size()))
 54   , _force_reexecute(false)
 55 {
 56   switch (kind) {
 57   case EmptyExceptionState:
 58   case CallerEmptyExceptionState:
 59     assert(!Compilation::current()->env()->should_retain_local_variables(), "need locals");
 60     // set to all nulls, like clear_locals()
 61     for (int i = 0; i < copy_from->locals_size(); ++i) {
 62       _locals.append(nullptr);
 63     }
 64     break;
 65   default:
 66     _locals.appendAll(&copy_from->_locals);
 67   }
 68 
 69   switch (kind) {
 70   case ExceptionState:

194   return num_locks;
195 }
196 
197 int ValueStack::lock(Value obj) {
198   if (_locks == nullptr) {
199     _locks = new Values();
200   }
201   _locks->push(obj);
202   int num_locks = total_locks_size();
203   scope()->set_min_number_of_locks(num_locks);
204   return num_locks - 1;
205 }
206 
207 
208 int ValueStack::unlock() {
209   assert(locks_size() > 0, "sanity");
210   _locks->pop();
211   return total_locks_size();
212 }
213 
214 
215 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) {
216   assert(stack_at(index)->as_Phi() == nullptr || stack_at(index)->as_Phi()->block() != b, "phi function already created");
217 
218   ValueType* t = stack_at(index)->type();
219   Value phi = new Phi(t, b, -index - 1);
220   _stack.at_put(index, phi);
221 
222   assert(!t->is_double_word() || _stack.at(index + 1) == nullptr, "hi-word of doubleword value must be null");
223 }
224 
225 void ValueStack::setup_phi_for_local(BlockBegin* b, int index) {
226   assert(local_at(index)->as_Phi() == nullptr || local_at(index)->as_Phi()->block() != b, "phi function already created");
227 
228   ValueType* t = local_at(index)->type();
229   Value phi = new Phi(t, b, index);
230   store_local(index, phi);
231 }
232 
233 #ifndef PRODUCT
234 

 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "c1/c1_IR.hpp"
 27 #include "c1/c1_InstructionPrinter.hpp"
 28 #include "c1/c1_ValueStack.hpp"
 29 
 30 
 31 // Implementation of ValueStack
 32 
 33 ValueStack::ValueStack(IRScope* scope, ValueStack* caller_state)
 34 : _scope(scope)
 35 , _caller_state(caller_state)
 36 , _bci(-99)
 37 , _kind(Parsing)
 38 , _should_reexecute(false)
 39 , _locals(scope->method()->max_locals(), scope->method()->max_locals(), nullptr)
 40 , _stack(scope->method()->max_stack())
 41 , _locks(nullptr)
 42 , _force_reexecute(false)
 43 {
 44   verify();
 45 }
 46 
 47 ValueStack::ValueStack(ValueStack* copy_from, Kind kind, int bci, bool reexecute)
 48   : _scope(copy_from->scope())
 49   , _caller_state(copy_from->caller_state())
 50   , _bci(bci)
 51   , _kind(kind)
 52   , _should_reexecute(reexecute)
 53   , _locals(copy_from->locals_size_for_copy(kind))
 54   , _stack(copy_from->stack_size_for_copy(kind))
 55   , _locks(copy_from->locks_size() == 0 ? nullptr : new Values(copy_from->locks_size()))
 56   , _force_reexecute(false)
 57 {
 58   switch (kind) {
 59   case EmptyExceptionState:
 60   case CallerEmptyExceptionState:
 61     assert(!Compilation::current()->env()->should_retain_local_variables(), "need locals");
 62     // set to all nulls, like clear_locals()
 63     for (int i = 0; i < copy_from->locals_size(); ++i) {
 64       _locals.append(nullptr);
 65     }
 66     break;
 67   default:
 68     _locals.appendAll(&copy_from->_locals);
 69   }
 70 
 71   switch (kind) {
 72   case ExceptionState:

196   return num_locks;
197 }
198 
199 int ValueStack::lock(Value obj) {
200   if (_locks == nullptr) {
201     _locks = new Values();
202   }
203   _locks->push(obj);
204   int num_locks = total_locks_size();
205   scope()->set_min_number_of_locks(num_locks);
206   return num_locks - 1;
207 }
208 
209 
210 int ValueStack::unlock() {
211   assert(locks_size() > 0, "sanity");
212   _locks->pop();
213   return total_locks_size();
214 }
215 

216 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) {
217   assert(stack_at(index)->as_Phi() == nullptr || stack_at(index)->as_Phi()->block() != b, "phi function already created");
218 
219   ValueType* t = stack_at(index)->type();
220   Value phi = new Phi(t, b, -index - 1);
221   _stack.at_put(index, phi);
222 
223   assert(!t->is_double_word() || _stack.at(index + 1) == nullptr, "hi-word of doubleword value must be null");
224 }
225 
226 void ValueStack::setup_phi_for_local(BlockBegin* b, int index) {
227   assert(local_at(index)->as_Phi() == nullptr || local_at(index)->as_Phi()->block() != b, "phi function already created");
228 
229   ValueType* t = local_at(index)->type();
230   Value phi = new Phi(t, b, index);
231   store_local(index, phi);
232 }
233 
234 #ifndef PRODUCT
235 
< prev index next >