< prev index next >

src/hotspot/share/code/nmethod.cpp

Print this page

 441 // Fill in default values for various flag fields
 442 void nmethod::init_defaults() {
 443   _state                      = not_installed;
 444   _has_flushed_dependencies   = 0;
 445   _load_reported              = false; // jvmti state
 446 
 447   _oops_do_mark_link       = NULL;
 448   _osr_link                = NULL;
 449 #if INCLUDE_RTM_OPT
 450   _rtm_state               = NoRTM;
 451 #endif
 452 }
 453 
 454 nmethod* nmethod::new_native_nmethod(const methodHandle& method,
 455   int compile_id,
 456   CodeBuffer *code_buffer,
 457   int vep_offset,
 458   int frame_complete,
 459   int frame_size,
 460   ByteSize basic_lock_owner_sp_offset,
 461   ByteSize basic_lock_sp_offset,
 462   OopMapSet* oop_maps,
 463   int exception_handler) {
 464   code_buffer->finalize_oop_references(method);
 465   // create nmethod
 466   nmethod* nm = NULL;
 467   int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod));
 468   {
 469     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 470 
 471     CodeOffsets offsets;
 472     offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
 473     offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
 474     if (exception_handler != -1) {
 475       offsets.set_value(CodeOffsets::Exceptions, exception_handler);
 476     }
 477     nm = new (native_nmethod_size, CompLevel_none)
 478     nmethod(method(), compiler_none, native_nmethod_size,
 479             compile_id, &offsets,
 480             code_buffer, frame_size,
 481             basic_lock_owner_sp_offset,
 482             basic_lock_sp_offset,
 483             oop_maps);
 484     NOT_PRODUCT(if (nm != NULL)  native_nmethod_stats.note_native_nmethod(nm));
 485   }
 486 
 487   if (nm != NULL) {
 488     // verify nmethod
 489     debug_only(nm->verify();) // might block
 490 
 491     nm->log_new_nmethod();
 492   }
 493   return nm;
 494 }
 495 
 496 nmethod* nmethod::new_nmethod(const methodHandle& method,
 497   int compile_id,
 498   int entry_bci,
 499   CodeOffsets* offsets,
 500   int orig_pc_offset,
 501   DebugInformationRecorder* debug_info,
 502   Dependencies* dependencies,

 585   }
 586   // Do verification and logging outside CodeCache_lock.
 587   if (nm != NULL) {
 588     // Safepoints in nmethod::verify aren't allowed because nm hasn't been installed yet.
 589     DEBUG_ONLY(nm->verify();)
 590     nm->log_new_nmethod();
 591   }
 592   return nm;
 593 }
 594 
 595 // For native wrappers
 596 nmethod::nmethod(
 597   Method* method,
 598   CompilerType type,
 599   int nmethod_size,
 600   int compile_id,
 601   CodeOffsets* offsets,
 602   CodeBuffer* code_buffer,
 603   int frame_size,
 604   ByteSize basic_lock_owner_sp_offset,
 605   ByteSize basic_lock_sp_offset,
 606   OopMapSet* oop_maps )
 607   : CompiledMethod(method, "native nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, true),
 608   _unlinked_next(NULL),
 609   _native_receiver_sp_offset(basic_lock_owner_sp_offset),
 610   _native_basic_lock_sp_offset(basic_lock_sp_offset),
 611   _is_unloading_state(0)
 612 {
 613   {
 614     int scopes_data_offset   = 0;
 615     int deoptimize_offset    = 0;
 616     int deoptimize_mh_offset = 0;
 617 
 618     debug_only(NoSafepointVerifier nsv;)
 619     assert_locked_or_safepoint(CodeCache_lock);
 620 
 621     init_defaults();
 622     _comp_level              = CompLevel_none;
 623     _entry_bci               = InvocationEntryBci;
 624     // We have no exception handler or deopt handler make the
 625     // values something that will never match a pc like the nmethod vtable entry
 626     _exception_offset        = 0;
 627     _orig_pc_offset          = 0;
 628     _gc_epoch                = CodeCache::gc_epoch();
 629 
 630     _consts_offset           = data_offset();

 725   CodeOffsets* offsets,
 726   int orig_pc_offset,
 727   DebugInformationRecorder* debug_info,
 728   Dependencies* dependencies,
 729   CodeBuffer *code_buffer,
 730   int frame_size,
 731   OopMapSet* oop_maps,
 732   ExceptionHandlerTable* handler_table,
 733   ImplicitExceptionTable* nul_chk_table,
 734   AbstractCompiler* compiler,
 735   CompLevel comp_level
 736 #if INCLUDE_JVMCI
 737   , char* speculations,
 738   int speculations_len,
 739   int jvmci_data_size
 740 #endif
 741   )
 742   : CompiledMethod(method, "nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, true),
 743   _unlinked_next(NULL),
 744   _native_receiver_sp_offset(in_ByteSize(-1)),
 745   _native_basic_lock_sp_offset(in_ByteSize(-1)),
 746   _is_unloading_state(0)
 747 {
 748   assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR");
 749   {
 750     debug_only(NoSafepointVerifier nsv;)
 751     assert_locked_or_safepoint(CodeCache_lock);
 752 
 753     _deopt_handler_begin = (address) this;
 754     _deopt_mh_handler_begin = (address) this;
 755 
 756     init_defaults();
 757     _entry_bci               = entry_bci;
 758     _compile_id              = compile_id;
 759     _comp_level              = comp_level;
 760     _orig_pc_offset          = orig_pc_offset;
 761     _gc_epoch                = CodeCache::gc_epoch();
 762 
 763     // Section offsets
 764     _consts_offset           = content_offset()      + code_buffer->total_offset_of(code_buffer->consts());
 765     _stub_offset             = content_offset()      + code_buffer->total_offset_of(code_buffer->stubs());

 441 // Fill in default values for various flag fields
 442 void nmethod::init_defaults() {
 443   _state                      = not_installed;
 444   _has_flushed_dependencies   = 0;
 445   _load_reported              = false; // jvmti state
 446 
 447   _oops_do_mark_link       = NULL;
 448   _osr_link                = NULL;
 449 #if INCLUDE_RTM_OPT
 450   _rtm_state               = NoRTM;
 451 #endif
 452 }
 453 
 454 nmethod* nmethod::new_native_nmethod(const methodHandle& method,
 455   int compile_id,
 456   CodeBuffer *code_buffer,
 457   int vep_offset,
 458   int frame_complete,
 459   int frame_size,
 460   ByteSize basic_lock_owner_sp_offset,

 461   OopMapSet* oop_maps,
 462   int exception_handler) {
 463   code_buffer->finalize_oop_references(method);
 464   // create nmethod
 465   nmethod* nm = NULL;
 466   int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod));
 467   {
 468     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
 469 
 470     CodeOffsets offsets;
 471     offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
 472     offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
 473     if (exception_handler != -1) {
 474       offsets.set_value(CodeOffsets::Exceptions, exception_handler);
 475     }
 476     nm = new (native_nmethod_size, CompLevel_none)
 477     nmethod(method(), compiler_none, native_nmethod_size,
 478             compile_id, &offsets,
 479             code_buffer, frame_size,
 480             basic_lock_owner_sp_offset,

 481             oop_maps);
 482     NOT_PRODUCT(if (nm != NULL)  native_nmethod_stats.note_native_nmethod(nm));
 483   }
 484 
 485   if (nm != NULL) {
 486     // verify nmethod
 487     debug_only(nm->verify();) // might block
 488 
 489     nm->log_new_nmethod();
 490   }
 491   return nm;
 492 }
 493 
 494 nmethod* nmethod::new_nmethod(const methodHandle& method,
 495   int compile_id,
 496   int entry_bci,
 497   CodeOffsets* offsets,
 498   int orig_pc_offset,
 499   DebugInformationRecorder* debug_info,
 500   Dependencies* dependencies,

 583   }
 584   // Do verification and logging outside CodeCache_lock.
 585   if (nm != NULL) {
 586     // Safepoints in nmethod::verify aren't allowed because nm hasn't been installed yet.
 587     DEBUG_ONLY(nm->verify();)
 588     nm->log_new_nmethod();
 589   }
 590   return nm;
 591 }
 592 
 593 // For native wrappers
 594 nmethod::nmethod(
 595   Method* method,
 596   CompilerType type,
 597   int nmethod_size,
 598   int compile_id,
 599   CodeOffsets* offsets,
 600   CodeBuffer* code_buffer,
 601   int frame_size,
 602   ByteSize basic_lock_owner_sp_offset,

 603   OopMapSet* oop_maps )
 604   : CompiledMethod(method, "native nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, true),
 605   _unlinked_next(NULL),
 606   _native_receiver_sp_offset(basic_lock_owner_sp_offset),

 607   _is_unloading_state(0)
 608 {
 609   {
 610     int scopes_data_offset   = 0;
 611     int deoptimize_offset    = 0;
 612     int deoptimize_mh_offset = 0;
 613 
 614     debug_only(NoSafepointVerifier nsv;)
 615     assert_locked_or_safepoint(CodeCache_lock);
 616 
 617     init_defaults();
 618     _comp_level              = CompLevel_none;
 619     _entry_bci               = InvocationEntryBci;
 620     // We have no exception handler or deopt handler make the
 621     // values something that will never match a pc like the nmethod vtable entry
 622     _exception_offset        = 0;
 623     _orig_pc_offset          = 0;
 624     _gc_epoch                = CodeCache::gc_epoch();
 625 
 626     _consts_offset           = data_offset();

 721   CodeOffsets* offsets,
 722   int orig_pc_offset,
 723   DebugInformationRecorder* debug_info,
 724   Dependencies* dependencies,
 725   CodeBuffer *code_buffer,
 726   int frame_size,
 727   OopMapSet* oop_maps,
 728   ExceptionHandlerTable* handler_table,
 729   ImplicitExceptionTable* nul_chk_table,
 730   AbstractCompiler* compiler,
 731   CompLevel comp_level
 732 #if INCLUDE_JVMCI
 733   , char* speculations,
 734   int speculations_len,
 735   int jvmci_data_size
 736 #endif
 737   )
 738   : CompiledMethod(method, "nmethod", type, nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false, true),
 739   _unlinked_next(NULL),
 740   _native_receiver_sp_offset(in_ByteSize(-1)),

 741   _is_unloading_state(0)
 742 {
 743   assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR");
 744   {
 745     debug_only(NoSafepointVerifier nsv;)
 746     assert_locked_or_safepoint(CodeCache_lock);
 747 
 748     _deopt_handler_begin = (address) this;
 749     _deopt_mh_handler_begin = (address) this;
 750 
 751     init_defaults();
 752     _entry_bci               = entry_bci;
 753     _compile_id              = compile_id;
 754     _comp_level              = comp_level;
 755     _orig_pc_offset          = orig_pc_offset;
 756     _gc_epoch                = CodeCache::gc_epoch();
 757 
 758     // Section offsets
 759     _consts_offset           = content_offset()      + code_buffer->total_offset_of(code_buffer->consts());
 760     _stub_offset             = content_offset()      + code_buffer->total_offset_of(code_buffer->stubs());
< prev index next >