< prev index next >

src/hotspot/share/c1/c1_ValueStack.cpp

Print this page




 155   const ValueStack* state = this;
 156   for_each_state(state) {
 157     num_locks += state->locks_size();
 158   }
 159   return num_locks;
 160 }
 161 
 162 int ValueStack::lock(Value obj) {
 163   _locks.push(obj);
 164   int num_locks = total_locks_size();
 165   scope()->set_min_number_of_locks(num_locks);
 166   return num_locks - 1;
 167 }
 168 
 169 
 170 int ValueStack::unlock() {
 171   _locks.pop();
 172   return total_locks_size();
 173 }
 174 













 175 
 176 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) {
 177   assert(stack_at(index)->as_Phi() == NULL || stack_at(index)->as_Phi()->block() != b, "phi function already created");
 178 
 179   ValueType* t = stack_at(index)->type();
 180   Value phi = new Phi(t, b, -index - 1);
 181   _stack.at_put(index, phi);
 182 
 183   assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL");
 184 }
 185 
 186 void ValueStack::setup_phi_for_local(BlockBegin* b, int index) {
 187   assert(local_at(index)->as_Phi() == NULL || local_at(index)->as_Phi()->block() != b, "phi function already created");
 188 
 189   ValueType* t = local_at(index)->type();
 190   Value phi = new Phi(t, b, index);
 191   store_local(index, phi);
 192 }
 193 
 194 #ifndef PRODUCT
 195 
 196 void ValueStack::print() {
 197   scope()->method()->print_name();
 198   tty->cr();
 199   if (stack_is_empty()) {
 200     tty->print_cr("empty stack");
 201   } else {
 202     InstructionPrinter ip;
 203     for (int i = 0; i < stack_size();) {
 204       Value t = stack_at_inc(i);
 205       tty->print("%2d  ", i);
 206       tty->print("%c%d ", t->type()->tchar(), t->id());
 207       ip.print_instr(t);
 208       tty->cr();
 209     }
 210   }




 155   const ValueStack* state = this;
 156   for_each_state(state) {
 157     num_locks += state->locks_size();
 158   }
 159   return num_locks;
 160 }
 161 
 162 int ValueStack::lock(Value obj) {
 163   _locks.push(obj);
 164   int num_locks = total_locks_size();
 165   scope()->set_min_number_of_locks(num_locks);
 166   return num_locks - 1;
 167 }
 168 
 169 
 170 int ValueStack::unlock() {
 171   _locks.pop();
 172   return total_locks_size();
 173 }
 174 
 175 // When we merge two object slots, we usually lose the type information.
 176 // However, for aaload/aastore to work with flattened arrays, we need to preserve
 177 // the type info (because the aaload/aastore bytecode themselves don't carry the
 178 // type info).
 179 ciType* ValueStack::merge_types(Value existing_value, Value new_value) {
 180   if (new_value->is_flattened_array() &&
 181       (existing_value == NULL || existing_value->is_flattened_array())) {
 182     assert(existing_value == NULL || existing_value->exact_type() == new_value->exact_type(),
 183            "must be guaranteed by verifier");
 184     return new_value->exact_type();
 185   }
 186   return NULL;
 187 }
 188 
 189 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index, Value existing_value, Value new_value) {
 190   assert(stack_at(index)->as_Phi() == NULL || stack_at(index)->as_Phi()->block() != b, "phi function already created");
 191 
 192   ValueType* t = stack_at(index)->type();
 193   Value phi = new Phi(t, b, -index - 1, merge_types(existing_value, new_value));
 194   _stack.at_put(index, phi);
 195 
 196   assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL");
 197 }
 198 
 199 void ValueStack::setup_phi_for_local(BlockBegin* b, int index, Value existing_value, Value new_value) {
 200   assert(local_at(index)->as_Phi() == NULL || local_at(index)->as_Phi()->block() != b, "phi function already created");
 201 
 202   ValueType* t = local_at(index)->type();
 203   Value phi = new Phi(t, b, index, merge_types(existing_value, new_value));
 204   store_local(index, phi);
 205 }
 206 
 207 #ifndef PRODUCT
 208 
 209 void ValueStack::print() {
 210   scope()->method()->print_name();
 211   tty->cr();
 212   if (stack_is_empty()) {
 213     tty->print_cr("empty stack");
 214   } else {
 215     InstructionPrinter ip;
 216     for (int i = 0; i < stack_size();) {
 217       Value t = stack_at_inc(i);
 218       tty->print("%2d  ", i);
 219       tty->print("%c%d ", t->type()->tchar(), t->id());
 220       ip.print_instr(t);
 221       tty->cr();
 222     }
 223   }


< prev index next >