changeset 3687:7958ebb561b0

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 18 Nov 2011 17:20:38 +0100
parents 2b7278bec776 (diff) 5e331d5f760e (current diff)
children ff6582ef15b3
files src/share/vm/ci/ciEnv.cpp src/share/vm/graal/graalCodeInstaller.cpp src/share/vm/graal/graalVMEntries.cpp
diffstat 10 files changed, 102 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/domake	Fri Nov 18 17:01:32 2011 +0100
+++ b/domake	Fri Nov 18 17:20:38 2011 +0100
@@ -49,8 +49,8 @@
 pushd $graal_home/make
 
 # the piping magic runs stderr through grep and removes the complaints about Xusage.txt files
-ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=4 ALT_BOOTDIR=$JDK7G INSTALL=y make jvmggraal 3>&1 1>&2 2>&3 | grep -v Xusage[.]txt
-ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=4 ALT_BOOTDIR=$JDK7 INSTALL=y make productgraal 3>&1 1>&2 2>&3 | grep -v Xusage[.]txt
+ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=3 ALT_BOOTDIR=$JDK7 INSTALL=y make productgraal 3>&1 1>&2 2>&3 | grep -v Xusage[.]txt
+ARCH_DATA_MODEL=64 LANG=C HOTSPOT_BUILD_JOBS=3 ALT_BOOTDIR=$JDK7G INSTALL=y make jvmggraal 3>&1 1>&2 2>&3 | grep -v Xusage[.]txt
 
 popd
 
--- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Nov 18 17:20:38 2011 +0100
@@ -1058,6 +1058,39 @@
   thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message)());
 JRT_END
 
+JRT_ENTRY(void, graal_generic_callback(JavaThread* thread, oop _callback, oop _argument))
+  HandleMark hm;
+  Handle callback(_callback);
+  Handle argument(_argument);
+
+  KlassHandle klass = SystemDictionary::resolve_or_null(vmSymbols::com_sun_cri_ci_CiGenericCallback(), SystemDictionary::java_system_loader(), NULL, thread);
+  if (klass.is_null()) {
+    tty->print_cr("couldn't resolve com_sun_cri_ci_CiGenericCallback");
+  }
+
+  JavaValue result(T_OBJECT);
+  JavaCallArguments args;
+  args.push_oop(Handle(callback));
+  args.push_oop(Handle(argument));
+  JavaCalls::call_interface(&result, klass, vmSymbols::callback_name(), vmSymbols::callback_signature(), &args, thread);
+
+  if (thread->has_pending_exception()) {
+    Handle exception = PENDING_EXCEPTION;
+    CLEAR_PENDING_EXCEPTION;
+
+    assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
+    JavaValue result(T_VOID);
+    JavaCalls::call_virtual(&result,
+                            exception,
+                            KlassHandle(THREAD,
+                            SystemDictionary::Throwable_klass()),
+                            vmSymbols::printStackTrace_name(),
+                            vmSymbols::void_method_signature(),
+                            THREAD);
+  }
+  thread->set_vm_result((oop) result.get_jobject());
+JRT_END
+
 
 
 
@@ -1949,6 +1982,17 @@
       break;
     }
 
+    case graal_generic_callback_id: {
+    __ enter();
+    oop_maps = new OopMapSet();
+    OopMap* oop_map = save_live_registers(sasm, 0);
+    int call_offset = __ call_RT(rax, noreg, (address)graal_generic_callback, j_rarg0, j_rarg1);
+    oop_maps->add_gc_map(call_offset, oop_map);
+    __ leave();
+    __ ret(0);
+      break;
+    }
+
     case graal_handle_exception_id: {
       StubFrame f(sasm, "graal_handle_exception", dont_gc_arguments);
       oop_maps = new OopMapSet();
--- a/src/share/vm/c1/c1_Runtime1.hpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/c1/c1_Runtime1.hpp	Fri Nov 18 17:20:38 2011 +0100
@@ -81,6 +81,7 @@
   stub(graal_set_deopt_info)         \
   stub(graal_create_null_pointer_exception) \
   stub(graal_create_out_of_bounds_exception) \
+  stub(graal_generic_callback)       \
   last_entry(number_of_ids)
 
 #define DECLARE_STUB_ID(x)       x ## _id ,
--- a/src/share/vm/ci/ciEnv.cpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/ci/ciEnv.cpp	Fri Nov 18 17:20:38 2011 +0100
@@ -950,6 +950,8 @@
     // and invalidating our dependencies until we install this method.
     MutexLocker ml(Compile_lock);
 
+    // TODO(ls) this doesn't make much sense as long as graal doesn't support jvmti or dtrace...
+#ifndef GRAAL
     // Change in Jvmti state may invalidate compilation.
     if (!failing() &&
         ( (!jvmti_can_hotswap_or_post_breakpoint() &&
@@ -968,6 +970,7 @@
           (!dtrace_alloc_probes() && DTraceAllocProbes) )) {
       record_failure("DTrace flags change invalidated dependencies");
     }
+#endif
 
     if (!failing()) {
       if (log() != NULL) {
--- a/src/share/vm/classfile/vmSymbols.hpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/classfile/vmSymbols.hpp	Fri Nov 18 17:20:38 2011 +0100
@@ -281,6 +281,7 @@
   template(com_sun_cri_ci_CiAssumptions,              "com/sun/cri/ci/CiAssumptions")                                   \
   template(com_sun_cri_ci_CiAssumptions_ConcreteSubtype, "com/sun/cri/ci/CiAssumptions$ConcreteSubtype")                \
   template(com_sun_cri_ci_CiAssumptions_ConcreteMethod, "com/sun/cri/ci/CiAssumptions$ConcreteMethod")                  \
+  template(com_sun_cri_ci_CiGenericCallback,          "com/sun/cri/ci/CiGenericCallback")                               \
   template(com_sun_cri_ci_CiTargetMethod,             "com/sun/cri/ci/CiTargetMethod")                                  \
   template(com_sun_cri_ci_CiTargetMethod_Site,        "com/sun/cri/ci/CiTargetMethod$Site")                             \
   template(com_sun_cri_ci_CiTargetMethod_Call,        "com/sun/cri/ci/CiTargetMethod$Call")                             \
@@ -338,6 +339,8 @@
   template(initialize_name,                           "initialize")                                                     \
   template(getInstance_signature,                     "()Lcom/oracle/max/graal/hotspot/Compiler;")                      \
   template(forObject_name,                            "forObject")                                                      \
+  template(callback_name,                             "callback")                                                       \
+  template(callback_signature,                        "(Ljava/lang/Object;)Ljava/lang/Object;")                         \
                                                                                                                         \
   /* common method and field names */                                                             \
   template(object_initializer_name,                   "<init>")                                   \
--- a/src/share/vm/code/nmethod.cpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/code/nmethod.cpp	Fri Nov 18 17:20:38 2011 +0100
@@ -44,6 +44,9 @@
 #ifdef SHARK
 #include "shark/sharkCompiler.hpp"
 #endif
+#ifdef GRAAL
+#include "graal/graalJavaAccess.hpp"
+#endif
 
 #ifdef DTRACE_ENABLED
 
@@ -463,6 +466,8 @@
   _saved_nmethod_link      = NULL;
   _compiler                = NULL;
 
+  _graal_compiled_method   = NULL;
+
 #ifdef HAVE_DTRACE_H
   _trap_offset             = 0;
 #endif // def HAVE_DTRACE_H
@@ -1295,6 +1300,13 @@
       return false;
     }
 
+#ifdef GRAAL
+    if (_graal_compiled_method != NULL) {
+      HotSpotCompiledMethod::set_nmethod(_graal_compiled_method, 0);
+      _graal_compiled_method = NULL;
+    }
+#endif
+
     // The caller can be calling the method statically or through an inline
     // cache call.
     if (!is_osr_method() && !is_not_entrant()) {
@@ -1593,6 +1605,10 @@
     return;
   }
 
+  if (_graal_compiled_method != NULL && can_unload(is_alive, keep_alive, (oop*)&_graal_compiled_method, unloading_occurred)) {
+    return;
+  }
+
   // Exception cache
   ExceptionCache* ec = exception_cache();
   while (ec != NULL) {
@@ -1707,6 +1723,7 @@
 
   // Compiled code
   f->do_oop((oop*) &_method);
+  f->do_oop((oop*) &_graal_compiled_method);
   if (!do_strong_roots_only) {
     // weak roots processing phase -- update ExceptionCache oops
     ExceptionCache* ec = exception_cache();
--- a/src/share/vm/code/nmethod.hpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/code/nmethod.hpp	Fri Nov 18 17:20:38 2011 +0100
@@ -116,6 +116,8 @@
   int       _entry_bci;        // != InvocationEntryBci if this nmethod is an on-stack replacement method
   jmethodID _jmethod_id;       // Cache of method()->jmethod_id()
 
+  oop       _graal_compiled_method;
+
   // To support simple linked-list chaining of nmethods:
   nmethod*  _osr_link;         // from instanceKlass::osr_nmethods_head
   nmethod*  _scavenge_root_link; // from CodeCache::scavenge_root_nmethods
@@ -539,6 +541,10 @@
   // Evolution support. We make old (discarded) compiled methods point to new methodOops.
   void set_method(methodOop method) { _method = method; }
 
+
+  oop graal_compiled_method() { return _graal_compiled_method; }
+  void set_graal_compiled_method(oop compiled_method) { _graal_compiled_method = compiled_method; }
+
   // GC support
   void do_unloading(BoolObjectClosure* is_alive, OopClosure* keep_alive,
                     bool unloading_occurred);
--- a/src/share/vm/graal/graalCodeInstaller.cpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/graal/graalCodeInstaller.cpp	Fri Nov 18 17:20:38 2011 +0100
@@ -591,8 +591,13 @@
     TRACE_graal_3("CiRuntimeCall::ArithmeticTan()");
   } else if (runtime_call == CiRuntimeCall::RegisterFinalizer()) {
     target_addr = Runtime1::entry_for(Runtime1::register_finalizer_id);
+    TRACE_graal_3("CiRuntimeCall::RegisterFinalizer()");
   } else if (runtime_call == CiRuntimeCall::Deoptimize()) {
     target_addr = SharedRuntime::deopt_blob()->uncommon_trap();
+    TRACE_graal_3("CiRuntimeCall::Deoptimize()");
+  } else if (runtime_call == CiRuntimeCall::GenericCallback()) {
+    target_addr = Runtime1::entry_for(Runtime1::graal_generic_callback_id);
+    TRACE_graal_3("CiRuntimeCall::GenericCallback()");
   } else {
     runtime_call->print();
     fatal("runtime_call not implemented");
--- a/src/share/vm/graal/graalJavaAccess.hpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/graal/graalJavaAccess.hpp	Fri Nov 18 17:20:38 2011 +0100
@@ -78,6 +78,7 @@
   end_class                                                                             \
   start_class(HotSpotCompiledMethod)                                                    \
     long_field(HotSpotCompiledMethod, nmethod)                                          \
+    oop_field(HotSpotCompiledMethod, method, "Lcom/sun/cri/ri/RiResolvedMethod;")       \
   end_class                                                                             \
   start_class(HotSpotProxy)                                                             \
     static_oop_field(HotSpotProxy, DUMMY_CONSTANT_OBJ, "Ljava/lang/Long;")              \
@@ -195,6 +196,7 @@
     static_oop_field(CiRuntimeCall, ArithmeticLog10, "Lcom/sun/cri/ci/CiRuntimeCall;"); \
     static_oop_field(CiRuntimeCall, ArithmeticSin, "Lcom/sun/cri/ci/CiRuntimeCall;");   \
     static_oop_field(CiRuntimeCall, Deoptimize, "Lcom/sun/cri/ci/CiRuntimeCall;");      \
+    static_oop_field(CiRuntimeCall, GenericCallback, "Lcom/sun/cri/ci/CiRuntimeCall;"); \
   end_class                                                                             \
   start_class(RiMethod)                                                                 \
   end_class                                                                             \
--- a/src/share/vm/graal/graalVMEntries.cpp	Fri Nov 18 17:01:32 2011 +0100
+++ b/src/share/vm/graal/graalVMEntries.cpp	Fri Nov 18 17:20:38 2011 +0100
@@ -888,6 +888,8 @@
   set_int(env, config, "klassOopOffset", java_lang_Class::klass_offset_in_bytes());
   set_boolean(env, config, "isPollingPageFar", Assembler::is_polling_page_far());
 
+  set_int(env, config, "nmethodEntryOffset", nmethod::verified_entry_point_offset());
+
   BarrierSet* bs = Universe::heap()->barrier_set();
   switch (bs->kind()) {
     case BarrierSet::CardTableModRef:
@@ -923,8 +925,8 @@
   return config;
 }
 
-// public long installMethod(HotSpotTargetMethod targetMethod, boolean installCode);
-JNIEXPORT jlong JNICALL Java_com_oracle_graal_hotspot_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod, jboolean install_code) {
+// public HotSpotCompiledMethod installMethod(HotSpotTargetMethod targetMethod, boolean installCode);
+JNIEXPORT jobject JNICALL Java_com_oracle_graal_hotspot_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod, jboolean install_code) {
   VM_ENTRY_MARK;
   ResourceMark rm;
   HandleMark hm;
@@ -933,7 +935,19 @@
   Arena arena;
   ciEnv env(&arena);
   CodeInstaller installer(targetMethodHandle, nm, install_code != 0);
-  return (jlong) nm;
+
+  // if install_code is true then we installed the code into the given method, no need to return an RiCompiledMethod
+  if (!install_code && nm != NULL) {
+    instanceKlass::cast(HotSpotCompiledMethod::klass())->initialize(CHECK_NULL);
+    Handle obj = instanceKlass::cast(HotSpotCompiledMethod::klass())->allocate_permanent_instance(CHECK_NULL);
+    assert(obj() != NULL, "must succeed in allocating instance");
+    HotSpotCompiledMethod::set_nmethod(obj, (jlong) nm);
+    HotSpotCompiledMethod::set_method(obj, HotSpotTargetMethod::method(targetMethod));
+    nm->set_graal_compiled_method(obj());
+    return JNIHandles::make_local(obj());
+  } else {
+    return NULL;
+  }
 }
 
 // public HotSpotProxy installStub(HotSpotTargetMethod targetMethod, String name);
@@ -985,6 +999,7 @@
 #define TARGET_METHOD   "Lcom/oracle/max/graal/hotspot/HotSpotTargetMethod;"
 #define CONFIG          "Lcom/oracle/max/graal/hotspot/HotSpotVMConfig;"
 #define HS_METHOD       "Lcom/oracle/max/graal/hotspot/HotSpotMethod;"
+#define HS_COMP_METHOD  "Lcom/oracle/max/graal/hotspot/HotSpotCompiledMethod;"
 #define CI_CONSTANT     "Lcom/sun/cri/ci/CiConstant;"
 #define CI_KIND         "Lcom/sun/cri/ci/CiKind;"
 #define CI_RUNTIME_CALL "Lcom/sun/cri/ci/CiRuntimeCall;"
@@ -1023,7 +1038,7 @@
   {CC"getMaxCallTargetOffset",            CC"("CI_RUNTIME_CALL")J",                   FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getMaxCallTargetOffset)},
   {CC"getType",                           CC"("CLASS")"TYPE,                          FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getType)},
   {CC"getConfiguration",                  CC"()"CONFIG,                               FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_getConfiguration)},
-  {CC"installMethod",                     CC"("TARGET_METHOD"Z)J",                    FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installMethod)},
+  {CC"installMethod",                     CC"("TARGET_METHOD"Z)"HS_COMP_METHOD,       FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installMethod)},
   {CC"installStub",                       CC"("TARGET_METHOD")"PROXY,                 FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_installStub)},
   {CC"recordBailout",                     CC"("STRING")V",                            FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_recordBailout)},
   {CC"notifyJavaQueue",                   CC"()V",                                    FN_PTR(Java_com_oracle_graal_hotspot_VMEntries_notifyJavaQueue)}