< prev index next >

src/hotspot/share/c1/c1_ValueStack.cpp

Print this page

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 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 "c1/c1_IR.hpp"
 26 #include "c1/c1_InstructionPrinter.hpp"
 27 #include "c1/c1_ValueStack.hpp"
 28 
 29 
 30 // Implementation of ValueStack
 31 
 32 ValueStack::ValueStack(IRScope* scope, ValueStack* caller_state)
 33 : _scope(scope)
 34 , _caller_state(caller_state)
 35 , _bci(-99)
 36 , _kind(Parsing)

 37 , _locals(scope->method()->max_locals(), scope->method()->max_locals(), nullptr)
 38 , _stack(scope->method()->max_stack())
 39 , _locks(nullptr)
 40 , _force_reexecute(false)
 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   , _force_reexecute(false)
 54 {
 55   switch (kind) {
 56   case EmptyExceptionState:
 57   case CallerEmptyExceptionState:
 58     assert(!Compilation::current()->env()->should_retain_local_variables(), "need locals");
 59     // set to all nulls, like clear_locals()
 60     for (int i = 0; i < copy_from->locals_size(); ++i) {
 61       _locals.append(nullptr);
 62     }
 63     break;
 64   default:
 65     _locals.appendAll(&copy_from->_locals);
 66   }
 67 
 68   switch (kind) {
 69   case ExceptionState:

193   return num_locks;
194 }
195 
196 int ValueStack::lock(Value obj) {
197   if (_locks == nullptr) {
198     _locks = new Values();
199   }
200   _locks->push(obj);
201   int num_locks = total_locks_size();
202   scope()->set_min_number_of_locks(num_locks);
203   return num_locks - 1;
204 }
205 
206 
207 int ValueStack::unlock() {
208   assert(locks_size() > 0, "sanity");
209   _locks->pop();
210   return total_locks_size();
211 }
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 

 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 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 "c1/c1_IR.hpp"
 26 #include "c1/c1_InstructionPrinter.hpp"
 27 #include "c1/c1_ValueStack.hpp"
 28 
 29 
 30 // Implementation of ValueStack
 31 
 32 ValueStack::ValueStack(IRScope* scope, ValueStack* caller_state)
 33 : _scope(scope)
 34 , _caller_state(caller_state)
 35 , _bci(-99)
 36 , _kind(Parsing)
 37 , _should_reexecute(false)
 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, 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   , _force_reexecute(false)
 56 {
 57   switch (kind) {
 58   case EmptyExceptionState:
 59   case CallerEmptyExceptionState:
 60     assert(!Compilation::current()->env()->should_retain_local_variables(), "need locals");
 61     // set to all nulls, like clear_locals()
 62     for (int i = 0; i < copy_from->locals_size(); ++i) {
 63       _locals.append(nullptr);
 64     }
 65     break;
 66   default:
 67     _locals.appendAll(&copy_from->_locals);
 68   }
 69 
 70   switch (kind) {
 71   case ExceptionState:

195   return num_locks;
196 }
197 
198 int ValueStack::lock(Value obj) {
199   if (_locks == nullptr) {
200     _locks = new Values();
201   }
202   _locks->push(obj);
203   int num_locks = total_locks_size();
204   scope()->set_min_number_of_locks(num_locks);
205   return num_locks - 1;
206 }
207 
208 
209 int ValueStack::unlock() {
210   assert(locks_size() > 0, "sanity");
211   _locks->pop();
212   return total_locks_size();
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 
< prev index next >