Mercurial > hg > graal-compiler
comparison src/share/vm/runtime/sharedRuntime.cpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 3e9a960f0da1 |
children | 954c9df6ac79 |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
125 #endif // COMPILER2 | 125 #endif // COMPILER2 |
126 } | 126 } |
127 | 127 |
128 #include <math.h> | 128 #include <math.h> |
129 | 129 |
130 #ifndef USDT2 | |
131 HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); | |
132 HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int, | |
133 char*, int, char*, int, char*, int); | |
134 HS_DTRACE_PROBE_DECL7(hotspot, method__return, int, | |
135 char*, int, char*, int, char*, int); | |
136 #endif /* !USDT2 */ | |
137 | |
130 // Implementation of SharedRuntime | 138 // Implementation of SharedRuntime |
131 | 139 |
132 #ifndef PRODUCT | 140 #ifndef PRODUCT |
133 // For statistics | 141 // For statistics |
134 int SharedRuntime::_ic_miss_ctr = 0; | 142 int SharedRuntime::_ic_miss_ctr = 0; |
398 return (f <= (double)0.0) ? (double)0.0 - f : f; | 406 return (f <= (double)0.0) ? (double)0.0 - f : f; |
399 } | 407 } |
400 | 408 |
401 #endif | 409 #endif |
402 | 410 |
403 #if defined(__SOFTFP__) || defined(PPC32) | 411 #if defined(__SOFTFP__) || defined(PPC) |
404 double SharedRuntime::dsqrt(double f) { | 412 double SharedRuntime::dsqrt(double f) { |
405 return sqrt(f); | 413 return sqrt(f); |
406 } | 414 } |
407 #endif | 415 #endif |
408 | 416 |
462 | 470 |
463 JRT_LEAF(jdouble, SharedRuntime::l2d(jlong x)) | 471 JRT_LEAF(jdouble, SharedRuntime::l2d(jlong x)) |
464 return (jdouble)x; | 472 return (jdouble)x; |
465 JRT_END | 473 JRT_END |
466 | 474 |
467 // Exception handling across interpreter/compiler boundaries | 475 // Exception handling accross interpreter/compiler boundaries |
468 // | 476 // |
469 // exception_handler_for_return_address(...) returns the continuation address. | 477 // exception_handler_for_return_address(...) returns the continuation address. |
470 // The continuation address is the entry point of the exception handler of the | 478 // The continuation address is the entry point of the exception handler of the |
471 // previous frame depending on the return address. | 479 // previous frame depending on the return address. |
472 | 480 |
490 thread->set_is_method_handle_return(nm->is_method_handle_return(return_address)); | 498 thread->set_is_method_handle_return(nm->is_method_handle_return(return_address)); |
491 // native nmethods don't have exception handlers | 499 // native nmethods don't have exception handlers |
492 assert(!nm->is_native_method(), "no exception handler"); | 500 assert(!nm->is_native_method(), "no exception handler"); |
493 assert(nm->header_begin() != nm->exception_begin(), "no exception handler"); | 501 assert(nm->header_begin() != nm->exception_begin(), "no exception handler"); |
494 if (nm->is_deopt_pc(return_address)) { | 502 if (nm->is_deopt_pc(return_address)) { |
495 // If we come here because of a stack overflow, the stack may be | |
496 // unguarded. Reguard the stack otherwise if we return to the | |
497 // deopt blob and the stack bang causes a stack overflow we | |
498 // crash. | |
499 bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); | |
500 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); | |
501 assert(guard_pages_enabled, "stack banging in deopt blob may cause crash"); | |
502 return SharedRuntime::deopt_blob()->unpack_with_exception(); | 503 return SharedRuntime::deopt_blob()->unpack_with_exception(); |
503 } else { | 504 } else { |
504 return nm->exception_begin(); | 505 return nm->exception_begin(); |
505 } | 506 } |
506 } | 507 } |
711 HandlerTableEntry *t = table.entry_for(catch_pco, handler_bci, scope_depth); | 712 HandlerTableEntry *t = table.entry_for(catch_pco, handler_bci, scope_depth); |
712 if (t == NULL && (nm->is_compiled_by_c1() || handler_bci != -1)) { | 713 if (t == NULL && (nm->is_compiled_by_c1() || handler_bci != -1)) { |
713 // Allow abbreviated catch tables. The idea is to allow a method | 714 // Allow abbreviated catch tables. The idea is to allow a method |
714 // to materialize its exceptions without committing to the exact | 715 // to materialize its exceptions without committing to the exact |
715 // routing of exceptions. In particular this is needed for adding | 716 // routing of exceptions. In particular this is needed for adding |
716 // a synthetic handler to unlock monitors when inlining | 717 // a synthethic handler to unlock monitors when inlining |
717 // synchronized methods since the unlock path isn't represented in | 718 // synchonized methods since the unlock path isn't represented in |
718 // the bytecodes. | 719 // the bytecodes. |
719 t = table.entry_for(catch_pco, -1, 0); | 720 t = table.entry_for(catch_pco, -1, 0); |
720 } | 721 } |
721 | 722 |
722 #ifdef COMPILER1 | 723 #ifdef COMPILER1 |
850 if (cb == NULL) return NULL; | 851 if (cb == NULL) return NULL; |
851 | 852 |
852 // Exception happened in CodeCache. Must be either: | 853 // Exception happened in CodeCache. Must be either: |
853 // 1. Inline-cache check in C2I handler blob, | 854 // 1. Inline-cache check in C2I handler blob, |
854 // 2. Inline-cache check in nmethod, or | 855 // 2. Inline-cache check in nmethod, or |
855 // 3. Implicit null exception in nmethod | 856 // 3. Implict null exception in nmethod |
856 | 857 |
857 if (!cb->is_nmethod()) { | 858 if (!cb->is_nmethod()) { |
858 bool is_in_blob = cb->is_adapter_blob() || cb->is_method_handles_adapter_blob(); | 859 bool is_in_blob = cb->is_adapter_blob() || cb->is_method_handles_adapter_blob(); |
859 if (!is_in_blob) { | 860 if (!is_in_blob) { |
860 cb->print(); | 861 cb->print(); |
1024 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { | 1025 int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { |
1025 assert(DTraceAllocProbes, "wrong call"); | 1026 assert(DTraceAllocProbes, "wrong call"); |
1026 Klass* klass = o->klass(); | 1027 Klass* klass = o->klass(); |
1027 int size = o->size(); | 1028 int size = o->size(); |
1028 Symbol* name = klass->name(); | 1029 Symbol* name = klass->name(); |
1030 #ifndef USDT2 | |
1031 HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), | |
1032 name->bytes(), name->utf8_length(), size * HeapWordSize); | |
1033 #else /* USDT2 */ | |
1029 HOTSPOT_OBJECT_ALLOC( | 1034 HOTSPOT_OBJECT_ALLOC( |
1030 get_java_tid(thread), | 1035 get_java_tid(thread), |
1031 (char *) name->bytes(), name->utf8_length(), size * HeapWordSize); | 1036 (char *) name->bytes(), name->utf8_length(), size * HeapWordSize); |
1037 #endif /* USDT2 */ | |
1032 return 0; | 1038 return 0; |
1033 } | 1039 } |
1034 | 1040 |
1035 JRT_LEAF(int, SharedRuntime::dtrace_method_entry( | 1041 JRT_LEAF(int, SharedRuntime::dtrace_method_entry( |
1036 JavaThread* thread, Method* method)) | 1042 JavaThread* thread, Method* method)) |
1037 assert(DTraceMethodProbes, "wrong call"); | 1043 assert(DTraceMethodProbes, "wrong call"); |
1038 Symbol* kname = method->klass_name(); | 1044 Symbol* kname = method->klass_name(); |
1039 Symbol* name = method->name(); | 1045 Symbol* name = method->name(); |
1040 Symbol* sig = method->signature(); | 1046 Symbol* sig = method->signature(); |
1047 #ifndef USDT2 | |
1048 HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread), | |
1049 kname->bytes(), kname->utf8_length(), | |
1050 name->bytes(), name->utf8_length(), | |
1051 sig->bytes(), sig->utf8_length()); | |
1052 #else /* USDT2 */ | |
1041 HOTSPOT_METHOD_ENTRY( | 1053 HOTSPOT_METHOD_ENTRY( |
1042 get_java_tid(thread), | 1054 get_java_tid(thread), |
1043 (char *) kname->bytes(), kname->utf8_length(), | 1055 (char *) kname->bytes(), kname->utf8_length(), |
1044 (char *) name->bytes(), name->utf8_length(), | 1056 (char *) name->bytes(), name->utf8_length(), |
1045 (char *) sig->bytes(), sig->utf8_length()); | 1057 (char *) sig->bytes(), sig->utf8_length()); |
1058 #endif /* USDT2 */ | |
1046 return 0; | 1059 return 0; |
1047 JRT_END | 1060 JRT_END |
1048 | 1061 |
1049 JRT_LEAF(int, SharedRuntime::dtrace_method_exit( | 1062 JRT_LEAF(int, SharedRuntime::dtrace_method_exit( |
1050 JavaThread* thread, Method* method)) | 1063 JavaThread* thread, Method* method)) |
1051 assert(DTraceMethodProbes, "wrong call"); | 1064 assert(DTraceMethodProbes, "wrong call"); |
1052 Symbol* kname = method->klass_name(); | 1065 Symbol* kname = method->klass_name(); |
1053 Symbol* name = method->name(); | 1066 Symbol* name = method->name(); |
1054 Symbol* sig = method->signature(); | 1067 Symbol* sig = method->signature(); |
1068 #ifndef USDT2 | |
1069 HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread), | |
1070 kname->bytes(), kname->utf8_length(), | |
1071 name->bytes(), name->utf8_length(), | |
1072 sig->bytes(), sig->utf8_length()); | |
1073 #else /* USDT2 */ | |
1055 HOTSPOT_METHOD_RETURN( | 1074 HOTSPOT_METHOD_RETURN( |
1056 get_java_tid(thread), | 1075 get_java_tid(thread), |
1057 (char *) kname->bytes(), kname->utf8_length(), | 1076 (char *) kname->bytes(), kname->utf8_length(), |
1058 (char *) name->bytes(), name->utf8_length(), | 1077 (char *) name->bytes(), name->utf8_length(), |
1059 (char *) sig->bytes(), sig->utf8_length()); | 1078 (char *) sig->bytes(), sig->utf8_length()); |
1079 #endif /* USDT2 */ | |
1060 return 0; | 1080 return 0; |
1061 JRT_END | 1081 JRT_END |
1062 | 1082 |
1063 | 1083 |
1064 // Finds receiver, CallInfo (i.e. receiver method), and calling bytecode) | 1084 // Finds receiver, CallInfo (i.e. receiver method), and calling bytecode) |
2442 assert(ic_miss != NULL, "must have handler"); | 2462 assert(ic_miss != NULL, "must have handler"); |
2443 | 2463 |
2444 ResourceMark rm; | 2464 ResourceMark rm; |
2445 | 2465 |
2446 NOT_PRODUCT(int insts_size); | 2466 NOT_PRODUCT(int insts_size); |
2447 AdapterBlob* new_adapter = NULL; | 2467 AdapterBlob* B = NULL; |
2448 AdapterHandlerEntry* entry = NULL; | 2468 AdapterHandlerEntry* entry = NULL; |
2449 AdapterFingerPrint* fingerprint = NULL; | 2469 AdapterFingerPrint* fingerprint = NULL; |
2450 { | 2470 { |
2451 MutexLocker mu(AdapterHandlerLibrary_lock); | 2471 MutexLocker mu(AdapterHandlerLibrary_lock); |
2452 // make sure data structure is initialized | 2472 // make sure data structure is initialized |
2474 // Lookup method signature's fingerprint | 2494 // Lookup method signature's fingerprint |
2475 entry = _adapters->lookup(total_args_passed, sig_bt); | 2495 entry = _adapters->lookup(total_args_passed, sig_bt); |
2476 | 2496 |
2477 #ifdef ASSERT | 2497 #ifdef ASSERT |
2478 AdapterHandlerEntry* shared_entry = NULL; | 2498 AdapterHandlerEntry* shared_entry = NULL; |
2479 // Start adapter sharing verification only after the VM is booted. | 2499 if (VerifyAdapterSharing && entry != NULL) { |
2480 if (VerifyAdapterSharing && (entry != NULL)) { | |
2481 shared_entry = entry; | 2500 shared_entry = entry; |
2482 entry = NULL; | 2501 entry = NULL; |
2483 } | 2502 } |
2484 #endif | 2503 #endif |
2485 | 2504 |
2491 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); | 2510 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); |
2492 | 2511 |
2493 // Make a C heap allocated version of the fingerprint to store in the adapter | 2512 // Make a C heap allocated version of the fingerprint to store in the adapter |
2494 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt); | 2513 fingerprint = new AdapterFingerPrint(total_args_passed, sig_bt); |
2495 | 2514 |
2496 // StubRoutines::code2() is initialized after this function can be called. As a result, | |
2497 // VerifyAdapterCalls and VerifyAdapterSharing can fail if we re-use code that generated | |
2498 // prior to StubRoutines::code2() being set. Checks refer to checks generated in an I2C | |
2499 // stub that ensure that an I2C stub is called from an interpreter frame. | |
2500 bool contains_all_checks = StubRoutines::code2() != NULL; | |
2501 | |
2502 // Create I2C & C2I handlers | 2515 // Create I2C & C2I handlers |
2516 | |
2503 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2517 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2504 if (buf != NULL) { | 2518 if (buf != NULL) { |
2505 CodeBuffer buffer(buf); | 2519 CodeBuffer buffer(buf); |
2506 short buffer_locs[20]; | 2520 short buffer_locs[20]; |
2507 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, | 2521 buffer.insts()->initialize_shared_locs((relocInfo*)buffer_locs, |
2508 sizeof(buffer_locs)/sizeof(relocInfo)); | 2522 sizeof(buffer_locs)/sizeof(relocInfo)); |
2509 | |
2510 MacroAssembler _masm(&buffer); | 2523 MacroAssembler _masm(&buffer); |
2524 | |
2511 entry = SharedRuntime::generate_i2c2i_adapters(&_masm, | 2525 entry = SharedRuntime::generate_i2c2i_adapters(&_masm, |
2512 total_args_passed, | 2526 total_args_passed, |
2513 comp_args_on_stack, | 2527 comp_args_on_stack, |
2514 sig_bt, | 2528 sig_bt, |
2515 regs, | 2529 regs, |
2516 fingerprint); | 2530 fingerprint); |
2531 | |
2517 #ifdef ASSERT | 2532 #ifdef ASSERT |
2518 if (VerifyAdapterSharing) { | 2533 if (VerifyAdapterSharing) { |
2519 if (shared_entry != NULL) { | 2534 if (shared_entry != NULL) { |
2520 assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size()), "code must match"); | 2535 assert(shared_entry->compare_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt), |
2536 "code must match"); | |
2521 // Release the one just created and return the original | 2537 // Release the one just created and return the original |
2522 _adapters->free_entry(entry); | 2538 _adapters->free_entry(entry); |
2523 return shared_entry; | 2539 return shared_entry; |
2524 } else { | 2540 } else { |
2525 entry->save_code(buf->code_begin(), buffer.insts_size()); | 2541 entry->save_code(buf->code_begin(), buffer.insts_size(), total_args_passed, sig_bt); |
2526 } | 2542 } |
2527 } | 2543 } |
2528 #endif | 2544 #endif |
2529 | 2545 |
2530 new_adapter = AdapterBlob::create(&buffer); | 2546 B = AdapterBlob::create(&buffer); |
2531 NOT_PRODUCT(insts_size = buffer.insts_size()); | 2547 NOT_PRODUCT(insts_size = buffer.insts_size()); |
2532 } | 2548 } |
2533 if (new_adapter == NULL) { | 2549 if (B == NULL) { |
2534 // CodeCache is full, disable compilation | 2550 // CodeCache is full, disable compilation |
2535 // Ought to log this but compile log is only per compile thread | 2551 // Ought to log this but compile log is only per compile thread |
2536 // and we're some non descript Java thread. | 2552 // and we're some non descript Java thread. |
2537 MutexUnlocker mu(AdapterHandlerLibrary_lock); | 2553 MutexUnlocker mu(AdapterHandlerLibrary_lock); |
2538 CompileBroker::handle_full_code_cache(); | 2554 CompileBroker::handle_full_code_cache(); |
2539 return NULL; // Out of CodeCache space | 2555 return NULL; // Out of CodeCache space |
2540 } | 2556 } |
2541 entry->relocate(new_adapter->content_begin()); | 2557 entry->relocate(B->content_begin()); |
2542 #ifndef PRODUCT | 2558 #ifndef PRODUCT |
2543 // debugging suppport | 2559 // debugging suppport |
2544 if (PrintAdapterHandlers || PrintStubCode) { | 2560 if (PrintAdapterHandlers || PrintStubCode) { |
2545 ttyLocker ttyl; | 2561 ttyLocker ttyl; |
2546 entry->print_adapter_on(tty); | 2562 entry->print_adapter_on(tty); |
2555 tty->cr(); | 2571 tty->cr(); |
2556 } | 2572 } |
2557 } | 2573 } |
2558 } | 2574 } |
2559 #endif | 2575 #endif |
2560 // Add the entry only if the entry contains all required checks (see sharedRuntime_xxx.cpp) | 2576 |
2561 // The checks are inserted only if -XX:+VerifyAdapterCalls is specified. | 2577 _adapters->add(entry); |
2562 if (contains_all_checks || !VerifyAdapterCalls) { | |
2563 _adapters->add(entry); | |
2564 } | |
2565 } | 2578 } |
2566 // Outside of the lock | 2579 // Outside of the lock |
2567 if (new_adapter != NULL) { | 2580 if (B != NULL) { |
2568 char blob_id[256]; | 2581 char blob_id[256]; |
2569 jio_snprintf(blob_id, | 2582 jio_snprintf(blob_id, |
2570 sizeof(blob_id), | 2583 sizeof(blob_id), |
2571 "%s(%s)@" PTR_FORMAT, | 2584 "%s(%s)@" PTR_FORMAT, |
2572 new_adapter->name(), | 2585 B->name(), |
2573 fingerprint->as_string(), | 2586 fingerprint->as_string(), |
2574 new_adapter->content_begin()); | 2587 B->content_begin()); |
2575 Forte::register_stub(blob_id, new_adapter->content_begin(),new_adapter->content_end()); | 2588 Forte::register_stub(blob_id, B->content_begin(), B->content_end()); |
2576 | 2589 |
2577 if (JvmtiExport::should_post_dynamic_code_generated()) { | 2590 if (JvmtiExport::should_post_dynamic_code_generated()) { |
2578 JvmtiExport::post_dynamic_code_generated(blob_id, new_adapter->content_begin(), new_adapter->content_end()); | 2591 JvmtiExport::post_dynamic_code_generated(blob_id, B->content_begin(), B->content_end()); |
2579 } | 2592 } |
2580 } | 2593 } |
2581 return entry; | 2594 return entry; |
2582 } | 2595 } |
2583 | 2596 |
2605 | 2618 |
2606 void AdapterHandlerEntry::deallocate() { | 2619 void AdapterHandlerEntry::deallocate() { |
2607 delete _fingerprint; | 2620 delete _fingerprint; |
2608 #ifdef ASSERT | 2621 #ifdef ASSERT |
2609 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); | 2622 if (_saved_code) FREE_C_HEAP_ARRAY(unsigned char, _saved_code, mtCode); |
2623 if (_saved_sig) FREE_C_HEAP_ARRAY(Basictype, _saved_sig, mtCode); | |
2610 #endif | 2624 #endif |
2611 } | 2625 } |
2612 | 2626 |
2613 | 2627 |
2614 #ifdef ASSERT | 2628 #ifdef ASSERT |
2615 // Capture the code before relocation so that it can be compared | 2629 // Capture the code before relocation so that it can be compared |
2616 // against other versions. If the code is captured after relocation | 2630 // against other versions. If the code is captured after relocation |
2617 // then relative instructions won't be equivalent. | 2631 // then relative instructions won't be equivalent. |
2618 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length) { | 2632 void AdapterHandlerEntry::save_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { |
2619 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); | 2633 _saved_code = NEW_C_HEAP_ARRAY(unsigned char, length, mtCode); |
2620 _saved_code_length = length; | 2634 _code_length = length; |
2621 memcpy(_saved_code, buffer, length); | 2635 memcpy(_saved_code, buffer, length); |
2622 } | 2636 _total_args_passed = total_args_passed; |
2623 | 2637 _saved_sig = NEW_C_HEAP_ARRAY(BasicType, _total_args_passed, mtCode); |
2624 | 2638 memcpy(_saved_sig, sig_bt, _total_args_passed * sizeof(BasicType)); |
2625 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length) { | 2639 } |
2626 if (length != _saved_code_length) { | 2640 |
2641 | |
2642 bool AdapterHandlerEntry::compare_code(unsigned char* buffer, int length, int total_args_passed, BasicType* sig_bt) { | |
2643 if (length != _code_length) { | |
2627 return false; | 2644 return false; |
2628 } | 2645 } |
2629 | 2646 for (int i = 0; i < length; i++) { |
2630 return (memcmp(buffer, _saved_code, length) == 0) ? true : false; | 2647 if (buffer[i] != _saved_code[i]) { |
2631 } | 2648 return false; |
2632 #endif | 2649 } |
2633 | 2650 } |
2634 | 2651 return true; |
2635 /** | 2652 } |
2636 * Create a native wrapper for this native method. The wrapper converts the | 2653 #endif |
2637 * Java-compiled calling convention to the native convention, handles | 2654 |
2638 * arguments, and transitions to native. On return from the native we transition | 2655 |
2639 * back to java blocking if a safepoint is in progress. | 2656 // Create a native wrapper for this native method. The wrapper converts the |
2640 */ | 2657 // java compiled calling convention to the native convention, handlizes |
2641 void AdapterHandlerLibrary::create_native_wrapper(methodHandle method) { | 2658 // arguments, and transitions to native. On return from the native we transition |
2659 // back to java blocking if a safepoint is in progress. | |
2660 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method, int compile_id) { | |
2642 ResourceMark rm; | 2661 ResourceMark rm; |
2643 nmethod* nm = NULL; | 2662 nmethod* nm = NULL; |
2644 | 2663 |
2645 assert(method->is_native(), "must be native"); | 2664 assert(method->is_native(), "must be native"); |
2646 assert(method->is_method_handle_intrinsic() || | 2665 assert(method->is_method_handle_intrinsic() || |
2647 method->has_native_function(), "must have something valid to call!"); | 2666 method->has_native_function(), "must have something valid to call!"); |
2648 | 2667 |
2649 { | 2668 { |
2650 // Perform the work while holding the lock, but perform any printing outside the lock | 2669 // perform the work while holding the lock, but perform any printing outside the lock |
2651 MutexLocker mu(AdapterHandlerLibrary_lock); | 2670 MutexLocker mu(AdapterHandlerLibrary_lock); |
2652 // See if somebody beat us to it | 2671 // See if somebody beat us to it |
2653 nm = method->code(); | 2672 nm = method->code(); |
2654 if (nm != NULL) { | 2673 if (nm) { |
2655 return; | 2674 return nm; |
2656 } | 2675 } |
2657 | |
2658 const int compile_id = CompileBroker::assign_compile_id(method, CompileBroker::standard_entry_bci); | |
2659 assert(compile_id > 0, "Must generate native wrapper"); | |
2660 | |
2661 | 2676 |
2662 ResourceMark rm; | 2677 ResourceMark rm; |
2678 | |
2663 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2679 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2664 if (buf != NULL) { | 2680 if (buf != NULL) { |
2665 CodeBuffer buffer(buf); | 2681 CodeBuffer buffer(buf); |
2666 double locs_buf[20]; | 2682 double locs_buf[20]; |
2667 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); | 2683 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); |
2689 // are just trampolines so the argument registers must be outgoing ones. | 2705 // are just trampolines so the argument registers must be outgoing ones. |
2690 const bool is_outgoing = method->is_method_handle_intrinsic(); | 2706 const bool is_outgoing = method->is_method_handle_intrinsic(); |
2691 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); | 2707 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); |
2692 | 2708 |
2693 // Generate the compiled-to-native wrapper code | 2709 // Generate the compiled-to-native wrapper code |
2694 nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type); | 2710 nm = SharedRuntime::generate_native_wrapper(&_masm, |
2695 | 2711 method, |
2696 if (nm != NULL) { | 2712 compile_id, |
2697 method->set_code(method, nm); | 2713 sig_bt, |
2698 } | 2714 regs, |
2699 } | 2715 ret_type); |
2700 } // Unlock AdapterHandlerLibrary_lock | 2716 } |
2701 | 2717 } |
2718 | |
2719 // Must unlock before calling set_code | |
2702 | 2720 |
2703 // Install the generated code. | 2721 // Install the generated code. |
2704 if (nm != NULL) { | 2722 if (nm != NULL) { |
2705 if (PrintCompilation) { | 2723 if (PrintCompilation) { |
2706 ttyLocker ttyl; | 2724 ttyLocker ttyl; |
2707 CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : ""); | 2725 CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : ""); |
2708 } | 2726 } |
2727 method->set_code(method, nm); | |
2709 nm->post_compiled_method_load_event(); | 2728 nm->post_compiled_method_load_event(); |
2710 } else { | 2729 } else { |
2711 // CodeCache is full, disable compilation | 2730 // CodeCache is full, disable compilation |
2712 CompileBroker::handle_full_code_cache(); | 2731 CompileBroker::handle_full_code_cache(); |
2713 } | 2732 } |
2733 return nm; | |
2714 } | 2734 } |
2715 | 2735 |
2716 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread)) | 2736 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread)) |
2717 assert(thread == JavaThread::current(), "must be"); | 2737 assert(thread == JavaThread::current(), "must be"); |
2718 // The code is about to enter a JNI lazy critical native method and | 2738 // The code is about to enter a JNI lazy critical native method and |
2785 jlsValue->char_at_addr(jlsOffset); | 2805 jlsValue->char_at_addr(jlsOffset); |
2786 assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string"); | 2806 assert(TypeArrayKlass::cast(jlsValue->klass())->element_type() == T_CHAR, "compressed string"); |
2787 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size); | 2807 (void) UNICODE::as_utf8(jlsPos, jlsLen, (char *)dst, max_dtrace_string_size); |
2788 } | 2808 } |
2789 #endif // ndef HAVE_DTRACE_H | 2809 #endif // ndef HAVE_DTRACE_H |
2790 | |
2791 int SharedRuntime::convert_ints_to_longints_argcnt(int in_args_count, BasicType* in_sig_bt) { | |
2792 int argcnt = in_args_count; | |
2793 if (CCallingConventionRequiresIntsAsLongs) { | |
2794 for (int in = 0; in < in_args_count; in++) { | |
2795 BasicType bt = in_sig_bt[in]; | |
2796 switch (bt) { | |
2797 case T_BOOLEAN: | |
2798 case T_CHAR: | |
2799 case T_BYTE: | |
2800 case T_SHORT: | |
2801 case T_INT: | |
2802 argcnt++; | |
2803 break; | |
2804 default: | |
2805 break; | |
2806 } | |
2807 } | |
2808 } else { | |
2809 assert(0, "This should not be needed on this platform"); | |
2810 } | |
2811 | |
2812 return argcnt; | |
2813 } | |
2814 | |
2815 void SharedRuntime::convert_ints_to_longints(int i2l_argcnt, int& in_args_count, | |
2816 BasicType*& in_sig_bt, VMRegPair*& in_regs) { | |
2817 if (CCallingConventionRequiresIntsAsLongs) { | |
2818 VMRegPair *new_in_regs = NEW_RESOURCE_ARRAY(VMRegPair, i2l_argcnt); | |
2819 BasicType *new_in_sig_bt = NEW_RESOURCE_ARRAY(BasicType, i2l_argcnt); | |
2820 | |
2821 int argcnt = 0; | |
2822 for (int in = 0; in < in_args_count; in++, argcnt++) { | |
2823 BasicType bt = in_sig_bt[in]; | |
2824 VMRegPair reg = in_regs[in]; | |
2825 switch (bt) { | |
2826 case T_BOOLEAN: | |
2827 case T_CHAR: | |
2828 case T_BYTE: | |
2829 case T_SHORT: | |
2830 case T_INT: | |
2831 // Convert (bt) to (T_LONG,bt). | |
2832 new_in_sig_bt[argcnt ] = T_LONG; | |
2833 new_in_sig_bt[argcnt+1] = bt; | |
2834 assert(reg.first()->is_valid() && !reg.second()->is_valid(), ""); | |
2835 new_in_regs[argcnt ].set2(reg.first()); | |
2836 new_in_regs[argcnt+1].set_bad(); | |
2837 argcnt++; | |
2838 break; | |
2839 default: | |
2840 // No conversion needed. | |
2841 new_in_sig_bt[argcnt] = bt; | |
2842 new_in_regs[argcnt] = reg; | |
2843 break; | |
2844 } | |
2845 } | |
2846 assert(argcnt == i2l_argcnt, "must match"); | |
2847 | |
2848 in_regs = new_in_regs; | |
2849 in_sig_bt = new_in_sig_bt; | |
2850 in_args_count = i2l_argcnt; | |
2851 } else { | |
2852 assert(0, "This should not be needed on this platform"); | |
2853 } | |
2854 } | |
2855 | 2810 |
2856 // ------------------------------------------------------------------------- | 2811 // ------------------------------------------------------------------------- |
2857 // Java-Java calling convention | 2812 // Java-Java calling convention |
2858 // (what you use when Java calls Java) | 2813 // (what you use when Java calls Java) |
2859 | 2814 |
2950 // | 2905 // |
2951 // This code is used convert interpreter frames into compiled frames. It is | 2906 // This code is used convert interpreter frames into compiled frames. It is |
2952 // called from very start of a compiled OSR nmethod. A temp array is | 2907 // called from very start of a compiled OSR nmethod. A temp array is |
2953 // allocated to hold the interesting bits of the interpreter frame. All | 2908 // allocated to hold the interesting bits of the interpreter frame. All |
2954 // active locks are inflated to allow them to move. The displaced headers and | 2909 // active locks are inflated to allow them to move. The displaced headers and |
2955 // active interpreter locals are copied into the temp buffer. Then we return | 2910 // active interpeter locals are copied into the temp buffer. Then we return |
2956 // back to the compiled code. The compiled code then pops the current | 2911 // back to the compiled code. The compiled code then pops the current |
2957 // interpreter frame off the stack and pushes a new compiled frame. Then it | 2912 // interpreter frame off the stack and pushes a new compiled frame. Then it |
2958 // copies the interpreter locals and displaced headers where it wants. | 2913 // copies the interpreter locals and displaced headers where it wants. |
2959 // Finally it calls back to free the temp buffer. | 2914 // Finally it calls back to free the temp buffer. |
2960 // | 2915 // |