changeset 1449:8cfe3537a0d3

Pointer verification stub. Two loose oop fixes in C1X C++ part. Logging which methods have been compiled.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Thu, 11 Nov 2010 14:09:37 +0100
parents a7b84a5e16c6
children 565f45cebac2
files .hgignore c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java runscimark.sh src/cpu/x86/vm/c1_Runtime1_x86.cpp src/share/vm/c1/c1_Runtime1.cpp src/share/vm/c1/c1_Runtime1.hpp src/share/vm/c1x/c1x_CodeInstaller.cpp src/share/vm/c1x/c1x_Compiler.cpp src/share/vm/c1x/c1x_VMEntries.cpp
diffstat 14 files changed, 133 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Tue Nov 09 13:42:06 2010 +0100
+++ b/.hgignore	Thu Nov 11 14:09:37 2010 +0100
@@ -7,7 +7,9 @@
 .swp$
 .class$
 .log$
+.orig$
 output.txt$
+output.cfg$
 /nbproject/private/
 ^src/share/tools/hsdis/build/
 ^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Tue Nov 09 13:42:06 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/Compiler.java	Thu Nov 11 14:09:37 2010 +0100
@@ -174,13 +174,6 @@
         }
         compiler = new C1XCompiler(runtime, target, generator, registerConfig);
 
-        C1XOptions.setOptimizationLevel(3);
-        C1XOptions.OptInlineExcept = false;
-        C1XOptions.OptInlineSynchronized = false;
-        C1XOptions.UseDeopt = false;
-        C1XOptions.IRChecking = Logger.ENABLED;
-        C1XOptions.GenAssertionCode = Logger.ENABLED;
-
         // these options are important - c1x4hotspot will not generate correct code without them
         C1XOptions.GenSpecialDivChecks = true;
         C1XOptions.AlignCallsForPatching = true;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java	Tue Nov 09 13:42:06 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotMethodResolved.java	Thu Nov 11 14:09:37 2010 +0100
@@ -165,7 +165,7 @@
 
     @Override
     public String toString() {
-        return "HotSpotMethod<" + name + ">";
+        return "HotSpotMethod<" + holder.name() + ". " + name + ">";
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Tue Nov 09 13:42:06 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotRuntime.java	Thu Nov 11 14:09:37 2010 +0100
@@ -22,6 +22,7 @@
 
 import java.io.*;
 import java.lang.reflect.*;
+import java.util.*;
 
 import com.sun.cri.ci.*;
 import com.sun.cri.ci.CiTargetMethod.Call;
@@ -117,7 +118,8 @@
                 return string;
             }
         };
-        return disassemble(targetMethod.targetCode(), disassemblyPrinter);
+        final byte[] code = Arrays.copyOf(targetMethod.targetCode(), targetMethod.targetCodeSize());
+        return disassemble(code, disassemblyPrinter);
     }
 
     @Override
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Tue Nov 09 13:42:06 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotVMConfig.java	Thu Nov 11 14:09:37 2010 +0100
@@ -32,6 +32,7 @@
     // os information, register layout, code generation, ...
     public boolean windowsOs;
     public int codeEntryAlignment;
+    public boolean verifyPointers;
 
     // offsets, ...
     public int vmPageSize;
@@ -71,6 +72,7 @@
     public long throwArrayIndexException;
     public long monitorEnterStub;
     public long monitorExitStub;
+    public long verifyPointerStub;
 
     public void check() {
         assert vmPageSize >= 16;
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Tue Nov 09 13:42:06 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotXirGenerator.java	Thu Nov 11 14:09:37 2010 +0100
@@ -37,6 +37,7 @@
 import com.sun.cri.xir.CiXirAssembler.XirMark;
 import com.sun.cri.xir.CiXirAssembler.XirOperand;
 import com.sun.cri.xir.CiXirAssembler.XirParameter;
+import com.sun.cri.xir.CiXirAssembler.XirRegister;
 
 /**
  *
@@ -84,8 +85,8 @@
         @Override
         protected XirTemplate create(CiXirAssembler asm, long flags) {
             asm.restart(CiKind.Void);
-            XirOperand framePointer = asm.createRegister("frame pointer", CiKind.Word, AMD64.rbp);
-            XirOperand stackPointer = asm.createRegister("stack pointer", CiKind.Word, AMD64.rsp);
+            XirOperand framePointer = asm.createRegisterTemp("frame pointer", CiKind.Word, AMD64.rbp);
+            XirOperand stackPointer = asm.createRegisterTemp("stack pointer", CiKind.Word, AMD64.rsp);
             XirLabel unverifiedStub = null;
 
             asm.mark(MARK_OSR_ENTRY);
@@ -93,11 +94,11 @@
             if (!is(STATIC_METHOD, flags)) {
                 unverifiedStub = asm.createOutOfLineLabel("unverified");
 
-                XirOperand temp = asm.createRegister("temp (r10)", CiKind.Word, AMD64.r10);
-                XirOperand cache = asm.createRegister("cache (rax)", CiKind.Word, AMD64.rax);
+                XirOperand temp = asm.createRegisterTemp("temp (r10)", CiKind.Word, AMD64.r10);
+                XirOperand cache = asm.createRegisterTemp("cache (rax)", CiKind.Word, AMD64.rax);
 
                 CiCallingConvention conventions = registerConfig.getCallingConvention(Java, new CiKind[] {CiKind.Object}, false, target);
-                XirOperand receiver = asm.createRegister("cache (rax)", CiKind.Word, conventions.locations[0].asRegister());
+                XirOperand receiver = asm.createRegisterTemp("receiver", CiKind.Word, conventions.locations[0].asRegister());
 
                 asm.pload(CiKind.Word, temp, receiver, asm.i(config.hubOffset), false);
                 asm.jneq(unverifiedStub, cache, temp);
@@ -110,7 +111,7 @@
             asm.pushFrame();
 
             // -- out of line -------------------------------------------------------
-            XirOperand thread = asm.createRegister("thread", CiKind.Word, AMD64.r15);
+            XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15);
             XirOperand exceptionOop = asm.createTemp("exception oop", CiKind.Object);
             XirLabel unwind = asm.createOutOfLineLabel("unwind");
             asm.bindOutOfLine(unwind);
@@ -142,7 +143,7 @@
         @Override
         protected XirTemplate create(CiXirAssembler asm, long flags) {
             asm.restart(CiKind.Void);
-            XirOperand framePointer = asm.createRegister("frame pointer", CiKind.Word, AMD64.rbp);
+            XirOperand framePointer = asm.createRegisterTemp("frame pointer", CiKind.Word, AMD64.rbp);
 
             asm.popFrame();
             asm.pop(framePointer);
@@ -171,7 +172,7 @@
         @Override
         protected XirTemplate create(CiXirAssembler asm, long flags) {
             XirOperand result = asm.restart(CiKind.Object);
-            XirOperand thread = asm.createRegister("thread", CiKind.Word, AMD64.r15);
+            XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15);
 
             asm.pload(CiKind.Object, result, thread, asm.i(config.threadExceptionOopOffset), false);
             asm.pstore(CiKind.Object, thread, asm.i(config.threadExceptionOopOffset), asm.o(null), false);
@@ -206,7 +207,7 @@
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object);
             XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word);
-            XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax);
+            XirOperand temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.rax);
 
             if (is(NULL_CHECK, flags)) {
                 asm.nop(1);
@@ -227,7 +228,7 @@
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object);
             XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word);
-            XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax);
+            XirOperand temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.rax);
 
             if (is(NULL_CHECK, flags)) {
                 asm.nop(1);
@@ -248,7 +249,7 @@
             asm.restart();
             XirParameter receiver = asm.createInputParameter("receiver", CiKind.Object);
             XirParameter addr = asm.createConstantInputParameter("addr", CiKind.Word);
-            XirOperand temp = asm.createRegister("temp", CiKind.Word, AMD64.rax);
+            XirOperand temp = asm.createRegisterTemp("temp", CiKind.Word, AMD64.rax);
             XirLabel stub = asm.createOutOfLineLabel("call stub");
 
             if (is(NULL_CHECK, flags)) {
@@ -260,7 +261,7 @@
 
             // -- out of line -------------------------------------------------------
             asm.bindOutOfLine(stub);
-            XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx);
+            XirOperand method = asm.createRegisterTemp("method", CiKind.Object, AMD64.rbx);
             asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE);
             asm.mov(method, asm.w(0L));
             XirLabel dummy = asm.createOutOfLineLabel("dummy");
@@ -283,7 +284,7 @@
 
             // -- out of line -------------------------------------------------------
             asm.bindOutOfLine(stub);
-            XirOperand method = asm.createRegister("method", CiKind.Object, AMD64.rbx);
+            XirOperand method = asm.createRegisterTemp("method", CiKind.Object, AMD64.rbx);
             asm.mark(MARK_STATIC_CALL_STUB, XirMark.CALLSITE);
             asm.mov(method, asm.w(0L));
             XirLabel dummy = asm.createOutOfLineLabel("dummy");
@@ -376,9 +377,14 @@
                 asm.nop(1);
                 asm.mark(MARK_IMPLICIT_NULL);
             }
+            if (kind == CiKind.Object) {
+                verifyPointer(asm, value);
+            }
             asm.pstore(kind, object, fieldOffset, value, is(NULL_CHECK, flags));
             if (is(WRITE_BARRIER, flags)) {
-                writeBarrier(asm, object);
+                XirOperand temp = asm.createTemp("temp", CiKind.Word);
+                asm.mov(temp, object);
+                writeBarrier(asm, temp);
             }
             return asm.finishTemplate("putfield<" + kind + ">");
         }
@@ -391,10 +397,10 @@
             XirOperand result = asm.restart(CiKind.Word);
             XirOperand type = asm.createInputParameter("type", CiKind.Object);
 
-            XirOperand thread = asm.createRegister("thread", CiKind.Word, AMD64.r15);
-            XirOperand temp1 = asm.createRegister("temp1", CiKind.Word, AMD64.rcx);
-            XirOperand temp2 = asm.createRegister("temp2", CiKind.Word, AMD64.rbx);
-            XirOperand temp2i = asm.createRegister("temp2i", CiKind.Int, AMD64.rbx);
+            XirOperand thread = asm.createRegisterTemp("thread", CiKind.Word, AMD64.r15);
+            XirOperand temp1 = asm.createRegisterTemp("temp1", CiKind.Word, AMD64.rcx);
+            XirOperand temp2 = asm.createRegisterTemp("temp2", CiKind.Word, AMD64.rbx);
+            XirOperand temp2i = asm.createRegisterTemp("temp2i", CiKind.Int, AMD64.rbx);
             useRegisters(asm, AMD64.rsi);
             XirLabel tlabFull = asm.createOutOfLineLabel("tlab full");
             XirLabel resume = asm.createInlineLabel("resume");
@@ -424,7 +430,7 @@
 
             // -- out of line -------------------------------------------------------
             asm.bindOutOfLine(tlabFull);
-            XirOperand arg = asm.createRegister("runtime call argument", CiKind.Object, AMD64.rdx);
+            XirOperand arg = asm.createRegisterTemp("runtime call argument", CiKind.Object, AMD64.rdx);
             asm.mov(arg, type);
             useRegisters(asm, AMD64.rax);
             asm.callRuntime(config.newInstanceStub, result);
@@ -439,7 +445,7 @@
         @Override
         protected XirTemplate create(CiXirAssembler asm, long flags) {
             XirOperand result = asm.restart(CiKind.Word);
-            XirOperand arg = asm.createRegister("runtime call argument", CiKind.Object, AMD64.rdx);
+            XirOperand arg = asm.createRegisterTemp("runtime call argument", CiKind.Object, AMD64.rdx);
 
             UnresolvedClassPatching patching = new UnresolvedClassPatching(asm, arg, config);
 
@@ -462,8 +468,8 @@
 
             XirParameter lengthParam = asm.createInputParameter("length", CiKind.Int);
 
-            XirOperand length = asm.createRegister("length", CiKind.Int, AMD64.rbx);
-            XirOperand hub = asm.createRegister("hub", CiKind.Object, AMD64.rdx);
+            XirOperand length = asm.createRegisterTemp("length", CiKind.Int, AMD64.rbx);
+            XirOperand hub = asm.createRegisterTemp("hub", CiKind.Object, AMD64.rdx);
 
             UnresolvedClassPatching patching = null;
             if (is(UNRESOLVED, flags)) {
@@ -493,8 +499,8 @@
             XirParameter lengthParam = asm.createInputParameter("length", CiKind.Int);
             XirParameter hubParam = asm.createConstantInputParameter("hub", CiKind.Object);
 
-            XirOperand length = asm.createRegister("length", CiKind.Int, AMD64.rbx);
-            XirOperand hub = asm.createRegister("hub", CiKind.Object, AMD64.rdx);
+            XirOperand length = asm.createRegisterTemp("length", CiKind.Int, AMD64.rbx);
+            XirOperand hub = asm.createRegisterTemp("hub", CiKind.Object, AMD64.rdx);
 
             asm.mov(hub, hubParam);
             asm.mov(length, lengthParam);
@@ -511,10 +517,10 @@
         protected XirTemplate create(CiXirAssembler asm, long flags, int dimensions) {
             XirOperand result = asm.restart(CiKind.Object);
 
-            XirOperand hub = asm.createRegister("hub", CiKind.Object, AMD64.rax);
-            XirOperand rank = asm.createRegister("rank", CiKind.Int, AMD64.rbx);
-            XirOperand sizes = asm.createRegister("sizes", CiKind.Long, AMD64.rcx);
-            XirOperand thread = asm.createRegister("thread", CiKind.Long, AMD64.r15);
+            XirOperand hub = asm.createRegisterTemp("hub", CiKind.Object, AMD64.rax);
+            XirOperand rank = asm.createRegisterTemp("rank", CiKind.Int, AMD64.rbx);
+            XirOperand sizes = asm.createRegisterTemp("sizes", CiKind.Long, AMD64.rcx);
+            XirOperand thread = asm.createRegisterTemp("thread", CiKind.Long, AMD64.r15);
             asm.add(sizes, thread, asm.l(config.threadMultiNewArrayStorage));
             for (int i = 0; i < dimensions; i++) {
                 XirParameter length = asm.createInputParameter("length" + i, CiKind.Int);
@@ -577,7 +583,7 @@
             asm.bindOutOfLine(slowPath);
             checkSubtype(asm, objHub, objHub, hub);
             asm.jneq(end, objHub, asm.o(null));
-            XirOperand scratch = asm.createRegister("scratch", CiKind.Object, AMD64.r10);
+            XirOperand scratch = asm.createRegisterTemp("scratch", CiKind.Object, AMD64.r10);
             asm.mov(scratch, object);
             asm.callRuntime(config.throwClassCastException, null);
             asm.shouldNotReachHere();
@@ -738,9 +744,17 @@
             if (implicitNullException) {
                 asm.mark(MARK_IMPLICIT_NULL);
             }
-            asm.pstore(kind, array, index, value, config.getArrayOffset(kind), Scale.fromInt(elemSize), implicitNullException);
+            int disp = config.getArrayOffset(kind);
+            Scale scale = Scale.fromInt(elemSize);
+            if (kind == CiKind.Object) {
+                verifyPointer(asm, value);
+            }
             if (is(WRITE_BARRIER, flags)) {
-                writeBarrier(asm, array);
+                asm.lea(temp, array, index, disp, scale);
+                asm.pstore(kind, temp, value, implicitNullException);
+                writeBarrier(asm, temp);
+            } else {
+                asm.pstore(kind, array, index, value, disp, scale, implicitNullException);
             }
 
             // -- out of line -------------------------------------------------------
@@ -771,6 +785,7 @@
                 asm.nop(1);
                 asm.mark(MARK_IMPLICIT_NULL);
             }
+            verifyPointer(asm, object);
             asm.pload(CiKind.Int, result, object, asm.i(config.arrayLengthOffset), true);
             return asm.finishTemplate("arrayLength");
         }
@@ -1077,6 +1092,17 @@
         }
     }
 
+    private void verifyPointer(CiXirAssembler asm, XirOperand pointer) {
+        if (config.verifyPointers) {
+            // The verify pointer stub wants the argument in a fixed register.
+            XirOperand fixed = asm.createRegisterTemp("fixed", CiKind.Object, AMD64.r13);
+            asm.push(fixed);
+            asm.mov(fixed, pointer);
+            asm.callRuntime(config.verifyPointerStub, null);
+            asm.pop(fixed);
+        }
+    }
+
     private void checkSubtype(CiXirAssembler asm, XirOperand result, XirOperand objHub, XirOperand hub) {
         asm.push(objHub);
         asm.push(hub);
@@ -1088,7 +1114,7 @@
     private void useRegisters(CiXirAssembler asm, CiRegister... registers) {
         if (registers != null) {
             for (CiRegister register : registers) {
-                asm.createRegister("reg", CiKind.Illegal, register);
+                asm.createRegisterTemp("reg", CiKind.Illegal, register);
             }
         }
     }
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Tue Nov 09 13:42:06 2010 +0100
+++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/VMExitsNative.java	Thu Nov 11 14:09:37 2010 +0100
@@ -23,6 +23,7 @@
 
 import java.io.*;
 import java.lang.reflect.*;
+import java.util.*;
 
 import com.sun.c1x.*;
 import com.sun.cri.ci.*;
@@ -38,6 +39,16 @@
 
     public static boolean compileMethods = true;
 
+    /**
+     * Default option configuration for C1X.
+     */
+    static {
+        C1XOptions.setOptimizationLevel(3);
+        C1XOptions.OptInlineExcept = false;
+        C1XOptions.OptInlineSynchronized = false;
+        C1XOptions.UseDeopt = false;
+    }
+
     @Override
     public boolean setOption(String option) {
         if (option.length() == 0) {
@@ -102,6 +113,8 @@
         return true;
     }
 
+    private static Set<String> compiledMethods = new HashSet<String>();
+
     @Override
     public void compileMethod(long methodVmId, String name, int entryBCI) throws Throwable {
 
@@ -113,11 +126,25 @@
             Compiler compiler = Compiler.getInstance();
             HotSpotMethodResolved riMethod = new HotSpotMethodResolved(methodVmId, name);
             CiResult result = compiler.getCompiler().compileMethod(riMethod, -1, null);
+            String qualifiedName = CiUtil.toJavaName(riMethod.holder()) + "::" + riMethod.name();
+            compiledMethods.add(qualifiedName);
 
             if (result.bailout() != null) {
                 StringWriter out = new StringWriter();
                 result.bailout().printStackTrace(new PrintWriter(out));
+                Throwable cause = result.bailout().getCause();
                 Logger.info("Bailout:\n" + out.toString());
+                if (cause != null) {
+                    Logger.info("Trace for cause: ");
+                    for (StackTraceElement e : cause.getStackTrace()) {
+                        String current = e.getClassName() + "::" + e.getMethodName();
+                        String type = "";
+                        if (compiledMethods.contains(current)) {
+                            type = "compiled";
+                        }
+                        Logger.info(String.format("%-10s %3d %s", type, e.getLineNumber(), current));
+                    }
+                }
                 Compiler.getVMEntries().recordBailout(result.bailout().getMessage());
             } else {
                 Logger.log("Compilation result: " + result.targetMethod());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/runscimark.sh	Thu Nov 11 14:09:37 2010 +0100
@@ -0,0 +1,18 @@
+#!/bin/bash
+if [ -z "${JRE7}" ]; then
+  echo "JRE7 is not defined."
+  exit 1;
+fi
+if [ -z "${MAXINE}" ]; then
+  echo "MAXINE is not defined. It must point to a maxine repository directory."
+  exit 1;
+fi
+if [ -z "${C1X}" ]; then
+  echo "C1X is not defined. It must point to a c1x4hotspot directory."
+  exit 1;
+fi
+for (( i = 1; i <= 4000; 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
+done
--- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Tue Nov 09 13:42:06 2010 +0100
+++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Thu Nov 11 14:09:37 2010 +0100
@@ -1915,6 +1915,12 @@
       break;
     }
 
+    case c1x_verify_pointer_id: {
+      __ verify_oop(r13, "c1x verify pointer");
+      __ ret(0);
+      break;
+    }
+
     case c1x_arithmetic_frem_id: {
       __ subptr(rsp, 8);
       __ movflt(Address(rsp, 0), xmm1);
--- a/src/share/vm/c1/c1_Runtime1.cpp	Tue Nov 09 13:42:06 2010 +0100
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Thu Nov 11 14:09:37 2010 +0100
@@ -173,6 +173,7 @@
     case slow_subtype_check_id:
     case fpu2long_stub_id:
     case unwind_exception_id:
+    case c1x_verify_pointer_id:
     case c1x_unwind_exception_call_id:
     case c1x_slow_subtype_check_id:
     case c1x_arithmetic_frem_id:
--- a/src/share/vm/c1/c1_Runtime1.hpp	Tue Nov 09 13:42:06 2010 +0100
+++ b/src/share/vm/c1/c1_Runtime1.hpp	Thu Nov 11 14:09:37 2010 +0100
@@ -69,6 +69,7 @@
   stub(c1x_arithmetic_drem)          \
   stub(c1x_monitorenter)             \
   stub(c1x_monitorexit)              \
+  stub(c1x_verify_pointer)           \
   last_entry(number_of_ids)
 
 #define DECLARE_STUB_ID(x)       x ## _id ,
--- a/src/share/vm/c1x/c1x_CodeInstaller.cpp	Tue Nov 09 13:42:06 2010 +0100
+++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp	Thu Nov 11 14:09:37 2010 +0100
@@ -93,21 +93,22 @@
   }
 
   BasicType type = C1XCompiler::kindToBasicType(CiKind::typeChar(CiValue::kind(value)));
+  Location::Type locationType = Location::normal;
+  if (type == T_OBJECT || type == T_ARRAY) locationType = Location::oop;
   if (value->is_a(CiRegisterValue::klass())) {
     jint number = CiRegister::number(CiRegisterValue::reg(value));
-
     if (number < 16) {
-      return new LocationValue(Location::new_reg_loc(Location::normal, as_Register(number)->as_VMReg()));
+      return new LocationValue(Location::new_reg_loc(locationType, as_Register(number)->as_VMReg()));
     } else {
-      return new LocationValue(Location::new_reg_loc(Location::normal, as_XMMRegister(number - 16)->as_VMReg()));
+      return new LocationValue(Location::new_reg_loc(locationType, as_XMMRegister(number - 16)->as_VMReg()));
     }
   } else if (value->is_a(CiStackSlot::klass())) {
     jint index = CiStackSlot::index(value);
     if (index >= 0) {
-      return new LocationValue(Location::new_stk_loc(Location::normal, index * HeapWordSize));
+      return new LocationValue(Location::new_stk_loc(locationType, index * HeapWordSize));
     } else {
       int frame_size_bytes = frame_size + 2 * HeapWordSize;
-      return new LocationValue(Location::new_stk_loc(Location::normal, -(index * HeapWordSize) + frame_size_bytes));
+      return new LocationValue(Location::new_stk_loc(locationType, -(index * HeapWordSize) + frame_size_bytes));
     }
   } else if (value->is_a(CiConstant::klass())){
     oop obj = CiConstant::object(value);
@@ -136,7 +137,6 @@
 
 // constructor used to create a method
 CodeInstaller::CodeInstaller(oop target_method) {
-  VM_ENTRY_MARK;
   _env = CURRENT_ENV;
 
   initialize_fields(target_method);
@@ -157,7 +157,7 @@
   process_exception_handlers();
   {
     int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
-    ThreadToNativeFromVM t((JavaThread*) THREAD);
+    ThreadToNativeFromVM t((JavaThread*) Thread::current());
     _env->register_method(ciMethodObject, -1, &_offsets, 0, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
         &_implicit_exception_table, C1XCompiler::instance(), _env->comp_level(), false, false);
   }
@@ -165,7 +165,6 @@
 
 // constructor used to create a stub
 CodeInstaller::CodeInstaller(oop target_method, jlong& id) {
-  VM_ENTRY_MARK;
   _env = CURRENT_ENV;
 
   initialize_fields(target_method);
@@ -328,7 +327,7 @@
   if (bci == -1) {
      reexecute = false;
   } else {
-    Bytecodes::Code code   = Bytecodes::java_code_at(method->bcp_from(bci));
+    Bytecodes::Code code = Bytecodes::java_code_at(method->bcp_from(bci));
     reexecute = Interpreter::bytecode_should_reexecute(code);
   }
 
--- a/src/share/vm/c1x/c1x_Compiler.cpp	Tue Nov 09 13:42:06 2010 +0100
+++ b/src/share/vm/c1x/c1x_Compiler.cpp	Thu Nov 11 14:09:37 2010 +0100
@@ -98,8 +98,8 @@
 }
 
 oop C1XCompiler::get_RiField(ciField *field, klassOop accessor, TRAPS) {
-  oop field_holder = get_RiType(field->holder(), accessor, CHECK_0);
-  oop field_type = get_RiType(field->type(), accessor, CHECK_0);
+  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;
 
--- a/src/share/vm/c1x/c1x_VMEntries.cpp	Tue Nov 09 13:42:06 2010 +0100
+++ b/src/share/vm/c1x/c1x_VMEntries.cpp	Thu Nov 11 14:09:37 2010 +0100
@@ -369,6 +369,7 @@
 #else
   set_boolean(env, config, "windowsOs", false);
 #endif
+  set_boolean(env, config, "verifyPointers", VerifyOops);
   set_int(env, config, "codeEntryAlignment", CodeEntryAlignment);
   set_int(env, config, "vmPageSize", os::vm_page_size());
   set_int(env, config, "stackShadowPages", StackShadowPages);
@@ -385,6 +386,7 @@
 
   set_long(env, config, "debugStub", VmIds::addStub((address)warning));
   set_long(env, config, "instanceofStub", VmIds::addStub(Runtime1::entry_for(Runtime1::slow_subtype_check_id)));
+  set_long(env, config, "verifyPointerStub", VmIds::addStub(Runtime1::entry_for(Runtime1::c1x_verify_pointer_id)));
   set_long(env, config, "newInstanceStub", VmIds::addStub(Runtime1::entry_for(Runtime1::fast_new_instance_init_check_id)));
   set_long(env, config, "unresolvedNewInstanceStub", VmIds::addStub(Runtime1::entry_for(Runtime1::new_instance_id)));
   set_long(env, config, "newTypeArrayStub", VmIds::addStub(Runtime1::entry_for(Runtime1::new_type_array_id)));
@@ -439,11 +441,13 @@
 
 // public void installMethod(HotSpotTargetMethod targetMethod);
 JNIEXPORT void JNICALL Java_com_sun_hotspot_c1x_VMEntries_installMethod(JNIEnv *jniEnv, jobject, jobject targetMethod) {
+  VM_ENTRY_MARK;
   CodeInstaller installer(JNIHandles::resolve(targetMethod));
 }
 
 // public HotSpotProxy installStub(HotSpotTargetMethod targetMethod, String name);
 JNIEXPORT jlong JNICALL Java_com_sun_hotspot_c1x_VMEntries_installStub(JNIEnv *jniEnv, jobject, jobject targetMethod) {
+  VM_ENTRY_MARK;
   jlong id;
   CodeInstaller installer(JNIHandles::resolve(targetMethod), id);
   return id;