src/share/vm/runtime/sharedRuntime.cpp

changeset 6220
7b9127b17b7a
parent 6215
69dc1be43fce
child 6503
a9becfeecd1b
     1.1 --- a/src/share/vm/runtime/sharedRuntime.cpp	Thu Jan 09 19:03:36 2014 +0400
     1.2 +++ b/src/share/vm/runtime/sharedRuntime.cpp	Fri Jan 10 06:36:18 2014 +0100
     1.3 @@ -2595,11 +2595,13 @@
     1.4  #endif
     1.5  
     1.6  
     1.7 -// Create a native wrapper for this native method.  The wrapper converts the
     1.8 -// java compiled calling convention to the native convention, handlizes
     1.9 -// arguments, and transitions to native.  On return from the native we transition
    1.10 -// back to java blocking if a safepoint is in progress.
    1.11 -nmethod *AdapterHandlerLibrary::create_native_wrapper(methodHandle method, int compile_id) {
    1.12 +/**
    1.13 + * Create a native wrapper for this native method.  The wrapper converts the
    1.14 + * Java-compiled calling convention to the native convention, handles
    1.15 + * arguments, and transitions to native.  On return from the native we transition
    1.16 + * back to java blocking if a safepoint is in progress.
    1.17 + */
    1.18 +void AdapterHandlerLibrary::create_native_wrapper(methodHandle method) {
    1.19    ResourceMark rm;
    1.20    nmethod* nm = NULL;
    1.21  
    1.22 @@ -2608,16 +2610,19 @@
    1.23           method->has_native_function(), "must have something valid to call!");
    1.24  
    1.25    {
    1.26 -    // perform the work while holding the lock, but perform any printing outside the lock
    1.27 +    // Perform the work while holding the lock, but perform any printing outside the lock
    1.28      MutexLocker mu(AdapterHandlerLibrary_lock);
    1.29      // See if somebody beat us to it
    1.30      nm = method->code();
    1.31 -    if (nm) {
    1.32 -      return nm;
    1.33 +    if (nm != NULL) {
    1.34 +      return;
    1.35      }
    1.36  
    1.37 +    const int compile_id = CompileBroker::assign_compile_id(method, CompileBroker::standard_entry_bci);
    1.38 +    assert(compile_id > 0, "Must generate native wrapper");
    1.39 +
    1.40 +
    1.41      ResourceMark rm;
    1.42 -
    1.43      BufferBlob*  buf = buffer_blob(); // the temporary code buffer in CodeCache
    1.44      if (buf != NULL) {
    1.45        CodeBuffer buffer(buf);
    1.46 @@ -2649,16 +2654,14 @@
    1.47        int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, is_outgoing);
    1.48  
    1.49        // Generate the compiled-to-native wrapper code
    1.50 -      nm = SharedRuntime::generate_native_wrapper(&_masm,
    1.51 -                                                  method,
    1.52 -                                                  compile_id,
    1.53 -                                                  sig_bt,
    1.54 -                                                  regs,
    1.55 -                                                  ret_type);
    1.56 +      nm = SharedRuntime::generate_native_wrapper(&_masm, method, compile_id, sig_bt, regs, ret_type);
    1.57 +
    1.58 +      if (nm != NULL) {
    1.59 +        method->set_code(method, nm);
    1.60 +      }
    1.61      }
    1.62 -  }
    1.63 -
    1.64 -  // Must unlock before calling set_code
    1.65 +  } // Unlock AdapterHandlerLibrary_lock
    1.66 +
    1.67  
    1.68    // Install the generated code.
    1.69    if (nm != NULL) {
    1.70 @@ -2666,13 +2669,11 @@
    1.71        ttyLocker ttyl;
    1.72        CompileTask::print_compilation(tty, nm, method->is_static() ? "(static)" : "");
    1.73      }
    1.74 -    method->set_code(method, nm);
    1.75      nm->post_compiled_method_load_event();
    1.76    } else {
    1.77      // CodeCache is full, disable compilation
    1.78      CompileBroker::handle_full_code_cache();
    1.79    }
    1.80 -  return nm;
    1.81  }
    1.82  
    1.83  JRT_ENTRY_NO_ASYNC(void, SharedRuntime::block_for_jni_critical(JavaThread* thread))

mercurial