< 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_if_flattened_array_types(Value existing_value, Value new_value) {
 180   assert(new_value != NULL, "must be");
 181   assert(existing_value != new_value, "must be");
 182 
 183   if (existing_value == NULL) {
 184     if (new_value->is_flattened_array()) {
 185       return new_value->exact_type();
 186     } else {
 187       return NULL;
 188     }
 189   }
 190 
 191   if (existing_value->is_flattened_array() && new_value->is_flattened_array()) {
 192     // The merged block should be able to access this value as a flattened array.
 193     assert(existing_value->exact_type() == new_value->exact_type(), "must be guaranteed by verifier");
 194     return existing_value->exact_type();
 195   } else {
 196     // The merged block cannot access value as a flattened array without first doing a type cast.
 197     return NULL;
 198   }
 199 }
 200 
 201 void ValueStack::setup_phi_for_stack(BlockBegin* b, int index, Value existing_value, Value new_value) {
 202   assert(stack_at(index)->as_Phi() == NULL || stack_at(index)->as_Phi()->block() != b, "phi function already created");
 203 
 204   ValueType* t = stack_at(index)->type();
 205   Value phi = new Phi(t, b, -index - 1, merge_if_flattened_array_types(existing_value, new_value));
 206   _stack.at_put(index, phi);
 207 
 208   assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL");
 209 }
 210 
 211 void ValueStack::setup_phi_for_local(BlockBegin* b, int index, Value existing_value, Value new_value) {
 212   assert(local_at(index)->as_Phi() == NULL || local_at(index)->as_Phi()->block() != b, "phi function already created");
 213 
 214   ValueType* t = local_at(index)->type();
 215   Value phi = new Phi(t, b, index, merge_if_flattened_array_types(existing_value, new_value));
 216   store_local(index, phi);
 217 }
 218 
 219 #ifndef PRODUCT
 220 
 221 void ValueStack::print() {
 222   scope()->method()->print_name();
 223   tty->cr();
 224   if (stack_is_empty()) {
 225     tty->print_cr("empty stack");
 226   } else {
 227     InstructionPrinter ip;
 228     for (int i = 0; i < stack_size();) {
 229       Value t = stack_at_inc(i);
 230       tty->print("%2d  ", i);
 231       tty->print("%c%d ", t->type()->tchar(), t->id());
 232       ip.print_instr(t);
 233       tty->cr();
 234     }
 235   }


< prev index next >