Mercurial > hg > truffle
comparison src/share/vm/runtime/sharedRuntime.cpp @ 17625:7b9127b17b7a
8022494: Make compilation IDs sequential
Summary: Use atomic operations to provide sequential compilation IDs
Reviewed-by: kvn, twisti
author | anoll |
---|---|
date | Fri, 10 Jan 2014 06:36:18 +0100 |
parents | 69dc1be43fce |
children | a9becfeecd1b |
comparison
equal
deleted
inserted
replaced
17624:9f4f77ef2706 | 17625:7b9127b17b7a |
---|---|
2593 return (memcmp(buffer, _saved_code, length) == 0) ? true : false; | 2593 return (memcmp(buffer, _saved_code, length) == 0) ? true : false; |
2594 } | 2594 } |
2595 #endif | 2595 #endif |
2596 | 2596 |
2597 | 2597 |
2598 // Create a native wrapper for this native method. The wrapper converts the | 2598 /** |
2599 // java compiled calling convention to the native convention, handlizes | 2599 * Create a native wrapper for this native method. The wrapper converts the |
2600 // arguments, and transitions to native. On return from the native we transition | 2600 * Java-compiled calling convention to the native convention, handles |
2601 // back to java blocking if a safepoint is in progress. | 2601 * arguments, and transitions to native. On return from the native we transition |
2602 nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method, int compile_id) { | 2602 * back to java blocking if a safepoint is in progress. |
2603 */ | |
2604 void AdapterHandlerLibrary::create_native_wrapper(methodHandle method) { | |
2603 ResourceMark rm; | 2605 ResourceMark rm; |
2604 nmethod* nm = NULL; | 2606 nmethod* nm = NULL; |
2605 | 2607 |
2606 assert(method->is_native(), "must be native"); | 2608 assert(method->is_native(), "must be native"); |
2607 assert(method->is_method_handle_intrinsic() || | 2609 assert(method->is_method_handle_intrinsic() || |
2608 method->has_native_function(), "must have something valid to call!"); | 2610 method->has_native_function(), "must have something valid to call!"); |
2609 | 2611 |
2610 { | 2612 { |
2611 // perform the work while holding the lock, but perform any printing outside the lock | 2613 // Perform the work while holding the lock, but perform any printing outside the lock |
2612 MutexLocker mu(AdapterHandlerLibrary_lock); | 2614 MutexLocker mu(AdapterHandlerLibrary_lock); |
2613 // See if somebody beat us to it | 2615 // See if somebody beat us to it |
2614 nm = method->code(); | 2616 nm = method->code(); |
2615 if (nm) { | 2617 if (nm != NULL) { |
2616 return nm; | 2618 return; |
2617 } | 2619 } |
2620 | |
2621 const int compile_id = CompileBroker::assign_compile_id(method, CompileBroker::standard_entry_bci); | |
2622 assert(compile_id > 0, "Must generate native wrapper"); | |
2623 | |
2618 | 2624 |
2619 ResourceMark rm; | 2625 ResourceMark rm; |
2620 | |
2621 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache | 2626 BufferBlob* buf = buffer_blob(); // the temporary code buffer in CodeCache |
2622 if (buf != NULL) { | 2627 if (buf != NULL) { |
2623 CodeBuffer buffer(buf); | 2628 CodeBuffer buffer(buf); |
2624 double locs_buf[20]; | 2629 double locs_buf[20]; |
2625 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); | 2630 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buf, sizeof(locs_buf) / sizeof(relocInfo)); |
2647 // are just trampolines so the argument registers must be outgoing ones. | 2652 // are just trampolines so the argument registers must be outgoing ones. |
2648 const bool is_outgoing = method->is_method_handle_intrinsic(); | 2653 const bool is_outgoing = method->is_method_handle_intrinsic(); |
2649 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); | 2654 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing); |
2650 | 2655 |
2651 // Generate the compiled-to-native wrapper code | 2656 // Generate the compiled-to-native wrapper code |
2652 nm = SharedRuntime::generate_native_wrapper(&_masm, | 2657 nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type); |
2653 method, | 2658 |
2654 compile_id, | 2659 if (nm != NULL) { |
2655 sig_bt, | 2660 method->set_code(method, nm); |
2656 regs, | 2661 } |
2657 ret_type); | 2662 } |
2658 } | 2663 } // Unlock AdapterHandlerLibrary_lock |
2659 } | 2664 |
2660 | |
2661 // Must unlock before calling set_code | |
2662 | 2665 |
2663 // Install the generated code. | 2666 // Install the generated code. |
2664 if (nm != NULL) { | 2667 if (nm != NULL) { |
2665 if (PrintCompilation) { | 2668 if (PrintCompilation) { |
2666 ttyLocker ttyl; | 2669 ttyLocker ttyl; |
2667 CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : ""); | 2670 CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : ""); |
2668 } | 2671 } |
2669 method->set_code(method, nm); | |
2670 nm->post_compiled_method_load_event(); | 2672 nm->post_compiled_method_load_event(); |
2671 } else { | 2673 } else { |
2672 // CodeCache is full, disable compilation | 2674 // CodeCache is full, disable compilation |
2673 CompileBroker::handle_full_code_cache(); | 2675 CompileBroker::handle_full_code_cache(); |
2674 } | 2676 } |
2675 return nm; | |
2676 } | 2677 } |
2677 | 2678 |
2678 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread)) | 2679 JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread)) |
2679 assert(thread == JavaThread::current(), "must be"); | 2680 assert(thread == JavaThread::current(), "must be"); |
2680 // The code is about to enter a JNI lazy critical native method and | 2681 // The code is about to enter a JNI lazy critical native method and |