# HG changeset patch # User Thomas Wuerthinger # Date 1400775004 -7200 # Node ID e751da27fd48f98d464436b9ba2fac3402cb6bce # Parent a6eeb37502384dcfc3886467dc3c92c68bc6da51# Parent 241044995c8753ee1128e9a3886ccee113c2caac Merge. diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Thu May 22 18:10:04 2014 +0200 @@ -460,7 +460,6 @@ private int totalFrameSize = -1; private int customStackAreaOffset = -1; - private int registerRestoreEpilogueOffset = -1; private final String name; @@ -641,26 +640,6 @@ } /** - * Allows a method to specify the offset of the epilogue that restores the callee saved - * registers. Must be called iff the method is a callee saved method and stores callee registers - * on the stack. - * - * @param registerRestoreEpilogueOffset the offset in the machine code where the epilogue begins - */ - public void setRegisterRestoreEpilogueOffset(int registerRestoreEpilogueOffset) { - assert this.registerRestoreEpilogueOffset == -1; - this.registerRestoreEpilogueOffset = registerRestoreEpilogueOffset; - } - - /** - * @return the code offset of the start of the epilogue that restores all callee saved - * registers, or -1 if this is not a callee saved method - */ - public int getRegisterRestoreEpilogueOffset() { - return registerRestoreEpilogueOffset; - } - - /** * Offset in bytes for the custom stack area (relative to sp). * * @return the offset in bytes diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/ReferenceMap.java Thu May 22 18:10:04 2014 +0200 @@ -29,8 +29,6 @@ void setRegister(int idx, PlatformKind kind); - PlatformKind getRegister(int idx); - void setStackSlot(int offset, PlatformKind kind); boolean hasRegisterRefMap(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.api.meta.test/src/com/oracle/graal/api/meta/test/TestResolvedJavaType.java Thu May 22 18:10:04 2014 +0200 @@ -513,6 +513,16 @@ return result; } + public static Set getStaticFields(Class c) { + Set result = new HashSet<>(); + for (Field f : c.getDeclaredFields()) { + if (Modifier.isStatic(f.getModifiers())) { + result.add(f); + } + } + return result; + } + public boolean fieldsEqual(Field f, ResolvedJavaField rjf) { return rjf.getDeclaringClass().equals(metaAccess.lookupJavaType(f.getDeclaringClass())) && rjf.getName().equals(f.getName()) && rjf.getType().resolve(rjf.getDeclaringClass()).equals(metaAccess.lookupJavaType(f.getType())); @@ -570,6 +580,27 @@ } @Test + public void getStaticFieldsTest() { + for (Class c : classes) { + ResolvedJavaType type = metaAccess.lookupJavaType(c); + Set expected = getStaticFields(c); + ResolvedJavaField[] actual = type.getStaticFields(); + for (Field f : expected) { + assertNotNull(lookupField(actual, f)); + } + for (ResolvedJavaField rf : actual) { + if (!isHiddenFromReflection(rf)) { + assertEquals(lookupField(expected, rf) != null, !rf.isInternal()); + } + } + + // Test stability of getStaticFields + ResolvedJavaField[] actual2 = type.getStaticFields(); + assertArrayEquals(actual, actual2); + } + } + + @Test public void getDeclaredMethodsTest() { for (Class c : classes) { ResolvedJavaType type = metaAccess.lookupJavaType(c); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/JavaTypeProfile.java Thu May 22 18:10:04 2014 +0200 @@ -109,14 +109,20 @@ if (result.size() == 0) { return new JavaTypeProfile(newNullSeen, 1.0, EMPTY_ARRAY); } - double probabilitySum = 0.0; - for (int i = 0; i < result.size(); i++) { - probabilitySum += result.get(i).getProbability(); + double factor; + if (result.size() == this.getItems().length) { + /* List of types did not change, no need to recompute probabilities. */ + factor = 1.0; + } else { + double probabilitySum = 0.0; + for (int i = 0; i < result.size(); i++) { + probabilitySum += result.get(i).getProbability(); + } + probabilitySum += newNotRecorded; + + factor = 1.0 / probabilitySum; // Normalize to 1.0 + assert factor >= 1.0; } - probabilitySum += newNotRecorded; - - double factor = 1.0 / probabilitySum; // Normalize to 1.0 - assert factor >= 1.0; ProfiledType[] newResult = new ProfiledType[result.size()]; for (int i = 0; i < newResult.length; ++i) { ProfiledType curType = result.get(i); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ResolvedJavaType.java Thu May 22 18:10:04 2014 +0200 @@ -247,6 +247,14 @@ ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses); /** + * Returns the static fields of this class, including + * {@linkplain ResolvedJavaField#isInternal() internal} fields. A zero-length array is returned + * for array and primitive types. The order of fields returned by this method is stable. That + * is, for a single JVM execution the same order is returned each time this method is called. + */ + ResolvedJavaField[] getStaticFields(); + + /** * Returns the annotation for the specified type of this class, if such an annotation is * present. * diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java --- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Thu May 22 18:10:04 2014 +0200 @@ -137,7 +137,7 @@ FrameMap frameMap = backend.newFrameMap(null); TargetDescription target = backend.getTarget(); CallingConvention cc = CodeUtil.getCallingConvention(backend.getProviders().getCodeCache(), CallingConvention.Type.JavaCallee, method, false); - this.lirGenRes = backend.newLIRGenerationResult(lir, frameMap, null); + this.lirGenRes = backend.newLIRGenerationResult(lir, frameMap, method, null); this.gen = backend.newLIRGenerator(cc, lirGenRes); this.lirBuilder = backend.newBytecodeLIRBuilder(gen, this); @@ -441,13 +441,13 @@ } @Override - protected Value genCheckCast(ResolvedJavaType type, Value object, JavaTypeProfile profileForTypeCheck, boolean b) { + protected Value createCheckCast(ResolvedJavaType type, Value object, JavaTypeProfile profileForTypeCheck, boolean b) { // TODO Auto-generated method stub throw GraalInternalError.unimplemented("Auto-generated method stub"); } @Override - protected Value genInstanceOf(ResolvedJavaType type, Value object, JavaTypeProfile profileForTypeCheck) { + protected Value createInstanceOf(ResolvedJavaType type, Value object, JavaTypeProfile profileForTypeCheck) { // TODO Auto-generated method stub throw GraalInternalError.unimplemented("Auto-generated method stub"); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/AbstractObjectStamp.java Thu May 22 18:10:04 2014 +0200 @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2012, 2014, 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.compiler.common.type; + +import java.util.*; + +import com.oracle.graal.api.meta.*; + +public abstract class AbstractObjectStamp extends Stamp { + + private final ResolvedJavaType type; + private final boolean exactType; + private final boolean nonNull; + private final boolean alwaysNull; + + protected AbstractObjectStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) { + this.type = type; + this.exactType = exactType; + this.nonNull = nonNull; + this.alwaysNull = alwaysNull; + } + + protected abstract AbstractObjectStamp copyWith(ResolvedJavaType newType, boolean newExactType, boolean newNonNull, boolean newAlwaysNull); + + @Override + public Stamp unrestricted() { + return copyWith(null, false, false, false); + } + + @Override + public Stamp illegal() { + return copyWith(null, true, true, false); + } + + @Override + public boolean isLegal() { + return !exactType || (type != null && (isConcreteType(type))); + } + + @Override + public Kind getStackKind() { + return Kind.Object; + } + + @Override + public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { + if (type != null) { + return type; + } + return metaAccess.lookupJavaType(Object.class); + } + + public boolean nonNull() { + return nonNull; + } + + public boolean alwaysNull() { + return alwaysNull; + } + + public ResolvedJavaType type() { + return type; + } + + public boolean isExactType() { + return exactType; + } + + protected void appendString(StringBuilder str) { + str.append(nonNull ? "!" : "").append(exactType ? "#" : "").append(' ').append(type == null ? "-" : type.getName()).append(alwaysNull ? " NULL" : ""); + } + + @Override + public Stamp meet(Stamp otherStamp) { + if (this == otherStamp) { + return this; + } + if (!isCompatible(otherStamp)) { + return StampFactory.illegal(Kind.Illegal); + } + AbstractObjectStamp other = (AbstractObjectStamp) otherStamp; + if (!isLegal()) { + return other; + } else if (!other.isLegal()) { + return this; + } + ResolvedJavaType meetType; + boolean meetExactType; + boolean meetNonNull; + boolean meetAlwaysNull; + if (other.alwaysNull) { + meetType = type(); + meetExactType = exactType; + meetNonNull = false; + meetAlwaysNull = alwaysNull; + } else if (alwaysNull) { + meetType = other.type(); + meetExactType = other.exactType; + meetNonNull = false; + meetAlwaysNull = other.alwaysNull; + } else { + meetType = meetTypes(type(), other.type()); + meetExactType = exactType && other.exactType; + if (meetExactType && type != null && other.type != null) { + // meeting two valid exact types may result in a non-exact type + meetExactType = Objects.equals(meetType, type) && Objects.equals(meetType, other.type); + } + meetNonNull = nonNull && other.nonNull; + meetAlwaysNull = false; + } + + if (Objects.equals(meetType, type) && meetExactType == exactType && meetNonNull == nonNull && meetAlwaysNull == alwaysNull) { + return this; + } else if (Objects.equals(meetType, other.type) && meetExactType == other.exactType && meetNonNull == other.nonNull && meetAlwaysNull == other.alwaysNull) { + return other; + } else { + return copyWith(meetType, meetExactType, meetNonNull, meetAlwaysNull); + } + } + + @Override + public Stamp join(Stamp otherStamp) { + return join0(otherStamp, false); + } + + /** + * Returns the stamp representing the type of this stamp after a cast to the type represented by + * the {@code to} stamp. While this is very similar to a {@link #join} operation, in the case + * where both types are not obviously related, the cast operation will prefer the type of the + * {@code to} stamp. This is necessary as long as ObjectStamps are not able to accurately + * represent intersection types. + * + * For example when joining the {@link RandomAccess} type with the {@link AbstractList} type, + * without intersection types, this would result in the most generic type ({@link Object} ). For + * this reason, in some cases a {@code castTo} operation is preferable in order to keep at least + * the {@link AbstractList} type. + * + * @param to the stamp this stamp should be casted to + * @return This stamp casted to the {@code to} stamp + */ + public Stamp castTo(ObjectStamp to) { + return join0(to, true); + } + + private Stamp join0(Stamp otherStamp, boolean castToOther) { + if (this == otherStamp) { + return this; + } + if (!isCompatible(otherStamp)) { + return StampFactory.illegal(Kind.Illegal); + } + AbstractObjectStamp other = (AbstractObjectStamp) otherStamp; + if (!isLegal()) { + return this; + } else if (!other.isLegal()) { + return other; + } + + ResolvedJavaType joinType; + boolean joinAlwaysNull = alwaysNull || other.alwaysNull; + boolean joinNonNull = nonNull || other.nonNull; + boolean joinExactType = exactType || other.exactType; + if (Objects.equals(type, other.type)) { + joinType = type; + } else if (type == null && other.type == null) { + joinType = null; + } else if (type == null) { + joinType = other.type; + } else if (other.type == null) { + joinType = type; + } else { + // both types are != null and different + if (type.isAssignableFrom(other.type)) { + joinType = other.type; + if (exactType) { + joinAlwaysNull = true; + } + } else if (other.type.isAssignableFrom(type)) { + joinType = type; + if (other.exactType) { + joinAlwaysNull = true; + } + } else { + if (castToOther) { + joinType = other.type; + joinExactType = other.exactType; + } else { + joinType = null; + } + if (joinExactType || (!type.isInterface() && !other.type.isInterface())) { + joinAlwaysNull = true; + } + } + } + if (joinAlwaysNull) { + joinType = null; + joinExactType = false; + } + if (joinExactType && joinType == null) { + return StampFactory.illegal(Kind.Object); + } + if (joinAlwaysNull && joinNonNull) { + return StampFactory.illegal(Kind.Object); + } else if (joinExactType && !isConcreteType(joinType)) { + return StampFactory.illegal(Kind.Object); + } + if (Objects.equals(joinType, type) && joinExactType == exactType && joinNonNull == nonNull && joinAlwaysNull == alwaysNull) { + return this; + } else if (Objects.equals(joinType, other.type) && joinExactType == other.exactType && joinNonNull == other.nonNull && joinAlwaysNull == other.alwaysNull) { + return other; + } else { + return copyWith(joinType, joinExactType, joinNonNull, joinAlwaysNull); + } + } + + public static boolean isConcreteType(ResolvedJavaType type) { + return !(type.isAbstract() && !type.isArray()); + } + + private static ResolvedJavaType meetTypes(ResolvedJavaType a, ResolvedJavaType b) { + if (Objects.equals(a, b)) { + return a; + } else if (a == null || b == null) { + return null; + } else { + return a.findLeastCommonAncestor(b); + } + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (exactType ? 1231 : 1237); + result = prime * result + (nonNull ? 1231 : 1237); + result = prime * result + (alwaysNull ? 1231 : 1237); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + AbstractObjectStamp other = (AbstractObjectStamp) obj; + if (exactType != other.exactType || nonNull != other.nonNull || alwaysNull != other.alwaysNull) { + return false; + } + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + return true; + } +} diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/ObjectStamp.java Thu May 22 18:10:04 2014 +0200 @@ -22,23 +22,18 @@ */ package com.oracle.graal.compiler.common.type; -import java.util.*; - import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.common.spi.*; -public class ObjectStamp extends Stamp { - - private final ResolvedJavaType type; - private final boolean exactType; - private final boolean nonNull; - private final boolean alwaysNull; +public class ObjectStamp extends AbstractObjectStamp { public ObjectStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) { - this.type = type; - this.exactType = exactType; - this.nonNull = nonNull; - this.alwaysNull = alwaysNull; + super(type, exactType, nonNull, alwaysNull); + } + + @Override + protected AbstractObjectStamp copyWith(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) { + return new ObjectStamp(type, exactType, nonNull, alwaysNull); } @Override @@ -47,111 +42,19 @@ } @Override - public Stamp illegal() { - return new ObjectStamp(null, true, true, false); - } - - @Override - public boolean isLegal() { - return !exactType || (type != null && (isConcreteType(type))); - } - - @Override - public Kind getStackKind() { - return Kind.Object; - } - - @Override public PlatformKind getPlatformKind(PlatformKindTool tool) { return tool.getObjectKind(); } @Override - public ResolvedJavaType javaType(MetaAccessProvider metaAccess) { - if (type != null) { - return type; - } - return metaAccess.lookupJavaType(Object.class); - } - - public boolean nonNull() { - return nonNull; - } - - public boolean alwaysNull() { - return alwaysNull; - } - - public ResolvedJavaType type() { - return type; - } - - public boolean isExactType() { - return exactType; - } - - @Override public String toString() { StringBuilder str = new StringBuilder(); str.append('a'); - str.append(nonNull ? "!" : "").append(exactType ? "#" : "").append(' ').append(type == null ? "-" : type.getName()).append(alwaysNull ? " NULL" : ""); + appendString(str); return str.toString(); } @Override - public Stamp meet(Stamp otherStamp) { - if (this == otherStamp) { - return this; - } - if (!(otherStamp instanceof ObjectStamp)) { - return StampFactory.illegal(Kind.Illegal); - } - ObjectStamp other = (ObjectStamp) otherStamp; - if (!isLegal()) { - return other; - } else if (!other.isLegal()) { - return this; - } - ResolvedJavaType meetType; - boolean meetExactType; - boolean meetNonNull; - boolean meetAlwaysNull; - if (other.alwaysNull) { - meetType = type(); - meetExactType = exactType; - meetNonNull = false; - meetAlwaysNull = alwaysNull; - } else if (alwaysNull) { - meetType = other.type(); - meetExactType = other.exactType; - meetNonNull = false; - meetAlwaysNull = other.alwaysNull; - } else { - meetType = meetTypes(type(), other.type()); - meetExactType = exactType && other.exactType; - if (meetExactType && type != null && other.type != null) { - // meeting two valid exact types may result in a non-exact type - meetExactType = Objects.equals(meetType, type) && Objects.equals(meetType, other.type); - } - meetNonNull = nonNull && other.nonNull; - meetAlwaysNull = false; - } - - if (Objects.equals(meetType, type) && meetExactType == exactType && meetNonNull == nonNull && meetAlwaysNull == alwaysNull) { - return this; - } else if (Objects.equals(meetType, other.type) && meetExactType == other.exactType && meetNonNull == other.nonNull && meetAlwaysNull == other.alwaysNull) { - return other; - } else { - return new ObjectStamp(meetType, meetExactType, meetNonNull, meetAlwaysNull); - } - } - - @Override - public Stamp join(Stamp otherStamp) { - return join0(otherStamp, false); - } - - @Override public boolean isCompatible(Stamp other) { if (this == other) { return true; @@ -161,142 +64,4 @@ } return false; } - - /** - * Returns the stamp representing the type of this stamp after a cast to the type represented by - * the {@code to} stamp. While this is very similar to a {@link #join} operation, in the case - * where both types are not obviously related, the cast operation will prefer the type of the - * {@code to} stamp. This is necessary as long as ObjectStamps are not able to accurately - * represent intersection types. - * - * For example when joining the {@link RandomAccess} type with the {@link AbstractList} type, - * without intersection types, this would result in the most generic type ({@link Object} ). For - * this reason, in some cases a {@code castTo} operation is preferable in order to keep at least - * the {@link AbstractList} type. - * - * @param to the stamp this stamp should be casted to - * @return This stamp casted to the {@code to} stamp - */ - public Stamp castTo(ObjectStamp to) { - return join0(to, true); - } - - private Stamp join0(Stamp otherStamp, boolean castToOther) { - if (this == otherStamp) { - return this; - } - if (!(otherStamp instanceof ObjectStamp)) { - return StampFactory.illegal(Kind.Illegal); - } - ObjectStamp other = (ObjectStamp) otherStamp; - if (!isLegal()) { - return this; - } else if (!other.isLegal()) { - return other; - } - - ResolvedJavaType joinType; - boolean joinAlwaysNull = alwaysNull || other.alwaysNull; - boolean joinNonNull = nonNull || other.nonNull; - boolean joinExactType = exactType || other.exactType; - if (Objects.equals(type, other.type)) { - joinType = type; - } else if (type == null && other.type == null) { - joinType = null; - } else if (type == null) { - joinType = other.type; - } else if (other.type == null) { - joinType = type; - } else { - // both types are != null and different - if (type.isAssignableFrom(other.type)) { - joinType = other.type; - if (exactType) { - joinAlwaysNull = true; - } - } else if (other.type.isAssignableFrom(type)) { - joinType = type; - if (other.exactType) { - joinAlwaysNull = true; - } - } else { - if (castToOther) { - joinType = other.type; - joinExactType = other.exactType; - } else { - joinType = null; - } - if (joinExactType || (!type.isInterface() && !other.type.isInterface())) { - joinAlwaysNull = true; - } - } - } - if (joinAlwaysNull) { - joinType = null; - joinExactType = false; - } - if (joinExactType && joinType == null) { - return StampFactory.illegal(Kind.Object); - } - if (joinAlwaysNull && joinNonNull) { - return StampFactory.illegal(Kind.Object); - } else if (joinExactType && !isConcreteType(joinType)) { - return StampFactory.illegal(Kind.Object); - } - if (Objects.equals(joinType, type) && joinExactType == exactType && joinNonNull == nonNull && joinAlwaysNull == alwaysNull) { - return this; - } else if (Objects.equals(joinType, other.type) && joinExactType == other.exactType && joinNonNull == other.nonNull && joinAlwaysNull == other.alwaysNull) { - return other; - } else { - return new ObjectStamp(joinType, joinExactType, joinNonNull, joinAlwaysNull); - } - } - - public static boolean isConcreteType(ResolvedJavaType type) { - return !(type.isAbstract() && !type.isArray()); - } - - private static ResolvedJavaType meetTypes(ResolvedJavaType a, ResolvedJavaType b) { - if (Objects.equals(a, b)) { - return a; - } else if (a == null || b == null) { - return null; - } else { - return a.findLeastCommonAncestor(b); - } - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + (exactType ? 1231 : 1237); - result = prime * result + (nonNull ? 1231 : 1237); - result = prime * result + (alwaysNull ? 1231 : 1237); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - ObjectStamp other = (ObjectStamp) obj; - if (exactType != other.exactType || nonNull != other.nonNull || alwaysNull != other.alwaysNull) { - return false; - } - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - return true; - } - } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java --- a/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.common/src/com/oracle/graal/compiler/common/type/StampFactory.java Thu May 22 18:10:04 2014 +0200 @@ -200,7 +200,7 @@ ResolvedJavaType type = value.isNull() ? null : metaAccess.lookupJavaType(value); return new ObjectStamp(type, value.isNonNull(), value.isNonNull(), value.isNull()); } else { - throw new GraalInternalError(Kind.Object + " expected, actual kind: %s", value.getKind()); + return forConstant(value); } } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndAddTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndAddTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndAddTest.java Thu May 22 18:10:04 2014 +0200 @@ -45,6 +45,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndSetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndSetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicIntGetAndSetTest.java Thu May 22 18:10:04 2014 +0200 @@ -45,6 +45,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndAddTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndAddTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndAddTest.java Thu May 22 18:10:04 2014 +0200 @@ -45,6 +45,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndSetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndSetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/AtomicLongGetAndSetTest.java Thu May 22 18:10:04 2014 +0200 @@ -45,6 +45,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetGidTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetGidTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetGidTest.java Thu May 22 18:10:04 2014 +0200 @@ -47,6 +47,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntAddAndGetTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntDecAndGetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntDecAndGetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntDecAndGetTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndAddTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndAddTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndAddTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndDecTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndDecTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndDecTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndIncTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndIncTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntGetAndIncTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntIncAndGetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntIncAndGetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicIntIncAndGetTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongAddAndGetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongAddAndGetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongAddAndGetTest.java Thu May 22 18:10:04 2014 +0200 @@ -46,6 +46,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndAddTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndAddTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndAddTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndIncTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndIncTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongGetAndIncTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongIncAndGetTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongIncAndGetTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/AtomicLongIncAndGetTest.java Thu May 22 18:10:04 2014 +0200 @@ -44,6 +44,11 @@ } @Override + protected boolean supportsRequiredCapabilities() { + return (canDeoptimize()); + } + + @Override public void runTest() { setupArrays(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ForEachToGraalTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ForEachToGraalTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/ForEachToGraalTest.java Thu May 22 18:10:04 2014 +0200 @@ -23,12 +23,13 @@ package com.oracle.graal.compiler.hsail.test.lambda; -import java.util.stream.IntStream; - +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static org.junit.Assert.*; -import org.junit.Test; -import java.util.Arrays; -import java.util.ArrayList; + +import java.util.*; +import java.util.stream.*; + +import org.junit.*; /** * Several tests for the Sumatra APIs. @@ -266,6 +267,10 @@ // Graal throws NYI @Test public void testForEachIntRangeNoCapturesUseEscapingNew() { + if (runtime().getConfig().useHSAILDeoptimization == false) { + return; + } + MyPoint[] dest = new MyPoint[size]; IntStream range = IntStream.range(0, dest.length).parallel(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyDeoptTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyDeoptTest.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/lambda/VecmathNBodyDeoptTest.java Thu May 22 18:10:04 2014 +0200 @@ -122,7 +122,7 @@ @Override protected boolean supportsRequiredCapabilities() { - return (canHandleDeoptVirtualObjects()); + return (canHandleDeoptVirtualObjects() && canDeoptimize()); } @Test diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu May 22 18:10:04 2014 +0200 @@ -241,7 +241,7 @@ } try (Scope ds = Debug.scope("BackEnd", lir)) { FrameMap frameMap = backend.newFrameMap(registerConfig); - LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMap, stub); + LIRGenerationResult lirGenRes = backend.newLIRGenerationResult(lir, frameMap, graph.method(), stub); LIRGeneratorTool lirGen = backend.newLIRGenerator(cc, lirGenRes); NodeLIRBuilderTool nodeLirGen = backend.newNodeLIRBuilder(graph, lirGen); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Thu May 22 18:10:04 2014 +0200 @@ -824,14 +824,12 @@ // liveOut(block) is the union of liveIn(sux), for successors sux of block int n = block.getSuccessorCount(); if (n > 0) { + liveOut.clear(); // block has successors if (n > 0) { - liveOut.clear(); for (AbstractBlock successor : block.getSuccessors()) { liveOut.or(blockData.get(successor).liveIn); } - } else { - liveOut.clear(); } if (!blockSets.liveOut.equals(liveOut)) { diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/NodeLIRBuilder.java Thu May 22 18:10:04 2014 +0200 @@ -101,14 +101,14 @@ public NodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool gen) { this.gen = gen; this.nodeOperands = graph.createNodeMap(); - this.debugInfoBuilder = createDebugInfoBuilder(nodeOperands); + this.debugInfoBuilder = createDebugInfoBuilder(graph, nodeOperands); if (MatchExpressions.getValue()) { matchRules = MatchRuleRegistry.lookup(getClass()); } } - @SuppressWarnings("hiding") - protected DebugInfoBuilder createDebugInfoBuilder(NodeMap nodeOperands) { + @SuppressWarnings({"unused", "hiding"}) + protected DebugInfoBuilder createDebugInfoBuilder(StructuredGraph graph, NodeMap nodeOperands) { return new DebugInfoBuilder(nodeOperands); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchProcessor.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchProcessor.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchProcessor.java Thu May 22 18:10:04 2014 +0200 @@ -219,7 +219,7 @@ */ private static final boolean DEBUG = false; - private static final String MATCHPROCESSOR_LOG = "/tmp/matchprocessor.log"; + private static final String LOGFILE = new File(System.getProperty("java.io.tmpdir"), "matchprocessor.log").getPath(); private static PrintWriter log; @@ -230,7 +230,7 @@ private static synchronized PrintWriter getLog() { if (log == null) { try { - log = new PrintWriter(new FileWriter(MATCHPROCESSOR_LOG, true)); + log = new PrintWriter(new FileWriter(LOGFILE, true)); } catch (IOException e) { // Do nothing } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/match/MatchRuleRegistry.java Thu May 22 18:10:04 2014 +0200 @@ -95,31 +95,7 @@ if (result == null) { NodeClassLookup lookup = new DefaultNodeClassLookup(); - HashMap, List> localRules = new HashMap<>(); - ServiceLoader sl = ServiceLoader.loadInstalled(MatchStatementSet.class); - for (MatchStatementSet rules : sl) { - localRules.put(rules.forClass(), rules.statements(lookup)); - } - - // Walk the class hierarchy collecting lists and merge them together. The subclass - // rules are first which gives them preference over earlier rules. - Map, List> rules = new HashMap<>(); - Class currentClass = theClass; - do { - List statements = localRules.get(currentClass); - if (statements != null) { - for (MatchStatement statement : statements) { - Class nodeClass = statement.getPattern().nodeClass(); - List current = rules.get(nodeClass); - if (current == null) { - current = new ArrayList<>(); - rules.put(nodeClass, current); - } - current.add(statement); - } - } - currentClass = currentClass.getSuperclass(); - } while (currentClass != NodeLIRBuilder.class); + Map, List> rules = createRules(theClass, lookup); registry.put(theClass, rules); assert registry.get(theClass) == rules; result = rules; @@ -142,4 +118,38 @@ } return result; } + + /* + * This is a separate, public method so that external clients can create rules with a custom + * lookup and without the default caching behavior. + */ + public static Map, List> createRules(Class theClass, NodeClassLookup lookup) { + HashMap, MatchStatementSet> matchSets = new HashMap<>(); + ServiceLoader sl = ServiceLoader.loadInstalled(MatchStatementSet.class); + for (MatchStatementSet rules : sl) { + matchSets.put(rules.forClass(), rules); + } + + // Walk the class hierarchy collecting lists and merge them together. The subclass + // rules are first which gives them preference over earlier rules. + Map, List> rules = new HashMap<>(); + Class currentClass = theClass; + do { + MatchStatementSet matchSet = matchSets.get(currentClass); + if (matchSet != null) { + List statements = matchSet.statements(lookup); + for (MatchStatement statement : statements) { + Class nodeClass = statement.getPattern().nodeClass(); + List current = rules.get(nodeClass); + if (current == null) { + current = new ArrayList<>(); + rules.put(nodeClass, current); + } + current.add(statement); + } + } + currentClass = currentClass.getSuperclass(); + } while (currentClass != NodeLIRBuilder.class); + return rules; + } } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Thu May 22 18:10:04 2014 +0200 @@ -78,7 +78,7 @@ appendPhase(canonicalizer); } - appendPhase(new LoopSafepointEliminationPhase()); + appendPhase(new IncrementalCanonicalizerPhase<>(canonicalizer, new LoopSafepointEliminationPhase())); appendPhase(new LoopSafepointInsertionPhase()); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Thu May 22 18:10:04 2014 +0200 @@ -75,7 +75,7 @@ public abstract LIRGeneratorTool newLIRGenerator(CallingConvention cc, LIRGenerationResult lirGenRes); - public abstract LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub); + public abstract LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, ResolvedJavaMethod method, Object stub); public abstract NodeLIRBuilderTool newNodeLIRBuilder(StructuredGraph graph, LIRGeneratorTool lirGen); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java --- a/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.debug/src/com/oracle/graal/debug/Debug.java Thu May 22 18:10:04 2014 +0200 @@ -277,7 +277,11 @@ } public static Scope forceLog() { - return Debug.sandbox("forceLog", new DelegatingDebugConfig().enable(LOG).enable(LOG_METHOD)); + ArrayList context = new ArrayList<>(); + for (Object obj : context()) { + context.add(obj); + } + return Debug.sandbox("forceLog", new DelegatingDebugConfig().enable(LOG).enable(LOG_METHOD), context.toArray()); } /** diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/Node.java Thu May 22 18:10:04 2014 +0200 @@ -142,13 +142,17 @@ */ private Node usage0; private Node usage1; - private Node[] extraUsages = NO_NODES; + private Node[] extraUsages; private Node predecessor; public Node() { - this.graph = null; - this.id = INITIAL_ID; + init(); + } + + final void init() { + id = INITIAL_ID; + extraUsages = NO_NODES; } int id() { @@ -953,7 +957,11 @@ * @param map */ public Map getDebugProperties(Map map) { - getNodeClass().getDebugProperties(this, map); + NodeClass nodeClass = getNodeClass(); + for (Integer pos : nodeClass.getPropertyPositions()) { + map.put(nodeClass.getPropertyName(pos), nodeClass.getProperty(this, pos)); + + } return map; } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/NodeClass.java Thu May 22 18:10:04 2014 +0200 @@ -755,43 +755,6 @@ return number; } - /** - * Populates a given map with the names and values of all data fields. - * - * @param node the node from which to take the values. - * @param properties a map that will be populated. - */ - public void getDebugProperties(Node node, Map properties) { - for (int i = 0; i < dataOffsets.length; ++i) { - Class type = fieldTypes.get(dataOffsets[i]); - Object value = null; - if (type.isPrimitive()) { - if (type == Integer.TYPE) { - value = unsafe.getInt(node, dataOffsets[i]); - } else if (type == Long.TYPE) { - value = unsafe.getLong(node, dataOffsets[i]); - } else if (type == Boolean.TYPE) { - value = unsafe.getBoolean(node, dataOffsets[i]); - } else if (type == Float.TYPE) { - value = unsafe.getFloat(node, dataOffsets[i]); - } else if (type == Double.TYPE) { - value = unsafe.getDouble(node, dataOffsets[i]); - } else if (type == Short.TYPE) { - value = unsafe.getShort(node, dataOffsets[i]); - } else if (type == Character.TYPE) { - value = unsafe.getChar(node, dataOffsets[i]); - } else if (type == Byte.TYPE) { - value = unsafe.getByte(node, dataOffsets[i]); - } else { - assert false : "unhandled property type: " + type; - } - } else { - value = unsafe.getObject(node, dataOffsets[i]); - } - properties.put(fieldNames.get(dataOffsets[i]), value); - } - } - private static boolean deepEquals0(Object e1, Object e2) { assert e1 != null; boolean eq; @@ -933,6 +896,73 @@ return fieldNames.get(pos.isInput() ? inputOffsets[pos.getIndex()] : successorOffsets[pos.getIndex()]); } + public String getPropertyName(int pos) { + return fieldNames.get(dataOffsets[pos]); + } + + public Class getPropertyType(int pos) { + return fieldTypes.get(dataOffsets[pos]); + } + + public Object getProperty(Node node, int pos) { + long dataOffset = dataOffsets[pos]; + Class type = fieldTypes.get(dataOffset); + Object value = null; + if (type.isPrimitive()) { + if (type == Integer.TYPE) { + value = unsafe.getInt(node, dataOffset); + } else if (type == Long.TYPE) { + value = unsafe.getLong(node, dataOffset); + } else if (type == Boolean.TYPE) { + value = unsafe.getBoolean(node, dataOffset); + } else if (type == Float.TYPE) { + value = unsafe.getFloat(node, dataOffset); + } else if (type == Double.TYPE) { + value = unsafe.getDouble(node, dataOffset); + } else if (type == Short.TYPE) { + value = unsafe.getShort(node, dataOffset); + } else if (type == Character.TYPE) { + value = unsafe.getChar(node, dataOffset); + } else if (type == Byte.TYPE) { + value = unsafe.getByte(node, dataOffset); + } else { + assert false : "unhandled property type: " + type; + } + } else { + value = unsafe.getObject(node, dataOffset); + } + return value; + } + + public void setProperty(Node node, int pos, Object value) { + long dataOffset = dataOffsets[pos]; + Class type = fieldTypes.get(dataOffset); + if (type.isPrimitive()) { + if (type == Integer.TYPE) { + unsafe.putInt(node, dataOffset, (Integer) value); + } else if (type == Long.TYPE) { + unsafe.putLong(node, dataOffset, (Long) value); + } else if (type == Boolean.TYPE) { + unsafe.putBoolean(node, dataOffset, (Boolean) value); + } else if (type == Float.TYPE) { + unsafe.putFloat(node, dataOffset, (Float) value); + } else if (type == Double.TYPE) { + unsafe.putDouble(node, dataOffset, (Double) value); + } else if (type == Short.TYPE) { + unsafe.putShort(node, dataOffset, (Short) value); + } else if (type == Character.TYPE) { + unsafe.putChar(node, dataOffset, (Character) value); + } else if (type == Byte.TYPE) { + unsafe.putByte(node, dataOffset, (Byte) value); + } else { + assert false : "unhandled property type: " + type; + } + } else { + assert value == null || !value.getClass().isPrimitive(); + unsafe.putObject(node, dataOffset, value); + } + } + void updateInputSuccInPlace(Node node, InplaceUpdateClosure duplicationReplacement) { int index = 0; while (index < directInputCount) { @@ -1031,7 +1061,7 @@ if (pos.getSubIndex() < list.size()) { list.set(pos.getSubIndex(), x); } else { - while (pos.getSubIndex() < list.size() - 1) { + while (list.size() < pos.getSubIndex()) { list.add(null); } list.add(x); @@ -1353,6 +1383,54 @@ }; } + public Collection getPropertyPositions() { + return new AbstractCollection() { + @Override + public Iterator iterator() { + return new Iterator() { + int i = 0; + + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + public Integer next() { + Integer pos = i++; + return pos; + } + + public boolean hasNext() { + return i < dataOffsets.length; + } + }; + } + + @Override + public int size() { + return dataOffsets.length; + } + }; + } + + /** + * Initializes a fresh allocated node for which no constructor is called yet. Needed to + * implement node factories in svm. + */ + public void initRawNode(Node node) { + node.init(); + for (int inputPos = directInputCount; inputPos < inputOffsets.length; inputPos++) { + if (getNodeList(node, inputOffsets[inputPos]) == null) { + putNodeList(node, inputOffsets[inputPos], new NodeInputList<>(node)); + } + } + for (int successorPos = directSuccessorCount; successorPos < successorOffsets.length; successorPos++) { + if (getNodeList(node, successorOffsets[successorPos]) == null) { + putNodeList(node, successorOffsets[successorPos], new NodeSuccessorList<>(node)); + } + } + } + public Class getJavaClass() { return getClazz(); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Thu May 22 18:10:04 2014 +0200 @@ -26,6 +26,7 @@ import static com.oracle.graal.api.code.CallingConvention.Type.*; import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.compiler.common.GraalOptions.*; + import java.util.*; import sun.misc.*; @@ -77,7 +78,7 @@ } @Override - public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub) { + public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, ResolvedJavaMethod method, Object stub) { return new AMD64HotSpotLIRGenerationResult(lir, frameMap, stub); } @@ -190,7 +191,6 @@ CalleeSaveLayout csl = crb.frameMap.registerConfig.getCalleeSaveLayout(); if (csl != null && csl.size != 0) { - crb.compilationResult.setRegisterRestoreEpilogueOffset(asm.position()); // saved all registers, restore all registers int frameToCSA = crb.frameMap.offsetToCalleeSaveArea(); asm.restore(csl, frameToCSA); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotNodeLIRBuilder.java Thu May 22 18:10:04 2014 +0200 @@ -59,7 +59,10 @@ private static ValueNode filterCompression(ValueNode node) { ValueNode result = node; - while (result instanceof CompressionNode) { + if (result instanceof PiNode) { + result = ((PiNode) result).getOriginalNode(); + } + if (result instanceof CompressionNode) { result = ((CompressionNode) result).getInput(); } return result; @@ -131,7 +134,7 @@ } @Override - protected DebugInfoBuilder createDebugInfoBuilder(NodeMap nodeOperands) { + protected DebugInfoBuilder createDebugInfoBuilder(StructuredGraph graph, NodeMap nodeOperands) { HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), Kind.Long); return new HotSpotDebugInfoBuilder(nodeOperands, lockStack); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Thu May 22 18:10:04 2014 +0200 @@ -316,7 +316,6 @@ // from host code result.setTotalFrameSize(hostCode.getTotalFrameSize()); result.setCustomStackAreaOffset(hostCode.getCustomStackAreaOffset()); - result.setRegisterRestoreEpilogueOffset(hostCode.getRegisterRestoreEpilogueOffset()); result.setTargetCode(hostCode.getTargetCode(), hostCode.getTargetCodeSize()); for (CodeAnnotation annotation : hostCode.getAnnotations()) { result.addAnnotation(annotation); @@ -409,7 +408,7 @@ } @Override - public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub) { + public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, ResolvedJavaMethod method, Object stub) { return new HSAILHotSpotLIRGenerationResult(lir, frameMap); } @@ -490,6 +489,10 @@ boolean useHSAILDeoptimization = config.useHSAILDeoptimization; boolean useHSAILSafepoints = config.useHSAILSafepoints; + if ((useHSAILSafepoints == true) && (useHSAILDeoptimization == false)) { + Debug.log("+UseHSAILSafepoints requires +UseHSAILDeoptimization"); + } + // see what graph nodes we have to see if we are using the thread register // if not, we don't have to emit the code that sets that up // maybe there is a better way to do this? diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotLIRGenerator.java Thu May 22 18:10:04 2014 +0200 @@ -180,7 +180,7 @@ * We need 64-bit and 32-bit scratch registers for the codegen $s0 can be live at this block. */ private void emitDeoptimizeInner(Value actionAndReason, LIRFrameState lirFrameState, String emitName) { - DeoptimizeOp deopt = new DeoptimizeOp(actionAndReason, lirFrameState, emitName, getMetaAccess()); + DeoptimizeOp deopt = new DeoptimizeOp(actionAndReason, lirFrameState, emitName, config.useHSAILDeoptimization, getMetaAccess()); ((HSAILHotSpotLIRGenerationResult) getResult()).addDeopt(deopt); append(deopt); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotNodeLIRBuilder.java Thu May 22 18:10:04 2014 +0200 @@ -104,7 +104,7 @@ @Override public void visitSafepointNode(SafepointNode i) { HotSpotVMConfig config = getGen().config; - if (config.useHSAILSafepoints == true) { + if ((config.useHSAILSafepoints == true) && (config.useHSAILDeoptimization == true)) { LIRFrameState info = state(i); HSAILHotSpotSafepointOp safepoint = new HSAILHotSpotSafepointOp(info, config, this); ((HSAILHotSpotLIRGenerationResult) getGen().getResult()).addDeopt(safepoint); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java --- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotSafepointOp.java Thu May 22 18:10:04 2014 +0200 @@ -41,49 +41,54 @@ @State protected LIRFrameState frameState; protected int codeBufferPos = -1; final int offsetToNoticeSafepoints; + final HotSpotVMConfig config; public HSAILHotSpotSafepointOp(LIRFrameState state, HotSpotVMConfig config, NodeLIRBuilderTool tool) { actionAndReason = tool.getLIRGeneratorTool().getMetaAccess().encodeDeoptActionAndReason(DeoptimizationAction.None, DeoptimizationReason.None, 0); frameState = state; offsetToNoticeSafepoints = config.hsailNoticeSafepointsOffset; + this.config = config; } @Override public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + if (config.useHSAILDeoptimization) { + // get a unique codeBuffer position + // when we save our state, we will save this as well (it can be used as a key to get the + // debugInfo) + codeBufferPos = masm.position(); - // get a unique codeBuffer position - // when we save our state, we will save this as well (it can be used as a key to get the - // debugInfo) - codeBufferPos = masm.position(); + masm.emitComment(" /* HSAIL safepoint bci=" + frameState.debugInfo().getBytecodePosition().getBCI() + ", frameState=" + frameState + " */"); + String afterSafepointLabel = "@LAfterSafepoint_at_pos_" + codeBufferPos; - masm.emitComment(" /* HSAIL safepoint bci=" + frameState.debugInfo().getBytecodePosition().getBCI() + ", frameState=" + frameState + " */"); - String afterSafepointLabel = "@LAfterSafepoint_at_pos_" + codeBufferPos; + AllocatableValue scratch64 = HSAIL.d16.asValue(Kind.Object); + AllocatableValue spAddrReg = HSAIL.d17.asValue(Kind.Object); + AllocatableValue scratch32 = HSAIL.s34.asValue(Kind.Int); + masm.emitLoadKernelArg(scratch64, masm.getDeoptInfoName(), "u64"); - AllocatableValue scratch64 = HSAIL.d16.asValue(Kind.Object); - AllocatableValue spAddrReg = HSAIL.d17.asValue(Kind.Object); - AllocatableValue scratch32 = HSAIL.s34.asValue(Kind.Int); - masm.emitLoadKernelArg(scratch64, masm.getDeoptInfoName(), "u64"); + // Build address of noticeSafepoints field + HSAILAddress noticeSafepointsAddr = new HSAILAddressValue(Kind.Object, scratch64, offsetToNoticeSafepoints).toAddress(); + masm.emitLoad(Kind.Object, spAddrReg, noticeSafepointsAddr); - // Build address of noticeSafepoints field - HSAILAddress noticeSafepointsAddr = new HSAILAddressValue(Kind.Object, scratch64, offsetToNoticeSafepoints).toAddress(); - masm.emitLoad(Kind.Object, spAddrReg, noticeSafepointsAddr); - - // Load int value from that field - HSAILAddress noticeSafepointsIntAddr = new HSAILAddressValue(Kind.Int, spAddrReg, 0).toAddress(); - masm.emitLoadAcquire(scratch32, noticeSafepointsIntAddr); - masm.emitCompare(Kind.Int, scratch32, Constant.forInt(0), "eq", false, false); - masm.cbr(afterSafepointLabel); + // Load int value from that field + HSAILAddress noticeSafepointsIntAddr = new HSAILAddressValue(Kind.Int, spAddrReg, 0).toAddress(); + masm.emitLoadAcquire(scratch32, noticeSafepointsIntAddr); + masm.emitCompare(Kind.Int, scratch32, Constant.forInt(0), "eq", false, false); + masm.cbr(afterSafepointLabel); - AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(Kind.Int); - AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(Kind.Int); - masm.emitMov(Kind.Int, actionAndReasonReg, actionAndReason); - masm.emitMov(Kind.Int, codeBufferOffsetReg, Constant.forInt(codeBufferPos)); - masm.emitJumpToLabelName(masm.getDeoptLabelName()); + AllocatableValue actionAndReasonReg = HSAIL.actionAndReasonReg.asValue(Kind.Int); + AllocatableValue codeBufferOffsetReg = HSAIL.codeBufferOffsetReg.asValue(Kind.Int); + masm.emitMov(Kind.Int, actionAndReasonReg, actionAndReason); + masm.emitMov(Kind.Int, codeBufferOffsetReg, Constant.forInt(codeBufferPos)); + masm.emitJumpToLabelName(masm.getDeoptLabelName()); - masm.emitString0(afterSafepointLabel + ":\n"); + masm.emitString0(afterSafepointLabel + ":\n"); - // now record the debuginfo - crb.recordInfopoint(codeBufferPos, frameState, InfopointReason.SAFEPOINT); + // now record the debuginfo + crb.recordInfopoint(codeBufferPos, frameState, InfopointReason.SAFEPOINT); + } else { + masm.emitComment("/* HSAIL safepoint would have been here. */"); + } } public LIRFrameState getFrameState() { @@ -93,4 +98,4 @@ public int getCodeBufferPos() { return codeBufferPos; } -} \ No newline at end of file +} diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Thu May 22 18:10:04 2014 +0200 @@ -346,7 +346,7 @@ } @Override - public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub) { + public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, ResolvedJavaMethod method, Object stub) { return new LIRGenerationResultBase(lir, frameMap); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Thu May 22 18:10:04 2014 +0200 @@ -26,6 +26,7 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.sparc.SPARC.*; + import java.util.*; import sun.misc.*; @@ -83,7 +84,7 @@ } @Override - public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, Object stub) { + public LIRGenerationResult newLIRGenerationResult(LIR lir, FrameMap frameMap, ResolvedJavaMethod method, Object stub) { return new SPARCHotSpotLIRGenerationResult(lir, frameMap, stub); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotNodeLIRBuilder.java Thu May 22 18:10:04 2014 +0200 @@ -51,7 +51,7 @@ } @Override - protected DebugInfoBuilder createDebugInfoBuilder(NodeMap nodeOperands) { + protected DebugInfoBuilder createDebugInfoBuilder(StructuredGraph graph, NodeMap nodeOperands) { HotSpotLockStack lockStack = new HotSpotLockStack(gen.getResult().getFrameMap(), Kind.Long); return new HotSpotDebugInfoBuilder(nodeOperands, lockStack); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Thu May 22 18:10:04 2014 +0200 @@ -40,7 +40,7 @@ * @param metaspaceMethod the metaspace Method object * @return a new byte array containing the original bytecode */ - byte[] initializeBytecode(long metaspaceMethod); + byte[] getBytecode(long metaspaceMethod); int exceptionTableLength(long metaspaceMethod); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Thu May 22 18:10:04 2014 +0200 @@ -43,7 +43,7 @@ public native long getMetaspaceMethod(Class holder, int slot); @Override - public native byte[] initializeBytecode(long metaspaceMethod); + public native byte[] getBytecode(long metaspaceMethod); @Override public native int exceptionTableLength(long metaspaceMethod); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/DefaultHotSpotLoweringProvider.java Thu May 22 18:10:04 2014 +0200 @@ -277,7 +277,7 @@ case Object: if (compressible && runtime.getConfig().useCompressedOops) { - return new NarrowOopStamp((ObjectStamp) stamp, runtime.getConfig().getOopEncoding()); + return NarrowOopStamp.compressed((ObjectStamp) stamp, runtime.getConfig().getOopEncoding()); } } return stamp; diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Thu May 22 18:10:04 2014 +0200 @@ -56,6 +56,7 @@ private final HotSpotSignature signature; private HotSpotMethodData methodData; private byte[] code; + private Member toJavaCache; /** * Gets the holder of a HotSpot metaspace method native object. @@ -195,7 +196,7 @@ return null; } if (code == null && holder.isLinked()) { - code = runtime().getCompilerToVM().initializeBytecode(metaspaceMethod); + code = runtime().getCompilerToVM().getBytecode(metaspaceMethod); assert code.length == getCodeSize() : "expected: " + getCodeSize() + ", actual: " + code.length; } return code; @@ -505,16 +506,26 @@ } private Method toJava() { + if (toJavaCache != null) { + return (Method) toJavaCache; + } try { - return holder.mirror().getDeclaredMethod(name, signatureToTypes()); + Method result = holder.mirror().getDeclaredMethod(name, signatureToTypes()); + toJavaCache = result; + return result; } catch (NoSuchMethodException e) { return null; } } private Constructor toJavaConstructor() { + if (toJavaCache != null) { + return (Constructor) toJavaCache; + } try { - return holder.mirror().getDeclaredConstructor(signatureToTypes()); + Constructor result = holder.mirror().getDeclaredConstructor(signatureToTypes()); + toJavaCache = result; + return result; } catch (NoSuchMethodException e) { return null; } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Thu May 22 18:10:04 2014 +0200 @@ -607,6 +607,29 @@ return instanceFields; } + @Override + public ResolvedJavaField[] getStaticFields() { + if (isArray()) { + return new HotSpotResolvedJavaField[0]; + } else { + final int fieldCount = getFieldCount(); + ArrayList fieldsArray = new ArrayList<>(fieldCount); + + for (int i = 0; i < fieldCount; i++) { + FieldInfo field = new FieldInfo(i); + + // We are only interested in static fields. + if (field.isStatic()) { + HotSpotResolvedJavaField resolvedJavaField = createField(field.getName(), field.getType(), field.getOffset(), field.getAccessFlags()); + fieldsArray.add(resolvedJavaField); + } + } + + fieldsArray.sort(new OffsetComparator()); + return fieldsArray.toArray(new HotSpotResolvedJavaField[fieldsArray.size()]); + } + } + /** * Returns the actual field count of this class's internal {@code InstanceKlass::_fields} array * by walking the array and discounting the generic signature slots at the end of the array. diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedPrimitiveType.java Thu May 22 18:10:04 2014 +0200 @@ -39,7 +39,7 @@ /** * Gets the Graal mirror for a {@link Kind}. - * + * * @return the {@link HotSpotResolvedObjectType} corresponding to {@code kind} */ public static ResolvedJavaType fromKind(Kind kind) { @@ -49,12 +49,12 @@ /** * Creates the Graal mirror for a primitive {@link Kind}. - * + * *

* NOTE: Creating an instance of this class does not install the mirror for the * {@link Class} type. Use {@link #fromKind(Kind)} or {@link #fromClass(Class)} instead. *

- * + * * @param kind the Kind to create the mirror for */ public HotSpotResolvedPrimitiveType(Kind kind) { @@ -188,6 +188,11 @@ } @Override + public ResolvedJavaField[] getStaticFields() { + return new ResolvedJavaField[0]; + } + + @Override public T getAnnotation(Class annotationClass) { return null; } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CompressionNode.java Thu May 22 18:10:04 2014 +0200 @@ -71,7 +71,7 @@ case Compress: if (input instanceof ObjectStamp) { // compressed oop - return new NarrowOopStamp((ObjectStamp) input, encoding); + return NarrowOopStamp.compressed((ObjectStamp) input, encoding); } else if (input instanceof IntegerStamp) { // compressed metaspace pointer assert PrimitiveStamp.getBits(input) == 64; diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/type/NarrowOopStamp.java Thu May 22 18:10:04 2014 +0200 @@ -27,7 +27,7 @@ import com.oracle.graal.compiler.common.type.*; import com.oracle.graal.hotspot.HotSpotVMConfig.CompressEncoding; -public class NarrowOopStamp extends ObjectStamp { +public class NarrowOopStamp extends AbstractObjectStamp { public static final PlatformKind NarrowOop = new PlatformKind() { @@ -43,15 +43,20 @@ private final CompressEncoding encoding; - public NarrowOopStamp(ObjectStamp stamp, CompressEncoding encoding) { - this(stamp.type(), stamp.isExactType(), stamp.nonNull(), stamp.alwaysNull(), encoding); - } - public NarrowOopStamp(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull, CompressEncoding encoding) { super(type, exactType, nonNull, alwaysNull); this.encoding = encoding; } + @Override + protected AbstractObjectStamp copyWith(ResolvedJavaType type, boolean exactType, boolean nonNull, boolean alwaysNull) { + return new NarrowOopStamp(type, exactType, nonNull, alwaysNull, encoding); + } + + public static Stamp compressed(AbstractObjectStamp stamp, CompressEncoding encoding) { + return new NarrowOopStamp(stamp.type(), stamp.isExactType(), stamp.nonNull(), stamp.alwaysNull(), encoding); + } + public Stamp uncompressed() { return new ObjectStamp(type(), isExactType(), nonNull(), alwaysNull()); } @@ -61,21 +66,6 @@ } @Override - public Stamp unrestricted() { - return new NarrowOopStamp((ObjectStamp) super.unrestricted(), encoding); - } - - @Override - public Stamp illegal() { - return new NarrowOopStamp((ObjectStamp) super.illegal(), encoding); - } - - @Override - public Kind getStackKind() { - return Kind.Object; - } - - @Override public PlatformKind getPlatformKind(PlatformKindTool tool) { return NarrowOop; } @@ -84,33 +74,11 @@ public String toString() { StringBuilder str = new StringBuilder(); str.append('n'); - str.append(super.toString()); + appendString(str); return str.toString(); } @Override - public Stamp meet(Stamp otherStamp) { - if (this == otherStamp) { - return this; - } - if (!isCompatible(otherStamp)) { - return StampFactory.illegal(); - } - return new NarrowOopStamp((ObjectStamp) super.meet(otherStamp), encoding); - } - - @Override - public Stamp join(Stamp otherStamp) { - if (this == otherStamp) { - return this; - } - if (!isCompatible(otherStamp)) { - return StampFactory.illegal(Kind.Illegal); - } - return new NarrowOopStamp((ObjectStamp) super.join(otherStamp), encoding); - } - - @Override public boolean isCompatible(Stamp other) { if (this == other) { return true; diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java --- a/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Thu May 22 18:10:04 2014 +0200 @@ -54,7 +54,7 @@ */ private static final boolean DEBUG = true; - private static final String LOGFILE = "/tmp/hotspotvmconfigprocessor.log"; + private static final String LOGFILE = new File(System.getProperty("java.io.tmpdir"), "hotspotvmconfigprocessor.log").getPath(); private static PrintWriter log; @@ -109,7 +109,7 @@ //@formatter:off String[] prologue = new String[]{ - "// The normal wrappers boolAt and intxAt skip constant flags", + "// The normal wrappers CommandLineFlags::boolAt and CommandLineFlags::intxAt skip constant flags", "static bool boolAt(char* name, bool* value) {", " Flag* result = Flag::find_flag(name, strlen(name), true, true);", " if (result == NULL) return false;", @@ -157,12 +157,12 @@ out.println(); Set fieldTypes = new HashSet<>(); - for (String key : annotations.keySet()) { - fieldTypes.add(annotations.get(key).getType()); + for (VMConfigField key : annotations.values()) { + fieldTypes.add(key.getType()); } // For each type of field, generate a switch on the length of the symbol and then do a // direct compare. In general this reduces each operation to 2 tests plus a string - // compare. Being more prefect than that is probably not worth it. + // compare. Being more perfect than that is probably not worth it. for (String type : fieldTypes) { String sigtype = type.equals("boolean") ? "bool" : type; out.println(" if (fs.signature() == vmSymbols::" + sigtype + "_signature()) {"); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractBytecodeParser.java Thu May 22 18:10:04 2014 +0200 @@ -583,7 +583,7 @@ } } - protected abstract T genCheckCast(ResolvedJavaType type, T object, JavaTypeProfile profileForTypeCheck, boolean b); + protected abstract T createCheckCast(ResolvedJavaType type, T object, JavaTypeProfile profileForTypeCheck, boolean forStoreCheck); private void genCheckCast() { int cpi = getStream().readCPI(); @@ -591,14 +591,14 @@ T object = frameState.apop(); if (type instanceof ResolvedJavaType) { JavaTypeProfile profileForTypeCheck = getProfileForTypeCheck((ResolvedJavaType) type); - T checkCastNode = append(genCheckCast((ResolvedJavaType) type, object, profileForTypeCheck, false)); + T checkCastNode = append(createCheckCast((ResolvedJavaType) type, object, profileForTypeCheck, false)); frameState.apush(checkCastNode); } else { handleUnresolvedCheckCast(type, object); } } - protected abstract T genInstanceOf(ResolvedJavaType type, T object, JavaTypeProfile profileForTypeCheck); + protected abstract T createInstanceOf(ResolvedJavaType type, T object, JavaTypeProfile profileForTypeCheck); protected abstract T genConditional(T x); @@ -608,7 +608,7 @@ T object = frameState.apop(); if (type instanceof ResolvedJavaType) { ResolvedJavaType resolvedType = (ResolvedJavaType) type; - T instanceOfNode = genInstanceOf((ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType)); + T instanceOfNode = createInstanceOf((ResolvedJavaType) type, object, getProfileForTypeCheck(resolvedType)); frameState.ipush(append(genConditional(genUnique(instanceOfNode)))); } else { handleUnresolvedInstanceOf(type, object); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/AbstractFrameStateBuilder.java Thu May 22 18:10:04 2014 +0200 @@ -160,6 +160,10 @@ return lockedObjects[i]; } + public void storeLock(int i, T lock) { + lockedObjects[i] = lock; + } + /** * Loads the local variable at the specified index, checking that the returned value is non-null * and that two-stack values are properly handled. diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/GraphBuilderPhase.java Thu May 22 18:10:04 2014 +0200 @@ -150,7 +150,7 @@ methodSynchronizedObject = null; this.currentGraph = graph; HIRFrameStateBuilder frameState = new HIRFrameStateBuilder(method, graph, graphBuilderConfig.eagerResolving()); - this.parser = new BytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, new BytecodeStream(method.getCode()), profilingInfo, method.getConstantPool(), + this.parser = createBytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, new BytecodeStream(method.getCode()), profilingInfo, method.getConstantPool(), entryBCI); TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); try { @@ -163,6 +163,12 @@ ComputeLoopFrequenciesClosure.compute(graph); } + @SuppressWarnings("hiding") + protected BytecodeParser createBytecodeParser(MetaAccessProvider metaAccess, ResolvedJavaMethod method, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, + HIRFrameStateBuilder frameState, BytecodeStream stream, ProfilingInfo profilingInfo, ConstantPool constantPool, int entryBCI) { + return new BytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, stream, profilingInfo, constantPool, entryBCI); + } + @Override protected String getDetailedName() { return getName() + " " + MetaUtil.format("%H.%n(%p):%r", parser.getMethod()); @@ -190,7 +196,7 @@ } } - class BytecodeParser extends AbstractBytecodeParser { + public class BytecodeParser extends AbstractBytecodeParser { private BciBlock[] loopHeaders; private LocalLiveness liveness; @@ -433,12 +439,13 @@ dispatchBegin.setStateAfter(dispatchState.create(bci)); } else { dispatchBegin = currentGraph.add(new DispatchBeginNode()); + dispatchState.apush(exceptionObject); dispatchBegin.setStateAfter(dispatchState.create(bci)); - dispatchState.apush(exceptionObject); dispatchState.setRethrowException(true); } + FixedWithNextNode finishedDispatch = finishInstruction(dispatchBegin, dispatchState); FixedNode target = createTarget(dispatchBlock, dispatchState); - finishInstruction(dispatchBegin, dispatchState).setNext(target); + finishedDispatch.setNext(target); return dispatchBegin; } @@ -600,12 +607,12 @@ } @Override - protected ValueNode genCheckCast(ResolvedJavaType type, ValueNode object, JavaTypeProfile profileForTypeCheck, boolean b) { - return new CheckCastNode(type, object, profileForTypeCheck, b); + protected ValueNode createCheckCast(ResolvedJavaType type, ValueNode object, JavaTypeProfile profileForTypeCheck, boolean forStoreCheck) { + return new CheckCastNode(type, object, profileForTypeCheck, forStoreCheck); } @Override - protected ValueNode genInstanceOf(ResolvedJavaType type, ValueNode object, JavaTypeProfile profileForTypeCheck) { + protected ValueNode createInstanceOf(ResolvedJavaType type, ValueNode object, JavaTypeProfile profileForTypeCheck) { return new InstanceOfNode(type, object, profileForTypeCheck); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java --- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Thu May 22 18:10:04 2014 +0200 @@ -141,13 +141,15 @@ protected MetaAccessProvider metaAccessProvider; protected String emitName; protected int codeBufferPos = -1; + private final boolean emitInfopoint; - public DeoptimizeOp(Value actionAndReason, LIRFrameState frameState, String emitName, MetaAccessProvider metaAccessProvider) { + public DeoptimizeOp(Value actionAndReason, LIRFrameState frameState, String emitName, boolean emitInfopoint, MetaAccessProvider metaAccessProvider) { super(Value.ILLEGAL); // return with no ret value this.actionAndReason = actionAndReason; this.frameState = frameState; this.emitName = emitName; this.metaAccessProvider = metaAccessProvider; + this.emitInfopoint = emitInfopoint; } @Override @@ -181,8 +183,12 @@ masm.emitMov(Kind.Int, codeBufferOffsetReg, Constant.forInt(codeBufferPos)); masm.emitJumpToLabelName(masm.getDeoptLabelName()); - // now record the debuginfo - crb.recordInfopoint(codeBufferPos, frameState, InfopointReason.IMPLICIT_EXCEPTION); + // Now record the debuginfo. If HSAIL deoptimization is off, + // no debuginfo is emitted and the kernel will return without + // a deoptimization. + if (emitInfopoint) { + crb.recordInfopoint(codeBufferPos, frameState, InfopointReason.IMPLICIT_EXCEPTION); + } } public LIRFrameState getFrameState() { diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/PiNode.java Thu May 22 18:10:04 2014 +0200 @@ -93,6 +93,10 @@ @Override public Node canonical(CanonicalizerTool tool) { + if (stamp() == StampFactory.forNodeIntrinsic()) { + /* The actual stamp has not been set yet. */ + return this; + } inferStamp(); if (stamp().equals(object().stamp())) { return object(); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java Thu May 22 18:10:04 2014 +0200 @@ -50,7 +50,6 @@ public LoadHubNode(ValueNode object, Kind kind, ValueNode guard) { super(getKind(kind), (GuardingNode) guard); assert object != guard; - assert guard != null; this.object = object; } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/CheckCastNode.java Thu May 22 18:10:04 2014 +0200 @@ -39,7 +39,7 @@ /** * Implements a type check against a compile-time known type. */ -public final class CheckCastNode extends FixedWithNextNode implements Canonicalizable, Lowerable, Virtualizable, ValueProxy { +public class CheckCastNode extends FixedWithNextNode implements Canonicalizable, Lowerable, Virtualizable, ValueProxy { @Input private ValueNode object; private final ResolvedJavaType type; diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/InstanceOfNode.java Thu May 22 18:10:04 2014 +0200 @@ -34,7 +34,7 @@ /** * The {@code InstanceOfNode} represents an instanceof test. */ -public final class InstanceOfNode extends UnaryOpLogicNode implements Canonicalizable, Lowerable, Virtualizable { +public class InstanceOfNode extends UnaryOpLogicNode implements Canonicalizable, Lowerable, Virtualizable { private final ResolvedJavaType type; private JavaTypeProfile profile; diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/java/MethodCallTargetNode.java Thu May 22 18:10:04 2014 +0200 @@ -137,12 +137,10 @@ return this; } - assert targetMethod.getDeclaringClass().asExactType() == null : "should have been handled by canBeStaticallyBound"; - // check if the type of the receiver can narrow the result ValueNode receiver = receiver(); ResolvedJavaType type = StampTool.typeOrNull(receiver); - if (type != null) { + if (type != null && (invoke().stateAfter() != null || invoke().stateDuring() != null)) { // either the holder class is exact, or the receiver object has an exact type ResolvedJavaMethod resolvedMethod = type.resolveMethod(targetMethod, invoke().getContextType()); if (resolvedMethod != null && (resolvedMethod.canBeStaticallyBound() || StampTool.isExactType(receiver))) { diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/ConditionalEliminationPhase.java Thu May 22 18:10:04 2014 +0200 @@ -710,7 +710,9 @@ if (nonNull) { replacementAnchor = searchAnchor(GraphUtil.unproxify(object), type); } - replacementAnchor = BeginNode.prevBegin(checkCast); + if (replacementAnchor == null) { + replacementAnchor = BeginNode.prevBegin(checkCast); + } PiNode piNode; if (isNull) { ConstantNode nullObject = ConstantNode.defaultForKind(Kind.Object, graph); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/FixedNodeProbabilityCache.java Thu May 22 18:10:04 2014 +0200 @@ -42,10 +42,14 @@ private final Map cache = newIdentityMap(); public double applyAsDouble(FixedNode node) { + assert node != null; metricComputeNodeProbability.increment(); FixedNode current = node; while (true) { + if (current == null) { + return 1D; + } Node predecessor = current.predecessor(); if (current instanceof BeginNode) { if (predecessor == null) { @@ -54,6 +58,9 @@ assert predecessor instanceof ControlSplitNode : "a FixedNode with multiple successors needs to be a ControlSplitNode: " + current + " / " + predecessor; break; } + } else if (predecessor == null) { + // this should only appear for dead code + return 1D; } current = (FixedNode) predecessor; } @@ -70,10 +77,8 @@ if (current instanceof LoopBeginNode) { probability *= ((LoopBeginNode) current).loopFrequency(); } - } else if (current instanceof StartNode) { - probability = 1D; } else { - // this should only appear for dead code + assert current instanceof StartNode; probability = 1D; } } else { diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu May 22 18:10:04 2014 +0200 @@ -223,7 +223,7 @@ private boolean check(String name, boolean constParam, boolean varargsParam) { assert nextParamIdx < info.getParameterCount() : "too many parameters: " + name + " " + this; - assert info.names[nextParamIdx].equals(name) : "wrong parameter name: " + name + " " + this; + assert info.names[nextParamIdx] == null || info.names[nextParamIdx].equals(name) : "wrong parameter name: " + name + " " + this; assert constParam == info.isConstantParameter(nextParamIdx) : "Parameter " + (constParam ? "not " : "") + "annotated with @" + ConstantParameter.class.getSimpleName() + ": " + name + " " + this; assert varargsParam == info.isVarargsParameter(nextParamIdx) : "Parameter " + (varargsParam ? "not " : "") + "annotated with @" + VarargsParameter.class.getSimpleName() + ": " + name + diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomizedUnsafeLoadFinalNode.java Thu May 22 18:10:04 2014 +0200 @@ -57,7 +57,7 @@ @Override public Node canonical(CanonicalizerTool tool) { - if (object.isConstant() && !object.isNullConstant() && offset.isConstant()) { + if (object.isConstant() && !object.isNullConstant() && offset.isConstant() && condition.isConstant() && condition.asConstant().asInt() == 1) { Constant constant = tool.getConstantReflection().readUnsafeConstant(accessKind, object.asConstant(), offset.asConstant().asLong()); return ConstantNode.forConstant(constant, tool.getMetaAccess(), graph()); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.word/src/com/oracle/graal/word/BarrieredAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/BarrieredAccess.java Thu May 22 18:10:04 2014 +0200 @@ -0,0 +1,937 @@ +/* + * Copyright (c) 2014, 2014, 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.word; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.nodes.extended.*; +import com.oracle.graal.word.Word.Opcode; +import com.oracle.graal.word.Word.Operation; + +/** + * Medium-level memory access for Objects. Similarly to the readXxx and writeXxx methods defined for + * {@link Pointer} and {@link ObjectAccess}, these methods access the memory without any null + * checks. However, these methods use read- or write barriers. When the VM uses compressed pointers, + * then readObject and writeObject methods access compressed pointers. + */ +public class BarrieredAccess { + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native byte readByte(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native char readChar(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native short readShort(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native int readInt(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native long readLong(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native float readFloat(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native double readDouble(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Word readWord(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Object readObject(Object object, WordBase offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native byte readByte(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native char readChar(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native short readShort(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native int readInt(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native long readLong(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native float readFloat(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native double readDouble(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Word readWord(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the read (see {@link LocationNode}) + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Object readObject(Object object, int offset, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeByte(Object object, WordBase offset, byte val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeChar(Object object, WordBase offset, char val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeShort(Object object, WordBase offset, short val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeInt(Object object, WordBase offset, int val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeLong(Object object, WordBase offset, long val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeFloat(Object object, WordBase offset, float val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeDouble(Object object, WordBase offset, double val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeWord(Object object, WordBase offset, WordBase val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeObject(Object object, WordBase offset, Object val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeByte(Object object, int offset, byte val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeChar(Object object, int offset, char val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeShort(Object object, int offset, short val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeInt(Object object, int offset, int val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeLong(Object object, int offset, long val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeFloat(Object object, int offset, float val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeDouble(Object object, int offset, double val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeWord(Object object, int offset, WordBase val, LocationIdentity locationIdentity); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param locationIdentity the identity of the write (see {@link LocationNode}) + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeObject(Object object, int offset, Object val, LocationIdentity locationIdentity); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native byte readByte(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native char readChar(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native short readShort(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native int readInt(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native long readLong(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native float readFloat(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native double readDouble(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Word readWord(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Object readObject(Object object, WordBase offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native byte readByte(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native char readChar(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native short readShort(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native int readInt(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native long readLong(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native float readFloat(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native double readDouble(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Word readWord(Object object, int offset); + + /** + * Reads the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @return the result of the memory access + */ + @Operation(opcode = Opcode.READ_BARRIERED) + public static native Object readObject(Object object, int offset); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeByte(Object object, WordBase offset, byte val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeChar(Object object, WordBase offset, char val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeShort(Object object, WordBase offset, short val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeInt(Object object, WordBase offset, int val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeLong(Object object, WordBase offset, long val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeFloat(Object object, WordBase offset, float val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeDouble(Object object, WordBase offset, double val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeWord(Object object, WordBase offset, WordBase val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + *

+ * The offset is always treated as a {@link Signed} value. However, the static type is + * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller + * knows that the highest-order bit of the unsigned value is never used). + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeObject(Object object, WordBase offset, Object val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeByte(Object object, int offset, byte val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeChar(Object object, int offset, char val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeShort(Object object, int offset, short val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeInt(Object object, int offset, int val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeLong(Object object, int offset, long val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeFloat(Object object, int offset, float val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeDouble(Object object, int offset, double val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeWord(Object object, int offset, WordBase val); + + /** + * Writes the memory at address {@code (object + offset)}. The offset is in bytes. + * + * @param object the base object for the memory access + * @param offset the signed offset for the memory access + * @param val the value to be written to memory + */ + @Operation(opcode = Opcode.WRITE_BARRIERED) + public static native void writeObject(Object object, int offset, Object val); +} diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.word/src/com/oracle/graal/word/ObjectAccess.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/ObjectAccess.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/ObjectAccess.java Thu May 22 18:10:04 2014 +0200 @@ -30,7 +30,8 @@ /** * Low-level memory access for Objects. Similarly to the readXxx and writeXxx methods defined for * {@link Pointer}, these methods access the raw memory without any null checks, read- or write - * barriers. + * barriers. When the VM uses compressed pointers, then readObject and writeObject methods access + * compressed pointers. */ public final class ObjectAccess { @@ -40,13 +41,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native byte readByte(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -55,13 +56,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native char readChar(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -70,13 +71,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native short readShort(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -85,13 +86,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native int readInt(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -100,13 +101,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native long readLong(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -115,13 +116,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native float readFloat(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -130,13 +131,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native double readDouble(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -145,13 +146,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Word readWord(Object object, WordBase offset, LocationIdentity locationIdentity); /** @@ -160,112 +161,112 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Object readObject(Object object, WordBase offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native byte readByte(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native char readChar(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native short readShort(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native int readInt(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native long readLong(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native float readFloat(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native double readDouble(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Word readWord(Object object, int offset, LocationIdentity locationIdentity); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Object readObject(Object object, int offset, LocationIdentity locationIdentity); /** @@ -274,13 +275,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeByte(Object object, WordBase offset, byte val, LocationIdentity locationIdentity); /** @@ -289,13 +290,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeChar(Object object, WordBase offset, char val, LocationIdentity locationIdentity); /** @@ -304,13 +305,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeShort(Object object, WordBase offset, short val, LocationIdentity locationIdentity); /** @@ -319,13 +320,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeInt(Object object, WordBase offset, int val, LocationIdentity locationIdentity); /** @@ -334,13 +335,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeLong(Object object, WordBase offset, long val, LocationIdentity locationIdentity); /** @@ -349,13 +350,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeFloat(Object object, WordBase offset, float val, LocationIdentity locationIdentity); /** @@ -364,13 +365,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeDouble(Object object, WordBase offset, double val, LocationIdentity locationIdentity); /** @@ -379,13 +380,13 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeWord(Object object, WordBase offset, WordBase val, LocationIdentity locationIdentity); /** @@ -394,112 +395,112 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeObject(Object object, WordBase offset, Object val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeByte(Object object, int offset, byte val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeChar(Object object, int offset, char val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeShort(Object object, int offset, short val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeInt(Object object, int offset, int val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeLong(Object object, int offset, long val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeFloat(Object object, int offset, float val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeDouble(Object object, int offset, double val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeWord(Object object, int offset, WordBase val, LocationIdentity locationIdentity); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeObject(Object object, int offset, Object val, LocationIdentity locationIdentity); /** @@ -508,12 +509,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native byte readByte(Object object, WordBase offset); /** @@ -522,12 +523,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native char readChar(Object object, WordBase offset); /** @@ -536,12 +537,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native short readShort(Object object, WordBase offset); /** @@ -550,12 +551,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native int readInt(Object object, WordBase offset); /** @@ -564,12 +565,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native long readLong(Object object, WordBase offset); /** @@ -578,12 +579,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native float readFloat(Object object, WordBase offset); /** @@ -592,12 +593,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native double readDouble(Object object, WordBase offset); /** @@ -606,12 +607,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Word readWord(Object object, WordBase offset); /** @@ -620,102 +621,102 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Object readObject(Object object, WordBase offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native byte readByte(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native char readChar(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native short readShort(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native int readInt(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native long readLong(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native float readFloat(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native double readDouble(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Word readWord(Object object, int offset); /** * Reads the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @return the result of the memory access */ - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_OBJECT) public static native Object readObject(Object object, int offset); /** @@ -724,12 +725,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeByte(Object object, WordBase offset, byte val); /** @@ -738,12 +739,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeChar(Object object, WordBase offset, char val); /** @@ -752,12 +753,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeShort(Object object, WordBase offset, short val); /** @@ -766,12 +767,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeInt(Object object, WordBase offset, int val); /** @@ -780,12 +781,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeLong(Object object, WordBase offset, long val); /** @@ -794,12 +795,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeFloat(Object object, WordBase offset, float val); /** @@ -808,12 +809,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeDouble(Object object, WordBase offset, double val); /** @@ -822,12 +823,12 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeWord(Object object, WordBase offset, WordBase val); /** @@ -836,101 +837,101 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeObject(Object object, WordBase offset, Object val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeByte(Object object, int offset, byte val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeChar(Object object, int offset, char val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeShort(Object object, int offset, short val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeInt(Object object, int offset, int val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeLong(Object object, int offset, long val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeFloat(Object object, int offset, float val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeDouble(Object object, int offset, double val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeWord(Object object, int offset, WordBase val); /** * Writes the memory at address {@code (object + offset)}. The offset is in bytes. - * + * * @param object the base object for the memory access * @param offset the signed offset for the memory access * @param val the value to be written to memory */ - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_OBJECT) public static native void writeObject(Object object, int offset, Object val); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Pointer.java Thu May 22 18:10:04 2014 +0200 @@ -26,13 +26,22 @@ import com.oracle.graal.nodes.HeapAccess.BarrierType; import com.oracle.graal.nodes.extended.*; +/** + * Lowest-level memory access of native C memory. These methods access the raw memory without any + * null checks, read- or write barriers. Even when the VM uses compressed pointers, then readObject + * and writeObject methods access uncompressed pointers. + *

+ * Do not use these methods to access Java objects, i.e., do not use + * {@code Word.fromObject(obj).readXxx()}. Instead, use {@link ObjectAccess} or + * {@link BarrieredAccess} to access Java objects. + */ public interface Pointer extends Unsigned, PointerBase { /** * Unsafe conversion of this Pointer to a Java language object. No correctness checks or type * checks are performed. The caller must ensure that the Pointer contains a valid Java object * that can i.e., processed by the garbage collector. - * + * * @return this Pointer cast to Object. */ Object toObject(); @@ -44,7 +53,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -58,7 +67,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -72,7 +81,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -86,7 +95,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -100,7 +109,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -114,7 +123,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -128,7 +137,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -142,7 +151,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -156,7 +165,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -166,7 +175,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -176,7 +185,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -186,7 +195,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -196,7 +205,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -206,7 +215,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -216,7 +225,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -226,7 +235,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -236,7 +245,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -246,7 +255,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the read (see {@link LocationNode}) * @return the result of the memory access @@ -260,7 +269,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -274,7 +283,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -288,7 +297,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -302,7 +311,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -316,7 +325,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -330,7 +339,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -344,7 +353,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -358,7 +367,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -372,7 +381,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -386,7 +395,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -396,7 +405,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -406,7 +415,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -416,7 +425,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -426,7 +435,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -436,7 +445,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -446,7 +455,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -456,7 +465,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -466,7 +475,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -476,7 +485,7 @@ /** * Initializes the memory at address {@code (this + offset)}. Both the base address and offset * are in bytes. The memory must be uninitialized or zero prior to this operation. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -486,7 +495,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param locationIdentity the identity of the write (see {@link LocationNode}) * @param val the value to be written to memory @@ -500,7 +509,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -513,7 +522,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -526,7 +535,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -539,7 +548,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -552,7 +561,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -565,7 +574,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -578,7 +587,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -591,7 +600,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -604,7 +613,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -618,7 +627,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param barrierType the type of the read barrier to be added * @return the result of the memory access @@ -628,7 +637,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -637,7 +646,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -646,7 +655,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -655,7 +664,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -664,7 +673,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -673,7 +682,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -682,7 +691,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -691,7 +700,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -700,7 +709,7 @@ /** * Reads the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @return the result of the memory access */ @@ -710,7 +719,7 @@ * Reads the memory at address {@code (this + offset)}. This access will decompress the oop if * the VM uses compressed oops, and it can be parameterized to allow read barriers (G1 referent * field). - * + * * @param offset the signed offset for the memory access * @param barrierType the type of the read barrier to be added * @return the result of the memory access @@ -724,7 +733,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -737,7 +746,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -750,7 +759,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -763,7 +772,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -776,7 +785,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -789,7 +798,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -802,7 +811,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -815,7 +824,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -828,7 +837,7 @@ * The offset is always treated as a {@link Signed} value. However, the static type is * {@link WordBase} to avoid the frequent casts to of {@link Unsigned} values (where the caller * knows that the highest-order bit of the unsigned value is never used). - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -837,7 +846,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -846,7 +855,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -855,7 +864,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -864,7 +873,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -873,7 +882,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -882,7 +891,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -891,7 +900,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -900,7 +909,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ @@ -909,7 +918,7 @@ /** * Writes the memory at address {@code (this + offset)}. Both the base address and offset are in * bytes. - * + * * @param offset the signed offset for the memory access * @param val the value to be written to memory */ diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/Word.java Thu May 22 18:10:04 2014 +0200 @@ -60,9 +60,13 @@ NODE_CLASS, COMPARISON, NOT, - READ, + READ_POINTER, + READ_OBJECT, + READ_BARRIERED, READ_HEAP, - WRITE, + WRITE_POINTER, + WRITE_OBJECT, + WRITE_BARRIERED, INITIALIZE, ZERO, FROM_UNSIGNED, @@ -91,7 +95,7 @@ /** * The constant 0, i.e., the word with no bits set. There is no difference between a signed and * unsigned zero. - * + * * @return the constant 0. */ @Operation(opcode = Opcode.ZERO) @@ -102,7 +106,7 @@ /** * Unsafe conversion from a Java long value to a Word. The parameter is treated as an unsigned * 64-bit value (in contrast to the semantics of a Java long). - * + * * @param val a 64 bit unsigned value * @return the value cast to Word */ @@ -114,7 +118,7 @@ /** * Unsafe conversion from a Java long value to a {@link PointerBase pointer}. The parameter is * treated as an unsigned 64-bit value (in contrast to the semantics of a Java long). - * + * * @param val a 64 bit unsigned value * @return the value cast to PointerBase */ @@ -127,7 +131,7 @@ /** * Unsafe conversion from a Java int value to a Word. The parameter is treated as an unsigned * 32-bit value (in contrast to the semantics of a Java int). - * + * * @param val a 32 bit unsigned value * @return the value cast to Word */ @@ -139,7 +143,7 @@ /** * Unsafe conversion from a Java long value to a Word. The parameter is treated as a signed * 64-bit value (unchanged semantics of a Java long). - * + * * @param val a 64 bit signed value * @return the value cast to Word */ @@ -151,7 +155,7 @@ /** * Unsafe conversion from a Java int value to a Word. The parameter is treated as a signed * 32-bit value (unchanged semantics of a Java int). - * + * * @param val a 32 bit signed value * @return the value cast to Word */ @@ -634,155 +638,155 @@ } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public byte readByte(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getByte(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public char readChar(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getChar(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public short readShort(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getShort(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public int readInt(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getInt(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public long readLong(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getLong(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public float readFloat(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getFloat(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public double readDouble(WordBase offset, LocationIdentity locationIdentity) { return unsafe.getDouble(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public Word readWord(WordBase offset, LocationIdentity locationIdentity) { return box(unsafe.getAddress(add((Word) offset).unbox())); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public native Object readObject(WordBase offset, LocationIdentity locationIdentity); @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public byte readByte(int offset, LocationIdentity locationIdentity) { return readByte(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public char readChar(int offset, LocationIdentity locationIdentity) { return readChar(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public short readShort(int offset, LocationIdentity locationIdentity) { return readShort(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public int readInt(int offset, LocationIdentity locationIdentity) { return readInt(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public long readLong(int offset, LocationIdentity locationIdentity) { return readLong(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public float readFloat(int offset, LocationIdentity locationIdentity) { return readFloat(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public double readDouble(int offset, LocationIdentity locationIdentity) { return readDouble(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public Word readWord(int offset, LocationIdentity locationIdentity) { return readWord(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public Object readObject(int offset, LocationIdentity locationIdentity) { return readObject(signed(offset), locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(WordBase offset, byte val, LocationIdentity locationIdentity) { unsafe.putByte(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(WordBase offset, char val, LocationIdentity locationIdentity) { unsafe.putChar(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(WordBase offset, short val, LocationIdentity locationIdentity) { unsafe.putShort(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(WordBase offset, int val, LocationIdentity locationIdentity) { unsafe.putInt(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(WordBase offset, long val, LocationIdentity locationIdentity) { unsafe.putLong(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(WordBase offset, float val, LocationIdentity locationIdentity) { unsafe.putFloat(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(WordBase offset, double val, LocationIdentity locationIdentity) { unsafe.putDouble(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(WordBase offset, WordBase val, LocationIdentity locationIdentity) { unsafe.putAddress(add((Word) offset).unbox(), ((Word) val).unbox()); } @@ -794,53 +798,53 @@ } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public native void writeObject(WordBase offset, Object val, LocationIdentity locationIdentity); @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(int offset, byte val, LocationIdentity locationIdentity) { writeByte(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(int offset, char val, LocationIdentity locationIdentity) { writeChar(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(int offset, short val, LocationIdentity locationIdentity) { writeShort(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(int offset, int val, LocationIdentity locationIdentity) { writeInt(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(int offset, long val, LocationIdentity locationIdentity) { writeLong(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(int offset, float val, LocationIdentity locationIdentity) { writeFloat(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(int offset, double val, LocationIdentity locationIdentity) { writeDouble(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(int offset, WordBase val, LocationIdentity locationIdentity) { writeWord(signed(offset), val, locationIdentity); } @@ -852,116 +856,116 @@ } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeObject(int offset, Object val, LocationIdentity locationIdentity) { writeObject(signed(offset), val, locationIdentity); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public byte readByte(WordBase offset) { return unsafe.getByte(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public char readChar(WordBase offset) { return unsafe.getChar(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public short readShort(WordBase offset) { return unsafe.getShort(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public int readInt(WordBase offset) { return unsafe.getInt(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public long readLong(WordBase offset) { return unsafe.getLong(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public float readFloat(WordBase offset) { return unsafe.getFloat(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public double readDouble(WordBase offset) { return unsafe.getDouble(add((Word) offset).unbox()); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public Word readWord(WordBase offset) { return box(unsafe.getAddress(add((Word) offset).unbox())); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public native Object readObject(WordBase offset); @Operation(opcode = Opcode.READ_HEAP) public native Object readObject(WordBase offset, BarrierType barrierType); @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public byte readByte(int offset) { return readByte(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public char readChar(int offset) { return readChar(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public short readShort(int offset) { return readShort(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public int readInt(int offset) { return readInt(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public long readLong(int offset) { return readLong(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public float readFloat(int offset) { return readFloat(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public double readDouble(int offset) { return readDouble(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public Word readWord(int offset) { return readWord(signed(offset)); } @Override - @Operation(opcode = Opcode.READ) + @Operation(opcode = Opcode.READ_POINTER) public Object readObject(int offset) { return readObject(signed(offset)); } @@ -972,107 +976,107 @@ } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(WordBase offset, byte val) { unsafe.putByte(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(WordBase offset, char val) { unsafe.putChar(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(WordBase offset, short val) { unsafe.putShort(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(WordBase offset, int val) { unsafe.putInt(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(WordBase offset, long val) { unsafe.putLong(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(WordBase offset, float val) { unsafe.putFloat(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(WordBase offset, double val) { unsafe.putDouble(add((Word) offset).unbox(), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(WordBase offset, WordBase val) { unsafe.putAddress(add((Word) offset).unbox(), ((Word) val).unbox()); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public native void writeObject(WordBase offset, Object val); @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeByte(int offset, byte val) { writeByte(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeChar(int offset, char val) { writeChar(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeShort(int offset, short val) { writeShort(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeInt(int offset, int val) { writeInt(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeLong(int offset, long val) { writeLong(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeFloat(int offset, float val) { writeFloat(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeDouble(int offset, double val) { writeDouble(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeWord(int offset, WordBase val) { writeWord(signed(offset), val); } @Override - @Operation(opcode = Opcode.WRITE) + @Operation(opcode = Opcode.WRITE_POINTER) public void writeObject(int offset, Object val) { writeObject(signed(offset), val); } diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java --- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java Thu May 22 18:10:04 2014 +0200 @@ -57,6 +57,7 @@ protected final ResolvedJavaType wordBaseType; protected final ResolvedJavaType wordImplType; protected final ResolvedJavaType objectAccessType; + protected final ResolvedJavaType barrieredAccessType; protected final Kind wordKind; public WordTypeRewriterPhase(MetaAccessProvider metaAccess, SnippetReflectionProvider snippetReflection, Kind wordKind) { @@ -66,6 +67,7 @@ this.wordBaseType = metaAccess.lookupJavaType(WordBase.class); this.wordImplType = metaAccess.lookupJavaType(Word.class); this.objectAccessType = metaAccess.lookupJavaType(ObjectAccess.class); + this.barrieredAccessType = metaAccess.lookupJavaType(BarrieredAccess.class); } @Override @@ -170,10 +172,13 @@ */ protected void rewriteInvoke(StructuredGraph graph, MethodCallTargetNode callTargetNode) { ResolvedJavaMethod targetMethod = callTargetNode.targetMethod(); - if (!wordBaseType.isAssignableFrom(targetMethod.getDeclaringClass()) && !objectAccessType.equals(targetMethod.getDeclaringClass())) { + final boolean isWordBase = wordBaseType.isAssignableFrom(targetMethod.getDeclaringClass()); + final boolean isObjectAccess = objectAccessType.equals(targetMethod.getDeclaringClass()); + final boolean isBarrieredAccess = barrieredAccessType.equals(targetMethod.getDeclaringClass()); + if (!isWordBase && !isObjectAccess && !isBarrieredAccess) { /* * Not a method defined on WordBase or a subclass / subinterface, and not on - * ObjectAccess, so nothing to rewrite. + * ObjectAccess and not on BarrieredAccess, so nothing to rewrite. */ return; } @@ -211,7 +216,9 @@ replace(invoke, graph.unique(new XorNode(StampFactory.forKind(wordKind), arguments.get(0), ConstantNode.forIntegerKind(wordKind, -1, graph)))); break; - case READ: { + case READ_POINTER: + case READ_OBJECT: + case READ_BARRIERED: { assert arguments.size() == 2 || arguments.size() == 3; Kind readKind = asKind(callTargetNode.returnType()); LocationNode location; @@ -220,7 +227,7 @@ } else { location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2)); } - replace(invoke, readOp(graph, arguments.get(0), invoke, location, BarrierType.NONE, false)); + replace(invoke, readOp(graph, arguments.get(0), invoke, location, operation.opcode())); break; } case READ_HEAP: { @@ -231,7 +238,9 @@ replace(invoke, readOp(graph, arguments.get(0), invoke, location, barrierType, true)); break; } - case WRITE: + case WRITE_POINTER: + case WRITE_OBJECT: + case WRITE_BARRIERED: case INITIALIZE: { assert arguments.size() == 3 || arguments.size() == 4; Kind writeKind = asKind(targetMethod.getSignature().getParameterType(targetMethod.isStatic() ? 2 : 1, targetMethod.getDeclaringClass())); @@ -375,6 +384,14 @@ return IndexedLocationNode.create(locationIdentity, readKind, 0, fromSigned(graph, offset), graph, 1); } + protected ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location, Opcode op) { + assert op == Opcode.READ_POINTER || op == Opcode.READ_OBJECT || op == Opcode.READ_BARRIERED; + final BarrierType barrier = (op == Opcode.READ_BARRIERED ? BarrierType.PRECISE : BarrierType.NONE); + final boolean compressible = (op == Opcode.READ_OBJECT || op == Opcode.READ_BARRIERED); + + return readOp(graph, base, invoke, location, barrier, compressible); + } + protected ValueNode readOp(StructuredGraph graph, ValueNode base, Invoke invoke, LocationNode location, BarrierType barrierType, boolean compressible) { JavaReadNode read = graph.add(new JavaReadNode(base, location, barrierType, compressible)); graph.addBeforeFixed(invoke.asNode(), read); @@ -387,8 +404,11 @@ } protected ValueNode writeOp(StructuredGraph graph, ValueNode base, ValueNode value, Invoke invoke, LocationNode location, Opcode op) { - assert op == Opcode.WRITE || op == Opcode.INITIALIZE; - JavaWriteNode write = graph.add(new JavaWriteNode(base, value, location, BarrierType.NONE, false, op == Opcode.INITIALIZE)); + assert op == Opcode.WRITE_POINTER || op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED || op == Opcode.INITIALIZE; + final BarrierType barrier = (op == Opcode.WRITE_BARRIERED ? BarrierType.PRECISE : BarrierType.NONE); + final boolean compressible = (op == Opcode.WRITE_OBJECT || op == Opcode.WRITE_BARRIERED); + final boolean initialize = (op == Opcode.INITIALIZE); + JavaWriteNode write = graph.add(new JavaWriteNode(base, value, location, barrier, compressible, initialize)); write.setStateAfter(invoke.stateAfter()); graph.addBeforeFixed(invoke.asNode(), write); return write; diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java Thu May 22 18:10:04 2014 +0200 @@ -154,23 +154,6 @@ public abstract String getLanguageShortName(); /** - * Add instrumentation to subsequently constructed Truffle ASTs for the guest language; every - * one added will have the opportunity to add instrumentation. - * - * @throws IllegalStateException if AST instrumentation not enabled - * @throws IllegalArgumentException if prober not usable for the guest language implementation. - */ - public abstract void addNodeProber(ASTNodeProber nodeProber) throws IllegalStateException, IllegalArgumentException; - - /** - * Assigns a guest language-specific manager for using {@link ASTNodeProber}s added by tools to - * instrument ASTs with {@link Probe}s at specified nodes. This must be assigned outside the - * implementation context to avoid build circularities. It must also be set before any - * instrumentation probe implementations are assigned. - */ - public abstract void setASTProber(ASTProber astProber); - - /** * Establishes source event reporting */ protected abstract void setSourceCallback(SourceCallback sourceCallback); diff -r a6eeb3750238 -r e751da27fd48 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Wed May 21 11:45:50 2014 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Thu May 22 18:10:04 2014 +0200 @@ -47,6 +47,8 @@ public interface FieldOffsetProvider { long objectFieldOffset(Field field); + + int getTypeSize(Class clazz); } private static final FieldOffsetProvider unsafeFieldOffsetProvider = new FieldOffsetProvider() { @@ -55,6 +57,17 @@ public long objectFieldOffset(Field field) { return unsafe.objectFieldOffset(field); } + + @Override + public int getTypeSize(Class clazz) { + if (!clazz.isPrimitive()) { + return Unsafe.ARRAY_OBJECT_INDEX_SCALE; + } else if (clazz == int.class) { + return Unsafe.ARRAY_INT_INDEX_SCALE; + } else { + throw new UnsupportedOperationException("unsupported field type: " + clazz); + } + } }; public static enum NodeFieldKind { diff -r a6eeb3750238 -r e751da27fd48 mx/mx_graal.py --- a/mx/mx_graal.py Wed May 21 11:45:50 2014 +0200 +++ b/mx/mx_graal.py Thu May 22 18:10:04 2014 +0200 @@ -690,7 +690,7 @@ mustBuild = False timestamp = os.path.getmtime(timestampFile) sources = [] - for d in ['src', 'make', 'graal/com.oracle.graal.hotspot/src_gen/hotspot']: + for d in ['src', 'make', join('graal', 'com.oracle.graal.hotspot', 'src_gen', 'hotspot')]: for root, dirnames, files in os.walk(join(_graal_home, d)): # ignore /src/share/tools if root == join(_graal_home, 'src', 'share'): @@ -1542,7 +1542,7 @@ if not mx.library(name, fatalIfMissing=False): mx.log('Skipping ' + groupId + '.' + artifactId + '.jar as ' + name + ' cannot be resolved') return - d = mx.Distribution(graalSuite, name=artifactId, path=path, sourcesPath=path, deps=deps, excludedDependencies=[], distDependencies=[]) + d = mx.Distribution(graalSuite, name=artifactId, path=path, sourcesPath=path, deps=deps, mainClass=None, excludedDependencies=[], distDependencies=[]) d.make_archive() cmd = ['mvn', 'install:install-file', '-DgroupId=' + groupId, '-DartifactId=' + artifactId, '-Dversion=1.0-SNAPSHOT', '-Dpackaging=jar', '-Dfile=' + d.path] @@ -2093,37 +2093,3 @@ _vm_prefix = opts.vm_prefix mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) - -def packagejar(classpath, outputFile, mainClass=None, annotationProcessor=None, stripDebug=False): - prefix = '' if mx.get_os() != 'windows' else '\\??\\' # long file name hack - print "creating", outputFile - filecount, totalsize = 0, 0 - with zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED) as zf: - manifest = "Manifest-Version: 1.0\n" - if mainClass != None: - manifest += "Main-Class: %s\n\n" % (mainClass) - zf.writestr("META-INF/MANIFEST.MF", manifest) - if annotationProcessor != None: - zf.writestr("META-INF/services/javax.annotation.processing.Processor", annotationProcessor) - for cp in classpath: - print "+", cp - if cp.endswith(".jar"): - with zipfile.ZipFile(cp, 'r') as jar: - for arcname in jar.namelist(): - if arcname.endswith('/') or arcname == 'META-INF/MANIFEST.MF' or arcname.endswith('.java') or arcname.lower().startswith("license") or arcname in [".project", ".classpath"]: - continue - zf.writestr(arcname, jar.read(arcname)) - else: - for root, _, files in os.walk(cp): - for f in files: - fullname = os.path.join(root, f) - arcname = fullname[len(cp) + 1:].replace('\\', '/') - if f.endswith(".class"): - zf.write(prefix + fullname, arcname) - - for zi in zf.infolist(): - filecount += 1 - totalsize += zi.file_size - print "%d files (total size: %.2f kB, jar size: %.2f kB)" % (filecount, totalsize / 1e3, os.path.getsize(outputFile) / 1e3) - mx.run([mx.exe_suffix(join(mx.java().jdk, 'bin', 'pack200')), '-r'] + (['-G'] if stripDebug else []) + [outputFile]) - print "repacked jar size: %.2f kB" % (os.path.getsize(outputFile) / 1e3) diff -r a6eeb3750238 -r e751da27fd48 mxtool/mx.py --- a/mxtool/mx.py Wed May 21 11:45:50 2014 +0200 +++ b/mxtool/mx.py Thu May 22 18:10:04 2014 +0200 @@ -34,6 +34,7 @@ """ import sys, os, errno, time, subprocess, shlex, types, urllib2, contextlib, StringIO, zipfile, signal, xml.sax.saxutils, tempfile, fnmatch +import multiprocessing import textwrap import socket import tarfile @@ -63,7 +64,7 @@ A distribution is a jar or zip file containing the output from one or more Java projects. """ class Distribution: - def __init__(self, suite, name, path, sourcesPath, deps, excludedDependencies, distDependencies): + def __init__(self, suite, name, path, sourcesPath, deps, mainClass, excludedDependencies, distDependencies): self.suite = suite self.name = name self.path = path.replace('/', os.sep) @@ -71,6 +72,7 @@ self.sourcesPath = _make_absolute(sourcesPath.replace('/', os.sep), suite.dir) if sourcesPath else None self.deps = deps self.update_listeners = set() + self.mainClass = mainClass self.excludedDependencies = excludedDependencies self.distDependencies = distDependencies @@ -98,9 +100,17 @@ if not hasattr(zf, '_provenance'): zf._provenance = {} existingSource = zf._provenance.get(arcname, None) - if existingSource and existingSource != source and not arcname.endswith('/'): - log('warning: ' + self.path + ': overwriting ' + arcname + '\n new: ' + source + '\n old: ' + existingSource) + isOverwrite = False + if existingSource and existingSource != source: + log('warning: ' + self.path + ': avoid overwrite of ' + arcname + '\n new: ' + source + '\n old: ' + existingSource) + isOverwrite = True zf._provenance[arcname] = source + return isOverwrite + + if self.mainClass: + manifest = "Manifest-Version: 1.0\nMain-Class: %s\n\n" % (self.mainClass) + if not overwriteCheck(arc.zf, "META-INF/MANIFEST.MF", "project files"): + arc.zf.writestr("META-INF/MANIFEST.MF", manifest) for dep in self.sorted_deps(includeLibs=True): if dep.isLibrary(): @@ -117,13 +127,13 @@ assert '/' not in service services.setdefault(service, []).extend(lp.read(arcname).splitlines()) else: - overwriteCheck(arc.zf, arcname, lpath + '!' + arcname) - arc.zf.writestr(arcname, lp.read(arcname)) + if not overwriteCheck(arc.zf, arcname, lpath + '!' + arcname): + arc.zf.writestr(arcname, lp.read(arcname)) if srcArc.zf and libSourcePath: with zipfile.ZipFile(libSourcePath, 'r') as lp: for arcname in lp.namelist(): - overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname) - srcArc.zf.writestr(arcname, lp.read(arcname)) + if not overwriteCheck(srcArc.zf, arcname, lpath + '!' + arcname): + srcArc.zf.writestr(arcname, lp.read(arcname)) elif dep.isProject(): p = dep @@ -157,8 +167,8 @@ else: for f in files: arcname = join(relpath, f).replace(os.sep, '/') - overwriteCheck(arc.zf, arcname, join(root, f)) - arc.zf.write(join(root, f), arcname) + if not overwriteCheck(arc.zf, arcname, join(root, f)): + arc.zf.write(join(root, f), arcname) if srcArc.zf: sourceDirs = p.source_dirs() if p.source_gen_dir(): @@ -169,8 +179,8 @@ for f in files: if f.endswith('.java'): arcname = join(relpath, f).replace(os.sep, '/') - overwriteCheck(srcArc.zf, arcname, join(root, f)) - srcArc.zf.write(join(root, f), arcname) + if not overwriteCheck(srcArc.zf, arcname, join(root, f)): + srcArc.zf.write(join(root, f), arcname) for service, providers in services.iteritems(): arcname = 'META-INF/services/' + service @@ -822,9 +832,10 @@ path = attrs.pop('path') sourcesPath = attrs.pop('sourcesPath', None) deps = pop_list(attrs, 'dependencies') + mainClass = attrs.pop('mainClass', None) exclDeps = pop_list(attrs, 'exclude') distDeps = pop_list(attrs, 'distDependencies') - d = Distribution(self, name, path, sourcesPath, deps, exclDeps, distDeps) + d = Distribution(self, name, path, sourcesPath, deps, mainClass, exclDeps, distDeps) d.__dict__.update(attrs) self.dists.append(d) @@ -1834,14 +1845,22 @@ if _opts.killwithsigquit: _send_sigquit() + def is_alive(p): + if isinstance(p, subprocess.Popen): + return p.poll() is None + assert isinstance(p, multiprocessing.Process), p + return p.is_alive() + for p, args in _currentSubprocesses: - try: - if get_os() == 'windows': - p.terminate() - else: - _kill_process_group(p.pid, signal.SIGKILL) - except BaseException as e: - log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) + if is_alive(p): + try: + if get_os() == 'windows': + p.terminate() + else: + _kill_process_group(p.pid, signal.SIGKILL) + except BaseException as e: + if is_alive(p): + log('error while killing subprocess {} "{}": {}'.format(p.pid, ' '.join(args), e)) if _opts and _opts.verbose: import traceback @@ -2285,7 +2304,6 @@ t._d = None return sorted(tasks, compareTasks) - import multiprocessing cpus = multiprocessing.cpu_count() worklist = sortWorklist(tasks.values()) active = [] @@ -2625,6 +2643,10 @@ # Atomic on Unix shutil.move(self.tmpPath, self.path) +def _archive(args): + archive(args) + return 0 + def archive(args): """create jar files for projects and distributions""" parser = ArgumentParser(prog='mx archive') @@ -2642,6 +2664,7 @@ p = project(name) archives.append(p.make_archive()) + logv("generated archives: " + str(archives)) return archives def canonicalizeprojects(args): @@ -4694,7 +4717,7 @@ 'ideclean': [ideclean, ''], 'ideinit': [ideinit, ''], 'intellijinit': [intellijinit, ''], - 'archive': [archive, '[options]'], + 'archive': [_archive, '[options]'], 'projectgraph': [projectgraph, ''], 'pylint': [pylint, ''], 'javap': [javap, ''], diff -r a6eeb3750238 -r e751da27fd48 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Wed May 21 11:45:50 2014 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Thu May 22 18:10:04 2014 +0200 @@ -89,12 +89,12 @@ VMStructs::initHotSpotVMConfig(JNIHandles::resolve(config)); C2V_END -C2V_VMENTRY(jbyteArray, initializeBytecode, (JNIEnv *, jobject, jlong metaspace_method)) +C2V_VMENTRY(jbyteArray, getBytecode, (JNIEnv *, jobject, jlong metaspace_method)) methodHandle method = asMethod(metaspace_method); ResourceMark rm; int code_size = method->code_size(); - jbyte* reconstituted_code = NEW_RESOURCE_ARRAY(jbyte, code_size); + typeArrayOop reconstituted_code = oopFactory::new_byteArray(code_size, CHECK_NULL); guarantee(method->method_holder()->is_rewritten(), "Method's holder should be rewritten"); // iterate over all bytecodes and replace non-Java bytecodes @@ -106,9 +106,9 @@ int len = s.instruction_size(); // Restore original byte code. - reconstituted_code[bci] = (jbyte) (s.is_wide()? Bytecodes::_wide : code); + reconstituted_code->byte_at_put(bci, (jbyte) (s.is_wide()? Bytecodes::_wide : code)); if (len > 1) { - memcpy(&reconstituted_code[bci+1], s.bcp()+1, len-1); + memcpy(reconstituted_code->byte_at_addr(bci + 1), s.bcp()+1, len-1); } if (len > 1) { @@ -124,41 +124,39 @@ case Bytecodes::_invokestatic: case Bytecodes::_invokeinterface: case Bytecodes::_invokehandle: { - int cp_index = Bytes::get_native_u2((address) &reconstituted_code[bci + 1]); - Bytes::put_Java_u2((address) &reconstituted_code[bci + 1], (u2) cp_index); + int cp_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); + Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); break; } case Bytecodes::_invokedynamic: - int cp_index = Bytes::get_native_u4((address) &reconstituted_code[bci + 1]); - Bytes::put_Java_u4((address) &reconstituted_code[bci + 1], (u4) cp_index); + int cp_index = Bytes::get_native_u4((address) reconstituted_code->byte_at_addr(bci + 1)); + Bytes::put_Java_u4((address) reconstituted_code->byte_at_addr(bci + 1), (u4) cp_index); break; } // Not all ldc byte code are rewritten. switch (raw_code) { case Bytecodes::_fast_aldc: { - int cpc_index = reconstituted_code[bci + 1] & 0xff; + int cpc_index = reconstituted_code->byte_at(bci + 1) & 0xff; int cp_index = method->constants()->object_to_cp_index(cpc_index); assert(cp_index < method->constants()->length(), "sanity check"); - reconstituted_code[bci + 1] = (jbyte) cp_index; + reconstituted_code->byte_at_put(bci + 1, (jbyte) cp_index); break; } case Bytecodes::_fast_aldc_w: { - int cpc_index = Bytes::get_native_u2((address) &reconstituted_code[bci + 1]); + int cpc_index = Bytes::get_native_u2((address) reconstituted_code->byte_at_addr(bci + 1)); int cp_index = method->constants()->object_to_cp_index(cpc_index); assert(cp_index < method->constants()->length(), "sanity check"); - Bytes::put_Java_u2((address) &reconstituted_code[bci + 1], (u2) cp_index); + Bytes::put_Java_u2((address) reconstituted_code->byte_at_addr(bci + 1), (u2) cp_index); break; } } } } - typeArrayOop result_array = oopFactory::new_byteArray(code_size, CHECK_NULL); - memcpy(result_array->byte_at_addr(0), reconstituted_code, code_size); - return (jbyteArray) JNIHandles::make_local(result_array); + return (jbyteArray) JNIHandles::make_local(reconstituted_code); C2V_END C2V_VMENTRY(jint, exceptionTableLength, (JNIEnv *, jobject, jlong metaspace_method)) @@ -1004,7 +1002,7 @@ #define METASPACE_SYMBOL "J" JNINativeMethod CompilerToVM_methods[] = { - {CC"initializeBytecode", CC"("METASPACE_METHOD")[B", FN_PTR(initializeBytecode)}, + {CC"getBytecode", CC"("METASPACE_METHOD")[B", FN_PTR(getBytecode)}, {CC"exceptionTableStart", CC"("METASPACE_METHOD")J", FN_PTR(exceptionTableStart)}, {CC"exceptionTableLength", CC"("METASPACE_METHOD")I", FN_PTR(exceptionTableLength)}, {CC"hasBalancedMonitors", CC"("METASPACE_METHOD")Z", FN_PTR(hasBalancedMonitors)},