1.1 --- a/src/share/vm/c1/c1_LIRGenerator.cpp Wed Sep 22 23:51:03 2010 -0700 1.2 +++ b/src/share/vm/c1/c1_LIRGenerator.cpp Tue Dec 29 19:08:54 2009 +0100 1.3 @@ -386,18 +386,26 @@ 1.4 1.5 1.6 CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) { 1.7 - int index; 1.8 - Value value; 1.9 - for_each_stack_value(state, index, value) { 1.10 - assert(value->subst() == value, "missed substition"); 1.11 - if (!value->is_pinned() && value->as_Constant() == NULL && value->as_Local() == NULL) { 1.12 - walk(value); 1.13 - assert(value->operand()->is_valid(), "must be evaluated now"); 1.14 + assert(state != NULL, "state must be defined"); 1.15 + 1.16 + ValueStack* s = state; 1.17 + for_each_state(s) { 1.18 + if (s->kind() == ValueStack::EmptyExceptionState) { 1.19 + assert(s->stack_size() == 0 && s->locals_size() == 0 && (s->locks_size() == 0 || s->locks_size() == 1), "state must be empty"); 1.20 + continue; 1.21 } 1.22 - } 1.23 - ValueStack* s = state; 1.24 - int bci = x->bci(); 1.25 - for_each_state(s) { 1.26 + 1.27 + int index; 1.28 + Value value; 1.29 + for_each_stack_value(s, index, value) { 1.30 + assert(value->subst() == value, "missed substitution"); 1.31 + if (!value->is_pinned() && value->as_Constant() == NULL && value->as_Local() == NULL) { 1.32 + walk(value); 1.33 + assert(value->operand()->is_valid(), "must be evaluated now"); 1.34 + } 1.35 + } 1.36 + 1.37 + int bci = s->bci(); 1.38 IRScope* scope = s->scope(); 1.39 ciMethod* method = scope->method(); 1.40 1.41 @@ -428,15 +436,14 @@ 1.42 } 1.43 } 1.44 } 1.45 - bci = scope->caller_bci(); 1.46 } 1.47 1.48 - return new CodeEmitInfo(x->bci(), state, ignore_xhandler ? NULL : x->exception_handlers()); 1.49 + return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers()); 1.50 } 1.51 1.52 1.53 CodeEmitInfo* LIRGenerator::state_for(Instruction* x) { 1.54 - return state_for(x, x->lock_stack()); 1.55 + return state_for(x, x->exception_state()); 1.56 } 1.57 1.58 1.59 @@ -900,18 +907,14 @@ 1.60 Value sux_value; 1.61 int index; 1.62 1.63 + assert(cur_state->scope() == sux_state->scope(), "not matching"); 1.64 + assert(cur_state->locals_size() == sux_state->locals_size(), "not matching"); 1.65 + assert(cur_state->stack_size() == sux_state->stack_size(), "not matching"); 1.66 + 1.67 for_each_stack_value(sux_state, index, sux_value) { 1.68 move_to_phi(&resolver, cur_state->stack_at(index), sux_value); 1.69 } 1.70 1.71 - // Inlining may cause the local state not to match up, so walk up 1.72 - // the caller state until we get to the same scope as the 1.73 - // successor and then start processing from there. 1.74 - while (cur_state->scope() != sux_state->scope()) { 1.75 - cur_state = cur_state->caller_state(); 1.76 - assert(cur_state != NULL, "scopes don't match up"); 1.77 - } 1.78 - 1.79 for_each_local_value(sux_state, index, sux_value) { 1.80 move_to_phi(&resolver, cur_state->local_at(index), sux_value); 1.81 } 1.82 @@ -1023,10 +1026,10 @@ 1.83 1.84 // Code for a constant is generated lazily unless the constant is frequently used and can't be inlined. 1.85 void LIRGenerator::do_Constant(Constant* x) { 1.86 - if (x->state() != NULL) { 1.87 + if (x->state_before() != NULL) { 1.88 // Any constant with a ValueStack requires patching so emit the patch here 1.89 LIR_Opr reg = rlock_result(x); 1.90 - CodeEmitInfo* info = state_for(x, x->state()); 1.91 + CodeEmitInfo* info = state_for(x, x->state_before()); 1.92 __ oop2reg_patch(NULL, reg, info); 1.93 } else if (x->use_count() > 1 && !can_inline_as_constant(x)) { 1.94 if (!x->is_pinned()) { 1.95 @@ -1102,7 +1105,7 @@ 1.96 // need to perform the null check on the rcvr 1.97 CodeEmitInfo* info = NULL; 1.98 if (x->needs_null_check()) { 1.99 - info = state_for(x, x->state()->copy_locks()); 1.100 + info = state_for(x); 1.101 } 1.102 __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_OBJECT), result, info); 1.103 __ move(new LIR_Address(result, Klass::java_mirror_offset_in_bytes() + 1.104 @@ -1481,7 +1484,7 @@ 1.105 } else if (x->needs_null_check()) { 1.106 NullCheck* nc = x->explicit_null_check(); 1.107 if (nc == NULL) { 1.108 - info = state_for(x, x->lock_stack()); 1.109 + info = state_for(x); 1.110 } else { 1.111 info = state_for(nc); 1.112 } 1.113 @@ -1509,10 +1512,12 @@ 1.114 1.115 set_no_result(x); 1.116 1.117 +#ifndef PRODUCT 1.118 if (PrintNotLoaded && needs_patching) { 1.119 tty->print_cr(" ###class not loaded at store_%s bci %d", 1.120 - x->is_static() ? "static" : "field", x->bci()); 1.121 + x->is_static() ? "static" : "field", x->printable_bci()); 1.122 } 1.123 +#endif 1.124 1.125 if (x->needs_null_check() && 1.126 (needs_patching || 1.127 @@ -1575,7 +1580,7 @@ 1.128 } else if (x->needs_null_check()) { 1.129 NullCheck* nc = x->explicit_null_check(); 1.130 if (nc == NULL) { 1.131 - info = state_for(x, x->lock_stack()); 1.132 + info = state_for(x); 1.133 } else { 1.134 info = state_for(nc); 1.135 } 1.136 @@ -1585,10 +1590,12 @@ 1.137 1.138 object.load_item(); 1.139 1.140 +#ifndef PRODUCT 1.141 if (PrintNotLoaded && needs_patching) { 1.142 tty->print_cr(" ###class not loaded at load_%s bci %d", 1.143 - x->is_static() ? "static" : "field", x->bci()); 1.144 + x->is_static() ? "static" : "field", x->printable_bci()); 1.145 } 1.146 +#endif 1.147 1.148 if (x->needs_null_check() && 1.149 (needs_patching || 1.150 @@ -1781,7 +1788,7 @@ 1.151 if (GenerateCompilerNullChecks && 1.152 (x->exception()->as_NewInstance() == NULL && x->exception()->as_ExceptionObject() == NULL)) { 1.153 // if the exception object wasn't created using new then it might be null. 1.154 - __ null_check(exception_opr, new CodeEmitInfo(info, true)); 1.155 + __ null_check(exception_opr, new CodeEmitInfo(info, x->state()->copy(ValueStack::ExceptionState, x->state()->bci()))); 1.156 } 1.157 1.158 if (compilation()->env()->jvmti_can_post_on_exceptions()) { 1.159 @@ -2127,7 +2134,6 @@ 1.160 int lo_key = x->lo_key(); 1.161 int hi_key = x->hi_key(); 1.162 int len = x->length(); 1.163 - CodeEmitInfo* info = state_for(x, x->state()); 1.164 LIR_Opr value = tag.result(); 1.165 if (UseTableRanges) { 1.166 do_SwitchRanges(create_lookup_ranges(x), value, x->default_sux()); 1.167 @@ -2186,7 +2192,7 @@ 1.168 1.169 // increment backedge counter if needed 1.170 CodeEmitInfo* info = state_for(x, state); 1.171 - increment_backedge_counter(info, info->bci()); 1.172 + increment_backedge_counter(info, info->stack()->bci()); 1.173 CodeEmitInfo* safepoint_info = state_for(x, state); 1.174 __ safepoint(safepoint_poll_register(), safepoint_info); 1.175 } 1.176 @@ -2293,7 +2299,7 @@ 1.177 LIR_Opr lock = new_register(T_INT); 1.178 __ load_stack_address_monitor(0, lock); 1.179 1.180 - CodeEmitInfo* info = new CodeEmitInfo(SynchronizationEntryBCI, scope()->start()->state(), NULL); 1.181 + CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL); 1.182 CodeStub* slow_path = new MonitorEnterStub(obj, lock, info); 1.183 1.184 // receiver is guaranteed non-NULL so don't need CodeEmitInfo 1.185 @@ -2303,7 +2309,7 @@ 1.186 1.187 // increment invocation counters if needed 1.188 if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting. 1.189 - CodeEmitInfo* info = new CodeEmitInfo(InvocationEntryBci, scope()->start()->state(), NULL); 1.190 + CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state(), NULL); 1.191 increment_invocation_counter(info); 1.192 } 1.193 1.194 @@ -2463,7 +2469,7 @@ 1.195 break; 1.196 case Bytecodes::_invokedynamic: { 1.197 ciBytecodeStream bcs(x->scope()->method()); 1.198 - bcs.force_bci(x->bci()); 1.199 + bcs.force_bci(x->state()->bci()); 1.200 assert(bcs.cur_bc() == Bytecodes::_invokedynamic, "wrong stream"); 1.201 ciCPCache* cpcache = bcs.get_cpcache(); 1.202