comparison src/share/vm/code/nmethod.cpp @ 21559:be896a1983c0

recast all Graal native code as JVMCI code (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Thu, 28 May 2015 15:36:48 +0200
parents f34ae5c01864
children
comparison
equal deleted inserted replaced
21558:d563baeca9df 21559:be896a1983c0
44 #include "utilities/events.hpp" 44 #include "utilities/events.hpp"
45 #include "utilities/xmlstream.hpp" 45 #include "utilities/xmlstream.hpp"
46 #ifdef SHARK 46 #ifdef SHARK
47 #include "shark/sharkCompiler.hpp" 47 #include "shark/sharkCompiler.hpp"
48 #endif 48 #endif
49 #ifdef GRAAL 49 #ifdef JVMCI
50 #include "graal/graalJavaAccess.hpp" 50 #include "jvmci/jvmciJavaAccess.hpp"
51 #endif 51 #endif
52 52
53 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC 53 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
54 54
55 unsigned char nmethod::_global_unloading_clock = 0; 55 unsigned char nmethod::_global_unloading_clock = 0;
104 if (compiler() == NULL) { 104 if (compiler() == NULL) {
105 return false; 105 return false;
106 } 106 }
107 return compiler()->is_c1(); 107 return compiler()->is_c1();
108 } 108 }
109 bool nmethod::is_compiled_by_graal() const { 109 bool nmethod::is_compiled_by_jvmci() const {
110 if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing 110 if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing
111 if (is_native_method()) return false; 111 if (is_native_method()) return false;
112 return compiler()->is_graal(); 112 return compiler()->is_jvmci();
113 } 113 }
114 bool nmethod::is_compiled_by_c2() const { 114 bool nmethod::is_compiled_by_c2() const {
115 if (compiler() == NULL) { 115 if (compiler() == NULL) {
116 return false; 116 return false;
117 } 117 }
236 static java_nmethod_stats_struct c1_java_nmethod_stats; 236 static java_nmethod_stats_struct c1_java_nmethod_stats;
237 #endif 237 #endif
238 #ifdef COMPILER2 238 #ifdef COMPILER2
239 static java_nmethod_stats_struct c2_java_nmethod_stats; 239 static java_nmethod_stats_struct c2_java_nmethod_stats;
240 #endif 240 #endif
241 #ifdef GRAAL 241 #ifdef JVMCI
242 static java_nmethod_stats_struct graal_java_nmethod_stats; 242 static java_nmethod_stats_struct jvmci_java_nmethod_stats;
243 #endif 243 #endif
244 #ifdef SHARK 244 #ifdef SHARK
245 static java_nmethod_stats_struct shark_java_nmethod_stats; 245 static java_nmethod_stats_struct shark_java_nmethod_stats;
246 #endif 246 #endif
247 static java_nmethod_stats_struct unknown_java_nmethod_stats; 247 static java_nmethod_stats_struct unknown_java_nmethod_stats;
262 #ifdef COMPILER2 262 #ifdef COMPILER2
263 if (nm->is_compiled_by_c2()) { 263 if (nm->is_compiled_by_c2()) {
264 c2_java_nmethod_stats.note_nmethod(nm); 264 c2_java_nmethod_stats.note_nmethod(nm);
265 } else 265 } else
266 #endif 266 #endif
267 #ifdef GRAAL 267 #ifdef JVMCI
268 if (nm->is_compiled_by_graal()) { 268 if (nm->is_compiled_by_jvmci()) {
269 graal_java_nmethod_stats.note_nmethod(nm); 269 jvmci_java_nmethod_stats.note_nmethod(nm);
270 } else 270 } else
271 #endif 271 #endif
272 #ifdef SHARK 272 #ifdef SHARK
273 if (nm->is_compiled_by_shark()) { 273 if (nm->is_compiled_by_shark()) {
274 shark_java_nmethod_stats.note_nmethod(nm); 274 shark_java_nmethod_stats.note_nmethod(nm);
557 _scavenge_root_state = 0; 557 _scavenge_root_state = 0;
558 _compiler = NULL; 558 _compiler = NULL;
559 #if INCLUDE_RTM_OPT 559 #if INCLUDE_RTM_OPT
560 _rtm_state = NoRTM; 560 _rtm_state = NoRTM;
561 #endif 561 #endif
562 #ifdef GRAAL 562 #ifdef JVMCI
563 _graal_installed_code = NULL; 563 _jvmci_installed_code = NULL;
564 _speculation_log = NULL; 564 _speculation_log = NULL;
565 #endif 565 #endif
566 #ifdef HAVE_DTRACE_H 566 #ifdef HAVE_DTRACE_H
567 _trap_offset = 0; 567 _trap_offset = 0;
568 #endif // def HAVE_DTRACE_H 568 #endif // def HAVE_DTRACE_H
655 OopMapSet* oop_maps, 655 OopMapSet* oop_maps,
656 ExceptionHandlerTable* handler_table, 656 ExceptionHandlerTable* handler_table,
657 ImplicitExceptionTable* nul_chk_table, 657 ImplicitExceptionTable* nul_chk_table,
658 AbstractCompiler* compiler, 658 AbstractCompiler* compiler,
659 int comp_level 659 int comp_level
660 #ifdef GRAAL 660 #ifdef JVMCI
661 , Handle installed_code, 661 , Handle installed_code,
662 Handle speculationLog 662 Handle speculationLog
663 #endif 663 #endif
664 ) 664 )
665 { 665 {
682 oop_maps, 682 oop_maps,
683 handler_table, 683 handler_table,
684 nul_chk_table, 684 nul_chk_table,
685 compiler, 685 compiler,
686 comp_level 686 comp_level
687 #ifdef GRAAL 687 #ifdef JVMCI
688 , installed_code, 688 , installed_code,
689 speculationLog 689 speculationLog
690 #endif 690 #endif
691 ); 691 );
692 692
918 OopMapSet* oop_maps, 918 OopMapSet* oop_maps,
919 ExceptionHandlerTable* handler_table, 919 ExceptionHandlerTable* handler_table,
920 ImplicitExceptionTable* nul_chk_table, 920 ImplicitExceptionTable* nul_chk_table,
921 AbstractCompiler* compiler, 921 AbstractCompiler* compiler,
922 int comp_level 922 int comp_level
923 #ifdef GRAAL 923 #ifdef JVMCI
924 , Handle installed_code, 924 , Handle installed_code,
925 Handle speculation_log 925 Handle speculation_log
926 #endif 926 #endif
927 ) 927 )
928 : CodeBlob("nmethod", code_buffer, sizeof(nmethod), 928 : CodeBlob("nmethod", code_buffer, sizeof(nmethod),
946 946
947 // Section offsets 947 // Section offsets
948 _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts()); 948 _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts());
949 _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs()); 949 _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs());
950 950
951 #ifdef GRAAL 951 #ifdef JVMCI
952 _graal_installed_code = installed_code(); 952 _jvmci_installed_code = installed_code();
953 _speculation_log = (instanceOop)speculation_log(); 953 _speculation_log = (instanceOop)speculation_log();
954 954
955 if (compiler->is_graal()) { 955 if (compiler->is_jvmci()) {
956 // Graal might not produce any stub sections 956 // JVMCI might not produce any stub sections
957 if (offsets->value(CodeOffsets::Exceptions) != -1) { 957 if (offsets->value(CodeOffsets::Exceptions) != -1) {
958 _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions); 958 _exception_offset = code_offset() + offsets->value(CodeOffsets::Exceptions);
959 } else { 959 } else {
960 _exception_offset = -1; 960 _exception_offset = -1;
961 } 961 }
979 _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); 979 _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt);
980 if (offsets->value(CodeOffsets::DeoptMH) != -1) { 980 if (offsets->value(CodeOffsets::DeoptMH) != -1) {
981 _deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH); 981 _deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH);
982 } else { 982 } else {
983 _deoptimize_mh_offset = -1; 983 _deoptimize_mh_offset = -1;
984 #ifdef GRAAL 984 #ifdef JVMCI
985 } 985 }
986 #endif 986 #endif
987 } 987 }
988 if (offsets->value(CodeOffsets::UnwindHandler) != -1) { 988 if (offsets->value(CodeOffsets::UnwindHandler) != -1) {
989 _unwind_handler_offset = code_offset() + offsets->value(CodeOffsets::UnwindHandler); 989 _unwind_handler_offset = code_offset() + offsets->value(CodeOffsets::UnwindHandler);
1025 handler_table->copy_to(this); 1025 handler_table->copy_to(this);
1026 nul_chk_table->copy_to(this); 1026 nul_chk_table->copy_to(this);
1027 1027
1028 // we use the information of entry points to find out if a method is 1028 // we use the information of entry points to find out if a method is
1029 // static or non static 1029 // static or non static
1030 assert(compiler->is_c2() || compiler->is_graal() || 1030 assert(compiler->is_c2() || compiler->is_jvmci() ||
1031 _method->is_static() == (entry_point() == _verified_entry_point), 1031 _method->is_static() == (entry_point() == _verified_entry_point),
1032 " entry points must be same for static methods and vice versa"); 1032 " entry points must be same for static methods and vice versa");
1033 } 1033 }
1034 1034
1035 bool printnmethods = PrintNMethods || PrintNMethodsAtLevel == _comp_level 1035 bool printnmethods = PrintNMethods || PrintNMethodsAtLevel == _comp_level
1396 return stack_traversal_mark()+1 < NMethodSweeper::traversal_count() && 1396 return stack_traversal_mark()+1 < NMethodSweeper::traversal_count() &&
1397 !is_locked_by_vm(); 1397 !is_locked_by_vm();
1398 } 1398 }
1399 1399
1400 void nmethod::inc_decompile_count() { 1400 void nmethod::inc_decompile_count() {
1401 if (!is_compiled_by_c2() && !is_compiled_by_graal()) return; 1401 if (!is_compiled_by_c2() && !is_compiled_by_jvmci()) return;
1402 // Could be gated by ProfileTraps, but do not bother... 1402 // Could be gated by ProfileTraps, but do not bother...
1403 Method* m = method(); 1403 Method* m = method();
1404 if (m == NULL) return; 1404 if (m == NULL) return;
1405 MethodData* mdo = m->method_data(); 1405 MethodData* mdo = m->method_data();
1406 if (mdo == NULL) return; 1406 if (mdo == NULL) return;
1473 } 1473 }
1474 1474
1475 // Unregister must be done before the state change 1475 // Unregister must be done before the state change
1476 Universe::heap()->unregister_nmethod(this); 1476 Universe::heap()->unregister_nmethod(this);
1477 1477
1478 #ifdef GRAAL 1478 #ifdef JVMCI
1479 // The method can only be unloaded after the pointer to the installed code 1479 // The method can only be unloaded after the pointer to the installed code
1480 // Java wrapper is no longer alive. Here we need to clear out this weak 1480 // Java wrapper is no longer alive. Here we need to clear out this weak
1481 // reference to the dead object. Nulling out the reference has to happen 1481 // reference to the dead object. Nulling out the reference has to happen
1482 // after the method is unregistered since the original value may be still 1482 // after the method is unregistered since the original value may be still
1483 // tracked by the rset. 1483 // tracked by the rset.
1484 if (_graal_installed_code != NULL) { 1484 if (_jvmci_installed_code != NULL) {
1485 InstalledCode::set_address(_graal_installed_code, 0); 1485 InstalledCode::set_address(_jvmci_installed_code, 0);
1486 _graal_installed_code = NULL; 1486 _jvmci_installed_code = NULL;
1487 } 1487 }
1488 #endif 1488 #endif
1489 1489
1490 _state = unloaded; 1490 _state = unloaded;
1491 1491
1650 // nmethod is in zombie state 1650 // nmethod is in zombie state
1651 set_method(NULL); 1651 set_method(NULL);
1652 } else { 1652 } else {
1653 assert(state == not_entrant, "other cases may need to be handled differently"); 1653 assert(state == not_entrant, "other cases may need to be handled differently");
1654 } 1654 }
1655 #ifdef GRAAL 1655 #ifdef JVMCI
1656 if (_graal_installed_code != NULL) { 1656 if (_jvmci_installed_code != NULL) {
1657 // Break the link between nmethod and InstalledCode such that the nmethod can subsequently be flushed safely. 1657 // Break the link between nmethod and InstalledCode such that the nmethod can subsequently be flushed safely.
1658 InstalledCode::set_address(_graal_installed_code, 0); 1658 InstalledCode::set_address(_jvmci_installed_code, 0);
1659 } 1659 }
1660 #endif 1660 #endif
1661 1661
1662 if (TraceCreateZombies) { 1662 if (TraceCreateZombies) {
1663 ResourceMark m; 1663 ResourceMark m;
1962 if (can_unload(is_alive, p, unloading_occurred)) { 1962 if (can_unload(is_alive, p, unloading_occurred)) {
1963 return; 1963 return;
1964 } 1964 }
1965 } 1965 }
1966 1966
1967 #ifdef GRAAL 1967 #ifdef JVMCI
1968 // Follow Graal method 1968 // Follow JVMCI method
1969 BarrierSet* bs = Universe::heap()->barrier_set(); 1969 BarrierSet* bs = Universe::heap()->barrier_set();
1970 if (_graal_installed_code != NULL) { 1970 if (_jvmci_installed_code != NULL) {
1971 if (_graal_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_graal_installed_code)) { 1971 if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) {
1972 if (!is_alive->do_object_b(_graal_installed_code)) { 1972 if (!is_alive->do_object_b(_jvmci_installed_code)) {
1973 bs->write_ref_nmethod_pre(&_graal_installed_code, this); 1973 bs->write_ref_nmethod_pre(&_jvmci_installed_code, this);
1974 _graal_installed_code = NULL; 1974 _jvmci_installed_code = NULL;
1975 bs->write_ref_nmethod_post(&_graal_installed_code, this); 1975 bs->write_ref_nmethod_post(&_jvmci_installed_code, this);
1976 } 1976 }
1977 } else { 1977 } else {
1978 if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { 1978 if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) {
1979 return; 1979 return;
1980 } 1980 }
1981 } 1981 }
1982 } 1982 }
1983 1983
2099 // call to post_compiled_method_unload() so that the unloading 2099 // call to post_compiled_method_unload() so that the unloading
2100 // of this nmethod is reported. 2100 // of this nmethod is reported.
2101 unloading_occurred = true; 2101 unloading_occurred = true;
2102 } 2102 }
2103 2103
2104 #ifdef GRAAL 2104 #ifdef JVMCI
2105 // Follow Graal method 2105 // Follow JVMCI method
2106 if (_graal_installed_code != NULL) { 2106 if (_jvmci_installed_code != NULL) {
2107 if (_graal_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_graal_installed_code)) { 2107 if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) {
2108 if (!is_alive->do_object_b(_graal_installed_code)) { 2108 if (!is_alive->do_object_b(_jvmci_installed_code)) {
2109 _graal_installed_code = NULL; 2109 _jvmci_installed_code = NULL;
2110 } 2110 }
2111 } else { 2111 } else {
2112 if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { 2112 if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) {
2113 return false; 2113 return false;
2114 } 2114 }
2115 } 2115 }
2116 } 2116 }
2117 2117
2188 2188
2189 if (is_unloaded) { 2189 if (is_unloaded) {
2190 return postponed; 2190 return postponed;
2191 } 2191 }
2192 2192
2193 #ifdef GRAAL 2193 #ifdef JVMCI
2194 // Follow Graal method 2194 // Follow JVMCI method
2195 BarrierSet* bs = Universe::heap()->barrier_set(); 2195 BarrierSet* bs = Universe::heap()->barrier_set();
2196 if (_graal_installed_code != NULL) { 2196 if (_jvmci_installed_code != NULL) {
2197 if (_graal_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_graal_installed_code)) { 2197 if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) {
2198 if (!is_alive->do_object_b(_graal_installed_code)) { 2198 if (!is_alive->do_object_b(_jvmci_installed_code)) {
2199 bs->write_ref_nmethod_pre(&_graal_installed_code, this); 2199 bs->write_ref_nmethod_pre(&_jvmci_installed_code, this);
2200 _graal_installed_code = NULL; 2200 _jvmci_installed_code = NULL;
2201 bs->write_ref_nmethod_post(&_graal_installed_code, this); 2201 bs->write_ref_nmethod_post(&_jvmci_installed_code, this);
2202 } 2202 }
2203 } else { 2203 } else {
2204 if (can_unload(is_alive, (oop*)&_graal_installed_code, unloading_occurred)) { 2204 if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) {
2205 is_unloaded = true; 2205 is_unloaded = true;
2206 } 2206 }
2207 } 2207 }
2208 } 2208 }
2209 2209
2398 low_boundary += NativeJump::instruction_size; 2398 low_boundary += NativeJump::instruction_size;
2399 // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. 2399 // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
2400 // (See comment above.) 2400 // (See comment above.)
2401 } 2401 }
2402 2402
2403 #ifdef GRAAL 2403 #ifdef JVMCI
2404 if (_graal_installed_code != NULL) { 2404 if (_jvmci_installed_code != NULL) {
2405 f->do_oop((oop*) &_graal_installed_code); 2405 f->do_oop((oop*) &_jvmci_installed_code);
2406 } 2406 }
2407 if (_speculation_log != NULL) { 2407 if (_speculation_log != NULL) {
2408 f->do_oop((oop*) &_speculation_log); 2408 f->do_oop((oop*) &_speculation_log);
2409 } 2409 }
2410 #endif 2410 #endif
3055 tty->print("(c1) "); 3055 tty->print("(c1) ");
3056 } else if (is_compiled_by_c2()) { 3056 } else if (is_compiled_by_c2()) {
3057 tty->print("(c2) "); 3057 tty->print("(c2) ");
3058 } else if (is_compiled_by_shark()) { 3058 } else if (is_compiled_by_shark()) {
3059 tty->print("(shark) "); 3059 tty->print("(shark) ");
3060 } else if (is_compiled_by_graal()) { 3060 } else if (is_compiled_by_jvmci()) {
3061 tty->print("(Graal) "); 3061 tty->print("(JVMCI) ");
3062 } else { 3062 } else {
3063 tty->print("(nm) "); 3063 tty->print("(nm) ");
3064 } 3064 }
3065 3065
3066 print_on(tty, NULL); 3066 print_on(tty, NULL);
3260 } 3260 }
3261 3261
3262 void nmethod::print_nmethod_labels(outputStream* stream, address block_begin) const { 3262 void nmethod::print_nmethod_labels(outputStream* stream, address block_begin) const {
3263 if (block_begin == entry_point()) stream->print_cr("[Entry Point]"); 3263 if (block_begin == entry_point()) stream->print_cr("[Entry Point]");
3264 if (block_begin == verified_entry_point()) stream->print_cr("[Verified Entry Point]"); 3264 if (block_begin == verified_entry_point()) stream->print_cr("[Verified Entry Point]");
3265 if (GRAAL_ONLY(_exception_offset >= 0 &&) block_begin == exception_begin()) stream->print_cr("[Exception Handler]"); 3265 if (JVMCI_ONLY(_exception_offset >= 0 &&) block_begin == exception_begin()) stream->print_cr("[Exception Handler]");
3266 if (block_begin == stub_begin()) stream->print_cr("[Stub Code]"); 3266 if (block_begin == stub_begin()) stream->print_cr("[Stub Code]");
3267 if (GRAAL_ONLY(_deoptimize_offset >= 0 &&) block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]"); 3267 if (JVMCI_ONLY(_deoptimize_offset >= 0 &&) block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]");
3268 3268
3269 if (has_method_handle_invokes()) 3269 if (has_method_handle_invokes())
3270 if (block_begin == deopt_mh_handler_begin()) stream->print_cr("[Deopt MH Handler Code]"); 3270 if (block_begin == deopt_mh_handler_begin()) stream->print_cr("[Deopt MH Handler Code]");
3271 3271
3272 if (block_begin == consts_begin()) stream->print_cr("[Constants]"); 3272 if (block_begin == consts_begin()) stream->print_cr("[Constants]");
3508 c1_java_nmethod_stats.print_nmethod_stats("C1"); 3508 c1_java_nmethod_stats.print_nmethod_stats("C1");
3509 #endif 3509 #endif
3510 #ifdef COMPILER2 3510 #ifdef COMPILER2
3511 c2_java_nmethod_stats.print_nmethod_stats("C2"); 3511 c2_java_nmethod_stats.print_nmethod_stats("C2");
3512 #endif 3512 #endif
3513 #ifdef GRAAL 3513 #ifdef JVMCI
3514 graal_java_nmethod_stats.print_nmethod_stats("Graal"); 3514 jvmci_java_nmethod_stats.print_nmethod_stats("JVMCI");
3515 #endif 3515 #endif
3516 #ifdef SHARK 3516 #ifdef SHARK
3517 shark_java_nmethod_stats.print_nmethod_stats("Shark"); 3517 shark_java_nmethod_stats.print_nmethod_stats("Shark");
3518 #endif 3518 #endif
3519 unknown_java_nmethod_stats.print_nmethod_stats("Unknown"); 3519 unknown_java_nmethod_stats.print_nmethod_stats("Unknown");
3523 #endif 3523 #endif
3524 Dependencies::print_statistics(); 3524 Dependencies::print_statistics();
3525 if (xtty != NULL) xtty->tail("statistics"); 3525 if (xtty != NULL) xtty->tail("statistics");
3526 } 3526 }
3527 3527
3528 #ifdef GRAAL 3528 #ifdef JVMCI
3529 char* nmethod::graal_installed_code_name(char* buf, size_t buflen) { 3529 char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) {
3530 if (!this->is_compiled_by_graal()) { 3530 if (!this->is_compiled_by_jvmci()) {
3531 return NULL; 3531 return NULL;
3532 } 3532 }
3533 oop installedCode = this->graal_installed_code(); 3533 oop installedCode = this->jvmci_installed_code();
3534 if (installedCode != NULL) { 3534 if (installedCode != NULL) {
3535 oop installedCodeName = NULL; 3535 oop installedCodeName = NULL;
3536 if (installedCode->is_a(InstalledCode::klass())) { 3536 if (installedCode->is_a(InstalledCode::klass())) {
3537 installedCodeName = InstalledCode::name(installedCode); 3537 installedCodeName = InstalledCode::name(installedCode);
3538 } 3538 }