26 #include "classfile/vmSymbols.hpp" |
26 #include "classfile/vmSymbols.hpp" |
27 #include "gc_interface/collectedHeap.hpp" |
27 #include "gc_interface/collectedHeap.hpp" |
28 #include "interpreter/bytecodeHistogram.hpp" |
28 #include "interpreter/bytecodeHistogram.hpp" |
29 #include "interpreter/bytecodeInterpreter.hpp" |
29 #include "interpreter/bytecodeInterpreter.hpp" |
30 #include "interpreter/bytecodeInterpreter.inline.hpp" |
30 #include "interpreter/bytecodeInterpreter.inline.hpp" |
|
31 #include "interpreter/bytecodeInterpreterProfiling.hpp" |
31 #include "interpreter/interpreter.hpp" |
32 #include "interpreter/interpreter.hpp" |
32 #include "interpreter/interpreterRuntime.hpp" |
33 #include "interpreter/interpreterRuntime.hpp" |
33 #include "memory/resourceArea.hpp" |
34 #include "memory/resourceArea.hpp" |
34 #include "oops/methodCounters.hpp" |
35 #include "oops/methodCounters.hpp" |
35 #include "oops/objArrayKlass.hpp" |
36 #include "oops/objArrayKlass.hpp" |
140 * VM_JAVA_ERROR - Macro for throwing a java exception from |
141 * VM_JAVA_ERROR - Macro for throwing a java exception from |
141 * the interpreter loop. Should really be a CALL_VM but there |
142 * the interpreter loop. Should really be a CALL_VM but there |
142 * is no entry point to do the transition to vm so we just |
143 * is no entry point to do the transition to vm so we just |
143 * do it by hand here. |
144 * do it by hand here. |
144 */ |
145 */ |
145 #define VM_JAVA_ERROR_NO_JUMP(name, msg) \ |
146 #define VM_JAVA_ERROR_NO_JUMP(name, msg, note_a_trap) \ |
146 DECACHE_STATE(); \ |
147 DECACHE_STATE(); \ |
147 SET_LAST_JAVA_FRAME(); \ |
148 SET_LAST_JAVA_FRAME(); \ |
148 { \ |
149 { \ |
|
150 InterpreterRuntime::note_a_trap(THREAD, istate->method(), BCI()); \ |
149 ThreadInVMfromJava trans(THREAD); \ |
151 ThreadInVMfromJava trans(THREAD); \ |
150 Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg); \ |
152 Exceptions::_throw_msg(THREAD, __FILE__, __LINE__, name, msg); \ |
151 } \ |
153 } \ |
152 RESET_LAST_JAVA_FRAME(); \ |
154 RESET_LAST_JAVA_FRAME(); \ |
153 CACHE_STATE(); |
155 CACHE_STATE(); |
154 |
156 |
155 // Normal throw of a java error |
157 // Normal throw of a java error. |
156 #define VM_JAVA_ERROR(name, msg) \ |
158 #define VM_JAVA_ERROR(name, msg, note_a_trap) \ |
157 VM_JAVA_ERROR_NO_JUMP(name, msg) \ |
159 VM_JAVA_ERROR_NO_JUMP(name, msg, note_a_trap) \ |
158 goto handle_exception; |
160 goto handle_exception; |
159 |
161 |
160 #ifdef PRODUCT |
162 #ifdef PRODUCT |
161 #define DO_UPDATE_INSTRUCTION_COUNT(opcode) |
163 #define DO_UPDATE_INSTRUCTION_COUNT(opcode) |
162 #else |
164 #else |
338 MethodCounters* mcs; \ |
340 MethodCounters* mcs; \ |
339 GET_METHOD_COUNTERS(mcs); \ |
341 GET_METHOD_COUNTERS(mcs); \ |
340 if (UseLoopCounter) { \ |
342 if (UseLoopCounter) { \ |
341 bool do_OSR = UseOnStackReplacement; \ |
343 bool do_OSR = UseOnStackReplacement; \ |
342 mcs->backedge_counter()->increment(); \ |
344 mcs->backedge_counter()->increment(); \ |
343 if (do_OSR) do_OSR = mcs->backedge_counter()->reached_InvocationLimit(); \ |
345 if (ProfileInterpreter) { \ |
|
346 BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception); \ |
|
347 /* Check for overflow against MDO count. */ \ |
|
348 do_OSR = do_OSR \ |
|
349 && (mdo_last_branch_taken_count >= (uint)InvocationCounter::InterpreterBackwardBranchLimit)\ |
|
350 /* When ProfileInterpreter is on, the backedge_count comes */ \ |
|
351 /* from the methodDataOop, which value does not get reset on */ \ |
|
352 /* the call to frequency_counter_overflow(). To avoid */ \ |
|
353 /* excessive calls to the overflow routine while the method is */ \ |
|
354 /* being compiled, add a second test to make sure the overflow */ \ |
|
355 /* function is called only once every overflow_frequency. */ \ |
|
356 && (!(mdo_last_branch_taken_count & 1023)); \ |
|
357 } else { \ |
|
358 /* check for overflow of backedge counter */ \ |
|
359 do_OSR = do_OSR \ |
|
360 && mcs->invocation_counter()->reached_InvocationLimit(mcs->backedge_counter()); \ |
|
361 } \ |
344 if (do_OSR) { \ |
362 if (do_OSR) { \ |
345 nmethod* osr_nmethod; \ |
363 nmethod* osr_nmethod; \ |
346 OSR_REQUEST(osr_nmethod, branch_pc); \ |
364 OSR_REQUEST(osr_nmethod, branch_pc); \ |
347 if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) { \ |
365 if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) { \ |
348 intptr_t* buf; \ |
366 intptr_t* buf; \ |
349 /* Call OSR migration with last java frame only, no checks. */ \ |
367 /* Call OSR migration with last java frame only, no checks. */ \ |
350 CALL_VM_NAKED_LJF(buf=SharedRuntime::OSR_migration_begin(THREAD)); \ |
368 CALL_VM_NAKED_LJF(buf=SharedRuntime::OSR_migration_begin(THREAD)); \ |
386 #define CACHE_CP() cp = istate->constants(); |
403 #define CACHE_CP() cp = istate->constants(); |
387 #define CACHE_LOCALS() locals = istate->locals(); |
404 #define CACHE_LOCALS() locals = istate->locals(); |
388 #undef CACHE_FRAME |
405 #undef CACHE_FRAME |
389 #define CACHE_FRAME() |
406 #define CACHE_FRAME() |
390 |
407 |
|
408 // BCI() returns the current bytecode-index. |
|
409 #undef BCI |
|
410 #define BCI() ((int)(intptr_t)(pc - (intptr_t)istate->method()->code_base())) |
|
411 |
391 /* |
412 /* |
392 * CHECK_NULL - Macro for throwing a NullPointerException if the object |
413 * CHECK_NULL - Macro for throwing a NullPointerException if the object |
393 * passed is a null ref. |
414 * passed is a null ref. |
394 * On some architectures/platforms it should be possible to do this implicitly |
415 * On some architectures/platforms it should be possible to do this implicitly |
395 */ |
416 */ |
396 #undef CHECK_NULL |
417 #undef CHECK_NULL |
397 #define CHECK_NULL(obj_) \ |
418 #define CHECK_NULL(obj_) \ |
398 if ((obj_) == NULL) { \ |
419 if ((obj_) == NULL) { \ |
399 VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), ""); \ |
420 VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), "", note_nullCheck_trap); \ |
400 } \ |
421 } \ |
401 VERIFY_OOP(obj_) |
422 VERIFY_OOP(obj_) |
402 |
423 |
403 #define VMdoubleConstZero() 0.0 |
424 #define VMdoubleConstZero() 0.0 |
404 #define VMdoubleConstOne() 1.0 |
425 #define VMdoubleConstOne() 1.0 |
405 #define VMlongConstZero() (max_jlong-max_jlong) |
426 #define VMlongConstZero() (max_jlong-max_jlong) |
406 #define VMlongConstOne() ((max_jlong-max_jlong)+1) |
427 #define VMlongConstOne() ((max_jlong-max_jlong)+1) |
633 guarantee(istate->msg() == initialize || |
654 guarantee(istate->msg() == initialize || |
634 topOfStack >= istate->stack_limit() && |
655 topOfStack >= istate->stack_limit() && |
635 topOfStack < istate->stack_base(), |
656 topOfStack < istate->stack_base(), |
636 "Stack top out of range"); |
657 "Stack top out of range"); |
637 |
658 |
|
659 #ifdef CC_INTERP_PROFILE |
|
660 // MethodData's last branch taken count. |
|
661 uint mdo_last_branch_taken_count = 0; |
|
662 #else |
|
663 const uint mdo_last_branch_taken_count = 0; |
|
664 #endif |
|
665 |
638 switch (istate->msg()) { |
666 switch (istate->msg()) { |
639 case initialize: { |
667 case initialize: { |
640 if (initialized++) ShouldNotReachHere(); // Only one initialize call |
668 if (initialized++) ShouldNotReachHere(); // Only one initialize call. |
641 _compiling = (UseCompiler || CountCompiledCalls); |
669 _compiling = (UseCompiler || CountCompiledCalls); |
642 #ifdef VM_JVMTI |
670 #ifdef VM_JVMTI |
643 _jvmti_interp_events = JvmtiExport::can_post_interpreter_events(); |
671 _jvmti_interp_events = JvmtiExport::can_post_interpreter_events(); |
644 #endif |
672 #endif |
645 return; |
673 return; |
654 GET_METHOD_COUNTERS(mcs); |
682 GET_METHOD_COUNTERS(mcs); |
655 if (ProfileInterpreter) { |
683 if (ProfileInterpreter) { |
656 METHOD->increment_interpreter_invocation_count(THREAD); |
684 METHOD->increment_interpreter_invocation_count(THREAD); |
657 } |
685 } |
658 mcs->invocation_counter()->increment(); |
686 mcs->invocation_counter()->increment(); |
659 if (mcs->invocation_counter()->reached_InvocationLimit()) { |
687 if (mcs->invocation_counter()->reached_InvocationLimit(mcs->backedge_counter())) { |
660 CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception); |
688 CALL_VM((void)InterpreterRuntime::frequency_counter_overflow(THREAD, NULL), handle_exception); |
661 |
689 // We no longer retry on a counter overflow. |
662 // We no longer retry on a counter overflow |
690 } |
663 |
691 // Get or create profile data. Check for pending (async) exceptions. |
664 // istate->set_msg(retry_method); |
692 BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception); |
665 // THREAD->clr_do_not_unlock(); |
|
666 // return; |
|
667 } |
|
668 SAFEPOINT; |
693 SAFEPOINT; |
669 } |
694 } |
670 |
695 |
671 if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) { |
696 if ((istate->_stack_base - istate->_stack_limit) != istate->method()->max_stack() + 1) { |
672 // initialize |
697 // initialize |
684 interesting = true; |
709 interesting = true; |
685 } |
710 } |
686 } |
711 } |
687 #endif // HACK |
712 #endif // HACK |
688 |
713 |
689 |
714 // Lock method if synchronized. |
690 // lock method if synchronized |
|
691 if (METHOD->is_synchronized()) { |
715 if (METHOD->is_synchronized()) { |
692 // oop rcvr = locals[0].j.r; |
716 // oop rcvr = locals[0].j.r; |
693 oop rcvr; |
717 oop rcvr; |
694 if (METHOD->is_static()) { |
718 if (METHOD->is_static()) { |
695 rcvr = METHOD->constants()->pool_holder()->java_mirror(); |
719 rcvr = METHOD->constants()->pool_holder()->java_mirror(); |
696 } else { |
720 } else { |
697 rcvr = LOCALS_OBJECT(0); |
721 rcvr = LOCALS_OBJECT(0); |
698 VERIFY_OOP(rcvr); |
722 VERIFY_OOP(rcvr); |
699 } |
723 } |
700 // The initial monitor is ours for the taking |
724 // The initial monitor is ours for the taking. |
701 // Monitor not filled in frame manager any longer as this caused race condition with biased locking. |
725 // Monitor not filled in frame manager any longer as this caused race condition with biased locking. |
702 BasicObjectLock* mon = &istate->monitor_base()[-1]; |
726 BasicObjectLock* mon = &istate->monitor_base()[-1]; |
703 mon->set_obj(rcvr); |
727 mon->set_obj(rcvr); |
704 bool success = false; |
728 bool success = false; |
705 uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place; |
729 uintptr_t epoch_mask_in_place = (uintptr_t)markOopDesc::epoch_mask_in_place; |
1465 /* comparison operators */ |
1518 /* comparison operators */ |
1466 |
1519 |
1467 |
1520 |
1468 #define COMPARISON_OP(name, comparison) \ |
1521 #define COMPARISON_OP(name, comparison) \ |
1469 CASE(_if_icmp##name): { \ |
1522 CASE(_if_icmp##name): { \ |
1470 int skip = (STACK_INT(-2) comparison STACK_INT(-1)) \ |
1523 const bool cmp = (STACK_INT(-2) comparison STACK_INT(-1)); \ |
|
1524 int skip = cmp \ |
1471 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1525 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1472 address branch_pc = pc; \ |
1526 address branch_pc = pc; \ |
|
1527 /* Profile branch. */ \ |
|
1528 BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp); \ |
1473 UPDATE_PC_AND_TOS(skip, -2); \ |
1529 UPDATE_PC_AND_TOS(skip, -2); \ |
1474 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1530 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1475 CONTINUE; \ |
1531 CONTINUE; \ |
1476 } \ |
1532 } \ |
1477 CASE(_if##name): { \ |
1533 CASE(_if##name): { \ |
1478 int skip = (STACK_INT(-1) comparison 0) \ |
1534 const bool cmp = (STACK_INT(-1) comparison 0); \ |
|
1535 int skip = cmp \ |
1479 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1536 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1480 address branch_pc = pc; \ |
1537 address branch_pc = pc; \ |
|
1538 /* Profile branch. */ \ |
|
1539 BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp); \ |
1481 UPDATE_PC_AND_TOS(skip, -1); \ |
1540 UPDATE_PC_AND_TOS(skip, -1); \ |
1482 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1541 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1483 CONTINUE; \ |
1542 CONTINUE; \ |
1484 } |
1543 } |
1485 |
1544 |
1486 #define COMPARISON_OP2(name, comparison) \ |
1545 #define COMPARISON_OP2(name, comparison) \ |
1487 COMPARISON_OP(name, comparison) \ |
1546 COMPARISON_OP(name, comparison) \ |
1488 CASE(_if_acmp##name): { \ |
1547 CASE(_if_acmp##name): { \ |
1489 int skip = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1)) \ |
1548 const bool cmp = (STACK_OBJECT(-2) comparison STACK_OBJECT(-1)); \ |
|
1549 int skip = cmp \ |
1490 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1550 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1491 address branch_pc = pc; \ |
1551 address branch_pc = pc; \ |
|
1552 /* Profile branch. */ \ |
|
1553 BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp); \ |
1492 UPDATE_PC_AND_TOS(skip, -2); \ |
1554 UPDATE_PC_AND_TOS(skip, -2); \ |
1493 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1555 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1494 CONTINUE; \ |
1556 CONTINUE; \ |
1495 } |
1557 } |
1496 |
1558 |
1497 #define NULL_COMPARISON_NOT_OP(name) \ |
1559 #define NULL_COMPARISON_NOT_OP(name) \ |
1498 CASE(_if##name): { \ |
1560 CASE(_if##name): { \ |
1499 int skip = (!(STACK_OBJECT(-1) == NULL)) \ |
1561 const bool cmp = (!(STACK_OBJECT(-1) == NULL)); \ |
|
1562 int skip = cmp \ |
1500 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1563 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1501 address branch_pc = pc; \ |
1564 address branch_pc = pc; \ |
|
1565 /* Profile branch. */ \ |
|
1566 BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp); \ |
1502 UPDATE_PC_AND_TOS(skip, -1); \ |
1567 UPDATE_PC_AND_TOS(skip, -1); \ |
1503 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1568 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1504 CONTINUE; \ |
1569 CONTINUE; \ |
1505 } |
1570 } |
1506 |
1571 |
1507 #define NULL_COMPARISON_OP(name) \ |
1572 #define NULL_COMPARISON_OP(name) \ |
1508 CASE(_if##name): { \ |
1573 CASE(_if##name): { \ |
1509 int skip = ((STACK_OBJECT(-1) == NULL)) \ |
1574 const bool cmp = ((STACK_OBJECT(-1) == NULL)); \ |
|
1575 int skip = cmp \ |
1510 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1576 ? (int16_t)Bytes::get_Java_u2(pc + 1) : 3; \ |
1511 address branch_pc = pc; \ |
1577 address branch_pc = pc; \ |
|
1578 /* Profile branch. */ \ |
|
1579 BI_PROFILE_UPDATE_BRANCH(/*is_taken=*/cmp); \ |
1512 UPDATE_PC_AND_TOS(skip, -1); \ |
1580 UPDATE_PC_AND_TOS(skip, -1); \ |
1513 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1581 DO_BACKEDGE_CHECKS(skip, branch_pc); \ |
1514 CONTINUE; \ |
1582 CONTINUE; \ |
1515 } |
1583 } |
1516 COMPARISON_OP(lt, <); |
1584 COMPARISON_OP(lt, <); |
1529 int32_t key = STACK_INT(-1); |
1597 int32_t key = STACK_INT(-1); |
1530 int32_t low = Bytes::get_Java_u4((address)&lpc[1]); |
1598 int32_t low = Bytes::get_Java_u4((address)&lpc[1]); |
1531 int32_t high = Bytes::get_Java_u4((address)&lpc[2]); |
1599 int32_t high = Bytes::get_Java_u4((address)&lpc[2]); |
1532 int32_t skip; |
1600 int32_t skip; |
1533 key -= low; |
1601 key -= low; |
1534 skip = ((uint32_t) key > (uint32_t)(high - low)) |
1602 if (((uint32_t) key > (uint32_t)(high - low))) { |
1535 ? Bytes::get_Java_u4((address)&lpc[0]) |
1603 key = -1; |
1536 : Bytes::get_Java_u4((address)&lpc[key + 3]); |
1604 skip = Bytes::get_Java_u4((address)&lpc[0]); |
1537 // Does this really need a full backedge check (osr?) |
1605 } else { |
|
1606 skip = Bytes::get_Java_u4((address)&lpc[key + 3]); |
|
1607 } |
|
1608 // Profile switch. |
|
1609 BI_PROFILE_UPDATE_SWITCH(/*switch_index=*/key); |
|
1610 // Does this really need a full backedge check (osr)? |
1538 address branch_pc = pc; |
1611 address branch_pc = pc; |
1539 UPDATE_PC_AND_TOS(skip, -1); |
1612 UPDATE_PC_AND_TOS(skip, -1); |
1540 DO_BACKEDGE_CHECKS(skip, branch_pc); |
1613 DO_BACKEDGE_CHECKS(skip, branch_pc); |
1541 CONTINUE; |
1614 CONTINUE; |
1542 } |
1615 } |
1543 |
1616 |
1544 /* Goto pc whose table entry matches specified key */ |
1617 /* Goto pc whose table entry matches specified key. */ |
1545 |
1618 |
1546 CASE(_lookupswitch): { |
1619 CASE(_lookupswitch): { |
1547 jint* lpc = (jint*)VMalignWordUp(pc+1); |
1620 jint* lpc = (jint*)VMalignWordUp(pc+1); |
1548 int32_t key = STACK_INT(-1); |
1621 int32_t key = STACK_INT(-1); |
1549 int32_t skip = Bytes::get_Java_u4((address) lpc); /* default amount */ |
1622 int32_t skip = Bytes::get_Java_u4((address) lpc); /* default amount */ |
|
1623 // Remember index. |
|
1624 int index = -1; |
|
1625 int newindex = 0; |
1550 int32_t npairs = Bytes::get_Java_u4((address) &lpc[1]); |
1626 int32_t npairs = Bytes::get_Java_u4((address) &lpc[1]); |
1551 while (--npairs >= 0) { |
1627 while (--npairs >= 0) { |
1552 lpc += 2; |
1628 lpc += 2; |
1553 if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) { |
1629 if (key == (int32_t)Bytes::get_Java_u4((address)lpc)) { |
1554 skip = Bytes::get_Java_u4((address)&lpc[1]); |
1630 skip = Bytes::get_Java_u4((address)&lpc[1]); |
1555 break; |
1631 index = newindex; |
1556 } |
1632 break; |
1557 } |
1633 } |
|
1634 newindex += 1; |
|
1635 } |
|
1636 // Profile switch. |
|
1637 BI_PROFILE_UPDATE_SWITCH(/*switch_index=*/index); |
1558 address branch_pc = pc; |
1638 address branch_pc = pc; |
1559 UPDATE_PC_AND_TOS(skip, -1); |
1639 UPDATE_PC_AND_TOS(skip, -1); |
1560 DO_BACKEDGE_CHECKS(skip, branch_pc); |
1640 DO_BACKEDGE_CHECKS(skip, branch_pc); |
1561 CONTINUE; |
1641 CONTINUE; |
1562 } |
1642 } |
1637 char message[jintAsStringSize]; \ |
1717 char message[jintAsStringSize]; \ |
1638 CHECK_NULL(arrObj); \ |
1718 CHECK_NULL(arrObj); \ |
1639 if ((uint32_t)index >= (uint32_t)arrObj->length()) { \ |
1719 if ((uint32_t)index >= (uint32_t)arrObj->length()) { \ |
1640 sprintf(message, "%d", index); \ |
1720 sprintf(message, "%d", index); \ |
1641 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \ |
1721 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), \ |
1642 message); \ |
1722 message, note_rangeCheck_trap); \ |
1643 } |
1723 } |
1644 |
1724 |
1645 /* 32-bit loads. These handle conversion from < 32-bit types */ |
1725 /* 32-bit loads. These handle conversion from < 32-bit types */ |
1646 #define ARRAY_LOADTO32(T, T2, format, stackRes, extra) \ |
1726 #define ARRAY_LOADTO32(T, T2, format, stackRes, extra) \ |
1647 { \ |
1727 { \ |
1711 VERIFY_OOP(rhsObject); |
1791 VERIFY_OOP(rhsObject); |
1712 ARRAY_INTRO( -3); |
1792 ARRAY_INTRO( -3); |
1713 // arrObj, index are set |
1793 // arrObj, index are set |
1714 if (rhsObject != NULL) { |
1794 if (rhsObject != NULL) { |
1715 /* Check assignability of rhsObject into arrObj */ |
1795 /* Check assignability of rhsObject into arrObj */ |
1716 Klass* rhsKlassOop = rhsObject->klass(); // EBX (subclass) |
1796 Klass* rhsKlass = rhsObject->klass(); // EBX (subclass) |
1717 Klass* elemKlassOop = ObjArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX |
1797 Klass* elemKlass = ObjArrayKlass::cast(arrObj->klass())->element_klass(); // superklass EAX |
1718 // |
1798 // |
1719 // Check for compatibilty. This check must not GC!! |
1799 // Check for compatibilty. This check must not GC!! |
1720 // Seems way more expensive now that we must dispatch |
1800 // Seems way more expensive now that we must dispatch |
1721 // |
1801 // |
1722 if (rhsKlassOop != elemKlassOop && !rhsKlassOop->is_subtype_of(elemKlassOop)) { // ebx->is... |
1802 if (rhsKlass != elemKlass && !rhsKlass->is_subtype_of(elemKlass)) { // ebx->is... |
1723 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), ""); |
1803 // Decrement counter if subtype check failed. |
1724 } |
1804 BI_PROFILE_SUBTYPECHECK_FAILED(rhsKlass); |
|
1805 VM_JAVA_ERROR(vmSymbols::java_lang_ArrayStoreException(), "", note_arrayCheck_trap); |
|
1806 } |
|
1807 // Profile checkcast with null_seen and receiver. |
|
1808 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/false, rhsKlass); |
|
1809 } else { |
|
1810 // Profile checkcast with null_seen and receiver. |
|
1811 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/true, NULL); |
1725 } |
1812 } |
1726 ((objArrayOopDesc *) arrObj)->obj_at_put(index, rhsObject); |
1813 ((objArrayOopDesc *) arrObj)->obj_at_put(index, rhsObject); |
1727 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); |
1814 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -3); |
1728 } |
1815 } |
1729 CASE(_bastore): |
1816 CASE(_bastore): |
2117 // If the TLAB isn't pre-zeroed then we'll have to do it |
2204 // If the TLAB isn't pre-zeroed then we'll have to do it |
2118 bool need_zero = !ZeroTLAB; |
2205 bool need_zero = !ZeroTLAB; |
2119 if (UseTLAB) { |
2206 if (UseTLAB) { |
2120 result = (oop) THREAD->tlab().allocate(obj_size); |
2207 result = (oop) THREAD->tlab().allocate(obj_size); |
2121 } |
2208 } |
|
2209 // Disable non-TLAB-based fast-path, because profiling requires that all |
|
2210 // allocations go through InterpreterRuntime::_new() if THREAD->tlab().allocate |
|
2211 // returns NULL. |
|
2212 #ifndef CC_INTERP_PROFILE |
2122 if (result == NULL) { |
2213 if (result == NULL) { |
2123 need_zero = true; |
2214 need_zero = true; |
2124 // Try allocate in shared eden |
2215 // Try allocate in shared eden |
2125 retry: |
2216 retry: |
2126 HeapWord* compare_to = *Universe::heap()->top_addr(); |
2217 HeapWord* compare_to = *Universe::heap()->top_addr(); |
2127 HeapWord* new_top = compare_to + obj_size; |
2218 HeapWord* new_top = compare_to + obj_size; |
2128 if (new_top <= *Universe::heap()->end_addr()) { |
2219 if (new_top <= *Universe::heap()->end_addr()) { |
2129 if (Atomic::cmpxchg_ptr(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) { |
2220 if (Atomic::cmpxchg_ptr(new_top, Universe::heap()->top_addr(), compare_to) != compare_to) { |
2130 goto retry; |
2221 goto retry; |
2131 } |
2222 } |
2132 result = (oop) compare_to; |
2223 result = (oop) compare_to; |
2133 } |
2224 } |
2134 } |
2225 } |
|
2226 #endif |
2135 if (result != NULL) { |
2227 if (result != NULL) { |
2136 // Initialize object (if nonzero size and need) and then the header |
2228 // Initialize object (if nonzero size and need) and then the header |
2137 if (need_zero ) { |
2229 if (need_zero ) { |
2138 HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize; |
2230 HeapWord* to_zero = (HeapWord*) result + sizeof(oopDesc) / oopSize; |
2139 obj_size -= sizeof(oopDesc) / oopSize; |
2231 obj_size -= sizeof(oopDesc) / oopSize; |
2185 } |
2277 } |
2186 CASE(_checkcast): |
2278 CASE(_checkcast): |
2187 if (STACK_OBJECT(-1) != NULL) { |
2279 if (STACK_OBJECT(-1) != NULL) { |
2188 VERIFY_OOP(STACK_OBJECT(-1)); |
2280 VERIFY_OOP(STACK_OBJECT(-1)); |
2189 u2 index = Bytes::get_Java_u2(pc+1); |
2281 u2 index = Bytes::get_Java_u2(pc+1); |
2190 if (ProfileInterpreter) { |
|
2191 // needs Profile_checkcast QQQ |
|
2192 ShouldNotReachHere(); |
|
2193 } |
|
2194 // Constant pool may have actual klass or unresolved klass. If it is |
2282 // Constant pool may have actual klass or unresolved klass. If it is |
2195 // unresolved we must resolve it |
2283 // unresolved we must resolve it. |
2196 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { |
2284 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { |
2197 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); |
2285 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); |
2198 } |
2286 } |
2199 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
2287 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
2200 Klass* objKlassOop = STACK_OBJECT(-1)->klass(); //ebx |
2288 Klass* objKlass = STACK_OBJECT(-1)->klass(); // ebx |
2201 // |
2289 // |
2202 // Check for compatibilty. This check must not GC!! |
2290 // Check for compatibilty. This check must not GC!! |
2203 // Seems way more expensive now that we must dispatch |
2291 // Seems way more expensive now that we must dispatch. |
2204 // |
2292 // |
2205 if (objKlassOop != klassOf && |
2293 if (objKlass != klassOf && !objKlass->is_subtype_of(klassOf)) { |
2206 !objKlassOop->is_subtype_of(klassOf)) { |
2294 // Decrement counter at checkcast. |
|
2295 BI_PROFILE_SUBTYPECHECK_FAILED(objKlass); |
2207 ResourceMark rm(THREAD); |
2296 ResourceMark rm(THREAD); |
2208 const char* objName = objKlassOop->external_name(); |
2297 const char* objName = objKlass->external_name(); |
2209 const char* klassName = klassOf->external_name(); |
2298 const char* klassName = klassOf->external_name(); |
2210 char* message = SharedRuntime::generate_class_cast_message( |
2299 char* message = SharedRuntime::generate_class_cast_message( |
2211 objName, klassName); |
2300 objName, klassName); |
2212 VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message); |
2301 VM_JAVA_ERROR(vmSymbols::java_lang_ClassCastException(), message, note_classCheck_trap); |
2213 } |
2302 } |
|
2303 // Profile checkcast with null_seen and receiver. |
|
2304 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/false, objKlass); |
2214 } else { |
2305 } else { |
2215 if (UncommonNullCast) { |
2306 // Profile checkcast with null_seen and receiver. |
2216 // istate->method()->set_null_cast_seen(); |
2307 BI_PROFILE_UPDATE_CHECKCAST(/*null_seen=*/true, NULL); |
2217 // [RGV] Not sure what to do here! |
|
2218 |
|
2219 } |
|
2220 } |
2308 } |
2221 UPDATE_PC_AND_CONTINUE(3); |
2309 UPDATE_PC_AND_CONTINUE(3); |
2222 |
2310 |
2223 CASE(_instanceof): |
2311 CASE(_instanceof): |
2224 if (STACK_OBJECT(-1) == NULL) { |
2312 if (STACK_OBJECT(-1) == NULL) { |
2225 SET_STACK_INT(0, -1); |
2313 SET_STACK_INT(0, -1); |
|
2314 // Profile instanceof with null_seen and receiver. |
|
2315 BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/true, NULL); |
2226 } else { |
2316 } else { |
2227 VERIFY_OOP(STACK_OBJECT(-1)); |
2317 VERIFY_OOP(STACK_OBJECT(-1)); |
2228 u2 index = Bytes::get_Java_u2(pc+1); |
2318 u2 index = Bytes::get_Java_u2(pc+1); |
2229 // Constant pool may have actual klass or unresolved klass. If it is |
2319 // Constant pool may have actual klass or unresolved klass. If it is |
2230 // unresolved we must resolve it |
2320 // unresolved we must resolve it. |
2231 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { |
2321 if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { |
2232 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); |
2322 CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); |
2233 } |
2323 } |
2234 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
2324 Klass* klassOf = (Klass*) METHOD->constants()->slot_at(index).get_klass(); |
2235 Klass* objKlassOop = STACK_OBJECT(-1)->klass(); |
2325 Klass* objKlass = STACK_OBJECT(-1)->klass(); |
2236 // |
2326 // |
2237 // Check for compatibilty. This check must not GC!! |
2327 // Check for compatibilty. This check must not GC!! |
2238 // Seems way more expensive now that we must dispatch |
2328 // Seems way more expensive now that we must dispatch. |
2239 // |
2329 // |
2240 if ( objKlassOop == klassOf || objKlassOop->is_subtype_of(klassOf)) { |
2330 if ( objKlass == klassOf || objKlass->is_subtype_of(klassOf)) { |
2241 SET_STACK_INT(1, -1); |
2331 SET_STACK_INT(1, -1); |
2242 } else { |
2332 } else { |
2243 SET_STACK_INT(0, -1); |
2333 SET_STACK_INT(0, -1); |
2244 } |
2334 // Decrement counter at checkcast. |
|
2335 BI_PROFILE_SUBTYPECHECK_FAILED(objKlass); |
|
2336 } |
|
2337 // Profile instanceof with null_seen and receiver. |
|
2338 BI_PROFILE_UPDATE_INSTANCEOF(/*null_seen=*/false, objKlass); |
2245 } |
2339 } |
2246 UPDATE_PC_AND_CONTINUE(3); |
2340 UPDATE_PC_AND_CONTINUE(3); |
2247 |
2341 |
2248 CASE(_ldc_w): |
2342 CASE(_ldc_w): |
2249 CASE(_ldc): |
2343 CASE(_ldc): |
2441 if (cache->is_forced_virtual()) { |
2541 if (cache->is_forced_virtual()) { |
2442 Method* callee; |
2542 Method* callee; |
2443 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2543 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2444 if (cache->is_vfinal()) { |
2544 if (cache->is_vfinal()) { |
2445 callee = cache->f2_as_vfinal_method(); |
2545 callee = cache->f2_as_vfinal_method(); |
|
2546 // Profile 'special case of invokeinterface' final call. |
|
2547 BI_PROFILE_UPDATE_FINALCALL(); |
2446 } else { |
2548 } else { |
2447 // get receiver |
2549 // Get receiver. |
2448 int parms = cache->parameter_size(); |
2550 int parms = cache->parameter_size(); |
2449 // Same comments as invokevirtual apply here |
2551 // Same comments as invokevirtual apply here. |
2450 VERIFY_OOP(STACK_OBJECT(-parms)); |
2552 oop rcvr = STACK_OBJECT(-parms); |
2451 InstanceKlass* rcvrKlass = (InstanceKlass*) |
2553 VERIFY_OOP(rcvr); |
2452 STACK_OBJECT(-parms)->klass(); |
2554 InstanceKlass* rcvrKlass = (InstanceKlass*)rcvr->klass(); |
2453 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
2555 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
|
2556 // Profile 'special case of invokeinterface' virtual call. |
|
2557 BI_PROFILE_UPDATE_VIRTUALCALL(rcvr->klass()); |
2454 } |
2558 } |
2455 istate->set_callee(callee); |
2559 istate->set_callee(callee); |
2456 istate->set_callee_entry_point(callee->from_interpreted_entry()); |
2560 istate->set_callee_entry_point(callee->from_interpreted_entry()); |
2457 #ifdef VM_JVMTI |
2561 #ifdef VM_JVMTI |
2458 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { |
2562 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { |
2479 } |
2583 } |
2480 // If the interface isn't found, this class doesn't implement this |
2584 // If the interface isn't found, this class doesn't implement this |
2481 // interface. The link resolver checks this but only for the first |
2585 // interface. The link resolver checks this but only for the first |
2482 // time this interface is called. |
2586 // time this interface is called. |
2483 if (i == int2->itable_length()) { |
2587 if (i == int2->itable_length()) { |
2484 VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), ""); |
2588 VM_JAVA_ERROR(vmSymbols::java_lang_IncompatibleClassChangeError(), "", note_no_trap); |
2485 } |
2589 } |
2486 int mindex = cache->f2_as_index(); |
2590 int mindex = cache->f2_as_index(); |
2487 itableMethodEntry* im = ki->first_method_entry(rcvr->klass()); |
2591 itableMethodEntry* im = ki->first_method_entry(rcvr->klass()); |
2488 callee = im[mindex].method(); |
2592 callee = im[mindex].method(); |
2489 if (callee == NULL) { |
2593 if (callee == NULL) { |
2490 VM_JAVA_ERROR(vmSymbols::java_lang_AbstractMethodError(), ""); |
2594 VM_JAVA_ERROR(vmSymbols::java_lang_AbstractMethodError(), "", note_no_trap); |
2491 } |
2595 } |
|
2596 |
|
2597 // Profile virtual call. |
|
2598 BI_PROFILE_UPDATE_VIRTUALCALL(rcvr->klass()); |
2492 |
2599 |
2493 istate->set_callee(callee); |
2600 istate->set_callee(callee); |
2494 istate->set_callee_entry_point(callee->from_interpreted_entry()); |
2601 istate->set_callee_entry_point(callee->from_interpreted_entry()); |
2495 #ifdef VM_JVMTI |
2602 #ifdef VM_JVMTI |
2496 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { |
2603 if (JvmtiExport::can_post_interpreter_events() && THREAD->is_interp_only_mode()) { |
2519 istate->set_msg(call_method); |
2626 istate->set_msg(call_method); |
2520 { |
2627 { |
2521 Method* callee; |
2628 Method* callee; |
2522 if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { |
2629 if ((Bytecodes::Code)opcode == Bytecodes::_invokevirtual) { |
2523 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2630 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2524 if (cache->is_vfinal()) callee = cache->f2_as_vfinal_method(); |
2631 if (cache->is_vfinal()) { |
2525 else { |
2632 callee = cache->f2_as_vfinal_method(); |
|
2633 // Profile final call. |
|
2634 BI_PROFILE_UPDATE_FINALCALL(); |
|
2635 } else { |
2526 // get receiver |
2636 // get receiver |
2527 int parms = cache->parameter_size(); |
2637 int parms = cache->parameter_size(); |
2528 // this works but needs a resourcemark and seems to create a vtable on every call: |
2638 // this works but needs a resourcemark and seems to create a vtable on every call: |
2529 // Method* callee = rcvr->klass()->vtable()->method_at(cache->f2_as_index()); |
2639 // Method* callee = rcvr->klass()->vtable()->method_at(cache->f2_as_index()); |
2530 // |
2640 // |
2531 // this fails with an assert |
2641 // this fails with an assert |
2532 // InstanceKlass* rcvrKlass = InstanceKlass::cast(STACK_OBJECT(-parms)->klass()); |
2642 // InstanceKlass* rcvrKlass = InstanceKlass::cast(STACK_OBJECT(-parms)->klass()); |
2533 // but this works |
2643 // but this works |
2534 VERIFY_OOP(STACK_OBJECT(-parms)); |
2644 oop rcvr = STACK_OBJECT(-parms); |
2535 InstanceKlass* rcvrKlass = (InstanceKlass*) STACK_OBJECT(-parms)->klass(); |
2645 VERIFY_OOP(rcvr); |
|
2646 InstanceKlass* rcvrKlass = (InstanceKlass*)rcvr->klass(); |
2536 /* |
2647 /* |
2537 Executing this code in java.lang.String: |
2648 Executing this code in java.lang.String: |
2538 public String(char value[]) { |
2649 public String(char value[]) { |
2539 this.count = value.length; |
2650 this.count = value.length; |
2540 this.value = (char[])value.clone(); |
2651 this.value = (char[])value.clone(); |
3006 // |
3132 // |
3007 // See if we are returning any exception |
3133 // See if we are returning any exception |
3008 // A pending exception that was pending prior to a possible popping frame |
3134 // A pending exception that was pending prior to a possible popping frame |
3009 // overrides the popping frame. |
3135 // overrides the popping frame. |
3010 // |
3136 // |
3011 assert(!suppress_error || suppress_error && illegal_state_oop() == NULL, "Error was not suppressed"); |
3137 assert(!suppress_error || (suppress_error && illegal_state_oop() == NULL), "Error was not suppressed"); |
3012 if (illegal_state_oop() != NULL || original_exception() != NULL) { |
3138 if (illegal_state_oop() != NULL || original_exception() != NULL) { |
3013 // inform the frame manager we have no result |
3139 // Inform the frame manager we have no result. |
3014 istate->set_msg(throwing_exception); |
3140 istate->set_msg(throwing_exception); |
3015 if (illegal_state_oop() != NULL) |
3141 if (illegal_state_oop() != NULL) |
3016 THREAD->set_pending_exception(illegal_state_oop(), NULL, 0); |
3142 THREAD->set_pending_exception(illegal_state_oop(), NULL, 0); |
3017 else |
3143 else |
3018 THREAD->set_pending_exception(original_exception(), NULL, 0); |
3144 THREAD->set_pending_exception(original_exception(), NULL, 0); |