500 // create nmethod |
499 // create nmethod |
501 nmethod* nm = NULL; |
500 nmethod* nm = NULL; |
502 { |
501 { |
503 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
502 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
504 int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); |
503 int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); |
505 CodeOffsets offsets; |
504 if (CodeCache::has_space(native_nmethod_size)) { |
506 offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); |
505 CodeOffsets offsets; |
507 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
506 offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); |
508 nm = new (native_nmethod_size) |
507 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
509 nmethod(method(), native_nmethod_size, compile_id, &offsets, |
508 nm = new (native_nmethod_size) nmethod(method(), native_nmethod_size, |
510 code_buffer, frame_size, |
509 compile_id, &offsets, |
511 basic_lock_owner_sp_offset, basic_lock_sp_offset, |
510 code_buffer, frame_size, |
512 oop_maps); |
511 basic_lock_owner_sp_offset, |
513 NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); |
512 basic_lock_sp_offset, oop_maps); |
514 if (PrintAssembly && nm != NULL) |
513 NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm)); |
515 Disassembler::decode(nm); |
514 if (PrintAssembly && nm != NULL) |
|
515 Disassembler::decode(nm); |
|
516 } |
516 } |
517 } |
517 // verify nmethod |
518 // verify nmethod |
518 debug_only(if (nm) nm->verify();) // might block |
519 debug_only(if (nm) nm->verify();) // might block |
519 |
520 |
520 if (nm != NULL) { |
521 if (nm != NULL) { |
535 // create nmethod |
536 // create nmethod |
536 nmethod* nm = NULL; |
537 nmethod* nm = NULL; |
537 { |
538 { |
538 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
539 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
539 int nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); |
540 int nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); |
540 CodeOffsets offsets; |
541 if (CodeCache::has_space(nmethod_size)) { |
541 offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); |
542 CodeOffsets offsets; |
542 offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); |
543 offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); |
543 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
544 offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset); |
544 |
545 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
545 nm = new (nmethod_size) nmethod(method(), nmethod_size, &offsets, code_buffer, frame_size); |
546 |
546 |
547 nm = new (nmethod_size) nmethod(method(), nmethod_size, |
547 NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); |
548 &offsets, code_buffer, frame_size); |
548 if (PrintAssembly && nm != NULL) |
549 |
549 Disassembler::decode(nm); |
550 NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm)); |
|
551 if (PrintAssembly && nm != NULL) |
|
552 Disassembler::decode(nm); |
|
553 } |
550 } |
554 } |
551 // verify nmethod |
555 // verify nmethod |
552 debug_only(if (nm) nm->verify();) // might block |
556 debug_only(if (nm) nm->verify();) // might block |
553 |
557 |
554 if (nm != NULL) { |
558 if (nm != NULL) { |
585 + adjust_pcs_size(debug_info->pcs_size()) |
589 + adjust_pcs_size(debug_info->pcs_size()) |
586 + round_to(dependencies->size_in_bytes() , oopSize) |
590 + round_to(dependencies->size_in_bytes() , oopSize) |
587 + round_to(handler_table->size_in_bytes(), oopSize) |
591 + round_to(handler_table->size_in_bytes(), oopSize) |
588 + round_to(nul_chk_table->size_in_bytes(), oopSize) |
592 + round_to(nul_chk_table->size_in_bytes(), oopSize) |
589 + round_to(debug_info->data_size() , oopSize); |
593 + round_to(debug_info->data_size() , oopSize); |
590 nm = new (nmethod_size) |
594 if (CodeCache::has_space(nmethod_size)) { |
|
595 nm = new (nmethod_size) |
591 nmethod(method(), nmethod_size, compile_id, entry_bci, offsets, |
596 nmethod(method(), nmethod_size, compile_id, entry_bci, offsets, |
592 orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, |
597 orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, |
593 oop_maps, |
598 oop_maps, |
594 handler_table, |
599 handler_table, |
595 nul_chk_table, |
600 nul_chk_table, |
596 compiler, |
601 compiler, |
597 comp_level); |
602 comp_level); |
|
603 } |
598 if (nm != NULL) { |
604 if (nm != NULL) { |
599 // To make dependency checking during class loading fast, record |
605 // To make dependency checking during class loading fast, record |
600 // the nmethod dependencies in the classes it is dependent on. |
606 // the nmethod dependencies in the classes it is dependent on. |
601 // This allows the dependency checking code to simply walk the |
607 // This allows the dependency checking code to simply walk the |
602 // class hierarchy above the loaded class, checking only nmethods |
608 // class hierarchy above the loaded class, checking only nmethods |
791 } |
797 } |
792 } |
798 } |
793 #endif // def HAVE_DTRACE_H |
799 #endif // def HAVE_DTRACE_H |
794 |
800 |
795 void* nmethod::operator new(size_t size, int nmethod_size) { |
801 void* nmethod::operator new(size_t size, int nmethod_size) { |
796 // Always leave some room in the CodeCache for I2C/C2I adapters |
802 void* alloc = CodeCache::allocate(nmethod_size); |
797 if (CodeCache::largest_free_block() < CodeCacheMinimumFreeSpace) return NULL; |
803 guarantee(alloc != NULL, "CodeCache should have enough space"); |
798 return CodeCache::allocate(nmethod_size); |
804 return alloc; |
799 } |
805 } |
800 |
806 |
801 |
807 |
802 nmethod::nmethod( |
808 nmethod::nmethod( |
803 Method* method, |
809 Method* method, |