comparison src/share/vm/code/nmethod.cpp @ 7000:bf2ea3ed3bce

Fixed nmethod not being unloaded after their classloader has been unloaded by initializing _graal_installed_code in an nmethod's constructor
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 21 Nov 2012 23:33:43 +0100
parents 679e6584c177
children 45029b3ac59f
comparison
equal deleted inserted replaced
6999:679e6584c177 7000:bf2ea3ed3bce
481 _scavenge_root_link = NULL; 481 _scavenge_root_link = NULL;
482 _scavenge_root_state = 0; 482 _scavenge_root_state = 0;
483 _saved_nmethod_link = NULL; 483 _saved_nmethod_link = NULL;
484 _compiler = NULL; 484 _compiler = NULL;
485 #ifdef GRAAL 485 #ifdef GRAAL
486 _graal_installed_code = (oop) Universe::non_oop_word(); 486 _graal_installed_code = NULL;
487 #endif 487 #endif
488 #ifdef HAVE_DTRACE_H 488 #ifdef HAVE_DTRACE_H
489 _trap_offset = 0; 489 _trap_offset = 0;
490 #endif // def HAVE_DTRACE_H 490 #endif // def HAVE_DTRACE_H
491 } 491 }
575 OopMapSet* oop_maps, 575 OopMapSet* oop_maps,
576 ExceptionHandlerTable* handler_table, 576 ExceptionHandlerTable* handler_table,
577 ImplicitExceptionTable* nul_chk_table, 577 ImplicitExceptionTable* nul_chk_table,
578 AbstractCompiler* compiler, 578 AbstractCompiler* compiler,
579 int comp_level 579 int comp_level
580 #ifdef GRAAL
581 , Handle installed_code
582 #endif
580 ) 583 )
581 { 584 {
582 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); 585 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR");
583 code_buffer->finalize_oop_references(method); 586 code_buffer->finalize_oop_references(method);
584 // create nmethod 587 // create nmethod
596 orig_pc_offset, debug_info, dependencies, code_buffer, frame_size, 599 orig_pc_offset, debug_info, dependencies, code_buffer, frame_size,
597 oop_maps, 600 oop_maps,
598 handler_table, 601 handler_table,
599 nul_chk_table, 602 nul_chk_table,
600 compiler, 603 compiler,
601 comp_level); 604 comp_level
605 #ifdef GRAAL
606 , installed_code
607 #endif
608 );
602 if (nm != NULL) { 609 if (nm != NULL) {
603 // To make dependency checking during class loading fast, record 610 // To make dependency checking during class loading fast, record
604 // the nmethod dependencies in the classes it is dependent on. 611 // the nmethod dependencies in the classes it is dependent on.
605 // This allows the dependency checking code to simply walk the 612 // This allows the dependency checking code to simply walk the
606 // class hierarchy above the loaded class, checking only nmethods 613 // class hierarchy above the loaded class, checking only nmethods
817 OopMapSet* oop_maps, 824 OopMapSet* oop_maps,
818 ExceptionHandlerTable* handler_table, 825 ExceptionHandlerTable* handler_table,
819 ImplicitExceptionTable* nul_chk_table, 826 ImplicitExceptionTable* nul_chk_table,
820 AbstractCompiler* compiler, 827 AbstractCompiler* compiler,
821 int comp_level 828 int comp_level
829 #ifdef GRAAL
830 , Handle installed_code
831 #endif
822 ) 832 )
823 : CodeBlob("nmethod", code_buffer, sizeof(nmethod), 833 : CodeBlob("nmethod", code_buffer, sizeof(nmethod),
824 nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps), 834 nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps),
825 _native_receiver_sp_offset(in_ByteSize(-1)), 835 _native_receiver_sp_offset(in_ByteSize(-1)),
826 _native_basic_lock_sp_offset(in_ByteSize(-1)) 836 _native_basic_lock_sp_offset(in_ByteSize(-1))
841 // Section offsets 851 // Section offsets
842 _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts()); 852 _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts());
843 _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs()); 853 _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs());
844 854
845 #ifdef GRAAL 855 #ifdef GRAAL
846 // graal produces no (!) stub section 856 _graal_installed_code = installed_code();
847 if (offsets->value(CodeOffsets::Exceptions) != -1) { 857
848 _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions); 858 // graal produces no (!) stub section
849 } else { 859 if (offsets->value(CodeOffsets::Exceptions) != -1) {
850 _exception_offset = -1; 860 _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions);
851 } 861 } else {
852 if (offsets->value(CodeOffsets::Deopt) != -1) { 862 _exception_offset = -1;
853 _deoptimize_offset = code_offset() + offsets->value(CodeOffsets::Deopt); 863 }
854 } else { 864 if (offsets->value(CodeOffsets::Deopt) != -1) {
855 _deoptimize_offset = -1; 865 _deoptimize_offset = code_offset() + offsets->value(CodeOffsets::Deopt);
856 } 866 } else {
857 if (offsets->value(CodeOffsets::DeoptMH) != -1) { 867 _deoptimize_offset = -1;
858 _deoptimize_mh_offset = code_offset() + offsets->value(CodeOffsets::DeoptMH); 868 }
859 } else { 869 if (offsets->value(CodeOffsets::DeoptMH) != -1) {
860 _deoptimize_mh_offset = -1; 870 _deoptimize_mh_offset = code_offset() + offsets->value(CodeOffsets::DeoptMH);
861 } 871 } else {
872 _deoptimize_mh_offset = -1;
873 }
862 #else 874 #else
863 // Exception handler and deopt handler are in the stub section 875 // Exception handler and deopt handler are in the stub section
864 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must be set"); 876 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must be set");
865 assert(offsets->value(CodeOffsets::Deopt ) != -1, "must be set"); 877 assert(offsets->value(CodeOffsets::Deopt ) != -1, "must be set");
866 878
1264 } 1276 }
1265 _method = NULL; // Clear the method of this dead nmethod 1277 _method = NULL; // Clear the method of this dead nmethod
1266 } 1278 }
1267 1279
1268 #ifdef GRAAL 1280 #ifdef GRAAL
1269 if (graal_installed_code() != NULL) { 1281 if (_graal_installed_code != NULL) {
1270 HotSpotInstalledCode::set_nmethod(_graal_installed_code, 0); 1282 HotSpotInstalledCode::set_nmethod(_graal_installed_code, 0);
1271 _graal_installed_code = NULL; 1283 _graal_installed_code = NULL;
1272 } 1284 }
1273 #endif 1285 #endif
1274 1286
1352 // to do, but return false to indicate this. 1364 // to do, but return false to indicate this.
1353 return false; 1365 return false;
1354 } 1366 }
1355 1367
1356 #ifdef GRAAL 1368 #ifdef GRAAL
1357 if (graal_installed_code() != NULL) { 1369 if (_graal_installed_code != NULL) {
1358 HotSpotInstalledCode::set_nmethod(_graal_installed_code, 0); 1370 HotSpotInstalledCode::set_nmethod(_graal_installed_code, 0);
1359 _graal_installed_code = NULL; 1371 _graal_installed_code = NULL;
1360 } 1372 }
1361 #endif 1373 #endif
1362 1374
1652 unloading_occurred = true; 1664 unloading_occurred = true;
1653 } 1665 }
1654 1666
1655 #ifdef GRAAL 1667 #ifdef GRAAL
1656 // Follow Graal method 1668 // Follow Graal method
1657 if (_graal_installed_code == Universe::non_oop_word()) {
1658 // May have not yet finished initializing a non-default nmethod
1659 return;
1660 }
1661 if (_graal_installed_code != NULL && can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { 1669 if (_graal_installed_code != NULL && can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) {
1662 return; 1670 return;
1663 } 1671 }
1664 #endif 1672 #endif
1665 1673
1881 // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. 1889 // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
1882 // (See comment above.) 1890 // (See comment above.)
1883 } 1891 }
1884 1892
1885 #ifdef GRAAL 1893 #ifdef GRAAL
1886 if (graal_installed_code() != NULL) { 1894 if (_graal_installed_code != NULL) {
1887 f->do_oop((oop*) &_graal_installed_code); 1895 f->do_oop((oop*) &_graal_installed_code);
1888 } 1896 }
1889 #endif 1897 #endif
1890 1898
1891 RelocIterator iter(this, low_boundary); 1899 RelocIterator iter(this, low_boundary);