changeset 5624:7d25723b7699

added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled
author Doug Simon <doug.simon@oracle.com>
date Fri, 15 Jun 2012 16:12:41 +0200
parents 2a44192a8b24
children 63bd4fd90c27
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VerifyOopStubCall.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/AMD64VerifyOopStubCallOp.java 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/graal/graalCompilerToVM.cpp
diffstat 9 files changed, 150 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java	Fri Jun 15 14:42:11 2012 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java	Fri Jun 15 16:12:41 2012 +0200
@@ -261,7 +261,7 @@
      * Only instructions in methods whose fully qualified name contains this option will be HIR lowered.
      */
     public static String HIRLowerCheckcast = "";
-    public static String HIRLowerNewInstance = "NewInstanceTest";
+    public static String HIRLowerNewInstance = "NewInstanceTest.new";
 
     /**
      * The profiling info cache directory.
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Fri Jun 15 14:42:11 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java	Fri Jun 15 16:12:41 2012 +0200
@@ -37,7 +37,7 @@
     // os information, register layout, code generation, ...
     public boolean windowsOs;
     public int codeEntryAlignment;
-    public boolean verifyPointers;
+    public boolean verifyOops;
     public boolean useFastLocking;
     public boolean useFastNewObjectArray;
     public boolean useFastNewTypeArray;
@@ -103,7 +103,7 @@
     public long monitorExitStub;
     public long fastMonitorEnterStub;
     public long fastMonitorExitStub;
-    public long verifyPointerStub;
+    public long verifyOopStub;
 
     public void check() {
         assert vmPageSize >= 16;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VerifyOopStubCall.java	Fri Jun 15 16:12:41 2012 +0200
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.nodes;
+
+import com.oracle.graal.compiler.gen.*;
+import com.oracle.graal.compiler.target.*;
+import com.oracle.graal.hotspot.target.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.type.*;
+
+/**
+ * Node implementing a call to HotSpot's object pointer verification stub.
+ *
+ * @see AMD64VerifyOopStubCallOp
+ */
+public class VerifyOopStubCall extends FixedWithNextNode implements LIRGenLowerable {
+
+    @Input private final ValueNode object;
+
+    public VerifyOopStubCall(ValueNode object) {
+        super(StampFactory.objectNonNull());
+        this.object = object;
+    }
+
+    @Override
+    public void generate(LIRGenerator gen) {
+        LIRDebugInfo info = gen.state();
+        AMD64VerifyOopStubCallOp op = new AMD64VerifyOopStubCallOp(gen.operand(object), info);
+        gen.append(op);
+    }
+
+    @SuppressWarnings("unused")
+    @NodeIntrinsic
+    public static Object call(Object object) {
+        throw new UnsupportedOperationException();
+    }
+}
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Fri Jun 15 14:42:11 2012 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java	Fri Jun 15 16:12:41 2012 +0200
@@ -72,7 +72,7 @@
                     Log.print(logType);
                     Log.println(" - uninit alloc");
                 }
-                return NewInstanceStubCall.call(hub);
+                return verifyOop(NewInstanceStubCall.call(hub));
             }
         }
 
@@ -90,7 +90,7 @@
                     Log.print(" - fast alloc at ");
                     Log.printlnAddress(instance);
                 }
-                return instance;
+                return verifyOop(instance);
             }
         }
 
@@ -98,7 +98,14 @@
             Log.print(logType);
             Log.println(" - slow alloc");
         }
-        return NewInstanceStubCall.call(hub);
+        return verifyOop(NewInstanceStubCall.call(hub));
+    }
+
+    private static Object verifyOop(Object object) {
+        if (verifyOops()) {
+            VerifyOopStubCall.call(object);
+        }
+        return object;
     }
 
     private static Word asWord(Object object) {
@@ -123,6 +130,11 @@
     }
 
     @Fold
+    private static boolean verifyOops() {
+        return HotSpotGraalRuntime.getInstance().getConfig().verifyOops;
+    }
+
+    @Fold
     private static int klassStateOffset() {
         return HotSpotGraalRuntime.getInstance().getConfig().klassStateOffset;
     }
@@ -196,6 +208,7 @@
             SnippetTemplate template = cache.get(key);
             Debug.log("Lowering newInstance in %s: node=%s, template=%s, arguments=%s", graph, newInstanceNode, template, arguments);
             //System.out.printf("Lowering newInstance in %s: node=%s, template=%s, arguments=%s%n", graph, newInstanceNode, template, arguments);
+            //DebugScope.getConfig().addToContext(graph.method());
             template.instantiate(runtime, newInstanceNode, newInstanceNode, arguments);
             new DeadCodeEliminationPhase().apply(graph);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/AMD64VerifyOopStubCallOp.java	Fri Jun 15 16:12:41 2012 +0200
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.hotspot.target;
+
+import static com.oracle.graal.api.code.ValueUtil.*;
+
+import java.util.*;
+
+import com.oracle.graal.api.code.*;
+import com.oracle.graal.api.meta.*;
+import com.oracle.graal.graph.*;
+import com.oracle.graal.hotspot.*;
+import com.oracle.graal.lir.*;
+import com.oracle.graal.lir.amd64.*;
+import com.oracle.graal.lir.asm.*;
+import com.oracle.max.asm.target.amd64.*;
+
+/**
+ * A call to HotSpot's object pointer verification stub.
+ */
+public class AMD64VerifyOopStubCallOp extends AMD64LIRInstruction {
+    public AMD64VerifyOopStubCallOp(Value object, LIRDebugInfo info) {
+        super("VERIFY_OOP", LIRInstruction.NO_OPERANDS, info, new Value[] {object}, NO_OPERANDS, NO_OPERANDS);
+    }
+
+    @Override
+    public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) {
+        Register object = asRegister(input(0));
+        // r13: (in) object
+        if (object != AMD64.r13) {
+            masm.push(AMD64.r13);
+            masm.movl(AMD64.r13, object);
+        }
+        AMD64Call.directCall(tasm, masm, HotSpotGraalRuntime.getInstance().getConfig().verifyOopStub, info);
+        if (object != AMD64.r13) {
+            masm.pop(AMD64.r13);
+        }
+    }
+
+    @Override
+    protected EnumSet<OperandFlag> flagsFor(OperandMode mode, int index) {
+        if (mode == OperandMode.Input) {
+            return EnumSet.of(OperandFlag.Register);
+        }
+        throw GraalInternalError.shouldNotReachHere();
+    }
+}
--- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Jun 15 14:42:11 2012 +0200
+++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp	Fri Jun 15 16:12:41 2012 +0200
@@ -1955,8 +1955,8 @@
       break;
     }
 
-    case graal_verify_pointer_id: {
-      __ verify_oop(r13, "graal verify pointer");
+    case graal_verify_oop_id: {
+      __ verify_oop(r13, "graal verify oop");
       __ ret(0);
       break;
     }
--- a/src/share/vm/c1/c1_Runtime1.cpp	Fri Jun 15 14:42:11 2012 +0200
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Fri Jun 15 16:12:41 2012 +0200
@@ -206,7 +206,7 @@
     case handle_exception_nofpu_id:  // Unused on sparc
 #endif
 #ifdef GRAAL
-    case graal_verify_pointer_id:
+    case graal_verify_oop_id:
     case graal_unwind_exception_call_id:
     case graal_slow_subtype_check_id:
     case graal_arithmetic_frem_id:
--- a/src/share/vm/c1/c1_Runtime1.hpp	Fri Jun 15 14:42:11 2012 +0200
+++ b/src/share/vm/c1/c1_Runtime1.hpp	Fri Jun 15 16:12:41 2012 +0200
@@ -76,7 +76,7 @@
   stub(graal_arithmetic_drem)        \
   stub(graal_monitorenter)           \
   stub(graal_monitorexit)            \
-  stub(graal_verify_pointer)         \
+  stub(graal_verify_oop)         \
   stub(graal_set_deopt_info)         \
   stub(graal_create_null_pointer_exception) \
   stub(graal_create_out_of_bounds_exception) \
--- a/src/share/vm/graal/graalCompilerToVM.cpp	Fri Jun 15 14:42:11 2012 +0200
+++ b/src/share/vm/graal/graalCompilerToVM.cpp	Fri Jun 15 16:12:41 2012 +0200
@@ -781,7 +781,7 @@
 #else
   set_boolean(env, config, "windowsOs", false);
 #endif
-  set_boolean(env, config, "verifyPointers", VerifyOops);
+  set_boolean(env, config, "verifyOops", VerifyOops);
   set_boolean(env, config, "useFastLocking", UseFastLocking);
   set_boolean(env, config, "useFastNewObjectArray", UseFastNewObjectArray);
   set_boolean(env, config, "useFastNewTypeArray", UseFastNewTypeArray);
@@ -823,7 +823,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::graal_verify_pointer_id)));
+  set_long(env, config, "verifyOopStub", VmIds::addStub(Runtime1::entry_for(Runtime1::graal_verify_oop_id)));
   set_long(env, config, "newInstanceStub", VmIds::addStub(Runtime1::entry_for(newInstanceStub)));
   set_long(env, config, "newTypeArrayStub", VmIds::addStub(Runtime1::entry_for(Runtime1::new_type_array_id)));
   set_long(env, config, "newObjectArrayStub", VmIds::addStub(Runtime1::entry_for(Runtime1::new_object_array_id)));