670 _stub_offset = data_offset();
671 _oops_offset = data_offset();
672 _metadata_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize);
673 _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize);
674 _scopes_pcs_offset = _scopes_data_offset;
675 _dependencies_offset = _scopes_pcs_offset;
676 _handler_table_offset = _dependencies_offset;
677 _nul_chk_table_offset = _handler_table_offset;
678 _nmethod_end_offset = _nul_chk_table_offset;
679 _compile_id = compile_id;
680 _comp_level = CompLevel_none;
681 _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
682 _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
683 _osr_entry_point = NULL;
684 _exception_cache = NULL;
685 _pc_desc_cache.reset_to(NULL);
686
687 code_buffer->copy_values_to(this);
688 if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
689 CodeCache::add_scavenge_root_nmethod(this);
690 }
691 debug_only(verify_scavenge_root_oops());
692 CodeCache::commit(this);
693 }
694
695 if (PrintNativeNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
696 ttyLocker ttyl; // keep the following output all in one block
697 // This output goes directly to the tty, not the compiler log.
698 // To enable tools to match it up with the compilation activity,
699 // be sure to tag this tty output with the compile ID.
700 if (xtty != NULL) {
701 xtty->begin_head("print_native_nmethod");
702 xtty->method(_method);
703 xtty->stamp();
704 xtty->end_head(" address='" INTPTR_FORMAT "'", (intptr_t) this);
705 }
706 // print the header part first
707 print();
708 // then print the requested information
709 if (PrintNativeNMethods) {
864 _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize);
865
866 _scopes_pcs_offset = _scopes_data_offset + round_to(debug_info->data_size (), oopSize);
867 _dependencies_offset = _scopes_pcs_offset + adjust_pcs_size(debug_info->pcs_size());
868 _handler_table_offset = _dependencies_offset + round_to(dependencies->size_in_bytes (), oopSize);
869 _nul_chk_table_offset = _handler_table_offset + round_to(handler_table->size_in_bytes(), oopSize);
870 _nmethod_end_offset = _nul_chk_table_offset + round_to(nul_chk_table->size_in_bytes(), oopSize);
871
872 _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
873 _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
874 _osr_entry_point = code_begin() + offsets->value(CodeOffsets::OSR_Entry);
875 _exception_cache = NULL;
876 _pc_desc_cache.reset_to(scopes_pcs_begin());
877
878 // Copy contents of ScopeDescRecorder to nmethod
879 code_buffer->copy_values_to(this);
880 debug_info->copy_to(this);
881 dependencies->copy_to(this);
882 if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
883 CodeCache::add_scavenge_root_nmethod(this);
884 }
885 debug_only(verify_scavenge_root_oops());
886
887 CodeCache::commit(this);
888
889 // Copy contents of ExceptionHandlerTable to nmethod
890 handler_table->copy_to(this);
891 nul_chk_table->copy_to(this);
892
893 // we use the information of entry points to find out if a method is
894 // static or non static
895 assert(compiler->is_c2() ||
896 _method->is_static() == (entry_point() == _verified_entry_point),
897 " entry points must be same for static methods and vice versa");
898 }
899
900 bool printnmethods = PrintNMethods
901 || CompilerOracle::should_print(_method)
902 || CompilerOracle::has_option_string(_method, "PrintNMethods");
903 if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
1320
1321 if (_state == state) {
1322 // another thread already performed this transition so nothing
1323 // to do, but return false to indicate this.
1324 return false;
1325 }
1326
1327 // The caller can be calling the method statically or through an inline
1328 // cache call.
1329 if (!is_osr_method() && !is_not_entrant()) {
1330 NativeJump::patch_verified_entry(entry_point(), verified_entry_point(),
1331 SharedRuntime::get_handle_wrong_method_stub());
1332 }
1333
1334 if (is_in_use()) {
1335 // It's a true state change, so mark the method as decompiled.
1336 // Do it only for transition from alive.
1337 inc_decompile_count();
1338 }
1339
1340 // Change state
1341 _state = state;
1342
1343 // Log the transition once
1344 log_state_change();
1345
1346 // Remove nmethod from method.
1347 // We need to check if both the _code and _from_compiled_code_entry_point
1348 // refer to this nmethod because there is a race in setting these two fields
1349 // in Method* as seen in bugid 4947125.
1350 // If the vep() points to the zombie nmethod, the memory for the nmethod
1351 // could be flushed and the compiler and vtable stubs could still call
1352 // through it.
1353 if (method() != NULL && (method()->code() == this ||
1354 method()->from_compiled_entry() == verified_entry_point())) {
1355 HandleMark hm;
1356 method()->clear_code();
1357 }
1358
1359 if (state == not_entrant) {
|
670 _stub_offset = data_offset();
671 _oops_offset = data_offset();
672 _metadata_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize);
673 _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize);
674 _scopes_pcs_offset = _scopes_data_offset;
675 _dependencies_offset = _scopes_pcs_offset;
676 _handler_table_offset = _dependencies_offset;
677 _nul_chk_table_offset = _handler_table_offset;
678 _nmethod_end_offset = _nul_chk_table_offset;
679 _compile_id = compile_id;
680 _comp_level = CompLevel_none;
681 _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
682 _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
683 _osr_entry_point = NULL;
684 _exception_cache = NULL;
685 _pc_desc_cache.reset_to(NULL);
686
687 code_buffer->copy_values_to(this);
688 if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
689 CodeCache::add_scavenge_root_nmethod(this);
690 Universe::heap()->register_nmethod(this);
691 }
692 debug_only(verify_scavenge_root_oops());
693 CodeCache::commit(this);
694 }
695
696 if (PrintNativeNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
697 ttyLocker ttyl; // keep the following output all in one block
698 // This output goes directly to the tty, not the compiler log.
699 // To enable tools to match it up with the compilation activity,
700 // be sure to tag this tty output with the compile ID.
701 if (xtty != NULL) {
702 xtty->begin_head("print_native_nmethod");
703 xtty->method(_method);
704 xtty->stamp();
705 xtty->end_head(" address='" INTPTR_FORMAT "'", (intptr_t) this);
706 }
707 // print the header part first
708 print();
709 // then print the requested information
710 if (PrintNativeNMethods) {
865 _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize);
866
867 _scopes_pcs_offset = _scopes_data_offset + round_to(debug_info->data_size (), oopSize);
868 _dependencies_offset = _scopes_pcs_offset + adjust_pcs_size(debug_info->pcs_size());
869 _handler_table_offset = _dependencies_offset + round_to(dependencies->size_in_bytes (), oopSize);
870 _nul_chk_table_offset = _handler_table_offset + round_to(handler_table->size_in_bytes(), oopSize);
871 _nmethod_end_offset = _nul_chk_table_offset + round_to(nul_chk_table->size_in_bytes(), oopSize);
872
873 _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
874 _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
875 _osr_entry_point = code_begin() + offsets->value(CodeOffsets::OSR_Entry);
876 _exception_cache = NULL;
877 _pc_desc_cache.reset_to(scopes_pcs_begin());
878
879 // Copy contents of ScopeDescRecorder to nmethod
880 code_buffer->copy_values_to(this);
881 debug_info->copy_to(this);
882 dependencies->copy_to(this);
883 if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
884 CodeCache::add_scavenge_root_nmethod(this);
885 Universe::heap()->register_nmethod(this);
886 }
887 debug_only(verify_scavenge_root_oops());
888
889 CodeCache::commit(this);
890
891 // Copy contents of ExceptionHandlerTable to nmethod
892 handler_table->copy_to(this);
893 nul_chk_table->copy_to(this);
894
895 // we use the information of entry points to find out if a method is
896 // static or non static
897 assert(compiler->is_c2() ||
898 _method->is_static() == (entry_point() == _verified_entry_point),
899 " entry points must be same for static methods and vice versa");
900 }
901
902 bool printnmethods = PrintNMethods
903 || CompilerOracle::should_print(_method)
904 || CompilerOracle::has_option_string(_method, "PrintNMethods");
905 if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
1322
1323 if (_state == state) {
1324 // another thread already performed this transition so nothing
1325 // to do, but return false to indicate this.
1326 return false;
1327 }
1328
1329 // The caller can be calling the method statically or through an inline
1330 // cache call.
1331 if (!is_osr_method() && !is_not_entrant()) {
1332 NativeJump::patch_verified_entry(entry_point(), verified_entry_point(),
1333 SharedRuntime::get_handle_wrong_method_stub());
1334 }
1335
1336 if (is_in_use()) {
1337 // It's a true state change, so mark the method as decompiled.
1338 // Do it only for transition from alive.
1339 inc_decompile_count();
1340 }
1341
1342 // If the state is becoming a zombie, unregister the nmethod with heap
1343 // This nmethod may have already been unloaded during a full GC.
1344 if ((state == zombie) && !is_unloaded()) {
1345 Universe::heap()->unregister_nmethod(this);
1346 }
1347
1348 // Change state
1349 _state = state;
1350
1351 // Log the transition once
1352 log_state_change();
1353
1354 // Remove nmethod from method.
1355 // We need to check if both the _code and _from_compiled_code_entry_point
1356 // refer to this nmethod because there is a race in setting these two fields
1357 // in Method* as seen in bugid 4947125.
1358 // If the vep() points to the zombie nmethod, the memory for the nmethod
1359 // could be flushed and the compiler and vtable stubs could still call
1360 // through it.
1361 if (method() != NULL && (method()->code() == this ||
1362 method()->from_compiled_entry() == verified_entry_point())) {
1363 HandleMark hm;
1364 method()->clear_code();
1365 }
1366
1367 if (state == not_entrant) {
|