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