changeset 1452:9b22e3e5df8e

Solved an issue with unresolved field patching.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Fri, 12 Nov 2010 18:04:27 +0100
parents 8c121f2190f8
children d603bdbec024
files c1x4hotspotsrc/HotSpotTest/src/JavaTester.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java runscimark.sh src/os_cpu/linux_x86/vm/os_linux_x86.cpp src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_Compiler.hpp src/share/vm/c1x/c1x_VMEntries.cpp
diffstat 10 files changed, 38 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotTest/src/JavaTester.java	Thu Nov 11 14:42:14 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotTest/src/JavaTester.java	Fri Nov 12 18:04:27 2010 +0100
@@ -1809,7 +1809,7 @@
 			jtt_jdk_Class_getName();
 			break;
 		case 581:
-			//jtt_jdk_EnumMap01();
+			jtt_jdk_EnumMap01();
 			break;
 		case 582:
 			jtt_jdk_EnumMap02();
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Thu Nov 11 14:42:14 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotConstantPool.java	Fri Nov 12 18:04:27 2010 +0100
@@ -64,7 +64,7 @@
 
     @Override
     public RiField lookupField(int cpi, int opcode) {
-        return Compiler.getVMEntries().RiConstantPool_lookupField(vmId, cpi);
+        return Compiler.getVMEntries().RiConstantPool_lookupField(vmId, cpi, (byte) opcode);
     }
 
 }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Thu Nov 11 14:42:14 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Fri Nov 12 18:04:27 2010 +0100
@@ -813,7 +813,7 @@
 
     @Override
     public XirSnippet genResolveClass(XirSite site, RiType type, Representation rep) {
-        assert rep == Representation.ObjectHub || rep == Representation.StaticFields : "unexpected representation: " + rep;
+        assert rep == Representation.ObjectHub || rep == Representation.StaticFields || rep == Representation.JavaClass : "unexpected representation: " + rep;
         if (type instanceof HotSpotTypeResolved) {
             return new XirSnippet(resolveClassTemplates.get(site), XirArgument.forObject(type));
         }
@@ -995,6 +995,8 @@
             asm.mark(MARK_DUMMY_OOP_RELOCATION);
             asm.jmp(patchStub);
 
+            // TODO(tw): Need a safepoint here?
+
             // TODO: make this more generic & safe - this is needed to create space for patching
             asm.nop(5);
 
@@ -1059,8 +1061,8 @@
             asm.mark(MARK_DUMMY_OOP_RELOCATION);
             if (nullCheck) {
                 asm.mark(MARK_IMPLICIT_NULL);
-                asm.safepoint();
             }
+            asm.safepoint();
             asm.jmp(patchStub);
 
             // TODO: make this more generic & safe - this is needed to create space for patching
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java	Thu Nov 11 14:42:14 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntries.java	Fri Nov 12 18:04:27 2010 +0100
@@ -55,7 +55,7 @@
 
     RiType RiConstantPool_lookupType(long vmId, int cpi);
 
-    RiField RiConstantPool_lookupField(long vmId, int cpi);
+    RiField RiConstantPool_lookupField(long vmId, int cpi, byte byteCode);
 
     RiConstantPool RiType_constantPool(long vmId);
 
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java	Thu Nov 11 14:42:14 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMEntriesNative.java	Fri Nov 12 18:04:27 2010 +0100
@@ -66,7 +66,7 @@
     public native RiType RiConstantPool_lookupType(long vmId, int cpi);
 
     @Override
-    public native RiField RiConstantPool_lookupField(long vmId, int cpi);
+    public native RiField RiConstantPool_lookupField(long vmId, int cpi, byte byteCode);
 
     @Override
     public native RiConstantPool RiType_constantPool(long vmId);
--- a/runscimark.sh	Thu Nov 11 14:42:14 2010 +0100
+++ b/runscimark.sh	Fri Nov 12 18:04:27 2010 +0100
@@ -11,8 +11,12 @@
   echo "C1X is not defined. It must point to a c1x4hotspot directory."
   exit 1;
 fi
-for (( i = 1; i <= 4000; i++ ))      ### Outer for loop ###
+if [ -z "${SCIMARK}" ]; then
+  echo "SCIMARK is not defined. It must point to a SciMark benchmark directory."
+  exit 1;
+fi
+for (( i = 1; i <= 5000; i++ ))      ### Outer for loop ###
 do
   echo "$i "
-  ${JRE7}/bin/java -client -esa -ea -XX:+UseC1X -Xms32m -Xmx100m -Xbootclasspath/p:${MAXINE}/C1X/bin:${MAXINE}/CRI/bin:${MAXINE}/Base/bin:${MAXINE}/Assembler/bin:${C1X}/c1x4hotspotsrc/HotSpotVM/bin -Xbootclasspath/a:/home/tw/Benchmarks/scimark/ -classpath "${SCIMARK}" -C1X:+PrintTimers  jnt.scimark2.commandline -large
+  ${JRE7}/bin/java -client -esa -ea -XX:+UseC1X -Xms32m -Xmx100m -Xbootclasspath/p:${MAXINE}/C1X/bin:${MAXINE}/CRI/bin:${MAXINE}/Base/bin:${MAXINE}/Assembler/bin:${C1X}/c1x4hotspotsrc/HotSpotVM/bin -Xbootclasspath/a:${SCIMARK} -C1X:+PrintTimers  jnt.scimark2.commandline -large
 done
--- a/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Nov 11 14:42:14 2010 +0100
+++ b/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Fri Nov 12 18:04:27 2010 +0100
@@ -268,7 +268,7 @@
           if (thread->thread_state() == _thread_in_Java) {
             // Throw a stack overflow exception.  Guard pages will be reenabled
             // while unwinding the stack.
-            tty->print("implicit: %08x%08x\n", ((long)pc) >> 32, pc);
+            if (WizardMode) tty->print("implicit: %08x%08x\n", ((long)pc) >> 32, pc);
             stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
           } else {
             // Thread was in the vm or native code.  Return and try to finish.
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Thu Nov 11 14:42:14 2010 +0100
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Fri Nov 12 18:04:27 2010 +0100
@@ -45,7 +45,10 @@
   assert(klass != NULL, "c1x VMEntries class not found");
   env->RegisterNatives(klass, VMEntries_methods, VMEntries_methods_count());
 
-  check_pending_exception("Could not register natives");
+  {
+    VM_ENTRY_MARK;
+    check_pending_exception("Could not register natives");
+  }
 
   c1x_compute_offsets();
 
@@ -83,7 +86,7 @@
   TRACE_C1X_1("C1XCompiler::print_timers");
 }
 
-oop C1XCompiler::get_RiType(ciType *type, klassOop accessor, TRAPS) {
+oop C1XCompiler::get_RiType(ciType *type, KlassHandle accessor, TRAPS) {
   if (type->is_loaded()) {
     if (type->is_primitive_type()) {
       return VMExits::createRiTypePrimitive((int) type->basic_type(), THREAD);
@@ -93,15 +96,23 @@
     return createHotSpotTypeResolved(klass, name, CHECK_NULL);
   } else {
     symbolOop name = ((ciKlass *) type)->name()->get_symbolOop();
-    return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), VmIds::add<klassOop>(accessor), THREAD);
+    return VMExits::createRiTypeUnresolved(VmIds::toString<Handle>(name, THREAD), VmIds::add<klassOop>(accessor()), THREAD);
   }
 }
 
-oop C1XCompiler::get_RiField(ciField *field, klassOop accessor, TRAPS) {
+oop C1XCompiler::get_RiField(ciField *field, KlassHandle accessor, Bytecodes::Code byteCode, TRAPS) {
   Handle field_holder = get_RiType(field->holder(), accessor, CHECK_0);
   Handle field_type = get_RiType(field->type(), accessor, CHECK_0);
   Handle field_name = VmIds::toString<Handle>(field->name()->get_symbolOop(), CHECK_0);
-  int offset = field->holder()->is_loaded() ? field->offset() : -1;
+
+  ciInstanceKlass* accessor_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(accessor());
+  bool will_link;
+  {
+    ThreadToNativeFromVM trans((JavaThread*)THREAD);
+    will_link = field->will_link(accessor_klass, byteCode);
+  }
+
+  int offset = (field->holder()->is_loaded() && will_link) ? field->offset() : -1;
 
   // TODO: implement caching
   return VMExits::createRiField(field_holder, field_name, field_type, offset, THREAD);
--- a/src/share/vm/c1x/c1x_Compiler.hpp	Thu Nov 11 14:42:14 2010 +0100
+++ b/src/share/vm/c1x/c1x_Compiler.hpp	Fri Nov 12 18:04:27 2010 +0100
@@ -56,8 +56,8 @@
   // Print compilation timers and statistics
   virtual void print_timers();
 
-  static oop get_RiType(ciType *klass, klassOop accessor, TRAPS);
-  static oop get_RiField(ciField *ciField, klassOop accessor, TRAPS);
+  static oop get_RiType(ciType *klass, KlassHandle accessor, TRAPS);
+  static oop get_RiField(ciField *ciField, KlassHandle accessor, Bytecodes::Code byteCode, TRAPS);
 
   static oop createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS);
 
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Thu Nov 11 14:42:14 2010 +0100
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Fri Nov 12 18:04:27 2010 +0100
@@ -248,14 +248,15 @@
 }
 
 // public RiField RiConstantPool_lookupField(long vmId, int cpi);
-JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index) {
+JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField(JNIEnv *env, jobject, jlong vmId, jint index, jbyte byteCode) {
   VM_ENTRY_MARK;
 
   constantPoolOop cp = VmIds::get<constantPoolOop>(vmId);
 
   ciInstanceKlass* loading_klass = (ciInstanceKlass *) CURRENT_ENV->get_object(cp->pool_holder());
   ciField *field = CURRENT_ENV->get_field_by_index(loading_klass, index);
-  return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field, cp->pool_holder(), THREAD));
+  Bytecodes::Code code = (Bytecodes::Code)(((int) byteCode) & 0xFF);
+  return JNIHandles::make_local(THREAD, C1XCompiler::get_RiField(field, cp->pool_holder(), code, THREAD));
 }
 
 // public RiConstantPool RiType_constantPool(long vmId);
@@ -319,7 +320,7 @@
   BasicType type = C1XCompiler::kindToBasicType(CiKind::typeChar(kind));
   assert(type != T_OBJECT, "primitive type expecteds");
   ciKlass* klass = ciTypeArrayKlass::make(type);
-  return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(klass, NULL, THREAD));
+  return JNIHandles::make_local(THREAD, C1XCompiler::get_RiType(klass, KlassHandle(NULL, THREAD), THREAD));
 }
 
 // public RiType getType(Class<?> javaClass);
@@ -494,7 +495,7 @@
   {CC"RiConstantPool_lookupMethod",     CC"("PROXY"IB)"METHOD,              FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupMethod)},
   {CC"RiConstantPool_lookupSignature",  CC"("PROXY"I)"SIGNATURE,            FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupSignature)},
   {CC"RiConstantPool_lookupType",       CC"("PROXY"I)"TYPE,                 FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupType)},
-  {CC"RiConstantPool_lookupField",      CC"("PROXY"I)"FIELD,                FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField)},
+  {CC"RiConstantPool_lookupField",      CC"("PROXY"IB)"FIELD,               FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiConstantPool_1lookupField)},
   {CC"RiType_constantPool",             CC"("PROXY")"CONSTANT_POOL,         FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_1constantPool)},
   {CC"RiType_resolveMethodImpl",        CC"("PROXY STRING STRING")"METHOD,  FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_3resolveMethodImpl)},
   {CC"RiType_isSubtypeOf",              CC"("PROXY TYPE")Z",                FN_PTR(Java_com_sun_hotspot_c1x_VMEntries_RiType_2isSubtypeOf)},