1703 } |
1703 } |
1704 LoadField* load = new LoadField(obj, offset, field, false, state_before, needs_patching); |
1704 LoadField* load = new LoadField(obj, offset, field, false, state_before, needs_patching); |
1705 Value replacement = !needs_patching ? _memory->load(load) : load; |
1705 Value replacement = !needs_patching ? _memory->load(load) : load; |
1706 if (replacement != load) { |
1706 if (replacement != load) { |
1707 assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked"); |
1707 assert(replacement->is_linked() || !replacement->can_be_linked(), "should already by linked"); |
|
1708 // Writing an (integer) value to a boolean, byte, char or short field includes an implicit narrowing |
|
1709 // conversion. Emit an explicit conversion here to get the correct field value after the write. |
|
1710 BasicType bt = field->type()->basic_type(); |
|
1711 switch (bt) { |
|
1712 case T_BOOLEAN: |
|
1713 case T_BYTE: |
|
1714 replacement = append(new Convert(Bytecodes::_i2b, replacement, as_ValueType(bt))); |
|
1715 break; |
|
1716 case T_CHAR: |
|
1717 replacement = append(new Convert(Bytecodes::_i2c, replacement, as_ValueType(bt))); |
|
1718 break; |
|
1719 case T_SHORT: |
|
1720 replacement = append(new Convert(Bytecodes::_i2s, replacement, as_ValueType(bt))); |
|
1721 break; |
|
1722 default: |
|
1723 break; |
|
1724 } |
1708 push(type, replacement); |
1725 push(type, replacement); |
1709 } else { |
1726 } else { |
1710 push(type, append(load)); |
1727 push(type, append(load)); |
1711 } |
1728 } |
1712 } |
1729 } |
2374 |
2391 |
2375 XHandlers* GraphBuilder::handle_exception(Instruction* instruction) { |
2392 XHandlers* GraphBuilder::handle_exception(Instruction* instruction) { |
2376 if (!has_handler() && (!instruction->needs_exception_state() || instruction->exception_state() != NULL)) { |
2393 if (!has_handler() && (!instruction->needs_exception_state() || instruction->exception_state() != NULL)) { |
2377 assert(instruction->exception_state() == NULL |
2394 assert(instruction->exception_state() == NULL |
2378 || instruction->exception_state()->kind() == ValueStack::EmptyExceptionState |
2395 || instruction->exception_state()->kind() == ValueStack::EmptyExceptionState |
2379 || (instruction->exception_state()->kind() == ValueStack::ExceptionState && _compilation->env()->jvmti_can_access_local_variables()), |
2396 || (instruction->exception_state()->kind() == ValueStack::ExceptionState && _compilation->env()->should_retain_local_variables()), |
2380 "exception_state should be of exception kind"); |
2397 "exception_state should be of exception kind"); |
2381 return new XHandlers(); |
2398 return new XHandlers(); |
2382 } |
2399 } |
2383 |
2400 |
2384 XHandlers* exception_handlers = new XHandlers(); |
2401 XHandlers* exception_handlers = new XHandlers(); |
2465 |
2482 |
2466 if (exception_handlers->length() == 0) { |
2483 if (exception_handlers->length() == 0) { |
2467 // This scope and all callees do not handle exceptions, so the local |
2484 // This scope and all callees do not handle exceptions, so the local |
2468 // variables of this scope are not needed. However, the scope itself is |
2485 // variables of this scope are not needed. However, the scope itself is |
2469 // required for a correct exception stack trace -> clear out the locals. |
2486 // required for a correct exception stack trace -> clear out the locals. |
2470 if (_compilation->env()->jvmti_can_access_local_variables()) { |
2487 if (_compilation->env()->should_retain_local_variables()) { |
2471 cur_state = cur_state->copy(ValueStack::ExceptionState, cur_state->bci()); |
2488 cur_state = cur_state->copy(ValueStack::ExceptionState, cur_state->bci()); |
2472 } else { |
2489 } else { |
2473 cur_state = cur_state->copy(ValueStack::EmptyExceptionState, cur_state->bci()); |
2490 cur_state = cur_state->copy(ValueStack::EmptyExceptionState, cur_state->bci()); |
2474 } |
2491 } |
2475 if (prev_state != NULL) { |
2492 if (prev_state != NULL) { |
3351 } |
3368 } |
3352 |
3369 |
3353 ValueStack* GraphBuilder::copy_state_for_exception_with_bci(int bci) { |
3370 ValueStack* GraphBuilder::copy_state_for_exception_with_bci(int bci) { |
3354 ValueStack* s = copy_state_exhandling_with_bci(bci); |
3371 ValueStack* s = copy_state_exhandling_with_bci(bci); |
3355 if (s == NULL) { |
3372 if (s == NULL) { |
3356 if (_compilation->env()->jvmti_can_access_local_variables()) { |
3373 if (_compilation->env()->should_retain_local_variables()) { |
3357 s = state()->copy(ValueStack::ExceptionState, bci); |
3374 s = state()->copy(ValueStack::ExceptionState, bci); |
3358 } else { |
3375 } else { |
3359 s = state()->copy(ValueStack::EmptyExceptionState, bci); |
3376 s = state()->copy(ValueStack::EmptyExceptionState, bci); |
3360 } |
3377 } |
3361 } |
3378 } |