# HG changeset patch # User Doug Simon # Date 1339769561 -7200 # Node ID 7d25723b7699da29f6af7229f22006dc8477f1ab # Parent 2a44192a8b24cc2a46d2c441f7eac0b75c2f24ab added oop verification to NewInstanceSnippets when -XX:+VerifyOops is enabled diff -r 2a44192a8b24 -r 7d25723b7699 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalOptions.java --- 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. diff -r 2a44192a8b24 -r 7d25723b7699 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- 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; diff -r 2a44192a8b24 -r 7d25723b7699 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VerifyOopStubCall.java --- /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(); + } +} diff -r 2a44192a8b24 -r 7d25723b7699 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewInstanceSnippets.java --- 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); } diff -r 2a44192a8b24 -r 7d25723b7699 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/target/AMD64VerifyOopStubCallOp.java --- /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 flagsFor(OperandMode mode, int index) { + if (mode == OperandMode.Input) { + return EnumSet.of(OperandFlag.Register); + } + throw GraalInternalError.shouldNotReachHere(); + } +} diff -r 2a44192a8b24 -r 7d25723b7699 src/cpu/x86/vm/c1_Runtime1_x86.cpp --- 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; } diff -r 2a44192a8b24 -r 7d25723b7699 src/share/vm/c1/c1_Runtime1.cpp --- 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: diff -r 2a44192a8b24 -r 7d25723b7699 src/share/vm/c1/c1_Runtime1.hpp --- 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) \ diff -r 2a44192a8b24 -r 7d25723b7699 src/share/vm/graal/graalCompilerToVM.cpp --- 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)));