< 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 {
 42   verify();
 43 }
 44 
 45 ValueStack::ValueStack(ValueStack* copy_from, Kind kind, int bci)
 46   : _scope(copy_from->scope())
 47   , _caller_state(copy_from->caller_state())
 48   , _bci(bci)
 49   , _kind(kind)

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

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

 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 {
 43   verify();
 44 }
 45 
 46 ValueStack::ValueStack(ValueStack* copy_from, Kind kind, int bci, bool reexecute)
 47   : _scope(copy_from->scope())
 48   , _caller_state(copy_from->caller_state())
 49   , _bci(bci)
 50   , _kind(kind)
 51   , _should_reexecute(reexecute)
 52   , _locals(copy_from->locals_size_for_copy(kind))
 53   , _stack(copy_from->stack_size_for_copy(kind))
 54   , _locks(copy_from->locks_size() == 0 ? nullptr : new Values(copy_from->locks_size()))
 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:
 71   case EmptyExceptionState:

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