# HG changeset patch # User Christian Humer # Date 1366911898 -7200 # Node ID 2e12f1719a42365f9b86f24b1f71e39086bd0f04 # Parent e6251a86e8e354ed0bd18d2378644a1e7b80a9ad# Parent 21bb567c444eceb07b967d683993babef32066dd Merge. diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AllocatableValue.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/AllocatableValue.java Thu Apr 25 11:02:50 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.api.code; - -import com.oracle.graal.api.meta.*; - -/** - * Common base class for values that can be manipulated by the register allocator. - */ -public abstract class AllocatableValue extends Value { - - private static final long serialVersionUID = 153019506717492133L; - - /** - * Marker to tell the register allocator that no storage location needs to be allocated for this - * value. - */ - @SuppressWarnings("serial") public static final AllocatableValue UNUSED = new AllocatableValue(Kind.Illegal) { - - @Override - public String toString() { - return "-"; - } - }; - - public AllocatableValue(Kind kind) { - super(kind); - } - -} diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CallingConvention.java Thu Apr 25 19:44:58 2013 +0200 @@ -76,17 +76,17 @@ */ private final int stackSize; - private final Value returnLocation; + private final AllocatableValue returnLocation; /** * The ordered locations in which the arguments are placed. */ - private final Value[] argumentLocations; + private final AllocatableValue[] argumentLocations; /** * The locations used (and killed) by the call in addition to the arguments. */ - private final Value[] temporaryLocations; + private final AllocatableValue[] temporaryLocations; /** * Creates a description of the registers and stack locations used by a call. @@ -97,8 +97,8 @@ * call * @param argumentLocations the ordered locations in which the arguments are placed */ - public CallingConvention(int stackSize, Value returnLocation, Value... argumentLocations) { - this(Value.NONE, stackSize, returnLocation, argumentLocations); + public CallingConvention(int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) { + this(AllocatableValue.NONE, stackSize, returnLocation, argumentLocations); } /** @@ -112,7 +112,7 @@ * call * @param argumentLocations the ordered locations in which the arguments are placed */ - public CallingConvention(Value[] temporaryLocations, int stackSize, Value returnLocation, Value... argumentLocations) { + public CallingConvention(AllocatableValue[] temporaryLocations, int stackSize, AllocatableValue returnLocation, AllocatableValue... argumentLocations) { assert argumentLocations != null; assert temporaryLocations != null; assert returnLocation != null; @@ -126,14 +126,14 @@ /** * Gets the location for the return value or {@link Value#ILLEGAL} if a void call. */ - public Value getReturn() { + public AllocatableValue getReturn() { return returnLocation; } /** * Gets the location for the {@code index}'th argument. */ - public Value getArgument(int index) { + public AllocatableValue getArgument(int index) { return argumentLocations[index]; } @@ -155,7 +155,7 @@ * Gets the locations used (and killed) by the call apart from the * {@linkplain #getArgument(int) arguments}. */ - public Value[] getTemporaries() { + public AllocatableValue[] getTemporaries() { if (temporaryLocations.length == 0) { return temporaryLocations; } diff -r e6251a86e8e3 -r 2e12f1719a42 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 Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CompilationResult.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.api.code; +import static java.util.Collections.*; + import java.io.*; import java.util.*; @@ -366,7 +368,7 @@ */ public void recordDataReference(int codePos, Constant data, int alignment, boolean inlined) { assert codePos >= 0 && data != null; - getDataReferences().add(new DataPatch(codePos, data, alignment, inlined)); + dataReferences.add(new DataPatch(codePos, data, alignment, inlined)); } /** @@ -390,7 +392,7 @@ * @param handlerPos the position of the handler */ public void recordExceptionHandler(int codePos, int handlerPos) { - getExceptionHandlers().add(new ExceptionHandler(codePos, handlerPos)); + exceptionHandlers.add(new ExceptionHandler(codePos, handlerPos)); } /** @@ -405,11 +407,11 @@ private void addInfopoint(Infopoint infopoint) { // The infopoints list must always be sorted - if (!getInfopoints().isEmpty() && getInfopoints().get(getInfopoints().size() - 1).pcOffset >= infopoint.pcOffset) { + if (!infopoints.isEmpty() && infopoints.get(infopoints.size() - 1).pcOffset >= infopoint.pcOffset) { // This re-sorting should be very rare - Collections.sort(getInfopoints()); + Collections.sort(infopoints); } - getInfopoints().add(infopoint); + infopoints.add(infopoint); } /** @@ -421,7 +423,7 @@ */ public Mark recordMark(int codePos, Object id, Mark[] references) { Mark mark = new Mark(codePos, id, references); - getMarks().add(mark); + marks.add(mark); return mark; } @@ -528,27 +530,39 @@ * @return the list of infopoints, sorted by {@link Site#pcOffset} */ public List getInfopoints() { - return infopoints; + if (infopoints.isEmpty()) { + return emptyList(); + } + return unmodifiableList(infopoints); } /** * @return the list of data references */ public List getDataReferences() { - return dataReferences; + if (dataReferences.isEmpty()) { + return emptyList(); + } + return unmodifiableList(dataReferences); } /** * @return the list of exception handlers */ public List getExceptionHandlers() { - return exceptionHandlers; + if (exceptionHandlers.isEmpty()) { + return emptyList(); + } + return unmodifiableList(exceptionHandlers); } /** * @return the list of marks */ public List getMarks() { - return marks; + if (marks.isEmpty()) { + return emptyList(); + } + return unmodifiableList(marks); } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/AllocatableValue.java Thu Apr 25 19:44:58 2013 +0200 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.api.meta; + +/** + * Common base class for values that are stored in some location that's managed by the register + * allocator (e.g. register, stack slot). + */ +public abstract class AllocatableValue extends Value { + + private static final long serialVersionUID = 153019506717492133L; + + public static final AllocatableValue[] NONE = {}; + + public AllocatableValue(Kind kind) { + super(kind); + } + +} diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Value.java Thu Apr 25 19:44:58 2013 +0200 @@ -32,9 +32,7 @@ private static final long serialVersionUID = -6909397188697766469L; - public static final Value[] NONE = {}; - - @SuppressWarnings("serial") public static final Value ILLEGAL = new Value(Kind.Illegal) { + @SuppressWarnings("serial") public static final AllocatableValue ILLEGAL = new AllocatableValue(Kind.Illegal) { @Override public String toString() { diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java Thu Apr 25 19:44:58 2013 +0200 @@ -90,7 +90,7 @@ public static class AMD64SpillMoveFactory implements LIR.SpillMoveFactory { @Override - public LIRInstruction createMove(Value result, Value input) { + public LIRInstruction createMove(AllocatableValue result, Value input) { return AMD64LIRGenerator.createMove(result, input); } } @@ -143,8 +143,10 @@ return result; } - private static AMD64LIRInstruction createMove(Value dst, Value src) { - if (isRegister(src) || isStackSlot(dst)) { + private static AMD64LIRInstruction createMove(AllocatableValue dst, Value src) { + if (src instanceof AMD64AddressValue) { + return new LeaOp(dst, (AMD64AddressValue) src); + } else if (isRegister(src) || isStackSlot(dst)) { return new MoveFromRegOp(dst, src); } else { return new MoveToRegOp(dst, src); @@ -152,24 +154,23 @@ } @Override - public void emitMove(Value dst, Value src) { + public void emitMove(AllocatableValue dst, Value src) { append(createMove(dst, src)); } - private AMD64AddressValue prepareAddress(Kind kind, Value base, long displacement, Value index, int scale) { + @Override + public AMD64AddressValue emitAddress(Value base, long displacement, Value index, int scale) { AllocatableValue baseRegister; long finalDisp = displacement; if (isConstant(base)) { if (asConstant(base).isNull()) { - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else if (asConstant(base).getKind() != Kind.Object && !runtime.needsDataPatch(asConstant(base))) { finalDisp += asConstant(base).asLong(); - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else { baseRegister = load(base); } - } else if (base == Value.ILLEGAL) { - baseRegister = AllocatableValue.UNUSED; } else { baseRegister = asAllocatable(base); } @@ -180,12 +181,12 @@ scaleEnum = Scale.fromInt(scale); if (isConstant(index)) { finalDisp += asConstant(index).asLong() * scale; - indexRegister = AllocatableValue.UNUSED; + indexRegister = Value.ILLEGAL; } else { indexRegister = asAllocatable(index); } } else { - indexRegister = AllocatableValue.UNUSED; + indexRegister = Value.ILLEGAL; scaleEnum = Scale.Times1; } @@ -195,9 +196,9 @@ } else { displacementInt = 0; AllocatableValue displacementRegister = load(Constant.forLong(finalDisp)); - if (baseRegister == AllocatableValue.UNUSED) { + if (baseRegister == Value.ILLEGAL) { baseRegister = displacementRegister; - } else if (indexRegister == AllocatableValue.UNUSED) { + } else if (indexRegister == Value.ILLEGAL) { indexRegister = displacementRegister; scaleEnum = Scale.Times1; } else { @@ -205,44 +206,44 @@ } } - return new AMD64AddressValue(kind, baseRegister, indexRegister, scaleEnum, displacementInt); + return new AMD64AddressValue(target().wordKind, baseRegister, indexRegister, scaleEnum, displacementInt); + } + + private AMD64AddressValue asAddress(Value address) { + if (address instanceof AMD64AddressValue) { + return (AMD64AddressValue) address; + } else { + return emitAddress(address, 0, Value.ILLEGAL, 0); + } } @Override - public Variable emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting) { - AMD64AddressValue loadAddress = prepareAddress(kind, base, displacement, index, scale); - Variable result = newVariable(loadAddress.getKind()); - append(new LoadOp(result, loadAddress, deopting != null ? state(deopting) : null)); + public Variable emitLoad(Kind kind, Value address, DeoptimizingNode deopting) { + AMD64AddressValue loadAddress = asAddress(address); + Variable result = newVariable(kind); + append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null)); return result; } @Override - public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value inputVal, DeoptimizingNode deopting) { - AMD64AddressValue storeAddress = prepareAddress(kind, base, displacement, index, scale); + public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode deopting) { + AMD64AddressValue storeAddress = asAddress(address); LIRFrameState state = deopting != null ? state(deopting) : null; if (isConstant(inputVal)) { Constant c = asConstant(inputVal); if (canStoreConstant(c)) { - append(new StoreConstantOp(storeAddress, c, state)); + append(new StoreConstantOp(kind, storeAddress, c, state)); return; } } Variable input = load(inputVal); - append(new StoreOp(storeAddress, input, state)); + append(new StoreOp(kind, storeAddress, input, state)); } @Override - public Variable emitLea(Value base, long displacement, Value index, int scale) { - Variable result = newVariable(target().wordKind); - AMD64AddressValue address = prepareAddress(result.getKind(), base, displacement, index, scale); - append(new LeaOp(result, address)); - return result; - } - - @Override - public Variable emitLea(StackSlot address) { + public Variable emitAddress(StackSlot address) { Variable result = newVariable(target().wordKind); append(new StackLeaOp(result, address)); return result; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java --- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,23 +22,19 @@ */ package com.oracle.graal.compiler.ptx.test; -import com.oracle.graal.api.code.CodeCacheProvider; -import com.oracle.graal.api.code.CompilationResult; -import com.oracle.graal.api.code.SpeculationLog; -import com.oracle.graal.api.code.TargetDescription; -import com.oracle.graal.api.runtime.Graal; -import com.oracle.graal.compiler.GraalCompiler; -import com.oracle.graal.compiler.ptx.PTXBackend; -import com.oracle.graal.compiler.test.GraalCompilerTest; -import com.oracle.graal.debug.Debug; -import com.oracle.graal.java.GraphBuilderConfiguration; -import com.oracle.graal.java.GraphBuilderPhase; -import com.oracle.graal.hotspot.HotSpotGraalRuntime; -import com.oracle.graal.nodes.StructuredGraph; -import com.oracle.graal.phases.OptimisticOptimizations; -import com.oracle.graal.phases.PhasePlan; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.ptx.*; +import com.oracle.graal.compiler.test.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.java.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.phases.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; -import com.oracle.graal.ptx.PTX; +import com.oracle.graal.ptx.*; public abstract class PTXTestBase extends GraalCompilerTest { @@ -48,14 +44,12 @@ TargetDescription target = new TargetDescription(new PTX(), true, 1, 0, true); PTXBackend ptxBackend = new PTXBackend(Graal.getRequiredCapability(CodeCacheProvider.class), target); PhasePlan phasePlan = new PhasePlan(); - GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), - OptimisticOptimizations.NONE); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.NONE); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); phasePlan.addPhase(PhasePosition.AFTER_PARSING, new PTXPhase()); new PTXPhase().apply(graph); - CompilationResult result = GraalCompiler.compileMethod(runtime, HotSpotGraalRuntime.getInstance().getReplacements(), - ptxBackend, target, graph.method(), graph, null, phasePlan, - OptimisticOptimizations.NONE, new SpeculationLog()); + CompilationResult result = GraalCompiler.compileMethod(runtime, graalRuntime().getReplacements(), ptxBackend, target, graph.method(), graph, null, phasePlan, OptimisticOptimizations.NONE, + new SpeculationLog()); return result; } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Thu Apr 25 19:44:58 2013 +0200 @@ -28,17 +28,13 @@ import static com.oracle.graal.lir.ptx.PTXBitManipulationOp.IntrinsicOpcode.*; import static com.oracle.graal.lir.ptx.PTXCompare.*; -import com.oracle.graal.api.code.AllocatableValue; import com.oracle.graal.api.code.CodeCacheProvider; import com.oracle.graal.api.code.DeoptimizationAction; import com.oracle.graal.api.code.RuntimeCallTarget; import com.oracle.graal.api.code.StackSlot; import com.oracle.graal.api.code.TargetDescription; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; -import com.oracle.graal.api.meta.Constant; -import com.oracle.graal.api.meta.Kind; -import com.oracle.graal.api.meta.ResolvedJavaMethod; -import com.oracle.graal.api.meta.Value; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.NumUtil; import com.oracle.graal.compiler.gen.LIRGenerator; import com.oracle.graal.compiler.target.LIRGenLowerable; @@ -84,7 +80,7 @@ public static class PTXSpillMoveFactory implements LIR.SpillMoveFactory { @Override - public LIRInstruction createMove(Value result, Value input) { + public LIRInstruction createMove(AllocatableValue result, Value input) { throw new InternalError("NYI"); } } @@ -129,7 +125,7 @@ } @Override - public void emitMove(Value dst, Value src) { + public void emitMove(AllocatableValue dst, Value src) { if (isRegister(src) || isStackSlot(dst)) { append(new MoveFromRegOp(dst, src)); } else { @@ -137,20 +133,19 @@ } } - private PTXAddressValue prepareAddress(Kind kind, Value base, long displacement, Value index, int scale) { + @Override + public PTXAddressValue emitAddress(Value base, long displacement, Value index, int scale) { AllocatableValue baseRegister; long finalDisp = displacement; if (isConstant(base)) { if (asConstant(base).isNull()) { - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else if (asConstant(base).getKind() != Kind.Object) { finalDisp += asConstant(base).asLong(); - baseRegister = AllocatableValue.UNUSED; + baseRegister = Value.ILLEGAL; } else { baseRegister = load(base); } - } else if (base == Value.ILLEGAL) { - baseRegister = AllocatableValue.UNUSED; } else { baseRegister = asAllocatable(base); } @@ -166,7 +161,7 @@ indexRegister = index; } - if (baseRegister == AllocatableValue.UNUSED) { + if (baseRegister == Value.ILLEGAL) { baseRegister = asAllocatable(indexRegister); } else { Variable newBase = newVariable(Kind.Int); @@ -177,31 +172,34 @@ } } - return new PTXAddressValue(kind, baseRegister, finalDisp); + return new PTXAddressValue(target().wordKind, baseRegister, finalDisp); + } + + private PTXAddressValue asAddress(Value address) { + if (address instanceof PTXAddressValue) { + return (PTXAddressValue) address; + } else { + return emitAddress(address, 0, Value.ILLEGAL, 0); + } } @Override - public Variable emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting) { - PTXAddressValue loadAddress = prepareAddress(kind, base, displacement, index, scale); - Variable result = newVariable(loadAddress.getKind()); - append(new LoadOp(result, loadAddress, deopting != null ? state(deopting) : null)); + public Variable emitLoad(Kind kind, Value address, DeoptimizingNode deopting) { + PTXAddressValue loadAddress = asAddress(address); + Variable result = newVariable(kind); + append(new LoadOp(kind, result, loadAddress, deopting != null ? state(deopting) : null)); return result; } @Override - public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value inputVal, DeoptimizingNode deopting) { - PTXAddressValue storeAddress = prepareAddress(kind, base, displacement, index, scale); + public void emitStore(Kind kind, Value address, Value inputVal, DeoptimizingNode deopting) { + PTXAddressValue storeAddress = asAddress(address); Variable input = load(inputVal); - append(new StoreOp(storeAddress, input, deopting != null ? state(deopting) : null)); + append(new StoreOp(kind, storeAddress, input, deopting != null ? state(deopting) : null)); } @Override - public Variable emitLea(Value base, long displacement, Value index, int scale) { - throw new InternalError("NYI"); - } - - @Override - public Variable emitLea(StackSlot address) { + public Variable emitAddress(StackSlot address) { throw new InternalError("NYI"); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java --- a/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler.sparc/src/com/oracle/graal/compiler/sparc/SPARCLIRGenerator.java Thu Apr 25 19:44:58 2013 +0200 @@ -208,31 +208,31 @@ } @Override - public void emitMove(Value dst, Value src) { + public void emitMove(AllocatableValue dst, Value src) { // SPARC: Auto-generated method stub } @Override - public Value emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode canTrap) { + public Value emitAddress(Value base, long displacement, Value index, int scale) { // SPARC: Auto-generated method stub return null; } @Override - public void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value input, DeoptimizingNode canTrap) { + public Value emitLoad(Kind kind, Value address, DeoptimizingNode canTrap) { + // SPARC: Auto-generated method stub + return null; + } + + @Override + public void emitStore(Kind kind, Value address, Value input, DeoptimizingNode canTrap) { // SPARC: Auto-generated method stub } @Override - public Value emitLea(Value base, long displacement, Value index, int scale) { - // SPARC: Auto-generated method stub - return null; - } - - @Override - public Value emitLea(StackSlot address) { + public Value emitAddress(StackSlot address) { // SPARC: Auto-generated method stub return null; } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/Interval.java Thu Apr 25 19:44:58 2013 +0200 @@ -409,7 +409,7 @@ * The {@linkplain RegisterValue register} or {@linkplain Variable variable} for this interval * prior to register allocation. */ - public final Value operand; + public final AllocatableValue operand; /** * The operand number for this interval's {@linkplain #operand operand}. @@ -420,7 +420,7 @@ * The {@linkplain RegisterValue register} or {@linkplain StackSlot spill slot} assigned to this * interval. */ - private Value location; + private AllocatableValue location; /** * The stack slot to which all splits of this interval are spilled if necessary. @@ -498,7 +498,7 @@ */ private Interval locationHint; - void assignLocation(Value newLocation) { + void assignLocation(AllocatableValue newLocation) { if (isRegister(newLocation)) { assert this.location == null : "cannot re-assign location for " + this; if (newLocation.getKind() == Kind.Illegal && kind != Kind.Illegal) { @@ -518,7 +518,7 @@ * Gets the {@linkplain RegisterValue register} or {@linkplain StackSlot spill slot} assigned to * this interval. */ - public Value location() { + public AllocatableValue location() { return location; } @@ -673,7 +673,7 @@ */ static final Interval EndMarker = new Interval(Value.ILLEGAL, -1); - Interval(Value operand, int operandNumber) { + Interval(AllocatableValue operand, int operandNumber) { assert operand != null; this.operand = operand; this.operandNumber = operandNumber; diff -r e6251a86e8e3 -r 2e12f1719a42 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 Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/LinearScan.java Thu Apr 25 19:44:58 2013 +0200 @@ -206,7 +206,7 @@ /** * Gets the operand denoted by a given operand number. */ - private Value operandFor(int operandNumber) { + private AllocatableValue operandFor(int operandNumber) { if (operandNumber < firstVariableNumber) { assert operandNumber >= 0; return registers[operandNumber].asValue(); @@ -281,7 +281,7 @@ * @param operand the operand for the interval * @return the created interval */ - Interval createInterval(Value operand) { + Interval createInterval(AllocatableValue operand) { assert isLegal(operand); int operandNumber = operandNumber(operand); Interval interval = new Interval(operand, operandNumber); @@ -346,7 +346,7 @@ return intervals[operandNumber]; } - Interval getOrCreateInterval(Value operand) { + Interval getOrCreateInterval(AllocatableValue operand) { Interval ret = intervalFor(operand); if (ret == null) { return createInterval(operand); @@ -555,8 +555,8 @@ insertionBuffer.init(instructions); } - Value fromLocation = interval.location(); - Value toLocation = canonicalSpillOpr(interval); + AllocatableValue fromLocation = interval.location(); + AllocatableValue toLocation = canonicalSpillOpr(interval); assert isRegister(fromLocation) : "from operand must be a register but is: " + fromLocation + " toLocation=" + toLocation + " spillState=" + interval.spillState(); assert isStackSlot(toLocation) : "to operand must be a stack slot"; @@ -968,7 +968,7 @@ TTY.println(blockData.get(block).liveOut.toString()); } - void addUse(Value operand, int from, int to, RegisterPriority registerPriority, Kind kind) { + void addUse(AllocatableValue operand, int from, int to, RegisterPriority registerPriority, Kind kind) { if (!isProcessed(operand)) { return; } @@ -987,7 +987,7 @@ interval.addUsePos(to & ~1, registerPriority); } - void addTemp(Value operand, int tempPos, RegisterPriority registerPriority, Kind kind) { + void addTemp(AllocatableValue operand, int tempPos, RegisterPriority registerPriority, Kind kind) { if (!isProcessed(operand)) { return; } @@ -1008,7 +1008,7 @@ return !isRegister(operand) || attributes(asRegister(operand)).isAllocatable(); } - void addDef(Value operand, int defPos, RegisterPriority registerPriority, Kind kind) { + void addDef(AllocatableValue operand, int defPos, RegisterPriority registerPriority, Kind kind) { if (!isProcessed(operand)) { return; } @@ -1114,8 +1114,8 @@ @Override protected Value doValue(Value registerHint) { if (isVariableOrRegister(registerHint)) { - Interval from = getOrCreateInterval(registerHint); - Interval to = getOrCreateInterval(targetValue); + Interval from = getOrCreateInterval((AllocatableValue) registerHint); + Interval to = getOrCreateInterval((AllocatableValue) targetValue); // hints always point from def to use if (hintAtDef) { @@ -1156,7 +1156,7 @@ BitSet live = blockData.get(block).liveOut; for (int operandNum = live.nextSetBit(0); operandNum >= 0; operandNum = live.nextSetBit(operandNum + 1)) { assert live.get(operandNum) : "should not stop here otherwise"; - Value operand = operandFor(operandNum); + AllocatableValue operand = operandFor(operandNum); if (GraalOptions.TraceLinearScanLevel >= 2) { TTY.println("live in %s to %d", operand, blockTo + 2); } @@ -1197,7 +1197,7 @@ @Override public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { - addDef(operand, opId, registerPriorityOfOutputOperand(op), operand.getKind().getStackKind()); + addDef((AllocatableValue) operand, opId, registerPriorityOfOutputOperand(op), operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, true); } return operand; @@ -1208,7 +1208,7 @@ @Override public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { - addTemp(operand, opId, RegisterPriority.MustHaveRegister, operand.getKind().getStackKind()); + addTemp((AllocatableValue) operand, opId, RegisterPriority.MustHaveRegister, operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1220,7 +1220,7 @@ public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(flags); - addUse(operand, blockFrom, opId + 1, p, operand.getKind().getStackKind()); + addUse((AllocatableValue) operand, blockFrom, opId + 1, p, operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1232,7 +1232,7 @@ public Value doValue(Value operand, OperandMode mode, EnumSet flags) { if (isVariableOrRegister(operand)) { RegisterPriority p = registerPriorityOfInputOperand(flags); - addUse(operand, blockFrom, opId, p, operand.getKind().getStackKind()); + addUse((AllocatableValue) operand, blockFrom, opId, p, operand.getKind().getStackKind()); addRegisterHint(op, operand, mode, flags, false); } return operand; @@ -1247,7 +1247,7 @@ @Override public Value doValue(Value operand) { - addUse(operand, blockFrom, opId + 1, RegisterPriority.None, operand.getKind().getStackKind()); + addUse((AllocatableValue) operand, blockFrom, opId + 1, RegisterPriority.None, operand.getKind().getStackKind()); return operand; } }); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/alloc/MoveResolver.java Thu Apr 25 19:44:58 2013 +0200 @@ -196,8 +196,8 @@ assert fromInterval.kind() == toInterval.kind() : "move between different types"; assert insertIdx != -1 : "must setup insert position first"; - Value fromOpr = fromInterval.operand; - Value toOpr = toInterval.operand; + AllocatableValue fromOpr = fromInterval.operand; + AllocatableValue toOpr = toInterval.operand; insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); @@ -210,7 +210,7 @@ assert fromOpr.getKind() == toInterval.kind() : "move between different types"; assert insertIdx != -1 : "must setup insert position first"; - Value toOpr = toInterval.operand; + AllocatableValue toOpr = toInterval.operand; insertionBuffer.append(insertIdx, allocator.ir.spillMoveFactory.createMove(toOpr, fromOpr)); if (GraalOptions.TraceLinearScanLevel >= 4) { diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/LIRGenerator.java Thu Apr 25 19:44:58 2013 +0200 @@ -52,7 +52,7 @@ /** * This class traverses the HIR instructions and generates LIR instructions from them. */ -public abstract class LIRGenerator extends LIRGeneratorTool { +public abstract class LIRGenerator implements LIRGeneratorTool { public final FrameMap frameMap; public final NodeMap nodeOperands; @@ -168,8 +168,8 @@ @Override public Value setResult(ValueNode x, Value operand) { - assert (isVariable(operand) && x.kind() == operand.getKind()) || (isRegister(operand) && !attributes(asRegister(operand)).isAllocatable()) || - (isConstant(operand) && x.kind() == operand.getKind().getStackKind()) : operand.getKind() + " for node " + x; + assert (!isVariable(operand) || x.kind() == operand.getKind()) : operand.getKind() + " for node " + x; + assert (!isRegister(operand) || !attributes(asRegister(operand)).isAllocatable()); assert operand(x) == null : "operand cannot be set twice"; assert operand != null && isLegal(operand) : "operand must be legal"; assert operand.getKind().getStackKind() == x.kind() : operand.getKind().getStackKind() + " must match " + x.kind(); @@ -251,7 +251,7 @@ * @return the operand representing the ABI defined location used return a value of kind * {@code kind} */ - public Value resultOperandFor(Kind kind) { + public AllocatableValue resultOperandFor(Kind kind) { if (kind == Kind.Void) { return ILLEGAL; } @@ -461,7 +461,7 @@ @Override public void visitReturn(ReturnNode x) { - Value operand = Value.ILLEGAL; + AllocatableValue operand = ILLEGAL; if (x.result() != null) { operand = resultOperandFor(x.result().kind()); emitMove(operand, operand(x.result())); @@ -630,7 +630,7 @@ protected abstract void emitCall(RuntimeCallTarget callTarget, Value result, Value[] arguments, Value[] temps, LIRFrameState info); - protected static Value toStackKind(Value value) { + protected static AllocatableValue toStackKind(AllocatableValue value) { if (value.getKind().getStackKind() != value.getKind()) { // We only have stack-kinds in the LIR, so convert the operand kind for values from the // calling convention. @@ -651,7 +651,7 @@ int j = 0; for (ValueNode arg : arguments) { if (arg != null) { - Value operand = toStackKind(cc.getArgument(j)); + AllocatableValue operand = toStackKind(cc.getArgument(j)); emitMove(operand, operand(arg)); result[j] = operand; j++; @@ -672,7 +672,7 @@ Value[] argLocations = new Value[args.length]; for (int i = 0; i < args.length; i++) { Value arg = args[i]; - Value loc = cc.getArgument(i); + AllocatableValue loc = cc.getArgument(i); emitMove(loc, arg); argLocations[i] = loc; } @@ -826,6 +826,10 @@ return frameMap; } + @Override + public void beforeRegisterAllocation() { + } + public abstract void emitBitCount(Variable result, Value operand); public abstract void emitBitScanForward(Variable result, Value operand); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/gen/PhiResolver.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,9 +22,9 @@ */ package com.oracle.graal.compiler.gen; +import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.api.meta.Value.*; import static com.oracle.graal.lir.LIRValueUtil.*; -import static com.oracle.graal.api.code.ValueUtil.*; import java.util.*; @@ -187,7 +187,7 @@ private void emitMove(Value dest, Value src) { assert isLegal(src); assert isLegal(dest); - gen.emitMove(dest, src); + gen.emitMove((AllocatableValue) dest, src); } // Traverse assignment graph in depth first order and generate moves in post order diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java --- a/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.graph/src/com/oracle/graal/graph/GraalInternalError.java Thu Apr 25 19:44:58 2013 +0200 @@ -51,6 +51,23 @@ } /** + * Checks a given condition and throws a {@link GraalInternalError} if it is false. Guarantees + * are stronger than assertions in that they are always checked. Error messages for guarantee + * violations should clearly indicate the nature of the problem as well as a suggested solution + * if possible. + * + * @param condition the condition to check + * @param msg the message that will be associated with the error, in + * {@link String#format(String, Object...)} syntax + * @param args arguments to the format string + */ + public static void guarantee(boolean condition, String msg, Object... args) { + if (!condition) { + throw new GraalInternalError("failed guarantee: " + msg, args); + } + } + + /** * This constructor creates a {@link GraalInternalError} with a message assembled via * {@link String#format(String, Object...)}. It always uses the ENGLISH locale in order to * always generate the same output. diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.amd64; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; @@ -49,7 +51,7 @@ @Override public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - HotSpotGraalRuntime runtime = HotSpotGraalRuntime.getInstance(); + HotSpotGraalRuntime runtime = graalRuntime(); Register thread = runtime.getRuntime().threadRegister(); masm.movl(new AMD64Address(thread, runtime.getConfig().pendingDeoptimizationOffset), tasm.runtime.encodeDeoptActionAndReason(action, reason)); AMD64Call.directCall(tasm, masm, tasm.runtime.lookupRuntimeCall(DEOPTIMIZE), null, false, info); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotGraalRuntime.java Thu Apr 25 19:44:58 2013 +0200 @@ -39,10 +39,10 @@ * Called from C++ code to retrieve the singleton instance, creating it first if necessary. */ public static HotSpotGraalRuntime makeInstance() { - if (getInstance() == null) { + if (graalRuntime() == null) { setInstance(new AMD64HotSpotGraalRuntime()); } - return getInstance(); + return graalRuntime(); } @Override diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotLIRGenerator.java Thu Apr 25 19:44:58 2013 +0200 @@ -241,9 +241,9 @@ @Override protected void emitIndirectCall(IndirectCallTargetNode callTarget, Value result, Value[] parameters, Value[] temps, LIRFrameState callState) { - Value metaspaceMethod = AMD64.rbx.asValue(); + AllocatableValue metaspaceMethod = AMD64.rbx.asValue(); emitMove(metaspaceMethod, operand(((HotSpotIndirectCallTargetNode) callTarget).metaspaceMethod())); - Value targetAddress = AMD64.rax.asValue(); + AllocatableValue targetAddress = AMD64.rax.asValue(); emitMove(targetAddress, operand(callTarget.computedAddress())); append(new AMD64IndirectCallOp(callTarget.target(), result, parameters, temps, metaspaceMethod, targetAddress, callState)); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Thu Apr 25 19:44:58 2013 +0200 @@ -143,7 +143,7 @@ } private CallingConvention callingConvention(Register[] generalParameterRegisters, JavaType returnType, JavaType[] parameterTypes, Type type, TargetDescription target, boolean stackOnly) { - Value[] locations = new Value[parameterTypes.length]; + AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; int currentGeneral = 0; int currentXMM = 0; @@ -183,7 +183,7 @@ } Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - Value returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind); + AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : getReturnRegister(returnKind).asValue(returnKind); return new CallingConvention(currentStackOffset, returnLocation, locations); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Thu Apr 25 19:44:58 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.amd64.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.LIRInstruction.Opcode; import com.oracle.graal.lir.amd64.*; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64SafepointOp.java Thu Apr 25 19:44:58 2013 +0200 @@ -27,6 +27,7 @@ import sun.misc.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.*; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotGraalRuntime.java Thu Apr 25 19:44:58 2013 +0200 @@ -38,10 +38,10 @@ * Called from C++ code to retrieve the singleton instance, creating it first if necessary. */ public static HotSpotGraalRuntime makeInstance() { - if (getInstance() == null) { + if (graalRuntime() == null) { setInstance(new SPARCHotSpotGraalRuntime()); } - return getInstance(); + return graalRuntime(); } @Override diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompileTheWorld.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; @@ -50,7 +52,7 @@ public static final String SUN_BOOT_CLASS_PATH = "sun.boot.class.path"; // Some runtime instances we need. - private final HotSpotGraalRuntime graalRuntime = HotSpotGraalRuntime.getInstance(); + private final HotSpotGraalRuntime graalRuntime = graalRuntime(); private final VMToCompilerImpl vmToCompiler = (VMToCompilerImpl) graalRuntime.getVMToCompiler(); /** List of Zip/Jar files to compile (see {@link GraalOptions#CompileTheWorld}. */ diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilerThread.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import java.io.*; import java.util.concurrent.*; @@ -59,7 +61,7 @@ public void run() { GraalDebugConfig hotspotDebugConfig = null; if (GraalOptions.Debug) { - PrintStream log = HotSpotGraalRuntime.getInstance().getVMToCompiler().log(); + PrintStream log = graalRuntime().getVMToCompiler().log(); DebugEnvironment.initialize(log); } try { diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Apr 25 19:44:58 2013 +0200 @@ -47,9 +47,9 @@ private static HotSpotGraalRuntime instance; /** - * Gets the singleton runtime instance object. + * Gets the singleton {@link HotSpotGraalRuntime} object. */ - public static HotSpotGraalRuntime getInstance() { + public static HotSpotGraalRuntime graalRuntime() { return instance; } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotRuntimeCallTarget.java Thu Apr 25 19:44:58 2013 +0200 @@ -91,13 +91,13 @@ assert stub != null : "linkage without an address must be a stub"; InstalledCode code = stub.getCode(backend); - Value[] argumentLocations = new Value[cc.getArgumentCount()]; + AllocatableValue[] argumentLocations = new AllocatableValue[cc.getArgumentCount()]; for (int i = 0; i < argumentLocations.length; i++) { argumentLocations[i] = cc.getArgument(i); } Set definedRegisters = stub.getDefinedRegisters(); - Value[] temporaryLocations = new Value[definedRegisters.size()]; + AllocatableValue[] temporaryLocations = new AllocatableValue[definedRegisters.size()]; int i = 0; for (Register reg : definedRegisters) { temporaryLocations[i++] = reg.asValue(); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Apr 25 19:44:58 2013 +0200 @@ -25,6 +25,7 @@ import static com.oracle.graal.graph.UnsafeAccess.*; import static com.oracle.graal.hotspot.CompilationTask.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import static com.oracle.graal.java.GraphBuilderPhase.*; import static com.oracle.graal.phases.common.InliningUtil.*; @@ -686,7 +687,7 @@ public HotSpotResolvedObjectType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, int sizeOrSpecies) { HotSpotResolvedObjectType type = new HotSpotResolvedObjectType(metaspaceKlass, name, simpleName, javaMirror, sizeOrSpecies); - long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset; + long offset = graalRuntime().getConfig().graalMirrorInClassOffset; if (!unsafe.compareAndSwapObject(javaMirror, offset, null, type)) { // lost the race - return the existing value instead type = (HotSpotResolvedObjectType) unsafe.getObject(javaMirror, offset); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/LocalImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/LocalImpl.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/LocalImpl.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,8 +22,9 @@ */ package com.oracle.graal.hotspot.debug; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; public class LocalImpl implements Local { @@ -39,9 +40,9 @@ this.bciStart = bciStart; this.bciEnd = bciEnd; this.slot = slot; - JavaType t = HotSpotGraalRuntime.getInstance().lookupType(type, holder, true); + JavaType t = graalRuntime().lookupType(type, holder, true); if (t instanceof ResolvedJavaType) { - this.resolvedType = (ResolvedJavaType) HotSpotGraalRuntime.getInstance().lookupType(type, holder, false); + this.resolvedType = (ResolvedJavaType) graalRuntime().lookupType(type, holder, false); } else { throw new AssertionError(t.getClass() + " is not a ResolvedJavaType"); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotConstantPool.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.bytecode.*; import com.oracle.graal.hotspot.*; @@ -41,13 +43,13 @@ @Override public int length() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().constantPoolLength(type); + return graalRuntime().getCompilerToVM().constantPoolLength(type); } @Override public Object lookupConstant(int cpi) { assert cpi != 0; - Object constant = HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupConstantInPool(type, cpi); + Object constant = graalRuntime().getCompilerToVM().lookupConstantInPool(type, cpi); return constant; } @@ -59,26 +61,26 @@ @Override public Object lookupAppendix(int cpi, int opcode) { assert Bytecodes.isInvoke(opcode); - return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupAppendixInPool(type, cpi, (byte) opcode); + return graalRuntime().getCompilerToVM().lookupAppendixInPool(type, cpi, (byte) opcode); } @Override public JavaMethod lookupMethod(int cpi, int opcode) { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupMethodInPool(type, cpi, (byte) opcode); + return graalRuntime().getCompilerToVM().lookupMethodInPool(type, cpi, (byte) opcode); } @Override public JavaType lookupType(int cpi, int opcode) { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupTypeInPool(type, cpi); + return graalRuntime().getCompilerToVM().lookupTypeInPool(type, cpi); } @Override public JavaField lookupField(int cpi, int opcode) { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupFieldInPool(type, cpi, (byte) opcode); + return graalRuntime().getCompilerToVM().lookupFieldInPool(type, cpi, (byte) opcode); } @Override public void loadReferencedType(int cpi, int opcode) { - HotSpotGraalRuntime.getInstance().getCompilerToVM().lookupReferencedTypeInPool(type, cpi, (byte) opcode); + graalRuntime().getCompilerToVM().lookupReferencedTypeInPool(type, cpi, (byte) opcode); } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotInstalledCode.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import java.lang.reflect.*; import com.oracle.graal.api.code.*; @@ -69,12 +71,12 @@ @Override public boolean isValid() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().isInstalledCodeValid(nmethod); + return graalRuntime().getCompilerToVM().isInstalledCodeValid(nmethod); } @Override public void invalidate() { - HotSpotGraalRuntime.getInstance().getCompilerToVM().invalidateInstalledCode(nmethod); + graalRuntime().getCompilerToVM().invalidateInstalledCode(nmethod); } @Override @@ -88,7 +90,7 @@ assert method.getSignature().getParameterKind(0) == Kind.Object; assert method.getSignature().getParameterKind(1) == Kind.Object; assert !Modifier.isStatic(method.getModifiers()) || method.getSignature().getParameterKind(2) == Kind.Object; - return HotSpotGraalRuntime.getInstance().getCompilerToVM().executeCompiledMethod(arg1, arg2, arg3, nmethod); + return graalRuntime().getCompilerToVM().executeCompiledMethod(arg1, arg2, arg3, nmethod); } private boolean checkArgs(Object... args) { @@ -108,7 +110,7 @@ @Override public Object executeVarargs(Object... args) throws InvalidInstalledCodeException { assert checkArgs(args); - return HotSpotGraalRuntime.getInstance().getCompilerToVM().executeCompiledMethodVarargs(args, nmethod); + return graalRuntime().getCompilerToVM().executeCompiledMethodVarargs(args, nmethod); } @Override @@ -118,6 +120,6 @@ @Override public byte[] getCode() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getCode(nmethod); + return graalRuntime().getCompilerToVM().getCode(nmethod); } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotMethodData.java Thu Apr 25 19:44:58 2013 +0200 @@ -40,7 +40,7 @@ private static final long serialVersionUID = -8873133496591225071L; - private static final HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + private static final HotSpotVMConfig config = graalRuntime().getConfig(); private static final HotSpotMethodDataAccessor NO_DATA_NO_EXCEPTION_ACCESSOR = new NoMethodData(TriState.FALSE); private static final HotSpotMethodDataAccessor NO_DATA_EXCEPTION_POSSIBLY_NOT_RECORDED_ACCESSOR = new NoMethodData(TriState.UNKNOWN); @@ -58,7 +58,7 @@ HotSpotMethodData(long metaspaceMethodData) { this.metaspaceMethodData = metaspaceMethodData; - HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeMethodData(metaspaceMethodData, this); + graalRuntime().getCompilerToVM().initializeMethodData(metaspaceMethodData, this); } public boolean hasNormalData() { @@ -78,7 +78,7 @@ } public int getDeoptimizationCount(DeoptimizationReason reason) { - int reasonIndex = HotSpotGraalRuntime.getInstance().getRuntime().convertDeoptReason(reason); + int reasonIndex = graalRuntime().getRuntime().convertDeoptReason(reason); return unsafe.getByte(metaspaceMethodData + config.methodDataOopTrapHistoryOffset + reasonIndex) & 0xFF; } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Thu Apr 25 19:44:58 2013 +0200 @@ -24,6 +24,7 @@ package com.oracle.graal.hotspot.meta; import static com.oracle.graal.api.meta.MetaUtil.*; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import java.lang.annotation.*; import java.lang.reflect.*; @@ -109,12 +110,12 @@ if (receiver == null) { assert Modifier.isStatic(flags); if (holder.isInitialized()) { - return HotSpotGraalRuntime.getInstance().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset); + return graalRuntime().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset); } return null; } else { assert !Modifier.isStatic(flags); - return HotSpotGraalRuntime.getInstance().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset); + return graalRuntime().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset); } } diff -r e6251a86e8e3 -r 2e12f1719a42 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 Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaMethod.java Thu Apr 25 19:44:58 2013 +0200 @@ -66,7 +66,7 @@ HotSpotResolvedJavaMethod(HotSpotResolvedObjectType holder, long metaspaceMethod) { this.metaspaceMethod = metaspaceMethod; this.holder = holder; - HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeMethod(metaspaceMethod, this); + graalRuntime().getCompilerToVM().initializeMethod(metaspaceMethod, this); } @Override @@ -82,12 +82,12 @@ * Gets the address of the C++ Method object for this method. */ public Constant getMetaspaceMethodConstant() { - return Constant.forIntegerKind(HotSpotGraalRuntime.getInstance().getTarget().wordKind, metaspaceMethod, this); + return Constant.forIntegerKind(graalRuntime().getTarget().wordKind, metaspaceMethod, this); } @Override public int getModifiers() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); return unsafe.getInt(metaspaceMethod + config.methodAccessFlagsOffset) & Modifier.methodModifiers(); } @@ -103,7 +103,7 @@ return null; } if (code == null) { - code = HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeBytecode(metaspaceMethod, new byte[codeSize]); + code = graalRuntime().getCompilerToVM().initializeBytecode(metaspaceMethod, new byte[codeSize]); assert code.length == codeSize : "expected: " + codeSize + ", actual: " + code.length; } return code; @@ -123,12 +123,12 @@ for (int i = 0; i < exceptionHandlerCount; i++) { handlers[i] = new ExceptionHandler(-1, -1, -1, -1, null); } - return HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeExceptionHandlers(metaspaceMethod, handlers); + return graalRuntime().getCompilerToVM().initializeExceptionHandlers(metaspaceMethod, handlers); } public boolean hasBalancedMonitors() { if (hasBalancedMonitors == null) { - hasBalancedMonitors = HotSpotGraalRuntime.getInstance().getCompilerToVM().hasBalancedMonitors(metaspaceMethod); + hasBalancedMonitors = graalRuntime().getCompilerToVM().hasBalancedMonitors(metaspaceMethod); } return hasBalancedMonitors; } @@ -145,14 +145,14 @@ @Override public int getMaxLocals() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); long metaspaceConstMethod = unsafe.getLong(metaspaceMethod + config.methodConstMethodOffset); return unsafe.getShort(metaspaceConstMethod + config.methodMaxLocalsOffset) & 0xFFFF; } @Override public int getMaxStackSize() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); long metaspaceConstMethod = unsafe.getLong(metaspaceMethod + config.methodConstMethodOffset); return config.extraStackEntries + (unsafe.getShort(metaspaceConstMethod + config.constMethodMaxStackOffset) & 0xFFFF); } @@ -161,15 +161,15 @@ public StackTraceElement asStackTraceElement(int bci) { if (bci < 0 || bci >= codeSize) { // HotSpot code can only construct stack trace elements for valid bcis - StackTraceElement ste = HotSpotGraalRuntime.getInstance().getCompilerToVM().getStackTraceElement(metaspaceMethod, 0); + StackTraceElement ste = graalRuntime().getCompilerToVM().getStackTraceElement(metaspaceMethod, 0); return new StackTraceElement(ste.getClassName(), ste.getMethodName(), ste.getFileName(), -1); } - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getStackTraceElement(metaspaceMethod, bci); + return graalRuntime().getCompilerToVM().getStackTraceElement(metaspaceMethod, bci); } public ResolvedJavaMethod uniqueConcreteMethod() { HotSpotResolvedObjectType[] resultHolder = {null}; - long ucm = HotSpotGraalRuntime.getInstance().getCompilerToVM().getUniqueConcreteMethod(metaspaceMethod, resultHolder); + long ucm = graalRuntime().getCompilerToVM().getUniqueConcreteMethod(metaspaceMethod, resultHolder); if (ucm != 0L) { assert resultHolder[0] != null; return resultHolder[0].createMethod(ucm); @@ -180,7 +180,7 @@ @Override public HotSpotSignature getSignature() { if (signature == null) { - signature = new HotSpotSignature(HotSpotGraalRuntime.getInstance().getCompilerToVM().getSignature(metaspaceMethod)); + signature = new HotSpotSignature(graalRuntime().getCompilerToVM().getSignature(metaspaceMethod)); } return signature; } @@ -191,11 +191,11 @@ } public int getCompiledCodeSize() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getCompiledCodeSize(metaspaceMethod); + return graalRuntime().getCompilerToVM().getCompiledCodeSize(metaspaceMethod); } public int invocationCount() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getInvocationCount(metaspaceMethod); + return graalRuntime().getCompilerToVM().getInvocationCount(metaspaceMethod); } @Override @@ -219,7 +219,7 @@ ProfilingInfo info; if (GraalOptions.UseProfilingInformation && methodData == null) { - long metaspaceMethodData = unsafeReadWord(metaspaceMethod + HotSpotGraalRuntime.getInstance().getConfig().methodDataOffset); + long metaspaceMethodData = unsafeReadWord(metaspaceMethod + graalRuntime().getConfig().methodDataOffset); if (metaspaceMethodData != 0) { methodData = new HotSpotMethodData(metaspaceMethodData); } @@ -237,7 +237,7 @@ @Override public void reprofile() { - HotSpotGraalRuntime.getInstance().getCompilerToVM().reprofile(metaspaceMethod); + graalRuntime().getCompilerToVM().reprofile(metaspaceMethod); } @Override @@ -311,12 +311,12 @@ @Override public boolean canBeInlined() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().isMethodCompilable(metaspaceMethod); + return graalRuntime().getCompilerToVM().isMethodCompilable(metaspaceMethod); } @Override public LineNumberTable getLineNumberTable() { - long[] values = HotSpotGraalRuntime.getInstance().getCompilerToVM().getLineNumberTable(this); + long[] values = graalRuntime().getCompilerToVM().getLineNumberTable(this); assert values.length % 2 == 0; int[] bci = new int[values.length / 2]; int[] line = new int[values.length / 2]; @@ -331,7 +331,7 @@ @Override public LocalVariableTable getLocalVariableTable() { - Local[] locals = HotSpotGraalRuntime.getInstance().getCompilerToVM().getLocalVariableTable(this); + Local[] locals = graalRuntime().getCompilerToVM().getLocalVariableTable(this); return new LocalVariableTableImpl(locals); } @@ -345,7 +345,7 @@ if (!holder.isInitialized()) { return -1; } - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getVtableEntryOffset(metaspaceMethod); + return graalRuntime().getCompilerToVM().getVtableEntryOffset(metaspaceMethod); } public void setCurrentTask(CompilationTask task) { @@ -364,7 +364,7 @@ } public int intrinsicId() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); return unsafe.getByte(metaspaceMethod + config.methodIntrinsicIdOffset) & 0xff; } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaType.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,8 +22,9 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; public abstract class HotSpotResolvedJavaType extends HotSpotJavaType implements ResolvedJavaType { @@ -37,6 +38,6 @@ @Override public String getSourceFileName() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getFileName(this); + return graalRuntime().getCompilerToVM().getFileName(this); } } diff -r e6251a86e8e3 -r 2e12f1719a42 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 Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedObjectType.java Thu Apr 25 19:44:58 2013 +0200 @@ -98,7 +98,7 @@ */ public static ResolvedJavaType fromMetaspaceKlass(long metaspaceKlass) { assert metaspaceKlass != 0; - Class javaClass = (Class) unsafe.getObject(null, metaspaceKlass + HotSpotGraalRuntime.getInstance().getConfig().classMirrorOffset); + Class javaClass = (Class) unsafe.getObject(null, metaspaceKlass + graalRuntime().getConfig().classMirrorOffset); assert javaClass != null; return fromClass(javaClass); } @@ -110,9 +110,9 @@ */ public static ResolvedJavaType fromClass(Class javaClass) { assert javaClass != null; - ResolvedJavaType type = (ResolvedJavaType) unsafe.getObject(javaClass, (long) HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset); + ResolvedJavaType type = (ResolvedJavaType) unsafe.getObject(javaClass, (long) graalRuntime().getConfig().graalMirrorInClassOffset); if (type == null) { - type = HotSpotGraalRuntime.getInstance().getCompilerToVM().getResolvedType(javaClass); + type = graalRuntime().getCompilerToVM().getResolvedType(javaClass); assert type != null; } return type; @@ -140,7 +140,7 @@ } public int getAccessFlags() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); return unsafe.getInt(metaspaceKlass + config.klassAccessFlagsOffset); } @@ -160,11 +160,11 @@ @Override public ResolvedJavaType findUniqueConcreteSubtype() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); if (isArray()) { return isFinal(getElementalType(this).getModifiers()) ? this : null; } else if (isInterface()) { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getUniqueImplementor(this); + return graalRuntime().getCompilerToVM().getUniqueImplementor(this); } else { HotSpotResolvedObjectType type = this; while (isAbstract(type.getModifiers())) { @@ -258,12 +258,12 @@ @Override public boolean hasFinalizableSubclass() { assert !isArray(); - return HotSpotGraalRuntime.getInstance().getCompilerToVM().hasFinalizableSubclass(this); + return graalRuntime().getCompilerToVM().hasFinalizableSubclass(this); } @Override public boolean hasFinalizer() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); return (getAccessFlags() & config.klassHasFinalizerFlag) != 0; } @@ -280,7 +280,7 @@ @Override public boolean isInitialized() { if (!isInitialized) { - isInitialized = HotSpotGraalRuntime.getInstance().getCompilerToVM().isTypeInitialized(this); + isInitialized = graalRuntime().getCompilerToVM().isTypeInitialized(this); } return isInitialized; } @@ -288,7 +288,7 @@ @Override public void initialize() { if (!isInitialized) { - HotSpotGraalRuntime.getInstance().getCompilerToVM().initializeType(this); + graalRuntime().getCompilerToVM().initializeType(this); } isInitialized = true; } @@ -328,7 +328,7 @@ @Override public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method) { assert method instanceof HotSpotMethod; - return (ResolvedJavaMethod) HotSpotGraalRuntime.getInstance().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).getMethodDescriptor()); + return (ResolvedJavaMethod) graalRuntime().getCompilerToVM().resolveMethod(this, method.getName(), ((HotSpotSignature) method.getSignature()).getMethodDescriptor()); } @Override @@ -411,7 +411,7 @@ if (isArray() || isInterface()) { instanceFields = new HotSpotResolvedJavaField[0]; } else { - HotSpotResolvedJavaField[] myFields = HotSpotGraalRuntime.getInstance().getCompilerToVM().getInstanceFields(this); + HotSpotResolvedJavaField[] myFields = graalRuntime().getCompilerToVM().getInstanceFields(this); Arrays.sort(myFields, new OffsetComparator()); if (javaMirror != Object.class) { HotSpotResolvedJavaField[] superFields = (HotSpotResolvedJavaField[]) getSuperclass().getInstanceFields(true); @@ -447,7 +447,7 @@ @Override public String getSourceFileName() { - return HotSpotGraalRuntime.getInstance().getCompilerToVM().getFileName(this); + return graalRuntime().getCompilerToVM().getFileName(this); } @Override @@ -464,20 +464,20 @@ * Gets the address of the C++ Klass object for this type. */ public Constant klass() { - return Constant.forIntegerKind(HotSpotGraalRuntime.getInstance().getTarget().wordKind, metaspaceKlass, this); + return Constant.forIntegerKind(graalRuntime().getTarget().wordKind, metaspaceKlass, this); } public boolean isPrimaryType() { - return HotSpotGraalRuntime.getInstance().getConfig().secondarySuperCacheOffset != superCheckOffset(); + return graalRuntime().getConfig().secondarySuperCacheOffset != superCheckOffset(); } public int superCheckOffset() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); return unsafe.getInt(metaspaceKlass + config.superCheckOffsetOffset); } public long prototypeMarkWord() { - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); if (isArray()) { return config.arrayPrototypeMarkWord; } else { @@ -523,7 +523,7 @@ Constructor[] constructors = javaMirror.getDeclaredConstructors(); ResolvedJavaMethod[] result = new ResolvedJavaMethod[constructors.length]; for (int i = 0; i < constructors.length; i++) { - result[i] = HotSpotGraalRuntime.getInstance().getRuntime().lookupJavaConstructor(constructors[i]); + result[i] = graalRuntime().getRuntime().lookupJavaConstructor(constructors[i]); assert result[i].isConstructor(); } return result; @@ -534,7 +534,7 @@ Method[] methods = javaMirror.getDeclaredMethods(); ResolvedJavaMethod[] result = new ResolvedJavaMethod[methods.length]; for (int i = 0; i < methods.length; i++) { - result[i] = HotSpotGraalRuntime.getInstance().getRuntime().lookupJavaMethod(methods[i]); + result[i] = graalRuntime().getRuntime().lookupJavaMethod(methods[i]); assert !result[i].isConstructor(); } return result; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Apr 25 19:44:58 2013 +0200 @@ -47,8 +47,8 @@ import com.oracle.graal.api.code.CodeUtil.RefMapFormatter; import com.oracle.graal.api.code.CompilationResult.Call; import com.oracle.graal.api.code.CompilationResult.DataPatch; +import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.CompilationResult.Mark; -import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.Register.RegisterFlag; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; @@ -163,23 +163,23 @@ } } - protected Value ret(Kind kind) { + protected AllocatableValue ret(Kind kind) { if (kind == Kind.Void) { return ILLEGAL; } return globalStubRegConfig.getReturnRegister(kind).asValue(kind); } - protected Value[] javaCallingConvention(Kind... arguments) { + protected AllocatableValue[] javaCallingConvention(Kind... arguments) { return callingConvention(arguments, RuntimeCall); } - protected Value[] nativeCallingConvention(Kind... arguments) { + protected AllocatableValue[] nativeCallingConvention(Kind... arguments) { return callingConvention(arguments, NativeCall); } - private Value[] callingConvention(Kind[] arguments, CallingConvention.Type type) { - Value[] result = new Value[arguments.length]; + private AllocatableValue[] callingConvention(Kind[] arguments, CallingConvention.Type type) { + AllocatableValue[] result = new AllocatableValue[arguments.length]; TargetDescription target = graalRuntime.getTarget(); int currentStackOffset = 0; @@ -285,7 +285,7 @@ * @param ret where the call returns its result * @param args where arguments are passed to the call */ - protected RuntimeCallTarget addStubCall(Descriptor descriptor, Value ret, Value... args) { + protected RuntimeCallTarget addStubCall(Descriptor descriptor, AllocatableValue ret, AllocatableValue... args) { return addRuntimeCall(descriptor, 0L, null, ret, args); } @@ -298,8 +298,8 @@ * @param ret where the call returns its result * @param args where arguments are passed to the call */ - protected RuntimeCallTarget addRuntimeCall(Descriptor descriptor, long address, Register[] tempRegs, Value ret, Value... args) { - Value[] temps = tempRegs == null || tempRegs.length == 0 ? Value.NONE : new Value[tempRegs.length]; + protected RuntimeCallTarget addRuntimeCall(Descriptor descriptor, long address, Register[] tempRegs, AllocatableValue ret, AllocatableValue... args) { + AllocatableValue[] temps = tempRegs == null || tempRegs.length == 0 ? AllocatableValue.NONE : new AllocatableValue[tempRegs.length]; for (int i = 0; i < temps.length; i++) { temps[i] = tempRegs[i].asValue(); } @@ -453,11 +453,11 @@ return "MARK:" + mark.id; } - private static void addExceptionHandlersComment(CompilationResult tm, HexCodeFile hcf) { - if (!tm.getExceptionHandlers().isEmpty()) { + private static void addExceptionHandlersComment(CompilationResult compResult, HexCodeFile hcf) { + if (!compResult.getExceptionHandlers().isEmpty()) { String nl = HexCodeFile.NEW_LINE; StringBuilder buf = new StringBuilder("------ Exception Handlers ------").append(nl); - for (CompilationResult.ExceptionHandler e : tm.getExceptionHandlers()) { + for (CompilationResult.ExceptionHandler e : compResult.getExceptionHandlers()) { buf.append(" ").append(e.pcOffset).append(" -> ").append(e.handlerPos).append(nl); hcf.addComment(e.pcOffset, "[exception -> " + e.handlerPos + "]"); hcf.addComment(e.handlerPos, "[exception handler for " + e.pcOffset + "]"); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSignature.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import java.util.*; import com.oracle.graal.api.meta.*; @@ -118,7 +120,7 @@ } JavaType type = argumentTypes[index]; if (type == null || !(type instanceof ResolvedJavaType)) { - type = HotSpotGraalRuntime.getInstance().lookupType(arguments.get(index), (HotSpotResolvedObjectType) accessingClass, false); + type = graalRuntime().lookupType(arguments.get(index), (HotSpotResolvedObjectType) accessingClass, false); argumentTypes[index] = type; } return type; @@ -137,7 +139,7 @@ @Override public JavaType getReturnType(ResolvedJavaType accessingClass) { if (returnTypeCache == null || !(returnTypeCache instanceof ResolvedJavaType)) { - returnTypeCache = HotSpotGraalRuntime.getInstance().lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); + returnTypeCache = graalRuntime().lookupType(returnType, (HotSpotResolvedObjectType) accessingClass, false); } return returnTypeCache; } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotUnresolvedJavaType.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,8 +22,9 @@ */ package com.oracle.graal.hotspot.meta; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; /** * Implementation of {@link JavaType} for unresolved HotSpot classes. @@ -85,6 +86,6 @@ @Override public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { - return (ResolvedJavaType) HotSpotGraalRuntime.getInstance().lookupType(getName(), (HotSpotResolvedObjectType) accessingClass, true); + return (ResolvedJavaType) graalRuntime().lookupType(getName(), (HotSpotResolvedObjectType) accessingClass, true); } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/BeginLockScopeNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -73,7 +73,7 @@ HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen; StackSlot slot = hsGen.getLockSlot(lockDepth); if (!eliminated) { - Value result = gen.emitLea(slot); + Value result = gen.emitAddress(slot); gen.setResult(this, result); } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentJavaThreadNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -26,7 +26,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -43,7 +42,7 @@ @Override public void generate(LIRGeneratorTool gen) { - Register rawThread = HotSpotGraalRuntime.getInstance().getRuntime().threadRegister(); + Register rawThread = graalRuntime().getRuntime().threadRegister(); gen.setResult(this, rawThread.asValue(this.kind())); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/CurrentLockNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -57,7 +57,7 @@ HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen; StackSlot slot = hsGen.getLockSlot(lockDepth); // The register allocator cannot handle stack -> register moves so we use an LEA here - Value result = gen.emitMove(gen.emitLea(slot)); + Value result = gen.emitMove(gen.emitAddress(slot)); gen.setResult(this, result); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/DimensionsNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -47,7 +47,7 @@ public void generate(LIRGenerator gen) { int size = rank * 4; StackSlot array = gen.frameMap().allocateStackBlock(size, false); - Value result = gen.emitLea(array); + Value result = gen.emitAddress(array); gen.setResult(this, result); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/GetObjectAddressNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -46,7 +46,7 @@ @Override public void generate(LIRGeneratorTool gen) { - Value obj = gen.newVariable(gen.target().wordKind); + AllocatableValue obj = gen.newVariable(gen.target().wordKind); gen.emitMove(obj, gen.operand(object)); gen.setResult(this, obj); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotInstalledCodeExecuteNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotInstalledCodeExecuteNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/HotSpotInstalledCodeExecuteNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,9 +22,10 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.replacements.*; import com.oracle.graal.nodes.*; @@ -86,7 +87,7 @@ StructuredGraph g = (StructuredGraph) graph(); LoadFieldNode loadnmethod = g.add(new LoadFieldNode(code, nmethodField)); - UnsafeLoadNode load = g.add(new UnsafeLoadNode(loadnmethod, verifiedEntryPointOffset, ConstantNode.forLong(0, graph()), HotSpotGraalRuntime.getInstance().getTarget().wordKind)); + UnsafeLoadNode load = g.add(new UnsafeLoadNode(loadnmethod, verifiedEntryPointOffset, ConstantNode.forLong(0, graph()), graalRuntime().getTarget().wordKind)); LoadFieldNode loadMethod = g.add(new LoadFieldNode(code, methodField)); LoadFieldNode loadmetaspaceMethod = g.add(new LoadFieldNode(loadMethod, metaspaceMethodField)); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorCounterNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -43,7 +43,7 @@ public void generate(LIRGenerator gen) { assert graph().getNodes().filter(MonitorCounterNode.class).count() == 1 : "monitor counters not canonicalized to single instance"; StackSlot counter = gen.frameMap().allocateStackBlock(gen.target().wordSize, false); - Value result = gen.emitLea(counter); + Value result = gen.emitAddress(counter); gen.setResult(this, result); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/MonitorExitStubCall.java Thu Apr 25 19:44:58 2013 +0200 @@ -60,7 +60,7 @@ HotSpotLIRGenerator hsGen = (HotSpotLIRGenerator) gen; StackSlot slot = hsGen.getLockSlot(lockDepth); RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(MonitorExitStubCall.MONITOREXIT); - gen.emitCall(stub, stub.getCallingConvention(), this, gen.operand(object), gen.emitLea(slot)); + gen.emitCall(stub, stub.getCallingConvention(), this, gen.operand(object), gen.emitAddress(slot)); } @NodeIntrinsic diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/TailcallNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,6 +22,8 @@ */ package com.oracle.graal.hotspot.nodes; +import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; + import java.lang.reflect.*; import java.util.*; @@ -58,7 +60,7 @@ @Override public void generate(LIRGeneratorTool generator) { LIRGenerator gen = (LIRGenerator) generator; - HotSpotVMConfig config = HotSpotGraalRuntime.getInstance().getConfig(); + HotSpotVMConfig config = graalRuntime().getConfig(); ResolvedJavaMethod method = frameState.method(); boolean isStatic = Modifier.isStatic(method.getModifiers()); @@ -69,7 +71,8 @@ parameters.add(frameState.localAt(slot)); } Value[] args = gen.visitInvokeArguments(cc, parameters); - Value entry = gen.emitLoad(Kind.Long, gen.operand(target), config.nmethodEntryOffset, Value.ILLEGAL, 0, null); + Value address = gen.emitAddress(gen.operand(target), config.nmethodEntryOffset, Value.ILLEGAL, 0); + Value entry = gen.emitLoad(Kind.Long, address, null); HotSpotLIRGenerator hsgen = (HotSpotLIRGenerator) gen; hsgen.emitTailcall(args, entry); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSnippetUtils.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSnippetUtils.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotSnippetUtils.java Thu Apr 25 19:44:58 2013 +0200 @@ -49,7 +49,7 @@ public static final Object FINAL_LOCATION = LocationNode.FINAL_LOCATION; public static HotSpotVMConfig config() { - return HotSpotGraalRuntime.getInstance().getConfig(); + return graalRuntime().getConfig(); } @Fold @@ -148,22 +148,22 @@ @Fold public static Kind wordKind() { - return HotSpotGraalRuntime.getInstance().getTarget().wordKind; + return graalRuntime().getTarget().wordKind; } @Fold public static Register threadRegister() { - return HotSpotGraalRuntime.getInstance().getRuntime().threadRegister(); + return graalRuntime().getRuntime().threadRegister(); } @Fold public static Register stackPointerRegister() { - return HotSpotGraalRuntime.getInstance().getRuntime().stackPointerRegister(); + return graalRuntime().getRuntime().stackPointerRegister(); } @Fold public static int wordSize() { - return HotSpotGraalRuntime.getInstance().getTarget().wordSize; + return graalRuntime().getTarget().wordSize; } @Fold diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64AddressValue.java Thu Apr 25 19:44:58 2013 +0200 @@ -30,18 +30,19 @@ import com.oracle.graal.asm.amd64.*; import com.oracle.graal.asm.amd64.AMD64Address.Scale; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.OperandFlag; public class AMD64AddressValue extends CompositeValue { private static final long serialVersionUID = -4444600052487578694L; - @Component({REG, UNUSED}) protected AllocatableValue base; - @Component({REG, UNUSED}) protected AllocatableValue index; + @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue base; + @Component({REG, OperandFlag.ILLEGAL}) protected AllocatableValue index; protected final Scale scale; protected final int displacement; public AMD64AddressValue(Kind kind, AllocatableValue base, int displacement) { - this(kind, base, AllocatableValue.UNUSED, Scale.Times1, displacement); + this(kind, base, Value.ILLEGAL, Scale.Times1, displacement); } public AMD64AddressValue(Kind kind, AllocatableValue base, AllocatableValue index, Scale scale, int displacement) { @@ -53,7 +54,7 @@ } private static Register toRegister(AllocatableValue value) { - if (value == AllocatableValue.UNUSED) { + if (value == Value.ILLEGAL) { return Register.None; } else { RegisterValue reg = (RegisterValue) value; @@ -67,8 +68,7 @@ @Override public String toString() { - StringBuilder s = new StringBuilder(); - s.append(getKind().getJavaName()).append("["); + StringBuilder s = new StringBuilder("["); String sep = ""; if (isLegal(base)) { s.append(base); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Thu Apr 25 19:44:58 2013 +0200 @@ -26,7 +26,6 @@ import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; import com.oracle.graal.amd64.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.graph.*; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Thu Apr 25 19:44:58 2013 +0200 @@ -23,6 +23,7 @@ package com.oracle.graal.lir.amd64; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.amd64.*; import com.oracle.graal.lir.asm.*; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java --- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Thu Apr 25 19:44:58 2013 +0200 @@ -44,10 +44,10 @@ @Opcode("MOVE") public static class MoveToRegOp extends AMD64LIRInstruction implements MoveOp { - @Def({REG, HINT}) protected Value result; + @Def({REG, HINT}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public MoveToRegOp(Value result, Value input) { + public MoveToRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -63,7 +63,7 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } @@ -71,10 +71,10 @@ @Opcode("MOVE") public static class MoveFromRegOp extends AMD64LIRInstruction implements MoveOp { - @Def({REG, STACK}) protected Value result; + @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, CONST, HINT}) protected Value input; - public MoveFromRegOp(Value result, Value input) { + public MoveFromRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -90,17 +90,19 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } public abstract static class MemOp extends AMD64LIRInstruction { + protected final Kind kind; @Use({COMPOSITE}) protected AMD64AddressValue address; @State protected LIRFrameState state; - public MemOp(AMD64AddressValue address, LIRFrameState state) { + public MemOp(Kind kind, AMD64AddressValue address, LIRFrameState state) { + this.kind = kind; this.address = address; this.state = state; } @@ -120,14 +122,14 @@ @Def({REG}) protected AllocatableValue result; - public LoadOp(AllocatableValue result, AMD64AddressValue address, LIRFrameState state) { - super(address, state); + public LoadOp(Kind kind, AllocatableValue result, AMD64AddressValue address, LIRFrameState state) { + super(kind, address, state); this.result = result; } @Override public void emitMemAccess(AMD64MacroAssembler masm) { - switch (address.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movsxb(asRegister(result), address.toAddress()); @@ -163,15 +165,15 @@ @Use({REG}) protected AllocatableValue input; - public StoreOp(AMD64AddressValue address, AllocatableValue input, LIRFrameState state) { - super(address, state); + public StoreOp(Kind kind, AMD64AddressValue address, AllocatableValue input, LIRFrameState state) { + super(kind, address, state); this.input = input; } @Override public void emitMemAccess(AMD64MacroAssembler masm) { assert isRegister(input); - switch (address.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movb(address.toAddress(), asRegister(input)); @@ -205,14 +207,14 @@ protected final Constant input; - public StoreConstantOp(AMD64AddressValue address, Constant input, LIRFrameState state) { - super(address, state); + public StoreConstantOp(Kind kind, AMD64AddressValue address, Constant input, LIRFrameState state) { + super(kind, address, state); this.input = input; } @Override public void emitMemAccess(AMD64MacroAssembler masm) { - switch (address.getKind()) { + switch (kind) { case Boolean: case Byte: masm.movb(address.toAddress(), input.asInt() & 0xFF); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXAddressValue.java Thu Apr 25 19:44:58 2013 +0200 @@ -29,6 +29,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.lir.*; +import com.oracle.graal.lir.LIRInstruction.OperandFlag; /** * Represents an address in target machine memory, specified via some combination of a base register @@ -38,7 +39,7 @@ private static final long serialVersionUID = 1802222435353022623L; - @Component({REG, UNUSED}) private AllocatableValue base; + @Component({REG, OperandFlag.ILLEGAL}) private AllocatableValue base; private final long displacement; /** @@ -68,7 +69,7 @@ } public PTXAddress toAddress() { - Register baseReg = base == AllocatableValue.UNUSED ? Register.None : asRegister(base); + Register baseReg = base == Value.ILLEGAL ? Register.None : asRegister(base); return new PTXAddress(baseReg, displacement); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Thu Apr 25 19:44:58 2013 +0200 @@ -25,7 +25,6 @@ import static com.oracle.graal.api.code.ValueUtil.*; import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; -import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.ptx.*; import com.oracle.graal.graph.*; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Thu Apr 25 19:44:58 2013 +0200 @@ -97,6 +97,7 @@ @SuppressWarnings("unused") public static class CondMoveOp extends PTXLIRInstruction { + @Def({REG, HINT}) protected Value result; @Alive({REG}) protected Value trueValue; @Use({REG, STACK, CONST}) protected Value falseValue; @@ -119,6 +120,7 @@ @SuppressWarnings("unused") public static class FloatCondMoveOp extends PTXLIRInstruction { + @Def({REG}) protected Value result; @Alive({REG}) protected Value trueValue; @Alive({REG}) protected Value falseValue; @@ -142,14 +144,14 @@ } public static class SequentialSwitchOp extends PTXLIRInstruction implements FallThroughOp { + @Use({CONST}) protected Constant[] keyConstants; private final LabelRef[] keyTargets; private LabelRef defaultTarget; @Alive({REG}) protected Value key; @Temp({REG, ILLEGAL}) protected Value scratch; - public SequentialSwitchOp(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, - Value key, Value scratch) { + public SequentialSwitchOp(Constant[] keyConstants, LabelRef[] keyTargets, LabelRef defaultTarget, Value key, Value scratch) { assert keyConstants.length == keyTargets.length; this.keyConstants = keyConstants; this.keyTargets = keyTargets; @@ -216,14 +218,14 @@ } public static class TableSwitchOp extends PTXLIRInstruction { + private final int lowKey; private final LabelRef defaultTarget; private final LabelRef[] targets; @Alive protected Value index; @Temp protected Value scratch; - public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, - Variable index, Variable scratch) { + public TableSwitchOp(final int lowKey, final LabelRef defaultTarget, final LabelRef[] targets, Variable index, Variable scratch) { this.lowKey = lowKey; this.defaultTarget = defaultTarget; this.targets = targets; @@ -238,9 +240,7 @@ } @SuppressWarnings("unused") - private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, - LabelRef defaultTarget, LabelRef[] targets, - Register value, Register scratch) { + private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds int highKey = lowKey + targets.length - 1; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Thu Apr 25 19:44:58 2013 +0200 @@ -39,10 +39,10 @@ @Opcode("MOVE") public static class SpillMoveOp extends PTXLIRInstruction implements MoveOp { - @Def({REG, STACK}) protected Value result; + @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public SpillMoveOp(Value result, Value input) { + public SpillMoveOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -58,7 +58,7 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } @@ -66,10 +66,10 @@ @Opcode("MOVE") public static class MoveToRegOp extends PTXLIRInstruction implements MoveOp { - @Def({REG, HINT}) protected Value result; + @Def({REG, HINT}) protected AllocatableValue result; @Use({REG, STACK, CONST}) protected Value input; - public MoveToRegOp(Value result, Value input) { + public MoveToRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -85,7 +85,7 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } @@ -93,10 +93,10 @@ @Opcode("MOVE") public static class MoveFromRegOp extends PTXLIRInstruction implements MoveOp { - @Def({REG, STACK}) protected Value result; + @Def({REG, STACK}) protected AllocatableValue result; @Use({REG, CONST, HINT}) protected Value input; - public MoveFromRegOp(Value result, Value input) { + public MoveFromRegOp(AllocatableValue result, Value input) { this.result = result; this.input = input; } @@ -112,18 +112,20 @@ } @Override - public Value getResult() { + public AllocatableValue getResult() { return result; } } public static class LoadOp extends PTXLIRInstruction { + private final Kind kind; @Def({REG}) protected AllocatableValue result; @Use({COMPOSITE}) protected PTXAddressValue address; @State protected LIRFrameState state; - public LoadOp(AllocatableValue result, PTXAddressValue address, LIRFrameState state) { + public LoadOp(Kind kind, AllocatableValue result, PTXAddressValue address, LIRFrameState state) { + this.kind = kind; this.result = result; this.address = address; this.state = state; @@ -132,7 +134,7 @@ @Override public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { PTXAddress addr = address.toAddress(); - switch (address.getKind()) { + switch (kind) { case Byte: masm.ld_global_s8(asRegister(result), addr.getBase(), addr.getDisplacement()); break; @@ -165,11 +167,13 @@ public static class StoreOp extends PTXLIRInstruction { + private final Kind kind; @Use({COMPOSITE}) protected PTXAddressValue address; @Use({REG}) protected AllocatableValue input; @State protected LIRFrameState state; - public StoreOp(PTXAddressValue address, AllocatableValue input, LIRFrameState state) { + public StoreOp(Kind kind, PTXAddressValue address, AllocatableValue input, LIRFrameState state) { + this.kind = kind; this.address = address; this.input = input; this.state = state; @@ -179,7 +183,7 @@ public void emitCode(TargetMethodAssembler tasm, PTXAssembler masm) { assert isRegister(input); PTXAddress addr = address.toAddress(); - switch (address.getKind()) { + switch (kind) { case Byte: masm.st_global_s8(addr.getBase(), addr.getDisplacement(), asRegister(input)); break; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Thu Apr 25 19:44:58 2013 +0200 @@ -64,7 +64,7 @@ public interface SpillMoveFactory { - LIRInstruction createMove(Value result, Value input); + LIRInstruction createMove(AllocatableValue result, Value input); } private boolean hasArgInCallerFrame; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Thu Apr 25 19:44:58 2013 +0200 @@ -181,11 +181,6 @@ ILLEGAL, /** - * The value can be {@link AllocatableValue#UNUSED}. - */ - UNUSED, - - /** * The register allocator should try to assign a certain register to improve code quality. * Use {@link LIRInstruction#forEachRegisterHint} to access the register hints. */ @@ -205,10 +200,10 @@ static { ALLOWED_FLAGS = new EnumMap<>(OperandMode.class); - ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNUSED, UNINITIALIZED)); - ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNUSED, UNINITIALIZED)); - ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, UNUSED, HINT)); - ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, UNUSED, HINT)); + ALLOWED_FLAGS.put(USE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); + ALLOWED_FLAGS.put(ALIVE, EnumSet.of(REG, STACK, COMPOSITE, CONST, ILLEGAL, HINT, UNINITIALIZED)); + ALLOWED_FLAGS.put(TEMP, EnumSet.of(REG, COMPOSITE, CONST, ILLEGAL, HINT)); + ALLOWED_FLAGS.put(DEF, EnumSet.of(REG, STACK, COMPOSITE, ILLEGAL, HINT)); } /** diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRVerifier.java Thu Apr 25 19:44:58 2013 +0200 @@ -232,8 +232,7 @@ private static Value allowed(Object op, Value value, OperandMode mode, EnumSet flags) { if ((isVariable(value) && flags.contains(OperandFlag.REG)) || (isRegister(value) && flags.contains(OperandFlag.REG)) || (isStackSlot(value) && flags.contains(OperandFlag.STACK)) || - (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL)) || - (value == AllocatableValue.UNUSED && flags.contains(OperandFlag.UNUSED))) { + (isConstant(value) && flags.contains(OperandFlag.CONST) && mode != OperandMode.DEF) || (isIllegal(value) && flags.contains(OperandFlag.ILLEGAL))) { return value; } TTY.println("instruction %s", op); diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,14 +22,14 @@ */ package com.oracle.graal.lir; +import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; + import com.oracle.graal.api.meta.*; import com.oracle.graal.asm.*; import com.oracle.graal.graph.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.cfg.*; -import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*; - /** * A collection of machine-independent LIR operations, as well as interfaces to be implemented for * specific kinds or LIR operations. @@ -117,7 +117,7 @@ Value getInput(); - Value getResult(); + AllocatableValue getResult(); } /** diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/AddLocationNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -91,18 +91,6 @@ return getY().generateAddress(gen, xAddr); } - @Override - public Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting) { - Value xAddr = getX().generateAddress(gen, base); - return getY().generateLoad(gen, xAddr, deopting); - } - - @Override - public void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting) { - Value xAddr = getX().generateAddress(gen, base); - getY().generateStore(gen, xAddr, value, deopting); - } - @NodeIntrinsic public static native Location addLocation(@ConstantNodeParameter Object identity, @ConstantNodeParameter Kind kind, Location x, Location y); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ConstantLocationNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; /** @@ -56,16 +55,6 @@ @Override public Value generateAddress(LIRGeneratorTool gen, Value base) { - return gen.emitLea(base, displacement(), Value.ILLEGAL, 0); - } - - @Override - public Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting) { - return gen.emitLoad(getValueKind(), base, displacement(), Value.ILLEGAL, 0, deopting); - } - - @Override - public void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting) { - gen.emitStore(getValueKind(), base, displacement(), Value.ILLEGAL, 0, value, deopting); + return gen.emitAddress(base, displacement(), Value.ILLEGAL, 0); } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -24,6 +24,7 @@ import java.util.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; @@ -53,7 +54,8 @@ @Override public void generate(LIRGeneratorTool gen) { - gen.setResult(this, location().generateLoad(gen, gen.operand(object()), this)); + Value address = location().generateAddress(gen, gen.operand(object())); + gen.setResult(this, gen.emitLoad(location().getValueKind(), address, this)); } @Override diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/IndexedLocationNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -91,17 +91,7 @@ @Override public Value generateAddress(LIRGeneratorTool gen, Value base) { - return gen.emitLea(base, displacement, gen.operand(index()), indexScaling()); - } - - @Override - public Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting) { - return gen.emitLoad(getValueKind(), base, displacement, gen.operand(index()), indexScaling(), deopting); - } - - @Override - public void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting) { - gen.emitStore(getValueKind(), base, displacement, gen.operand(index()), indexScaling(), value, deopting); + return gen.emitAddress(base, displacement, gen.operand(index()), indexScaling()); } @NodeIntrinsic diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LocationNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -24,7 +24,6 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.Node.ValueNumberable; -import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; @@ -100,8 +99,4 @@ } public abstract Value generateAddress(LIRGeneratorTool gen, Value base); - - public abstract Value generateLoad(LIRGeneratorTool gen, Value base, DeoptimizingNode deopting); - - public abstract void generateStore(LIRGeneratorTool gen, Value base, Value value, DeoptimizingNode deopting); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -57,7 +57,8 @@ @Override public void generate(LIRGeneratorTool gen) { - gen.setResult(this, location().generateLoad(gen, gen.operand(object()), this)); + Value address = location().generateAddress(gen, gen.operand(object())); + gen.setResult(this, gen.emitLoad(location().getValueKind(), address, this)); } @Override diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/UnsafeCastNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -91,7 +91,7 @@ public void generate(LIRGeneratorTool generator) { if (kind() != object().kind()) { assert generator.target().sizeInBytes(kind()) == generator.target().sizeInBytes(object().kind()) : "unsafe cast cannot be used to change the size of a value"; - Value result = generator.newVariable(kind()); + AllocatableValue result = generator.newVariable(kind()); generator.emitMove(result, generator.operand(object())); generator.setResult(this, result); } else { diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/WriteNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -22,10 +22,11 @@ */ package com.oracle.graal.nodes.extended; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.graph.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.nodes.type.*; -import com.oracle.graal.graph.*; /** * Writes a given {@linkplain #value() value} a {@linkplain AccessNode memory location}. @@ -84,7 +85,8 @@ @Override public void generate(LIRGeneratorTool gen) { - location().generateStore(gen, gen.operand(object()), gen.operand(value()), this); + Value address = location().generateAddress(gen, gen.operand(object())); + gen.emitStore(location().getValueKind(), address, gen.operand(value()), this); } @NodeIntrinsic diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java --- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/LIRGeneratorTool.java Thu Apr 25 19:44:58 2013 +0200 @@ -29,11 +29,11 @@ import com.oracle.graal.nodes.extended.*; import com.oracle.graal.nodes.java.*; -public abstract class LIRGeneratorTool { +public interface LIRGeneratorTool { - public abstract TargetDescription target(); + TargetDescription target(); - public abstract CodeCacheProvider getRuntime(); + CodeCacheProvider getRuntime(); /** * Checks whether the supplied constant can be used without loading it into a register for most @@ -43,100 +43,99 @@ * @return True if the constant can be used directly, false if the constant needs to be in a * register. */ - public abstract boolean canInlineConstant(Constant c); + boolean canInlineConstant(Constant c); - public abstract RegisterAttributes attributes(Register register); + RegisterAttributes attributes(Register register); - public abstract Value operand(ValueNode object); + Value operand(ValueNode object); - public abstract AllocatableValue newVariable(Kind kind); + AllocatableValue newVariable(Kind kind); - public abstract Value setResult(ValueNode x, Value operand); + Value setResult(ValueNode x, Value operand); - public abstract Value emitMove(Value input); + AllocatableValue emitMove(Value input); - public abstract void emitMove(Value dst, Value src); + void emitMove(AllocatableValue dst, Value src); - public abstract Value emitLoad(Kind kind, Value base, long displacement, Value index, int scale, DeoptimizingNode deopting); + Value emitAddress(Value base, long displacement, Value index, int scale); - public abstract void emitStore(Kind kind, Value base, long displacement, Value index, int scale, Value input, DeoptimizingNode deopting); + Value emitAddress(StackSlot slot); - public abstract Value emitLea(Value base, long displacement, Value index, int scale); + Value emitLoad(Kind kind, Value address, DeoptimizingNode deopting); - public abstract Value emitLea(StackSlot slot); + void emitStore(Kind kind, Value address, Value input, DeoptimizingNode deopting); - public abstract Value emitNegate(Value input); + Value emitNegate(Value input); - public abstract Value emitAdd(Value a, Value b); + Value emitAdd(Value a, Value b); - public abstract Value emitSub(Value a, Value b); + Value emitSub(Value a, Value b); - public abstract Value emitMul(Value a, Value b); + Value emitMul(Value a, Value b); - public abstract Value emitDiv(Value a, Value b, DeoptimizingNode deopting); + Value emitDiv(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitRem(Value a, Value b, DeoptimizingNode deopting); + Value emitRem(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitUDiv(Value a, Value b, DeoptimizingNode deopting); + Value emitUDiv(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitURem(Value a, Value b, DeoptimizingNode deopting); + Value emitURem(Value a, Value b, DeoptimizingNode deopting); - public abstract Value emitAnd(Value a, Value b); + Value emitAnd(Value a, Value b); - public abstract Value emitOr(Value a, Value b); + Value emitOr(Value a, Value b); - public abstract Value emitXor(Value a, Value b); + Value emitXor(Value a, Value b); - public abstract Value emitShl(Value a, Value b); + Value emitShl(Value a, Value b); - public abstract Value emitShr(Value a, Value b); + Value emitShr(Value a, Value b); - public abstract Value emitUShr(Value a, Value b); + Value emitUShr(Value a, Value b); - public abstract Value emitConvert(ConvertNode.Op opcode, Value inputVal); + Value emitConvert(ConvertNode.Op opcode, Value inputVal); - public abstract void emitMembar(int barriers); + void emitMembar(int barriers); - public abstract void emitDeoptimize(DeoptimizationAction action, DeoptimizingNode deopting); + void emitDeoptimize(DeoptimizationAction action, DeoptimizingNode deopting); - public abstract void emitNullCheck(ValueNode v, DeoptimizingNode deopting); + void emitNullCheck(ValueNode v, DeoptimizingNode deopting); - public abstract Value emitCall(RuntimeCallTarget callTarget, CallingConvention cc, DeoptimizingNode info, Value... args); + Value emitCall(RuntimeCallTarget callTarget, CallingConvention cc, DeoptimizingNode info, Value... args); - public abstract void emitIf(IfNode i); + void emitIf(IfNode i); - public abstract void emitConditional(ConditionalNode i); + void emitConditional(ConditionalNode i); - public abstract void emitSwitch(SwitchNode i); + void emitSwitch(SwitchNode i); - public abstract void emitInvoke(Invoke i); + void emitInvoke(Invoke i); - public abstract void visitRuntimeCall(RuntimeCallNode i); + void visitRuntimeCall(RuntimeCallNode i); // Handling of block-end nodes still needs to be unified in the LIRGenerator. - public abstract void visitMerge(MergeNode i); + void visitMerge(MergeNode i); - public abstract void visitEndNode(EndNode i); + void visitEndNode(EndNode i); - public abstract void visitLoopEnd(LoopEndNode i); + void visitLoopEnd(LoopEndNode i); - public abstract void visitCompareAndSwap(CompareAndSwapNode i); + void visitCompareAndSwap(CompareAndSwapNode i); // These methods define the contract a runtime specific backend must provide. - public abstract void visitReturn(ReturnNode i); + void visitReturn(ReturnNode i); - public abstract void visitSafepointNode(SafepointNode i); + void visitSafepointNode(SafepointNode i); - public abstract void visitBreakpointNode(BreakpointNode i); + void visitBreakpointNode(BreakpointNode i); - public abstract void emitUnwind(Value operand); + void emitUnwind(Value operand); /** * Called just before register allocation is performed on the LIR owned by this generator. */ - public void beforeRegisterAllocation() { - } + void beforeRegisterAllocation(); - public abstract void visitInfopointNode(InfopointNode i); + void visitInfopointNode(InfopointNode i); } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/NodeIntrinsificationVerificationPhase.java Thu Apr 25 19:44:58 2013 +0200 @@ -24,20 +24,20 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.graph.*; +import com.oracle.graal.graph.Node.ConstantNodeParameter; import com.oracle.graal.graph.Node.NodeIntrinsic; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.phases.*; -import com.oracle.graal.replacements.Snippet.*; +import com.oracle.graal.replacements.Snippet.Fold; /** * Checks that a graph contains no calls to {@link NodeIntrinsic} or {@link Fold} methods. */ public class NodeIntrinsificationVerificationPhase extends Phase { - public static boolean verify(StructuredGraph graph) { + public static void verify(StructuredGraph graph) { new NodeIntrinsificationVerificationPhase().apply(graph); - return true; } @Override @@ -49,11 +49,17 @@ private static void checkInvoke(MethodCallTargetNode n) { ResolvedJavaMethod target = n.targetMethod(); - NodeIntrinsic intrinsic = target.getAnnotation(Node.NodeIntrinsic.class); - if (intrinsic != null) { - throw new GraalInternalError("Illegal call to node intrinsic in " + n.graph() + ": " + n.invoke()); + if (target.getAnnotation(Node.NodeIntrinsic.class) != null) { + error(n, "Intrinsification"); } else if (target.getAnnotation(Fold.class) != null) { - throw new GraalInternalError("Illegal call to foldable method in " + n.graph() + ": " + n.invoke()); + error(n, "Folding"); } } + + private static void error(MethodCallTargetNode n, String failedAction) throws GraalInternalError { + String context = MetaUtil.format("%H.%n", ((StructuredGraph) n.graph()).method()); + String target = n.invoke().callTarget().targetName(); + throw new GraalInternalError(failedAction + " of call to '" + target + "' in '" + context + "' failed, most likely due to a parameter annotated with @" + + ConstantNodeParameter.class.getSimpleName() + " not being resolvable to a constant during compilation"); + } } diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ReplacementsImpl.java Thu Apr 25 19:44:58 2013 +0200 @@ -279,7 +279,9 @@ */ protected void finalizeGraph(StructuredGraph graph) { new NodeIntrinsificationPhase(runtime).apply(graph); - assert SnippetTemplate.hasConstantParameter(method) || NodeIntrinsificationVerificationPhase.verify(graph); + if (!SnippetTemplate.hasConstantParameter(method)) { + NodeIntrinsificationVerificationPhase.verify(graph); + } if (original == null) { new SnippetFrameStateCleanupPhase().apply(graph); diff -r e6251a86e8e3 -r 2e12f1719a42 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 Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Thu Apr 25 19:44:58 2013 +0200 @@ -378,7 +378,7 @@ new CanonicalizerPhase.Instance(runtime, replacements.getAssumptions(), 0, null).apply(snippetCopy); } - assert NodeIntrinsificationVerificationPhase.verify(snippetCopy); + NodeIntrinsificationVerificationPhase.verify(snippetCopy); // Gather the template parameters parameters = new Object[parameterCount]; diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectReadNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -47,7 +47,7 @@ @Override public void generate(LIRGeneratorTool gen) { - gen.setResult(this, gen.emitLoad(readKind, gen.operand(address), 0, Value.ILLEGAL, 0, null)); + gen.setResult(this, gen.emitLoad(readKind, gen.operand(address), null)); } @SuppressWarnings("unchecked") diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/DirectStoreNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -50,7 +50,7 @@ @Override public void generate(LIRGeneratorTool gen) { Value v = gen.operand(value); - gen.emitStore(kind, gen.operand(address), 0, Value.ILLEGAL, 0, v, null); + gen.emitStore(kind, gen.operand(address), v, null); } /* diff -r e6251a86e8e3 -r 2e12f1719a42 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java Thu Apr 25 11:02:50 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/nodes/WriteRegisterNode.java Thu Apr 25 19:44:58 2013 +0200 @@ -54,7 +54,7 @@ @Override public void generate(LIRGeneratorTool generator) { Value val = generator.operand(value); - generator.emitMove(val, register.asValue(val.getKind())); + generator.emitMove(register.asValue(val.getKind()), val); } @Override diff -r e6251a86e8e3 -r 2e12f1719a42 mx/commands.py --- a/mx/commands.py Thu Apr 25 11:02:50 2013 +0200 +++ b/mx/commands.py Thu Apr 25 19:44:58 2013 +0200 @@ -1361,7 +1361,7 @@ mx.add_argument('--' + c, action='store_const', dest='vmbuild', const=c, help='select the ' + c + ' build of the VM') mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='') - mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb -- args') + mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb --args') commands.update({ 'export': [export, '[-options] [zipfile]'], diff -r e6251a86e8e3 -r 2e12f1719a42 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Thu Apr 25 11:02:50 2013 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Thu Apr 25 19:44:58 2013 +0200 @@ -197,7 +197,7 @@ end_class \ start_class(Value) \ oop_field(Value, kind, "Lcom/oracle/graal/api/meta/Kind;") \ - static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/Value;"); \ + static_oop_field(Value, ILLEGAL, "Lcom/oracle/graal/api/meta/AllocatableValue;"); \ end_class \ start_class(RegisterValue) \ oop_field(RegisterValue, reg, "Lcom/oracle/graal/api/code/Register;") \