# HG changeset patch # User Thomas Wuerthinger # Date 1381066572 -7200 # Node ID f753092f608dae121f362cf95bb323d2afedd713 # Parent 992508ee13b6a33addbc88a9fe10daec6c975bfe Adjustments to unsafe access and unsafe cast compiler directives in Truffle API. diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Sat Oct 05 15:01:01 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Sun Oct 06 15:36:12 2013 +0200 @@ -1016,6 +1016,9 @@ } public ResolvedJavaType lookupJavaType(Class clazz) { + if (clazz == null) { + throw new IllegalArgumentException("Class parameter was null"); + } return HotSpotResolvedObjectType.fromClass(clazz); } diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Sat Oct 05 15:01:01 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/FrameWithoutBoxing.java Sun Oct 06 15:36:12 2013 +0200 @@ -57,7 +57,7 @@ @Override public T getArguments(Class clazz) { - return CompilerDirectives.unsafeCast(arguments, clazz); + return CompilerDirectives.unsafeCast(arguments, clazz, true); } @Override diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckMacroNode.java Sat Oct 05 15:01:01 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2013, 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.truffle.nodes.typesystem; - -import com.oracle.graal.graph.*; -import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.truffle.nodes.asserts.*; -import com.oracle.truffle.api.*; - -/** - * Macro node for method {@link CompilerDirectives#customTypeCheck(boolean, Object, Object)}. - */ -public class CustomTypeCheckMacroNode extends NeverPartOfCompilationNode implements Canonicalizable { - - private static final int ARGUMENT_COUNT = 3; - private static final int CONDITION_ARGUMENT_INDEX = 0; - private static final int OBJECT_ARGUMENT_INDEX = 1; - private static final int CUSTOM_TYPE_ARGUMENT_INDEX = 2; - - public CustomTypeCheckMacroNode(Invoke invoke) { - super(invoke, "The custom type parameter could not be reduced to a compile time constant."); - assert arguments.size() == ARGUMENT_COUNT; - } - - @Override - public Node canonical(CanonicalizerTool tool) { - ValueNode customTypeArgument = arguments.get(CUSTOM_TYPE_ARGUMENT_INDEX); - if (customTypeArgument.isConstant()) { - Object typeToken = customTypeArgument.asConstant().asObject(); - ValueNode conditionArgument = arguments.get(CONDITION_ARGUMENT_INDEX); - ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX); - return graph().unique(new ConditionalNode(graph().unique(new CustomTypeCheckNode(conditionArgument, objectArgument, typeToken)))); - } - return this; - } -} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java Sat Oct 05 15:01:01 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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.truffle.nodes.typesystem; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.spi.*; - -public final class CustomTypeCheckNode extends LogicNode implements Lowerable, Virtualizable, com.oracle.graal.graph.IterableNodeType { - - @Input private ValueNode condition; - @Input private ValueNode object; - private final Object customType; - - public CustomTypeCheckNode(ValueNode condition, ValueNode object, Object customType) { - this.condition = condition; - this.object = object; - this.customType = customType; - } - - public ValueNode getObject() { - return object; - } - - public ValueNode getCondition() { - return condition; - } - - public Object getCustomType() { - return customType; - } - - public void lower(LoweringTool tool) { - if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { - this.replaceAtUsages(graph().unique(new IntegerEqualsNode(condition, ConstantNode.forInt(1, graph())))); - this.safeDelete(); - } - } - - public void virtualize(VirtualizerTool tool) { - if (getObject() != null) { - State objectState = tool.getObjectState(getObject()); - if (objectState != null && objectState.getState() == EscapeState.Virtual) { - // The object is escape analyzed => cut the connection. - this.updateUsages(this.object, null); - this.object = null; - } - } - } -} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadNode.java Sun Oct 06 15:36:12 2013 +0200 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2012, 2013, 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.truffle.nodes.typesystem; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.graph.spi.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; + +public final class CustomizedUnsafeLoadNode extends UnsafeLoadNode { + + @Input private ValueNode condition; + @Input private ValueNode locationIdentity; + + public CustomizedUnsafeLoadNode(ValueNode object, ValueNode offset, Kind accessKind, ValueNode condition, ValueNode locationIdentity) { + super(object, 0, offset, accessKind); + this.condition = condition; + this.locationIdentity = locationIdentity; + } + + public ValueNode getCondition() { + return condition; + } + + public ValueNode getLocationIdentity() { + return locationIdentity; + } + + @Override + public Node canonical(CanonicalizerTool tool) { + return this; + } + + @Override + public void virtualize(VirtualizerTool tool) { + super.virtualize(tool); + } + + @SuppressWarnings("unused") + public static T load(Object object, long offset, @ConstantNodeParameter Kind kind, boolean condition, Object locationIdentity) { + return UnsafeLoadNode.load(object, 0, offset, kind); + } +} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeStoreNode.java Sun Oct 06 15:36:12 2013 +0200 @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2012, 2013, 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.truffle.nodes.typesystem; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.graph.spi.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; + +public final class CustomizedUnsafeStoreNode extends UnsafeStoreNode { + + @Input private ValueNode customLocationIdentity; + + public CustomizedUnsafeStoreNode(ValueNode object, ValueNode offset, ValueNode value, Kind accessKind, ValueNode customLocationIdentity) { + super(object, 0, offset, value, accessKind); + this.customLocationIdentity = customLocationIdentity; + } + + public ValueNode getCustomLocationIdentity() { + return customLocationIdentity; + } + + @Override + public Node canonical(CanonicalizerTool tool) { + return this; + } + + @Override + public void virtualize(VirtualizerTool tool) { + super.virtualize(tool); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, Object value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, boolean value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, byte value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, char value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, double value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, float value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, int value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, long value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } + + @SuppressWarnings("unused") + @NodeIntrinsic + public static void store(Object object, long offset, short value, @ConstantNodeParameter Kind kind, Object customLocationIdentity) { + UnsafeStoreNode.store(object, 0, offset, value, kind); + } +} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastMacroNode.java Sat Oct 05 15:01:01 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2013, 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.truffle.nodes.typesystem; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.truffle.nodes.asserts.*; -import com.oracle.truffle.api.*; - -/** - * Macro node for method {@link CompilerDirectives#unsafeCast(Object, Class)} and - * {@link CompilerDirectives#unsafeCast(Object, Class, Object, Object)}. - */ -public class TypeCastMacroNode extends NeverPartOfCompilationNode implements Canonicalizable { - - private static final int ARGUMENT_COUNT = 4; - private static final int OBJECT_ARGUMENT_INDEX = 0; - private static final int CLASS_ARGUMENT_INDEX = 1; - private static final int RECEIVER_ARGUMENT_INDEX = 2; - private static final int CUSTOM_TYPE_ARGUMENT_INDEX = 3; - - public TypeCastMacroNode(Invoke invoke) { - super(invoke, "The class of the unsafe cast could not be reduced to a compile time constant."); - assert arguments.size() == ARGUMENT_COUNT; - } - - @Override - public Node canonical(CanonicalizerTool tool) { - ValueNode classArgument = arguments.get(CLASS_ARGUMENT_INDEX); - ValueNode customTypeArgument = arguments.get(CUSTOM_TYPE_ARGUMENT_INDEX); - if (classArgument.isConstant() && customTypeArgument.isConstant()) { - Class c = (Class) classArgument.asConstant().asObject(); - ResolvedJavaType lookupJavaType = tool.runtime().lookupJavaType(c); - ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX); - ValueNode receiverArgument = arguments.get(RECEIVER_ARGUMENT_INDEX); - Object customType = customTypeArgument.asConstant().asObject(); - return graph().add(new TypeCastNode(objectArgument, lookupJavaType, receiverArgument, customType)); - } - return this; - } -} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java Sat Oct 05 15:01:01 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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.truffle.nodes.typesystem; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.extended.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; - -public final class TypeCastNode extends FixedWithNextNode implements Lowerable, com.oracle.graal.graph.IterableNodeType, ValueProxy, Virtualizable { - - @Input private ValueNode receiver; - @Input private ValueNode object; - private final Object customType; - private final ResolvedJavaType castTarget; - - public TypeCastNode(ValueNode object, ResolvedJavaType castTarget, ValueNode receiver, Object customType) { - super(StampFactory.declaredNonNull(castTarget)); - this.receiver = receiver; - this.object = object; - this.customType = customType; - this.castTarget = castTarget; - } - - public ValueNode getObject() { - return object; - } - - public ValueNode getReceiver() { - return receiver; - } - - public ResolvedJavaType getCastTarget() { - return castTarget; - } - - public Object getCustomType() { - return customType; - } - - public void lower(LoweringTool tool) { - if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { - ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode(null)); - PiNode piCast = graph().unique(new PiNode(object, this.stamp(), valueAnchorNode)); - this.replaceAtUsages(piCast); - graph().replaceFixedWithFixed(this, valueAnchorNode); - } - } - - public ValueNode getOriginalValue() { - return object; - } - - @Override - public void virtualize(VirtualizerTool tool) { - State state = tool.getObjectState(object); - if (state != null && state.getState() == EscapeState.Virtual) { - tool.replaceWithVirtual(state.getVirtualObject()); - } - } -} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeCustomizationMacroNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeCustomizationMacroNode.java Sat Oct 05 15:01:01 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2013, 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.truffle.nodes.typesystem; - -import com.oracle.graal.graph.*; -import com.oracle.graal.graph.spi.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.truffle.nodes.asserts.*; -import com.oracle.truffle.api.*; - -/** - * Macro node for method {@link CompilerDirectives#unsafeCustomization(Object, boolean, Object)}. - */ -public class UnsafeCustomizationMacroNode extends NeverPartOfCompilationNode implements Canonicalizable { - - private static final int ARGUMENT_COUNT = 3; - private static final int RECEIVER_ARGUMENT_INDEX = 0; - private static final int CUSTOM_TYPE_ARGUMENT_INDEX = 1; - private static final int LOCATION_IDENTITY_ARGUMENT_INDEX = 2; - - public UnsafeCustomizationMacroNode(Invoke invoke) { - super(invoke, "The custom type parameter and/or the location identity could not be reduced to a compile time constant."); - assert arguments.size() == ARGUMENT_COUNT; - } - - @Override - public Node canonical(CanonicalizerTool tool) { - ValueNode customTypeArgument = this.arguments.get(CUSTOM_TYPE_ARGUMENT_INDEX); - ValueNode locationIdentityArgument = this.arguments.get(LOCATION_IDENTITY_ARGUMENT_INDEX); - if (customTypeArgument.isConstant() && locationIdentityArgument.isConstant()) { - Object customType = customTypeArgument.asConstant().asObject(); - Object locationIdentity = locationIdentityArgument.asConstant().asObject(); - ValueNode receiverArgument = this.arguments.get(RECEIVER_ARGUMENT_INDEX); - return graph().unique(new UnsafeCustomizationNode(receiverArgument, customType, locationIdentity)); - } - return this; - } -} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeCustomizationNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeCustomizationNode.java Sat Oct 05 15:01:01 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2012, 2013, 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.truffle.nodes.typesystem; - -import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.calc.*; -import com.oracle.graal.nodes.spi.*; -import com.oracle.graal.nodes.type.*; - -public final class UnsafeCustomizationNode extends FloatingNode implements LIRLowerable, com.oracle.graal.graph.IterableNodeType { - - @Input private ValueNode receiver; - private final Object customType; - private final Object locationIdentity; - - public UnsafeCustomizationNode(ValueNode receiver, Object customType, Object locationIdentity) { - super(StampFactory.object()); - this.receiver = receiver; - this.customType = customType; - this.locationIdentity = locationIdentity; - } - - public ValueNode getReceiver() { - return receiver; - } - - public Object getCustomType() { - return customType; - } - - public Object getLocationIdentity() { - return locationIdentity; - } - - public void generate(LIRGeneratorTool generator) { - generator.setResult(this, generator.operand(receiver)); - } -} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastMacroNode.java Sun Oct 06 15:36:12 2013 +0200 @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2013, 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.truffle.nodes.typesystem; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.graph.spi.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.truffle.nodes.asserts.*; +import com.oracle.truffle.api.*; + +/** + * Macro node for method {@link CompilerDirectives#unsafeCast(Object, Class, boolean)}. + */ +public class UnsafeTypeCastMacroNode extends NeverPartOfCompilationNode implements Canonicalizable { + + private static final int ARGUMENT_COUNT = 3; + private static final int OBJECT_ARGUMENT_INDEX = 0; + private static final int CLASS_ARGUMENT_INDEX = 1; + private static final int CONDITION_ARGUMENT_INDEX = 2; + + public UnsafeTypeCastMacroNode(Invoke invoke) { + super(invoke, "The class of the unsafe cast could not be reduced to a compile time constant."); + assert arguments.size() == ARGUMENT_COUNT; + } + + @Override + public Node canonical(CanonicalizerTool tool) { + ValueNode classArgument = arguments.get(CLASS_ARGUMENT_INDEX); + if (classArgument.isConstant()) { + ValueNode objectArgument = arguments.get(OBJECT_ARGUMENT_INDEX); + ValueNode conditionArgument = arguments.get(CONDITION_ARGUMENT_INDEX); + Class c = (Class) classArgument.asConstant().asObject(); + if (c == null) { + return objectArgument; + } + ResolvedJavaType lookupJavaType = tool.runtime().lookupJavaType(c); + return graph().add(new UnsafeTypeCastNode(objectArgument, lookupJavaType, conditionArgument)); + } + return this; + } +} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/UnsafeTypeCastNode.java Sun Oct 06 15:36:12 2013 +0200 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2012, 2013, 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.truffle.nodes.typesystem; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.nodes.spi.*; +import com.oracle.graal.nodes.type.*; + +public final class UnsafeTypeCastNode extends FixedWithNextNode implements Lowerable, com.oracle.graal.graph.IterableNodeType, ValueProxy, Virtualizable { + + @Input private ValueNode object; + @Input private ValueNode condition; + private final ResolvedJavaType castTarget; + + public UnsafeTypeCastNode(ValueNode object, ResolvedJavaType castTarget, ValueNode condition) { + super(StampFactory.declaredNonNull(castTarget)); + this.condition = condition; + this.object = object; + this.castTarget = castTarget; + } + + public ValueNode getObject() { + return object; + } + + public ValueNode getCondition() { + return condition; + } + + public ResolvedJavaType getCastTarget() { + return castTarget; + } + + public void lower(LoweringTool tool) { + if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) { + ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode(null)); + PiNode piCast = graph().unique(new PiNode(object, this.stamp(), valueAnchorNode)); + this.replaceAtUsages(piCast); + graph().replaceFixedWithFixed(this, valueAnchorNode); + } + } + + public ValueNode getOriginalValue() { + return getObject(); + } + + @Override + public void virtualize(VirtualizerTool tool) { + State state = tool.getObjectState(object); + if (state != null && state.getState() == EscapeState.Virtual) { + tool.replaceWithVirtual(state.getVirtualObject()); + } + } +} diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java Sat Oct 05 15:01:01 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/CompilerDirectivesSubstitutions.java Sun Oct 06 15:36:12 2013 +0200 @@ -63,9 +63,81 @@ @MacroSubstitution(macro = BailoutNode.class, isStatic = true) public static native void bailout(String reason); - @MacroSubstitution(macro = TypeCastMacroNode.class, isStatic = true) - public static native Object unsafeCast(Object value, Class clazz, Object receiver, Object customType); + @MacroSubstitution(macro = UnsafeTypeCastMacroNode.class, isStatic = true) + public static native Object unsafeCast(Object value, Class clazz, boolean condition); + + @MethodSubstitution + public static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Boolean, condition, locationIdentity); + } + + @MethodSubstitution + public static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Byte, condition, locationIdentity); + } + + @MethodSubstitution + public static short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Short, condition, locationIdentity); + } + + @MethodSubstitution + public static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Int, condition, locationIdentity); + } + + @MethodSubstitution + public static float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Float, condition, locationIdentity); + } + + @MethodSubstitution + public static double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Double, condition, locationIdentity); + } + + @MethodSubstitution + public static Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity) { + return CustomizedUnsafeLoadNode.load(receiver, offset, Kind.Object, condition, locationIdentity); + } - @MacroSubstitution(macro = CustomTypeCheckMacroNode.class, isStatic = true) - public static native boolean customTypeCheck(boolean condition, Object value, Object customType); + @MethodSubstitution + public static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Boolean, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Byte, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Short, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Int, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Long, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Float, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Double, locationIdentity); + } + + @MethodSubstitution + public static void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity) { + CustomizedUnsafeStoreNode.store(receiver, offset, value, Kind.Object, locationIdentity); + } } diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Sat Oct 05 15:01:01 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerDirectives.java Sun Oct 06 15:36:12 2013 +0200 @@ -25,13 +25,16 @@ package com.oracle.truffle.api; import java.lang.annotation.*; +import java.lang.reflect.*; import java.util.concurrent.*; +import sun.misc.*; + /** * Directives that influence the optimizations of the Truffle compiler. All of the operations have * no effect when executed in the Truffle interpreter. */ -public class CompilerDirectives { +public final class CompilerDirectives { public static final double LIKELY_PROBABILITY = 0.75; public static final double UNLIKELY_PROBABILITY = 1.0 - LIKELY_PROBABILITY; @@ -39,6 +42,22 @@ public static final double SLOWPATH_PROBABILITY = 0.0001; public static final double FASTPATH_PROBABILITY = 1.0 - SLOWPATH_PROBABILITY; + private static final Unsafe UNSAFE = getUnsafe(); + + private static Unsafe getUnsafe() { + try { + return Unsafe.getUnsafe(); + } catch (SecurityException e) { + } + try { + Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafeInstance.setAccessible(true); + return (Unsafe) theUnsafeInstance.get(Unsafe.class); + } catch (Exception e) { + throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e); + } + } + /** * Directive for the compiler to discontinue compilation at this code position and instead * insert a transfer to the interpreter. @@ -130,72 +149,275 @@ } /** - * Marks methods that are considered unsafe. Wrong usage of those methods can lead to unexpected - * behavior including a crash of the runtime. Therefore, special care should be taken. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.METHOD}) - public @interface Unsafe { - } - - /** - * Treats the given value as a value of the given class. The class must evaluate to a constant. + * Casts the given value to the value of the given type without any checks. The class must + * evaluate to a constant. The condition parameter gives a hint to the compiler under which + * circumstances this cast can be moved to an earlier location in the program. * * @param value the value that is known to have the specified type - * @param clazz the specified type of the value - * @return the value - */ - @Unsafe - public static T unsafeCast(Object value, Class clazz) { - return unsafeCast(value, clazz, null, null); - } - - /** - * Associates the given type token with the given value for the case that condition is true. - * - * @param condition the custom type check - * @param value the value that is of the given custom type after the check - * @param customType the custom type that should be associated with the value - * @return the type check condition - */ - public static boolean customTypeCheck(boolean condition, Object value, Object customType) { - return condition; - } - - /** - * Treats the given value as a value of the given class. The class must evaluate to a constant. - * If the compiler can prove that the given value is of the given custom type, the cast is safe. - * - * @param value the value that is known to have the specified type - * @param clazz the specified type of the value - * @param receiver the receiver on which the custom type is tested - * @param customType the custom type that if present on a value makes this unsafe cast safe - * @return the value + * @param type the specified new type of the value + * @param condition the condition that makes this cast safe also at an earlier location of the + * program + * @return the value to be casted to the new type */ @SuppressWarnings("unchecked") - @Unsafe - public static T unsafeCast(Object value, Class clazz, Object receiver, Object customType) { + public static T unsafeCast(Object value, Class type, boolean condition) { return (T) value; } /** - * Proxies an object instance into an instance that adds a custom location identity on its - * accesses via sun.misc.Unsafe. This means that the accesses on these kind of location - * identities can only alias among themselves. It also allows to specify a custom type for the - * receiver values of follow-up unsafe accesses. Both the custom type and the location identity - * must evaluate to a constant. Furthermore, you should use the proxied receiver object - * immediately for one read or write access via a sun.misc.Unsafe method and not store it - * anywhere. + * Unsafe access to a boolean value within an object. The condition parameter gives a hint to + * the compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static boolean unsafeGetBoolean(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getBoolean(receiver, offset); + } + + /** + * Unsafe access to a byte value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static byte unsafeGetByte(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getByte(receiver, offset); + } + + /** + * Unsafe access to a short value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static short unsafeGetShort(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getShort(receiver, offset); + } + + /** + * Unsafe access to a int value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. * - * @param receiver the object that is accessed via sun.misc.Unsafe - * @param condition the condition that ifTrue allows this unsafe access to be floating + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static int unsafeGetInt(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getInt(receiver, offset); + } + + /** + * Unsafe access to a long value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static long unsafeGetLong(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getLong(receiver, offset); + } + + /** + * Unsafe access to a float value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static float unsafeGetFloat(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getFloat(receiver, offset); + } + + /** + * Unsafe access to a double value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program * @param locationIdentity the location identity token that can be used for improved global * value numbering or null * @return the accessed value */ - @Unsafe - public static Object unsafeCustomization(Object receiver, boolean condition, Object locationIdentity) { - return receiver; + public static double unsafeGetDouble(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getDouble(receiver, offset); + } + + /** + * Unsafe access to a Object value within an object. The condition parameter gives a hint to the + * compiler under which circumstances this access can be moved to an earlier location in the + * program. The location identity gives a hint to the compiler for improved global value + * numbering. + * + * @param receiver the object that is accessed + * @param offset the offset at which to access the object in bytes + * @param condition the condition that makes this access safe also at an earlier location in the + * program + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + * @return the accessed value + */ + public static Object unsafeGetObject(Object receiver, long offset, boolean condition, Object locationIdentity) { + return UNSAFE.getObject(receiver, offset); + } + + /** + * Write a boolean value within an object. The location identity gives a hint to the compiler + * for improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutBoolean(Object receiver, long offset, boolean value, Object locationIdentity) { + UNSAFE.putBoolean(receiver, offset, value); + } + + /** + * Write a byte value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutByte(Object receiver, long offset, byte value, Object locationIdentity) { + UNSAFE.putByte(receiver, offset, value); + } + + /** + * Write a short value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutShort(Object receiver, long offset, short value, Object locationIdentity) { + UNSAFE.putShort(receiver, offset, value); + } + + /** + * Write a int value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutInt(Object receiver, long offset, int value, Object locationIdentity) { + UNSAFE.putInt(receiver, offset, value); + } + + /** + * Write a long value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutLong(Object receiver, long offset, long value, Object locationIdentity) { + UNSAFE.putLong(receiver, offset, value); + } + + /** + * Write a float value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutFloat(Object receiver, long offset, float value, Object locationIdentity) { + UNSAFE.putFloat(receiver, offset, value); + } + + /** + * Write a double value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutDouble(Object receiver, long offset, double value, Object locationIdentity) { + UNSAFE.putDouble(receiver, offset, value); + } + + /** + * Write a Object value within an object. The location identity gives a hint to the compiler for + * improved global value numbering. + * + * @param receiver the object that is written to + * @param offset the offset at which to write to the object in bytes + * @param value the value to be written + * @param locationIdentity the location identity token that can be used for improved global + * value numbering or null + */ + public static void unsafePutObject(Object receiver, long offset, Object value, Object locationIdentity) { + UNSAFE.putObject(receiver, offset, value); } /** diff -r 992508ee13b6 -r f753092f608d graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java Sat Oct 05 15:01:01 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/Frame.java Sun Oct 06 15:36:12 2013 +0200 @@ -47,7 +47,6 @@ * @param clazz the known type of the arguments object as a compile time constant * @return the arguments used when calling this method */ - @CompilerDirectives.Unsafe T getArguments(Class clazz); /**