Mercurial > hg > truffle
comparison src/share/vm/code/nmethod.cpp @ 13086:096c224171c4
Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 20 Nov 2013 00:10:38 +0100 |
parents | ca33948fb804 78da3894b86f |
children | f9f4503a4ab5 |
comparison
equal
deleted
inserted
replaced
12782:92b7ec34ddfa | 13086:096c224171c4 |
---|---|
125 // NMethod statistics | 125 // NMethod statistics |
126 // They are printed under various flags, including: | 126 // They are printed under various flags, including: |
127 // PrintC1Statistics, PrintOptoStatistics, LogVMOutput, and LogCompilation. | 127 // PrintC1Statistics, PrintOptoStatistics, LogVMOutput, and LogCompilation. |
128 // (In the latter two cases, they like other stats are printed to the log only.) | 128 // (In the latter two cases, they like other stats are printed to the log only.) |
129 | 129 |
130 #ifndef PRODUCT | |
130 // These variables are put into one block to reduce relocations | 131 // These variables are put into one block to reduce relocations |
131 // and make it simpler to print from the debugger. | 132 // and make it simpler to print from the debugger. |
132 struct java_nmethod_stats_struct { | 133 struct java_nmethod_stats_struct { |
133 int nmethod_count; | 134 int nmethod_count; |
134 int total_size; | 135 int total_size; |
252 #endif | 253 #endif |
253 { | 254 { |
254 unknown_java_nmethod_stats.note_nmethod(nm); | 255 unknown_java_nmethod_stats.note_nmethod(nm); |
255 } | 256 } |
256 } | 257 } |
257 | 258 #endif |
258 | 259 |
259 //--------------------------------------------------------------------------------- | 260 //--------------------------------------------------------------------------------- |
260 | 261 |
261 | 262 |
262 ExceptionCache::ExceptionCache(Handle exception, address pc, address handler) { | 263 ExceptionCache::ExceptionCache(Handle exception, address pc, address handler) { |
555 nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, | 556 nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, |
556 compile_id, &offsets, | 557 compile_id, &offsets, |
557 code_buffer, frame_size, | 558 code_buffer, frame_size, |
558 basic_lock_owner_sp_offset, | 559 basic_lock_owner_sp_offset, |
559 basic_lock_sp_offset, oop_maps); | 560 basic_lock_sp_offset, oop_maps); |
560 if (nm != NULL) native_nmethod_stats.note_native_nmethod(nm); | 561 NOT_PRODUCT(if (nm != NULL) note_java_nmethod(nm)); |
561 if (PrintAssembly && nm != NULL) { | 562 if (PrintAssembly && nm != NULL) { |
562 Disassembler::decode(nm); | 563 Disassembler::decode(nm); |
563 } | 564 } |
564 } | 565 } |
565 // verify nmethod | 566 // verify nmethod |
591 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); | 592 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
592 | 593 |
593 nm = new (nmethod_size) nmethod(method(), nmethod_size, | 594 nm = new (nmethod_size) nmethod(method(), nmethod_size, |
594 &offsets, code_buffer, frame_size); | 595 &offsets, code_buffer, frame_size); |
595 | 596 |
596 if (nm != NULL) note_java_nmethod(nm); | 597 NOT_PRODUCT(if (nm != NULL) note_java_nmethod(nm)); |
597 if (PrintAssembly && nm != NULL) { | 598 if (PrintAssembly && nm != NULL) { |
598 Disassembler::decode(nm); | 599 Disassembler::decode(nm); |
599 } | 600 } |
600 } | 601 } |
601 // verify nmethod | 602 // verify nmethod |
675 } | 676 } |
676 | 677 |
677 // record this nmethod as dependent on this klass | 678 // record this nmethod as dependent on this klass |
678 InstanceKlass::cast(klass)->add_dependent_nmethod(nm); | 679 InstanceKlass::cast(klass)->add_dependent_nmethod(nm); |
679 } | 680 } |
680 } | 681 NOT_PRODUCT(if (nm != NULL) note_java_nmethod(nm)); |
681 if (nm != NULL) note_java_nmethod(nm); | 682 if (PrintAssembly) { |
682 if (PrintAssembly && nm != NULL) { | 683 Disassembler::decode(nm); |
683 Disassembler::decode(nm); | 684 } |
684 } | 685 } |
685 } | 686 } |
686 | 687 // Do verification and logging outside CodeCache_lock. |
687 // verify nmethod | |
688 debug_only(if (nm) nm->verify();) // might block | |
689 | |
690 if (nm != NULL) { | 688 if (nm != NULL) { |
689 // Safepoints in nmethod::verify aren't allowed because nm hasn't been installed yet. | |
690 DEBUG_ONLY(nm->verify();) | |
691 nm->log_new_nmethod(); | 691 nm->log_new_nmethod(); |
692 } | 692 } |
693 | |
694 // done | |
695 return nm; | 693 return nm; |
696 } | 694 } |
697 | 695 |
698 | 696 |
699 // For native wrappers | 697 // For native wrappers |
1367 // The Method* is gone at this point | 1365 // The Method* is gone at this point |
1368 assert(_method == NULL, "Tautology"); | 1366 assert(_method == NULL, "Tautology"); |
1369 | 1367 |
1370 set_osr_link(NULL); | 1368 set_osr_link(NULL); |
1371 //set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods | 1369 //set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods |
1372 NMethodSweeper::notify(); | 1370 NMethodSweeper::report_state_change(this); |
1373 } | 1371 } |
1374 | 1372 |
1375 void nmethod::invalidate_osr_method() { | 1373 void nmethod::invalidate_osr_method() { |
1376 assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); | 1374 assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod"); |
1377 // Remove from list of active nmethods | 1375 // Remove from list of active nmethods |
1401 if (PrintCompilation && _state != unloaded) { | 1399 if (PrintCompilation && _state != unloaded) { |
1402 print_on(tty, _state == zombie ? "made zombie" : "made not entrant"); | 1400 print_on(tty, _state == zombie ? "made zombie" : "made not entrant"); |
1403 } | 1401 } |
1404 } | 1402 } |
1405 | 1403 |
1406 // Common functionality for both make_not_entrant and make_zombie | 1404 /** |
1405 * Common functionality for both make_not_entrant and make_zombie | |
1406 */ | |
1407 bool nmethod::make_not_entrant_or_zombie(unsigned int state) { | 1407 bool nmethod::make_not_entrant_or_zombie(unsigned int state) { |
1408 assert(state == zombie || state == not_entrant, "must be zombie or not_entrant"); | 1408 assert(state == zombie || state == not_entrant, "must be zombie or not_entrant"); |
1409 assert(!is_zombie(), "should not already be a zombie"); | 1409 assert(!is_zombie(), "should not already be a zombie"); |
1410 | 1410 |
1411 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. | 1411 // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below. |
1532 if (TraceCreateZombies) { | 1532 if (TraceCreateZombies) { |
1533 ResourceMark m; | 1533 ResourceMark m; |
1534 tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", this, this->method()->name_and_sig_as_C_string(), (state == not_entrant) ? "not entrant" : "zombie"); | 1534 tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", this, this->method()->name_and_sig_as_C_string(), (state == not_entrant) ? "not entrant" : "zombie"); |
1535 } | 1535 } |
1536 | 1536 |
1537 // Make sweeper aware that there is a zombie method that needs to be removed | 1537 NMethodSweeper::report_state_change(this); |
1538 NMethodSweeper::notify(); | |
1539 | |
1540 return true; | 1538 return true; |
1541 } | 1539 } |
1542 | 1540 |
1543 void nmethod::flush() { | 1541 void nmethod::flush() { |
1544 // Note that there are no valid oops in the nmethod anymore. | 1542 // Note that there are no valid oops in the nmethod anymore. |
2531 verify_scopes(); | 2529 verify_scopes(); |
2532 } | 2530 } |
2533 | 2531 |
2534 | 2532 |
2535 void nmethod::verify_interrupt_point(address call_site) { | 2533 void nmethod::verify_interrupt_point(address call_site) { |
2536 // This code does not work in release mode since | 2534 // Verify IC only when nmethod installation is finished. |
2537 // owns_lock only is available in debug mode. | 2535 bool is_installed = (method()->code() == this) // nmethod is in state 'alive' and installed |
2538 CompiledIC* ic = NULL; | 2536 || !this->is_in_use(); // nmethod is installed, but not in 'alive' state |
2539 Thread *cur = Thread::current(); | 2537 if (is_installed) { |
2540 if (CompiledIC_lock->owner() == cur || | 2538 Thread *cur = Thread::current(); |
2541 ((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) && | 2539 if (CompiledIC_lock->owner() == cur || |
2542 SafepointSynchronize::is_at_safepoint())) { | 2540 ((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) && |
2543 ic = CompiledIC_at(this, call_site); | 2541 SafepointSynchronize::is_at_safepoint())) { |
2544 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); | 2542 CompiledIC_at(this, call_site); |
2545 } else { | 2543 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); |
2546 MutexLocker ml_verify (CompiledIC_lock); | 2544 } else { |
2547 ic = CompiledIC_at(this, call_site); | 2545 MutexLocker ml_verify (CompiledIC_lock); |
2548 } | 2546 CompiledIC_at(this, call_site); |
2549 PcDesc* pd = pc_desc_at(ic->end_of_call()); | 2547 } |
2548 } | |
2549 | |
2550 PcDesc* pd = pc_desc_at(nativeCall_at(call_site)->return_address()); | |
2550 assert(pd != NULL, "PcDesc must exist"); | 2551 assert(pd != NULL, "PcDesc must exist"); |
2551 for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(), | 2552 for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(), |
2552 pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), | 2553 pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), |
2553 pd->return_oop()); | 2554 pd->return_oop()); |
2554 !sd->is_top(); sd = sd->sender()) { | 2555 !sd->is_top(); sd = sd->sender()) { |
3074 | 3075 |
3075 void nmethod::print_nul_chk_table() { | 3076 void nmethod::print_nul_chk_table() { |
3076 ImplicitExceptionTable(this).print(code_begin()); | 3077 ImplicitExceptionTable(this).print(code_begin()); |
3077 } | 3078 } |
3078 | 3079 |
3079 #endif // PRODUCT | |
3080 | |
3081 void nmethod::print_statistics() { | 3080 void nmethod::print_statistics() { |
3082 ttyLocker ttyl; | 3081 ttyLocker ttyl; |
3083 if (xtty != NULL) xtty->head("statistics type='nmethod'"); | 3082 if (xtty != NULL) xtty->head("statistics type='nmethod'"); |
3084 native_nmethod_stats.print_native_nmethod_stats(); | 3083 native_nmethod_stats.print_native_nmethod_stats(); |
3085 #ifdef COMPILER1 | 3084 #ifdef COMPILER1 |
3095 DebugInformationRecorder::print_statistics(); | 3094 DebugInformationRecorder::print_statistics(); |
3096 pc_nmethod_stats.print_pc_stats(); | 3095 pc_nmethod_stats.print_pc_stats(); |
3097 Dependencies::print_statistics(); | 3096 Dependencies::print_statistics(); |
3098 if (xtty != NULL) xtty->tail("statistics"); | 3097 if (xtty != NULL) xtty->tail("statistics"); |
3099 } | 3098 } |
3099 #endif // PRODUCT |