Mercurial > hg > graal-compiler
comparison src/share/vm/interpreter/bytecodeInterpreter.cpp @ 14420:abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
Summary: Implement profiling for c2 jit compilation. Also enable new cppInterpreter features.
Reviewed-by: kvn
author | goetz |
---|---|
date | Sun, 15 Sep 2013 15:28:58 +0200 |
parents | f3806614494a |
children | 018b357638aa |
comparison
equal
deleted
inserted
replaced
14419:7373e44fa207 | 14420:abe03600372a |
---|---|
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)); \ |
353 istate->set_osr_entry(osr_nmethod->osr_entry()); \ | 371 istate->set_osr_entry(osr_nmethod->osr_entry()); \ |
354 return; \ | 372 return; \ |
355 } \ | 373 } \ |
356 } \ | 374 } \ |
357 } /* UseCompiler ... */ \ | 375 } /* UseCompiler ... */ \ |
358 mcs->invocation_counter()->increment(); \ | |
359 SAFEPOINT; \ | 376 SAFEPOINT; \ |
360 } | 377 } |
361 | 378 |
362 /* | 379 /* |
363 * For those opcodes that need to have a GC point on a backwards branch | 380 * For those opcodes that need to have a GC point on a backwards branch |
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; |
801 case popping_frame: { | 825 case popping_frame: { |
802 // returned from a java call to pop the frame, restart the call | 826 // returned from a java call to pop the frame, restart the call |
803 // clear the message so we don't confuse ourselves later | 827 // clear the message so we don't confuse ourselves later |
804 assert(THREAD->pop_frame_in_process(), "wrong frame pop state"); | 828 assert(THREAD->pop_frame_in_process(), "wrong frame pop state"); |
805 istate->set_msg(no_request); | 829 istate->set_msg(no_request); |
830 if (_compiling) { | |
831 // Set MDX back to the ProfileData of the invoke bytecode that will be | |
832 // restarted. | |
833 SET_MDX(NULL); | |
834 BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception); | |
835 } | |
806 THREAD->clr_pop_frame_in_process(); | 836 THREAD->clr_pop_frame_in_process(); |
807 goto run; | 837 goto run; |
808 } | 838 } |
809 | 839 |
810 case method_resume: { | 840 case method_resume: { |
834 } | 864 } |
835 | 865 |
836 if (THREAD->has_pending_exception()) goto handle_exception; | 866 if (THREAD->has_pending_exception()) goto handle_exception; |
837 // Update the pc by the saved amount of the invoke bytecode size | 867 // Update the pc by the saved amount of the invoke bytecode size |
838 UPDATE_PC(istate->bcp_advance()); | 868 UPDATE_PC(istate->bcp_advance()); |
869 | |
870 if (_compiling) { | |
871 // Get or create profile data. Check for pending (async) exceptions. | |
872 BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception); | |
873 } | |
839 goto run; | 874 goto run; |
840 } | 875 } |
841 | 876 |
842 case deopt_resume2: { | 877 case deopt_resume2: { |
843 // Returned from an opcode that will reexecute. Deopt was | 878 // Returned from an opcode that will reexecute. Deopt was |
844 // a result of a PopFrame request. | 879 // a result of a PopFrame request. |
845 // | 880 // |
881 | |
882 if (_compiling) { | |
883 // Get or create profile data. Check for pending (async) exceptions. | |
884 BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception); | |
885 } | |
846 goto run; | 886 goto run; |
847 } | 887 } |
848 | 888 |
849 case deopt_resume: { | 889 case deopt_resume: { |
850 // Returned from an opcode that has completed. The stack has | 890 // Returned from an opcode that has completed. The stack has |
863 // this will do the right thing even if an exception is pending. | 903 // this will do the right thing even if an exception is pending. |
864 goto handle_return; | 904 goto handle_return; |
865 } | 905 } |
866 UPDATE_PC(Bytecodes::length_at(METHOD, pc)); | 906 UPDATE_PC(Bytecodes::length_at(METHOD, pc)); |
867 if (THREAD->has_pending_exception()) goto handle_exception; | 907 if (THREAD->has_pending_exception()) goto handle_exception; |
908 | |
909 if (_compiling) { | |
910 // Get or create profile data. Check for pending (async) exceptions. | |
911 BI_PROFILE_GET_OR_CREATE_METHOD_DATA(handle_exception); | |
912 } | |
868 goto run; | 913 goto run; |
869 } | 914 } |
870 case got_monitors: { | 915 case got_monitors: { |
871 // continue locking now that we have a monitor to use | 916 // continue locking now that we have a monitor to use |
872 // we expect to find newly allocated monitor at the "top" of the monitor stack. | 917 // we expect to find newly allocated monitor at the "top" of the monitor stack. |
1113 | 1158 |
1114 CASE(_wide): { | 1159 CASE(_wide): { |
1115 uint16_t reg = Bytes::get_Java_u2(pc + 2); | 1160 uint16_t reg = Bytes::get_Java_u2(pc + 2); |
1116 | 1161 |
1117 opcode = pc[1]; | 1162 opcode = pc[1]; |
1163 | |
1164 // Wide and it's sub-bytecode are counted as separate instructions. If we | |
1165 // don't account for this here, the bytecode trace skips the next bytecode. | |
1166 DO_UPDATE_INSTRUCTION_COUNT(opcode); | |
1167 | |
1118 switch(opcode) { | 1168 switch(opcode) { |
1119 case Bytecodes::_aload: | 1169 case Bytecodes::_aload: |
1120 VERIFY_OOP(LOCALS_OBJECT(reg)); | 1170 VERIFY_OOP(LOCALS_OBJECT(reg)); |
1121 SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0); | 1171 SET_STACK_OBJECT(LOCALS_OBJECT(reg), 0); |
1122 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1); | 1172 UPDATE_PC_AND_TOS_AND_CONTINUE(4, 1); |
1156 // Be nice to see what this generates.... QQQ | 1206 // Be nice to see what this generates.... QQQ |
1157 SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg); | 1207 SET_LOCALS_INT(LOCALS_INT(reg) + offset, reg); |
1158 UPDATE_PC_AND_CONTINUE(6); | 1208 UPDATE_PC_AND_CONTINUE(6); |
1159 } | 1209 } |
1160 case Bytecodes::_ret: | 1210 case Bytecodes::_ret: |
1211 // Profile ret. | |
1212 BI_PROFILE_UPDATE_RET(/*bci=*/((int)(intptr_t)(LOCALS_ADDR(reg)))); | |
1213 // Now, update the pc. | |
1161 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg)); | 1214 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(reg)); |
1162 UPDATE_PC_AND_CONTINUE(0); | 1215 UPDATE_PC_AND_CONTINUE(0); |
1163 default: | 1216 default: |
1164 VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode"); | 1217 VM_JAVA_ERROR(vmSymbols::java_lang_InternalError(), "undefined opcode", note_no_trap); |
1165 } | 1218 } |
1166 } | 1219 } |
1167 | 1220 |
1168 | 1221 |
1169 #undef OPC_STORE_n | 1222 #undef OPC_STORE_n |
1240 #undef OPC_INT_BINARY | 1293 #undef OPC_INT_BINARY |
1241 #define OPC_INT_BINARY(opcname, opname, test) \ | 1294 #define OPC_INT_BINARY(opcname, opname, test) \ |
1242 CASE(_i##opcname): \ | 1295 CASE(_i##opcname): \ |
1243 if (test && (STACK_INT(-1) == 0)) { \ | 1296 if (test && (STACK_INT(-1) == 0)) { \ |
1244 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ | 1297 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ |
1245 "/ by zero"); \ | 1298 "/ by zero", note_div0Check_trap); \ |
1246 } \ | 1299 } \ |
1247 SET_STACK_INT(VMint##opname(STACK_INT(-2), \ | 1300 SET_STACK_INT(VMint##opname(STACK_INT(-2), \ |
1248 STACK_INT(-1)), \ | 1301 STACK_INT(-1)), \ |
1249 -2); \ | 1302 -2); \ |
1250 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ | 1303 UPDATE_PC_AND_TOS_AND_CONTINUE(1, -1); \ |
1252 { \ | 1305 { \ |
1253 if (test) { \ | 1306 if (test) { \ |
1254 jlong l1 = STACK_LONG(-1); \ | 1307 jlong l1 = STACK_LONG(-1); \ |
1255 if (VMlongEqz(l1)) { \ | 1308 if (VMlongEqz(l1)) { \ |
1256 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ | 1309 VM_JAVA_ERROR(vmSymbols::java_lang_ArithmeticException(), \ |
1257 "/ by long zero"); \ | 1310 "/ by long zero", note_div0Check_trap); \ |
1258 } \ | 1311 } \ |
1259 } \ | 1312 } \ |
1260 /* First long at (-1,-2) next long at (-3,-4) */ \ | 1313 /* First long at (-1,-2) next long at (-3,-4) */ \ |
1261 SET_STACK_LONG(VMlong##opname(STACK_LONG(-3), \ | 1314 SET_STACK_LONG(VMlong##opname(STACK_LONG(-3), \ |
1262 STACK_LONG(-1)), \ | 1315 STACK_LONG(-1)), \ |
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): |
2382 istate->set_msg(call_method); | 2476 istate->set_msg(call_method); |
2383 istate->set_callee(method); | 2477 istate->set_callee(method); |
2384 istate->set_callee_entry_point(method->from_interpreted_entry()); | 2478 istate->set_callee_entry_point(method->from_interpreted_entry()); |
2385 istate->set_bcp_advance(5); | 2479 istate->set_bcp_advance(5); |
2386 | 2480 |
2481 // Invokedynamic has got a call counter, just like an invokestatic -> increment! | |
2482 BI_PROFILE_UPDATE_CALL(); | |
2483 | |
2387 UPDATE_PC_AND_RETURN(0); // I'll be back... | 2484 UPDATE_PC_AND_RETURN(0); // I'll be back... |
2388 } | 2485 } |
2389 | 2486 |
2390 CASE(_invokehandle): { | 2487 CASE(_invokehandle): { |
2391 | 2488 |
2413 | 2510 |
2414 istate->set_msg(call_method); | 2511 istate->set_msg(call_method); |
2415 istate->set_callee(method); | 2512 istate->set_callee(method); |
2416 istate->set_callee_entry_point(method->from_interpreted_entry()); | 2513 istate->set_callee_entry_point(method->from_interpreted_entry()); |
2417 istate->set_bcp_advance(3); | 2514 istate->set_bcp_advance(3); |
2515 | |
2516 // Invokehandle has got a call counter, just like a final call -> increment! | |
2517 BI_PROFILE_UPDATE_FINALCALL(); | |
2418 | 2518 |
2419 UPDATE_PC_AND_RETURN(0); // I'll be back... | 2519 UPDATE_PC_AND_RETURN(0); // I'll be back... |
2420 } | 2520 } |
2421 | 2521 |
2422 CASE(_invokeinterface): { | 2522 CASE(_invokeinterface): { |
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(); |
2548 because rcvr->klass()->oop_is_instance() == 0 | 2659 because rcvr->klass()->oop_is_instance() == 0 |
2549 However it seems to have a vtable in the right location. Huh? | 2660 However it seems to have a vtable in the right location. Huh? |
2550 | 2661 |
2551 */ | 2662 */ |
2552 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; | 2663 callee = (Method*) rcvrKlass->start_of_vtable()[ cache->f2_as_index()]; |
2664 // Profile virtual call. | |
2665 BI_PROFILE_UPDATE_VIRTUALCALL(rcvr->klass()); | |
2553 } | 2666 } |
2554 } else { | 2667 } else { |
2555 if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { | 2668 if ((Bytecodes::Code)opcode == Bytecodes::_invokespecial) { |
2556 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); | 2669 CHECK_NULL(STACK_OBJECT(-(cache->parameter_size()))); |
2557 } | 2670 } |
2558 callee = cache->f1_as_method(); | 2671 callee = cache->f1_as_method(); |
2672 | |
2673 // Profile call. | |
2674 BI_PROFILE_UPDATE_CALL(); | |
2559 } | 2675 } |
2560 | 2676 |
2561 istate->set_callee(callee); | 2677 istate->set_callee(callee); |
2562 istate->set_callee_entry_point(callee->from_interpreted_entry()); | 2678 istate->set_callee_entry_point(callee->from_interpreted_entry()); |
2563 #ifdef VM_JVMTI | 2679 #ifdef VM_JVMTI |
2605 } | 2721 } |
2606 | 2722 |
2607 CASE(_goto): | 2723 CASE(_goto): |
2608 { | 2724 { |
2609 int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1); | 2725 int16_t offset = (int16_t)Bytes::get_Java_u2(pc + 1); |
2726 // Profile jump. | |
2727 BI_PROFILE_UPDATE_JUMP(); | |
2610 address branch_pc = pc; | 2728 address branch_pc = pc; |
2611 UPDATE_PC(offset); | 2729 UPDATE_PC(offset); |
2612 DO_BACKEDGE_CHECKS(offset, branch_pc); | 2730 DO_BACKEDGE_CHECKS(offset, branch_pc); |
2613 CONTINUE; | 2731 CONTINUE; |
2614 } | 2732 } |
2621 } | 2739 } |
2622 | 2740 |
2623 CASE(_goto_w): | 2741 CASE(_goto_w): |
2624 { | 2742 { |
2625 int32_t offset = Bytes::get_Java_u4(pc + 1); | 2743 int32_t offset = Bytes::get_Java_u4(pc + 1); |
2744 // Profile jump. | |
2745 BI_PROFILE_UPDATE_JUMP(); | |
2626 address branch_pc = pc; | 2746 address branch_pc = pc; |
2627 UPDATE_PC(offset); | 2747 UPDATE_PC(offset); |
2628 DO_BACKEDGE_CHECKS(offset, branch_pc); | 2748 DO_BACKEDGE_CHECKS(offset, branch_pc); |
2629 CONTINUE; | 2749 CONTINUE; |
2630 } | 2750 } |
2631 | 2751 |
2632 /* return from a jsr or jsr_w */ | 2752 /* return from a jsr or jsr_w */ |
2633 | 2753 |
2634 CASE(_ret): { | 2754 CASE(_ret): { |
2755 // Profile ret. | |
2756 BI_PROFILE_UPDATE_RET(/*bci=*/((int)(intptr_t)(LOCALS_ADDR(pc[1])))); | |
2757 // Now, update the pc. | |
2635 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1])); | 2758 pc = istate->method()->code_base() + (intptr_t)(LOCALS_ADDR(pc[1])); |
2636 UPDATE_PC_AND_CONTINUE(0); | 2759 UPDATE_PC_AND_CONTINUE(0); |
2637 } | 2760 } |
2638 | 2761 |
2639 /* debugger breakpoint */ | 2762 /* debugger breakpoint */ |
2711 istate->bcp() - (intptr_t)METHOD->code_base(), | 2834 istate->bcp() - (intptr_t)METHOD->code_base(), |
2712 continuation_bci, THREAD); | 2835 continuation_bci, THREAD); |
2713 } | 2836 } |
2714 // for AbortVMOnException flag | 2837 // for AbortVMOnException flag |
2715 NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); | 2838 NOT_PRODUCT(Exceptions::debug_check_abort(except_oop)); |
2839 | |
2840 // Update profiling data. | |
2841 BI_PROFILE_ALIGN_TO_CURRENT_BCI(); | |
2716 goto run; | 2842 goto run; |
2717 } | 2843 } |
2718 if (TraceExceptions) { | 2844 if (TraceExceptions) { |
2719 ttyLocker ttyl; | 2845 ttyLocker ttyl; |
2720 ResourceMark rm; | 2846 ResourceMark rm; |
2918 // and must use first monitor slot. | 3044 // and must use first monitor slot. |
2919 // | 3045 // |
2920 oop rcvr = base->obj(); | 3046 oop rcvr = base->obj(); |
2921 if (rcvr == NULL) { | 3047 if (rcvr == NULL) { |
2922 if (!suppress_error) { | 3048 if (!suppress_error) { |
2923 VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), ""); | 3049 VM_JAVA_ERROR_NO_JUMP(vmSymbols::java_lang_NullPointerException(), "", note_nullCheck_trap); |
2924 illegal_state_oop = THREAD->pending_exception(); | 3050 illegal_state_oop = THREAD->pending_exception(); |
2925 THREAD->clear_pending_exception(); | 3051 THREAD->clear_pending_exception(); |
2926 } | 3052 } |
2927 } else if (UseHeavyMonitors) { | 3053 } else if (UseHeavyMonitors) { |
2928 { | 3054 { |
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); |