Mercurial > hg > graal-compiler
changeset 13239:bb35fc7e0d68
Merge.
line wrap: on
line diff
--- a/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.asm/src/com/oracle/graal/asm/AbstractAssembler.java Tue Dec 03 18:40:03 2013 +0100 @@ -115,7 +115,7 @@ } /** - * This is used by the TargetMethodAssembler to convert a {@link StackSlot} to an + * This is used by the CompilationResultBuilder to convert a {@link StackSlot} to an * {@link AbstractAddress}. */ public abstract AbstractAddress makeAddress(Register base, int displacement);
--- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTestBase.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,20 +23,23 @@ package com.oracle.graal.compiler.ptx.test; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import java.lang.annotation.*; import java.lang.reflect.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; -import com.oracle.graal.compiler.*; -import com.oracle.graal.compiler.ptx.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.ptx.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.lir.ptx.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; @@ -57,6 +60,12 @@ super(PTX.class); } + private static CompilerToGPU toGPU = HotSpotGraalRuntime.runtime().getCompilerToGPU(); + + private static boolean validDevice = toGPU.deviceInit(); + + private static final int totalProcessors = (validDevice ? toGPU.availableProcessors() : 0); + protected CompilationResult compile(String test) { if (getBackend() instanceof PTXHotSpotBackend) { StructuredGraph graph = parse(test); @@ -80,8 +89,20 @@ * GPU fallback to CPU in cases of ECC failure on kernel invocation. */ Suites suites = Suites.createDefaultSuites(); - CompilationResult result = GraalCompiler.compileGraph(graph, cc, graph.method(), getProviders(), ptxBackend, target, null, phasePlan, OptimisticOptimizations.NONE, new SpeculationLog(), - suites, new ExternalCompilationResult()); + ExternalCompilationResult result = compileGraph(graph, cc, graph.method(), getProviders(), ptxBackend, target, null, phasePlan, OptimisticOptimizations.NONE, getProfilingInfo(graph), + new SpeculationLog(), suites, true, new ExternalCompilationResult(), CompilationResultBuilderFactory.Default); + + ResolvedJavaMethod method = graph.method(); + + try { + if ((validDevice) && (result.getTargetCode() != null)) { + long kernel = toGPU.generateKernel(result.getTargetCode(), method.getName()); + result.setEntryPoint(kernel); + } + } catch (Throwable th) { + th.printStackTrace(); + } + return result; } else { return null; @@ -143,7 +164,7 @@ * for now assert that the warp array block is no larger than the number of physical * gpu cores. */ - assert dimensionX * dimensionY * dimensionZ < PTXTargetMethodAssembler.getAvailableProcessors(); + assert dimensionX * dimensionY * dimensionZ < totalProcessors; r = ((HotSpotNmethod) installedCode).executeParallel(dimensionX, dimensionY, dimensionZ, executeArgs); } else {
--- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXTargetMethodAssembler.java Tue Dec 03 16:06:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +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.compiler.ptx; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.bridge.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.*; - -public class PTXTargetMethodAssembler extends TargetMethodAssembler { - - private static CompilerToGPU toGPU = HotSpotGraalRuntime.runtime().getCompilerToGPU(); - - private static boolean validDevice = toGPU.deviceInit(); - - private static final int totalProcessors = (validDevice ? toGPU.availableProcessors() : 0); - - public static int getAvailableProcessors() { - return totalProcessors; - } - - // detach ?? - - public PTXTargetMethodAssembler(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, - CompilationResult compilationResult) { - super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult); - } - - @Override - public CompilationResult finishTargetMethod(StructuredGraph graph) { - ResolvedJavaMethod method = graph.method(); - assert method != null : graph + " is not associated wth a method"; - - ExternalCompilationResult graalCompile = (ExternalCompilationResult) super.finishTargetMethod(graph); - - try { - if ((validDevice) && (graalCompile.getTargetCode() != null)) { - long kernel = toGPU.generateKernel(graalCompile.getTargetCode(), method.getName()); - graalCompile.setEntryPoint(kernel); - } - } catch (Throwable th) { - th.printStackTrace(); - } - - return graalCompile; - } -}
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.compiler.test; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.nodes.ConstantNode.*; import static com.oracle.graal.phases.GraalOptions.*; @@ -38,13 +39,13 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.Verbosity; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.spi.*; @@ -554,31 +555,17 @@ GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(getMetaAccess(), getForeignCalls(), GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, - new SpeculationLog(), getSuites(), new CompilationResult()); + final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, + getProfilingInfo(graph), new SpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); if (printCompilation) { TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize())); } try (Scope s = Debug.scope("CodeInstall", getCodeCache(), method)) { - InstalledCode code = addMethod(method, compResult); - if (code == null) { + installedCode = addMethod(method, compResult); + if (installedCode == null) { throw new GraalInternalError("Could not install code for " + MetaUtil.format("%H.%n(%p)", method)); } - if (Debug.isDumpEnabled()) { - Debug.dump(new Object[]{compResult, code}, "After code installation"); - } - if (Debug.isLogEnabled()) { - DisassemblerProvider dis = backend.getDisassembler(); - if (dis != null) { - String text = dis.disassemble(code); - if (text != null) { - Debug.log("Code installed for %s%n%s", method, text); - } - } - } - - installedCode = code; } catch (Throwable e) { throw Debug.handle(e); }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.compiler.test; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import static org.junit.Assert.*; import java.lang.reflect.*; @@ -33,7 +34,7 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.code.CompilationResult.Call; import com.oracle.graal.api.code.CompilationResult.Infopoint; -import com.oracle.graal.compiler.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; import com.oracle.graal.test.*; @@ -59,8 +60,8 @@ final Method method = getMethod("testMethod"); final StructuredGraph graph = parse(method); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultPhasePlan(), - OptimisticOptimizations.ALL, new SpeculationLog(), getSuites(), new CompilationResult()); + final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultPhasePlan(), OptimisticOptimizations.ALL, + getProfilingInfo(graph), new SpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); if (sp instanceof Call) { @@ -81,8 +82,8 @@ } assertTrue(graphLineSPs > 0); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - final CompilationResult cr = GraalCompiler.compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultPhasePlan(true), - OptimisticOptimizations.ALL, new SpeculationLog(), getSuites(), new CompilationResult()); + final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultPhasePlan(true), OptimisticOptimizations.ALL, + getProfilingInfo(graph), new SpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); int lineSPs = 0; for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason);
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Tue Dec 03 18:40:03 2013 +0100 @@ -30,6 +30,7 @@ import com.oracle.graal.alloc.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.CompilationResult.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.meta.ProfilingInfo.*; import com.oracle.graal.compiler.alloc.*; @@ -131,54 +132,43 @@ * @param installedCodeOwner the method the compiled code will be * {@linkplain InstalledCode#getMethod() associated} with once installed. This * argument can be null. + * @param withScope specifies if a {@link DebugScope} with the name {@code "GraalCompiler"} + * should be used for the compilation * @return the result of the compilation */ public static <T extends CompilationResult> T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, - T compilationResult) { - try (Scope s = Debug.scope("GraalCompiler", graph, providers.getCodeCache())) { - compileGraphNoScope(graph, cc, installedCodeOwner, providers, backend, target, cache, plan, optimisticOpts, profilingInfo, speculationLog, suites, compilationResult); + boolean withScope, T compilationResult, CompilationResultBuilderFactory factory) { + try (Scope s0 = withScope ? Debug.scope("GraalCompiler", graph, providers.getCodeCache()) : null) { + Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); + LIR lir = null; + try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) { + lir = emitHIR(providers, target, graph, assumptions, cache, plan, optimisticOpts, profilingInfo, speculationLog, suites); + } catch (Throwable e) { + throw Debug.handle(e); + } + try (TimerCloseable a = BackEnd.start()) { + LIRGenerator lirGen = null; + try (Scope s = Debug.scope("BackEnd", lir)) { + lirGen = emitLIR(backend, target, lir, graph, cc); + } catch (Throwable e) { + throw Debug.handle(e); + } + try (Scope s = Debug.scope("CodeGen", lirGen)) { + emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner, factory); + } catch (Throwable e) { + throw Debug.handle(e); + } + } catch (Throwable e) { + throw Debug.handle(e); + } } catch (Throwable e) { throw Debug.handle(e); } return compilationResult; } - /** - * Same as {@link #compileGraph} but without entering a - * {@linkplain Debug#scope(String, Object...) debug scope}. - */ - public static <T extends CompilationResult> T compileGraphNoScope(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, - TargetDescription target, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, - T compilationResult) { - Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); - - LIR lir = null; - try (Scope s = Debug.scope("FrontEnd"); TimerCloseable a = FrontEnd.start()) { - lir = emitHIR(providers, target, graph, assumptions, cache, plan, optimisticOpts, profilingInfo, speculationLog, suites); - } catch (Throwable e) { - throw Debug.handle(e); - } - try (TimerCloseable a = BackEnd.start()) { - LIRGenerator lirGen = null; - try (Scope s = Debug.scope("BackEnd", lir)) { - lirGen = emitLIR(backend, target, lir, graph, cc); - } catch (Throwable e) { - throw Debug.handle(e); - } - try (Scope s = Debug.scope("CodeGen", lirGen)) { - emitCode(backend, getLeafGraphIdArray(graph), assumptions, lirGen, compilationResult, installedCodeOwner); - } catch (Throwable e) { - throw Debug.handle(e); - } - } catch (Throwable e) { - throw Debug.handle(e); - } - - return compilationResult; - } - - private static ProfilingInfo getProfilingInfo(StructuredGraph graph) { + public static ProfilingInfo getProfilingInfo(StructuredGraph graph) { if (graph.method() != null) { return graph.method().getProfilingInfo(); } else { @@ -186,18 +176,6 @@ } } - public static <T extends CompilationResult> T compileGraph(final StructuredGraph graph, final CallingConvention cc, final ResolvedJavaMethod installedCodeOwner, final Providers providers, - final Backend backend, final TargetDescription target, final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts, - final SpeculationLog speculationLog, final Suites suites, final T compilationResult) { - return compileGraph(graph, cc, installedCodeOwner, providers, backend, target, cache, plan, optimisticOpts, getProfilingInfo(graph), speculationLog, suites, compilationResult); - } - - public static <T extends CompilationResult> T compileGraphNoScope(final StructuredGraph graph, final CallingConvention cc, final ResolvedJavaMethod installedCodeOwner, final Providers providers, - final Backend backend, final TargetDescription target, final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts, - final SpeculationLog speculationLog, final Suites suites, final T compilationResult) { - return compileGraphNoScope(graph, cc, installedCodeOwner, providers, backend, target, cache, plan, optimisticOpts, getProfilingInfo(graph), speculationLog, suites, compilationResult); - } - private static long[] getLeafGraphIdArray(StructuredGraph graph) { long[] leafGraphIdArray = new long[graph.getLeafGraphIds().size() + 1]; int i = 0; @@ -302,19 +280,43 @@ return lirGen; } - public static void emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, LIRGenerator lirGen, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner) { - TargetMethodAssembler tasm = backend.newAssembler(lirGen, compilationResult); - backend.emitCode(tasm, lirGen, installedCodeOwner); - CompilationResult result = tasm.finishTargetMethod(lirGen.getGraph()); + public static void emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, LIRGenerator lirGen, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, + CompilationResultBuilderFactory factory) { + CompilationResultBuilder crb = backend.newCompilationResultBuilder(lirGen, compilationResult, factory); + backend.emitCode(crb, lirGen, installedCodeOwner); + crb.finish(); if (!assumptions.isEmpty()) { - result.setAssumptions(assumptions); + compilationResult.setAssumptions(assumptions); } - result.setLeafGraphIds(leafGraphIds); + compilationResult.setLeafGraphIds(leafGraphIds); + + if (Debug.isMeterEnabled()) { + List<DataPatch> ldp = compilationResult.getDataReferences(); + DebugMetric[] dms = new DebugMetric[Kind.values().length]; + for (int i = 0; i < dms.length; i++) { + dms[i] = Debug.metric("DataPatches-" + Kind.values()[i].toString()); + } + DebugMetric dmRaw = Debug.metric("DataPatches-raw"); + + for (DataPatch dp : ldp) { + if (dp.constant != null) { + dms[dp.constant.getKind().ordinal()].add(1); + } else { + dmRaw.add(1); + } + } + + Debug.metric("CompilationResults").increment(); + Debug.metric("CodeBytesEmitted").add(compilationResult.getTargetCodeSize()); + Debug.metric("InfopointsEmitted").add(compilationResult.getInfopoints().size()); + Debug.metric("DataPatches").add(ldp.size()); + Debug.metric("ExceptionHandlersEmitted").add(compilationResult.getExceptionHandlers().size()); + } if (Debug.isLogEnabled()) { - Debug.log("%s", backend.getProviders().getCodeCache().disassemble(result, null)); + Debug.log("%s", backend.getProviders().getCodeCache().disassemble(compilationResult, null)); } - Debug.dump(result, "After code generation"); + Debug.dump(compilationResult, "After code generation"); } }
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/target/Backend.java Tue Dec 03 18:40:03 2013 +0100 @@ -67,9 +67,15 @@ public abstract LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir); + /** + * Creates the assembler used to emit the machine code. + */ protected abstract AbstractAssembler createAssembler(FrameMap frameMap); - public abstract TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult); + /** + * Creates the object used to fill in the details of a given compilation result. + */ + public abstract CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory); public abstract boolean shouldAllocateRegisters(); @@ -80,5 +86,5 @@ * {@linkplain InstalledCode#getMethod() associated} with once installed. This * argument can be null. */ - public abstract void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner); + public abstract void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner); }
--- a/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java Tue Dec 03 18:40:03 2013 +0100 @@ -54,6 +54,7 @@ @Override public void generateCode(AMD64Assembler asm) { + asm.nop(5); // padding for mt-safe patching asm.ret(0); } }); @@ -70,6 +71,7 @@ @Override public void generateCode(AMD64Assembler asm) { Register arg = getArgumentRegister(0, Kind.Int); + asm.nop(5); // padding for mt-safe patching asm.addl(arg, 5); asm.movl(rax, arg); asm.ret(0); @@ -88,6 +90,7 @@ @Override public void generateCode(AMD64Assembler asm) { Register arg = getArgumentRegister(0, Kind.Long); + asm.nop(5); // padding for mt-safe patching asm.addq(arg, 1); asm.movq(rax, arg); asm.ret(0);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64DeoptimizeOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -39,7 +39,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Call.directCall(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Call.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Tue Dec 03 18:40:03 2013 +0100 @@ -80,12 +80,14 @@ * * @param afterFrameInit specifies if the stack pointer has already been adjusted to allocate * the current frame + * @param isVerifiedEntryPoint specifies if the code buffer is currently at the verified entry + * point */ - protected static void emitStackOverflowCheck(TargetMethodAssembler tasm, boolean afterFrameInit) { + protected static void emitStackOverflowCheck(CompilationResultBuilder crb, boolean afterFrameInit, boolean isVerifiedEntryPoint) { if (StackShadowPages.getValue() > 0) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - int frameSize = tasm.frameMap.frameSize(); + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + int frameSize = crb.frameMap.frameSize(); if (frameSize > 0) { int lastFramePage = frameSize / unsafe.pageSize(); // emit multiple stack bangs for methods with frames larger than a page @@ -94,59 +96,92 @@ if (afterFrameInit) { disp -= frameSize; } - tasm.blockComment("[stack overflow check]"); + crb.blockComment("[stack overflow check]"); + int pos = asm.codeBuffer.position(); asm.movq(new AMD64Address(rsp, -disp), AMD64.rax); + assert i > 0 || !isVerifiedEntryPoint || asm.codeBuffer.position() - pos >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; } } } } + /** + * The size of the instruction used to patch the verified entry point of an nmethod when the + * nmethod is made non-entrant or a zombie (e.g. during deopt or class unloading). The first + * instruction emitted at an nmethod's verified entry point must be at least this length to + * ensure mp-safe patching. + */ + public static final int PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE = 5; + + /** + * Emits code at the verified entry point and return point(s) of a method. + */ class HotSpotFrameContext implements FrameContext { final boolean isStub; + final boolean omitFrame; - HotSpotFrameContext(boolean isStub) { + HotSpotFrameContext(boolean isStub, boolean omitFrame) { this.isStub = isStub; + this.omitFrame = omitFrame; + } + + public boolean hasFrame() { + return !omitFrame; } @Override - public void enter(TargetMethodAssembler tasm) { - FrameMap frameMap = tasm.frameMap; + public void enter(CompilationResultBuilder crb) { + FrameMap frameMap = crb.frameMap; int frameSize = frameMap.frameSize(); - - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - if (!isStub) { - emitStackOverflowCheck(tasm, false); - } - asm.decrementq(rsp, frameSize); - if (ZapStackOnMethodEntry.getValue()) { - final int intSize = 4; - for (int i = 0; i < frameSize / intSize; ++i) { - asm.movl(new AMD64Address(rsp, i * intSize), 0xC1C1C1C1); + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + if (omitFrame) { + if (!isStub) { + asm.nop(PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE); + } + } else { + int verifiedEntryPointOffset = asm.codeBuffer.position(); + if (!isStub) { + emitStackOverflowCheck(crb, false, true); + assert asm.codeBuffer.position() - verifiedEntryPointOffset >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; } - } - CalleeSaveLayout csl = frameMap.registerConfig.getCalleeSaveLayout(); - if (csl != null && csl.size != 0) { - int frameToCSA = frameMap.offsetToCalleeSaveArea(); - assert frameToCSA >= 0; - asm.save(csl, frameToCSA); + if (!isStub && asm.codeBuffer.position() == verifiedEntryPointOffset) { + asm.subq(rsp, frameSize); + assert asm.codeBuffer.position() - verifiedEntryPointOffset >= PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE; + } else { + asm.decrementq(rsp, frameSize); + } + if (ZapStackOnMethodEntry.getValue()) { + final int intSize = 4; + for (int i = 0; i < frameSize / intSize; ++i) { + asm.movl(new AMD64Address(rsp, i * intSize), 0xC1C1C1C1); + } + } + CalleeSaveLayout csl = frameMap.registerConfig.getCalleeSaveLayout(); + if (csl != null && csl.size != 0) { + int frameToCSA = frameMap.offsetToCalleeSaveArea(); + assert frameToCSA >= 0; + asm.save(csl, frameToCSA); + } } } @Override - public void leave(TargetMethodAssembler tasm) { - int frameSize = tasm.frameMap.frameSize(); - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - CalleeSaveLayout csl = tasm.frameMap.registerConfig.getCalleeSaveLayout(); + public void leave(CompilationResultBuilder crb) { + if (!omitFrame) { + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + CalleeSaveLayout csl = crb.frameMap.registerConfig.getCalleeSaveLayout(); - if (csl != null && csl.size != 0) { - tasm.compilationResult.setRegisterRestoreEpilogueOffset(asm.codeBuffer.position()); - // saved all registers, restore all registers - int frameToCSA = tasm.frameMap.offsetToCalleeSaveArea(); - asm.restore(csl, frameToCSA); + if (csl != null && csl.size != 0) { + crb.compilationResult.setRegisterRestoreEpilogueOffset(asm.codeBuffer.position()); + // saved all registers, restore all registers + int frameToCSA = crb.frameMap.offsetToCalleeSaveArea(); + asm.restore(csl, frameToCSA); + } + + int frameSize = crb.frameMap.frameSize(); + asm.incrementq(rsp, frameSize); } - - asm.incrementq(rsp, frameSize); } } @@ -156,7 +191,7 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { // Omit the frame if the method: // - has no spill slots or other slots allocated during register allocation // - has no callee-saved registers @@ -171,12 +206,12 @@ Stub stub = gen.getStub(); AbstractAssembler masm = createAssembler(frameMap); - HotSpotFrameContext frameContext = omitFrame ? null : new HotSpotFrameContext(stub != null); - TargetMethodAssembler tasm = new TargetMethodAssembler(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(frameMap.frameSize()); + HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null, omitFrame); + CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(frameMap.frameSize()); StackSlot deoptimizationRescueSlot = gen.deoptimizationRescueSlot; if (deoptimizationRescueSlot != null && stub == null) { - tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); + crb.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); } if (stub != null) { @@ -184,34 +219,36 @@ updateStub(stub, definedRegisters, gen.calleeSaveInfo, frameMap); } - return tasm; + return crb; } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - FrameMap frameMap = tasm.frameMap; + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { + AMD64MacroAssembler asm = (AMD64MacroAssembler) crb.asm; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; HotSpotVMConfig config = getRuntime().getConfig(); Label verifiedStub = new Label(); // Emit the prefix - emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub); + emitCodePrefix(installedCodeOwner, crb, asm, regConfig, config, verifiedStub); // Emit code for the LIR - emitCodeBody(installedCodeOwner, tasm, lirGen); + emitCodeBody(installedCodeOwner, crb, lirGen); // Emit the suffix - emitCodeSuffix(installedCodeOwner, tasm, lirGen, asm, frameMap); + emitCodeSuffix(installedCodeOwner, crb, lirGen, asm, frameMap); } /** + * Emits the code prior to the verified entry point. + * * @param installedCodeOwner see {@link Backend#emitCode} */ - public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { + public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { HotSpotProviders providers = getProviders(); if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) { - tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY); + crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY); CallingConvention cc = regConfig.getCallingConvention(JavaCallee, null, new JavaType[]{providers.getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false); Register inlineCacheKlass = rax; // see definition of IC_Klass in // c1_LIRAssembler_x86.cpp @@ -226,34 +263,36 @@ } else { asm.cmpq(inlineCacheKlass, src); } - AMD64Call.directConditionalJmp(tasm, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual); + AMD64Call.directConditionalJmp(crb, asm, getForeignCalls().lookupForeignCall(IC_MISS_HANDLER), ConditionFlag.NotEqual); } asm.align(config.codeEntryAlignment); - tasm.recordMark(Marks.MARK_OSR_ENTRY); + crb.recordMark(Marks.MARK_OSR_ENTRY); asm.bind(verifiedStub); - tasm.recordMark(Marks.MARK_VERIFIED_ENTRY); + crb.recordMark(Marks.MARK_VERIFIED_ENTRY); + } + + /** + * Emits the code which starts at the verified entry point. + * + * @param installedCodeOwner see {@link Backend#emitCode} + */ + public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIRGenerator lirGen) { + lirGen.lir.emitCode(crb); } /** * @param installedCodeOwner see {@link Backend#emitCode} */ - public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) { - lirGen.lir.emitCode(tasm); - } - - /** - * @param installedCodeOwner see {@link Backend#emitCode} - */ - public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { + public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, CompilationResultBuilder crb, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { HotSpotProviders providers = getProviders(); - HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext; - if (frameContext != null && !frameContext.isStub) { + HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; + if (!frameContext.isStub) { HotSpotForeignCallsProvider foreignCalls = providers.getForeignCalls(); - tasm.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); - AMD64Call.directCall(tasm, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); - tasm.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); - AMD64Call.directCall(tasm, asm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); + AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); + AMD64Call.directCall(crb, asm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); } else { // No need to emit the stubs for entries back into the method since // it has no calls that can cause such "return" entries
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -42,7 +42,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // reset last Java frame: masm.movslq(new AMD64Address(thread, threadLastJavaSpOffset), 0); masm.movslq(new AMD64Address(thread, threadLastJavaFpOffset), 0);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallPrologueOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotCRuntimeCallPrologueOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -42,7 +42,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // save last Java frame masm.movq(new AMD64Address(thread, threadLastJavaSpOffset), rsp); }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotDeoptimizeCallerOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -36,8 +36,8 @@ final class AMD64HotSpotDeoptimizeCallerOp extends AMD64HotSpotEpilogueOp { @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); - AMD64Call.directJmp(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); + AMD64Call.directJmp(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotEpilogueOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -47,18 +47,16 @@ @Use({REG, STACK}) protected AllocatableValue savedRbp = PLACEHOLDER; - protected void leaveFrameAndRestoreRbp(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + protected void leaveFrameAndRestoreRbp(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (isStackSlot(savedRbp)) { // Restoring RBP from the stack must be done before the frame is removed - masm.movq(rbp, (AMD64Address) tasm.asAddress(savedRbp)); + masm.movq(rbp, (AMD64Address) crb.asAddress(savedRbp)); } else { Register framePointer = asRegister(savedRbp); if (!framePointer.equals(rbp)) { masm.movq(rbp, framePointer); } } - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); - } + crb.frameContext.leave(crb); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -55,8 +55,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); // Discard the return address, thus completing restoration of caller frame masm.incrementq(rsp, 8);
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotMove.java Tue Dec 03 18:40:03 2013 +0100 @@ -126,7 +126,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.movq(asRegister(scratch), asRegister(input)); if (kind == Kind.Object) { encodePointer(masm, asRegister(scratch), heapBaseReg, heapBase, shift, alignment); @@ -134,7 +134,7 @@ encodeKlassPointer(masm, asRegister(scratch), heapBaseReg, klassBase, heapBase, shift, alignment); } if (state != null) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + crb.recordImplicitException(masm.codeBuffer.position(), state); } masm.movl(address.toAddress(), asRegister(scratch)); } @@ -169,12 +169,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - compareAndSwapCompressed(tasm, masm, result, address, cmpValue, newValue, scratch, base, shift, alignment, heapBaseReg); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + compareAndSwapCompressed(crb, masm, result, address, cmpValue, newValue, scratch, base, shift, alignment, heapBaseReg); } } - protected static void compareAndSwapCompressed(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, + protected static void compareAndSwapCompressed(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue, AllocatableValue scratch, long base, int shift, int alignment, Register heapBaseReg) { assert AMD64.rax.equals(asRegister(cmpValue)) && AMD64.rax.equals(asRegister(result)); final Register scratchRegister = asRegister(scratch); @@ -184,7 +184,7 @@ encodePointer(masm, cmpRegister, heapBase, base, shift, alignment); masm.movq(scratchRegister, newRegister); encodePointer(masm, scratchRegister, heapBase, base, shift, alignment); - if (tasm.target.isMP) { + if (crb.target.isMP) { masm.lock(); } masm.cmpxchgl(scratchRegister, address.toAddress());
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPatchReturnAddressOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotPatchReturnAddressOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -45,8 +45,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - int frameSize = tasm.frameMap.frameSize(); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + int frameSize = crb.frameMap.frameSize(); masm.movq(new AMD64Address(rsp, frameSize), asRegister(address)); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotReturnOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -49,10 +49,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); - if (!isStub && (tasm.frameContext != null || !OptEliminateSafepoints.getValue())) { - AMD64HotSpotSafepointOp.emitCode(tasm, masm, runtime().getConfig(), true, null, scratchForSafepointOnReturn); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); + if (!isStub && (crb.frameContext.hasFrame() || !OptEliminateSafepoints.getValue())) { + AMD64HotSpotSafepointOp.emitCode(crb, masm, runtime().getConfig(), true, null, scratchForSafepointOnReturn); } masm.ret(0); }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotSafepointOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -53,9 +53,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) { RegisterValue scratch = (RegisterValue) temp; - emitCode(tasm, asm, config, false, state, scratch.getRegister()); + emitCode(crb, asm, config, false, state, scratch.getRegister()); } /** @@ -68,19 +68,19 @@ return !NumUtil.isInt(pollingPageAddress - config.codeCacheLowBoundary()) || !NumUtil.isInt(pollingPageAddress - config.codeCacheHighBoundary()); } - public static void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { + public static void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { final int pos = asm.codeBuffer.position(); if (isPollingPageFar(config)) { asm.movq(scratch, config.safepointPollingAddress); - tasm.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); + crb.recordMark(atReturn ? MARK_POLL_RETURN_FAR : MARK_POLL_FAR); if (state != null) { - tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } asm.movq(scratch, new AMD64Address(scratch)); } else { - tasm.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); + crb.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); if (state != null) { - tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } // The C++ code transforms the polling page offset into an RIP displacement // to the real address at that offset in the polling page.
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotUnwindOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -47,10 +47,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - leaveFrameAndRestoreRbp(tasm, masm); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + leaveFrameAndRestoreRbp(crb, masm); - ForeignCallLinkage linkage = tasm.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); + ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); CallingConvention cc = linkage.getOutgoingCallingConvention(); assert cc.getArgumentCount() == 2; assert exception.equals(cc.getArgument(0)); @@ -59,6 +59,6 @@ Register returnAddress = asRegister(cc.getArgument(1)); masm.movq(returnAddress, new AMD64Address(rsp, 0)); - AMD64Call.directJmp(tasm, masm, linkage); + AMD64Call.directJmp(crb, masm, linkage); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectStaticCallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -51,12 +51,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - AMD64Move.move(tasm, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod); - tasm.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); - AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); - super.emitCode(tasm, masm); + AMD64Move.move(crb, masm, AMD64.rbx.asValue(Kind.Long), metaspaceMethod); + crb.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); + AMD64Move.move(crb, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); + super.emitCode(crb, masm); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotspotDirectVirtualCallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -51,11 +51,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - tasm.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); - AMD64Move.move(tasm, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); - super.emitCode(tasm, masm); + crb.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); + AMD64Move.move(crb, masm, AMD64.rax.asValue(Kind.Long), Constant.forLong(HotSpotGraalRuntime.runtime().getConfig().nonOopBits)); + super.emitCode(crb, masm); } }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64IndirectCallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -57,11 +57,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tasm.recordMark(Marks.MARK_INLINE_INVOKE); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + crb.recordMark(Marks.MARK_INLINE_INVOKE); Register callReg = asRegister(targetAddress); assert !callReg.equals(METHOD); - AMD64Call.indirectCall(tasm, masm, callReg, callTarget, state); + AMD64Call.indirectCall(crb, masm, callReg, callTarget, state); } @Override
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64TailcallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64TailcallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -47,7 +47,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // destroy the current frame (now the return address is the top of stack) masm.leave();
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILCompilationResult.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,24 +23,26 @@ package com.oracle.graal.hotspot.hsail; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import java.lang.reflect.*; + import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.bridge.CompilerToGPU; +import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hsail.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.nodes.java.MethodCallTargetNode; +import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.type.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; @@ -174,8 +176,8 @@ CallingConvention cc = getHSAILCallingConvention(Type.JavaCallee, target, graph.method(), false); SuitesProvider suitesProvider = backend.getSuites(); try { - HSAILCompilationResult compResult = GraalCompiler.compileGraph(graph, cc, graph.method(), providers, backend, target, null, phasePlan, OptimisticOptimizations.NONE, new SpeculationLog(), - suitesProvider.getDefaultSuites(), new HSAILCompilationResult()); + HSAILCompilationResult compResult = compileGraph(graph, cc, graph.method(), providers, backend, target, null, phasePlan, OptimisticOptimizations.NONE, getProfilingInfo(graph), + new SpeculationLog(), suitesProvider.getDefaultSuites(), true, new HSAILCompilationResult(), CompilationResultBuilderFactory.Default); if ((validDevice) && (compResult.getTargetCode() != null)) { long kernel = toGPU.generateKernel(compResult.getTargetCode(), graph.method().getName());
--- a/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.hsail/src/com/oracle/graal/hotspot/hsail/HSAILHotSpotBackend.java Tue Dec 03 18:40:03 2013 +0100 @@ -94,13 +94,17 @@ class HotSpotFrameContext implements FrameContext { + public boolean hasFrame() { + return true; + } + @Override - public void enter(TargetMethodAssembler tasm) { + public void enter(CompilationResultBuilder crb) { Debug.log("Nothing to do here"); } @Override - public void leave(TargetMethodAssembler tasm) { + public void leave(CompilationResultBuilder crb) { Debug.log("Nothing to do here"); } } @@ -111,20 +115,20 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { FrameMap frameMap = lirGen.frameMap; AbstractAssembler masm = createAssembler(frameMap); HotSpotFrameContext frameContext = new HotSpotFrameContext(); - TargetMethodAssembler tasm = new TargetMethodAssembler(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(frameMap.frameSize()); - return tasm; + CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(frameMap.frameSize()); + return crb; } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod method) { + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod method) { assert method != null : lirGen.getGraph() + " is not associated with a method"; // Emit the prologue. - codeBuffer = tasm.asm.codeBuffer; + codeBuffer = crb.asm.codeBuffer; codeBuffer.emitString0("version 0:95: $full : $large;"); codeBuffer.emitString(""); @@ -176,7 +180,7 @@ codeBuffer.emitString0("kernel &run ("); codeBuffer.emitString(""); - FrameMap frameMap = tasm.frameMap; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; // Build list of param types which does include the gid (for cc register mapping query). JavaType[] ccParamTypes = new JavaType[nonConstantParamCount + 1]; @@ -280,9 +284,9 @@ } } // Prologue done, Emit code for the LIR. - lirGen.lir.emitCode(tasm); + lirGen.lir.emitCode(crb); // Now that code is emitted go back and figure out what the upper Bound stack size was. - long maxStackSize = ((HSAILAssembler) tasm.asm).upperBoundStackSize(); + long maxStackSize = ((HSAILAssembler) crb.asm).upperBoundStackSize(); String spillsegStringFinal; if (maxStackSize == 0) { // If no spilling, get rid of spillseg declaration.
--- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotBackend.java Tue Dec 03 18:40:03 2013 +0100 @@ -157,17 +157,21 @@ class PTXFrameContext implements FrameContext { @Override - public void enter(TargetMethodAssembler tasm) { + public void enter(CompilationResultBuilder crb) { // codeBuffer.emitString(".address_size 32"); // PTX ISA version 2.3 } @Override - public void leave(TargetMethodAssembler tasm) { + public void leave(CompilationResultBuilder crb) { + } + + public boolean hasFrame() { + return true; } } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { // Omit the frame of the method: // - has no spill slots or other slots allocated during register allocation // - has no callee-saved registers @@ -176,9 +180,9 @@ FrameMap frameMap = lirGen.frameMap; AbstractAssembler masm = createAssembler(frameMap); PTXFrameContext frameContext = new PTXFrameContext(); - TargetMethodAssembler tasm = new PTXTargetMethodAssembler(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(0); - return tasm; + CompilationResultBuilder crb = factory.createBuilder(getCodeCache(), getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(0); + return crb; } @Override @@ -191,14 +195,14 @@ return new PTXLIRGenerator(graph, getProviders(), frameMap, cc, lir); } - private static void emitKernelEntry(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + private static void emitKernelEntry(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { // Emit PTX kernel entry text based on PTXParameterOp // instructions in the start block. Remove the instructions // once kernel entry text and directives are emitted to // facilitate seemless PTX code generation subsequently. assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; final String name = codeCacheOwner.getName(); - Buffer codeBuffer = tasm.asm.codeBuffer; + Buffer codeBuffer = crb.asm.codeBuffer; // Emit initial boiler-plate directives. codeBuffer.emitString(".version 3.0"); @@ -216,7 +220,7 @@ // instruction. for (LIRInstruction op : lirGen.lir.lir(startBlock)) { if (op instanceof PTXParameterOp) { - op.emitCode(tasm); + op.emitCode(crb); deleteOps.add(op); } } @@ -232,11 +236,11 @@ } // Emit .reg space declarations - private static void emitRegisterDecl(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + private static void emitRegisterDecl(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; - Buffer codeBuffer = tasm.asm.codeBuffer; + Buffer codeBuffer = crb.asm.codeBuffer; RegisterAnalysis registerAnalysis = new RegisterAnalysis(); for (Block b : lirGen.lir.codeEmittingOrder()) { @@ -261,15 +265,15 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; - Buffer codeBuffer = tasm.asm.codeBuffer; + Buffer codeBuffer = crb.asm.codeBuffer; // Emit the prologue - emitKernelEntry(tasm, lirGen, codeCacheOwner); + emitKernelEntry(crb, lirGen, codeCacheOwner); // Emit register declarations try { - emitRegisterDecl(tasm, lirGen, codeCacheOwner); + emitRegisterDecl(crb, lirGen, codeCacheOwner); } catch (GraalInternalError e) { e.printStackTrace(); // TODO : Better error handling needs to be done once @@ -280,7 +284,7 @@ } // Emit code for the LIR try { - lirGen.lir.emitCode(tasm); + lirGen.lir.emitCode(crb); } catch (GraalInternalError e) { e.printStackTrace(); // TODO : Better error handling needs to be done once
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCDeoptimizeOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -39,7 +39,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // TODO the patched call address looks odd (and is invalid) compared to other runtime calls: // 0xffffffff749bb5fc: call 0xffffffff415a720c ; {runtime_call} // [Exception Handler] @@ -48,6 +48,6 @@ // [Deopt Handler Code] // 0xffffffff749bb60c: call 0xffffffff748da540 ; {runtime_call} // 0xffffffff749bb610: nop - SPARCCall.directCall(tasm, masm, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); + SPARCCall.directCall(crb, masm, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP), null, false, info); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java Tue Dec 03 18:40:03 2013 +0100 @@ -81,10 +81,10 @@ * @param afterFrameInit specifies if the stack pointer has already been adjusted to allocate * the current frame */ - protected static void emitStackOverflowCheck(TargetMethodAssembler tasm, boolean afterFrameInit) { + protected static void emitStackOverflowCheck(CompilationResultBuilder crb, boolean afterFrameInit) { if (StackShadowPages.getValue() > 0) { - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; - final int frameSize = tasm.frameMap.totalFrameSize(); + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; + final int frameSize = crb.frameMap.totalFrameSize(); if (frameSize > 0) { int lastFramePage = frameSize / unsafe.pageSize(); // emit multiple stack bangs for methods with frames larger than a page @@ -93,7 +93,7 @@ if (afterFrameInit) { disp -= frameSize; } - tasm.blockComment("[stack overflow check]"); + crb.blockComment("[stack overflow check]"); // Use SPARCAddress to get the final displacement including the stack bias. SPARCAddress address = new SPARCAddress(sp, -disp); if (SPARCAssembler.isSimm13(address.getDisplacement())) { @@ -115,13 +115,17 @@ this.isStub = isStub; } - @Override - public void enter(TargetMethodAssembler tasm) { - final int frameSize = tasm.frameMap.totalFrameSize(); + public boolean hasFrame() { + return true; + } - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; + @Override + public void enter(CompilationResultBuilder crb) { + final int frameSize = crb.frameMap.totalFrameSize(); + + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; if (!isStub) { - emitStackOverflowCheck(tasm, false); + emitStackOverflowCheck(crb, false); } new Save(sp, -frameSize, sp).emit(masm); @@ -135,8 +139,8 @@ } @Override - public void leave(TargetMethodAssembler tasm) { - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; + public void leave(CompilationResultBuilder crb) { + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; new RestoreWindow().emit(masm); } } @@ -147,7 +151,7 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public CompilationResultBuilder newCompilationResultBuilder(LIRGenerator lirGen, CompilationResult compilationResult, CompilationResultBuilderFactory factory) { SPARCHotSpotLIRGenerator gen = (SPARCHotSpotLIRGenerator) lirGen; FrameMap frameMap = gen.frameMap; assert gen.deoptimizationRescueSlot == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame"; @@ -156,11 +160,11 @@ AbstractAssembler masm = createAssembler(frameMap); // On SPARC we always use stack frames. HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null); - TargetMethodAssembler tasm = new TargetMethodAssembler(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, frameContext, compilationResult); - tasm.setFrameSize(frameMap.frameSize()); + CompilationResultBuilder crb = factory.createBuilder(getProviders().getCodeCache(), getProviders().getForeignCalls(), frameMap, masm, frameContext, compilationResult); + crb.setFrameSize(frameMap.frameSize()); StackSlot deoptimizationRescueSlot = gen.deoptimizationRescueSlot; if (deoptimizationRescueSlot != null && stub == null) { - tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); + crb.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot)); } if (stub != null) { @@ -170,13 +174,13 @@ updateStub(stub, destroyedRegisters, calleeSaveInfo, frameMap); } - return tasm; + return crb; } @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { - SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm; - FrameMap frameMap = tasm.frameMap; + public void emitCode(CompilationResultBuilder crb, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { + SPARCMacroAssembler masm = (SPARCMacroAssembler) crb.asm; + FrameMap frameMap = crb.frameMap; RegisterConfig regConfig = frameMap.registerConfig; HotSpotVMConfig config = getRuntime().getConfig(); Label unverifiedStub = installedCodeOwner == null || isStatic(installedCodeOwner.getModifiers()) ? null : new Label(); @@ -184,7 +188,7 @@ // Emit the prefix if (unverifiedStub != null) { - tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY); + crb.recordMark(Marks.MARK_UNVERIFIED_ENTRY); // We need to use JavaCall here because we haven't entered the frame yet. CallingConvention cc = regConfig.getCallingConvention(JavaCall, null, new JavaType[]{getProviders().getMetaAccess().lookupJavaType(Object.class)}, getTarget(), false); Register inlineCacheKlass = g5; // see MacroAssembler::ic_call @@ -199,19 +203,19 @@ } masm.align(config.codeEntryAlignment); - tasm.recordMark(Marks.MARK_OSR_ENTRY); - tasm.recordMark(Marks.MARK_VERIFIED_ENTRY); + crb.recordMark(Marks.MARK_OSR_ENTRY); + crb.recordMark(Marks.MARK_VERIFIED_ENTRY); // Emit code for the LIR - lirGen.lir.emitCode(tasm); + lirGen.lir.emitCode(crb); - HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext; + HotSpotFrameContext frameContext = (HotSpotFrameContext) crb.frameContext; HotSpotForeignCallsProvider foreignCalls = getProviders().getForeignCalls(); - if (frameContext != null && !frameContext.isStub) { - tasm.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); - SPARCCall.directCall(tasm, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); - tasm.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); - SPARCCall.directCall(tasm, masm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); + if (!frameContext.isStub) { + crb.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY); + SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(EXCEPTION_HANDLER), null, false, null); + crb.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY); + SPARCCall.directCall(crb, masm, foreignCalls.lookupForeignCall(DEOPT_HANDLER), null, false, null); } else { // No need to emit the stubs for entries back into the method since // it has no calls that can cause such "return" entries @@ -221,7 +225,7 @@ if (unverifiedStub != null) { masm.bind(unverifiedStub); Register scratch = g3; - SPARCCall.indirectJmp(tasm, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER)); + SPARCCall.indirectJmp(crb, masm, scratch, foreignCalls.lookupForeignCall(IC_MISS_HANDLER)); } } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallEpilogueOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -49,7 +49,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // Restore the thread register when coming back from the runtime. new Mov(l7, thread).emit(masm);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotCRuntimeCallPrologueOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -47,7 +47,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // Save last Java frame. new Add(stackPointer, new SPARCAddress(stackPointer, 0).getDisplacement(), g4).emit(masm);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotDeoptimizeCallerOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -38,17 +38,17 @@ final class SPARCHotSpotDeoptimizeCallerOp extends SPARCHotSpotEpilogueOp { @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - leaveFrame(tasm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + leaveFrame(crb); // SPARCHotSpotBackend backend = (SPARCHotSpotBackend) // HotSpotGraalRuntime.runtime().getBackend(); // final boolean isStub = true; // HotSpotFrameContext frameContext = backend.new HotSpotFrameContext(isStub); - // frameContext.enter(tasm); + // frameContext.enter(crb); Register scratch = g3; - SPARCCall.indirectJmp(tasm, masm, scratch, tasm.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); + SPARCCall.indirectJmp(crb, masm, scratch, crb.foreignCalls.lookupForeignCall(UNCOMMON_TRAP)); - // frameContext.leave(tasm); + // frameContext.leave(crb); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotEpilogueOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -30,9 +30,7 @@ */ abstract class SPARCHotSpotEpilogueOp extends SPARCLIRInstruction { - protected void leaveFrame(TargetMethodAssembler tasm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); - } + protected void leaveFrame(CompilationResultBuilder crb) { + crb.frameContext.leave(crb); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotJumpToExceptionHandlerInCallerOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -60,8 +60,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - leaveFrame(tasm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + leaveFrame(crb); // Restore SP from L7 if the exception PC is a method handle call site. SPARCAddress dst = new SPARCAddress(thread, isMethodHandleReturnOffset);
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotPatchReturnAddressOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -45,10 +45,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // FIXME This is non-trivial. On SPARC we need to flush all register windows first before we // can patch the return address (see: frame::patch_pc). - // int frameSize = tasm.frameMap.frameSize(); + // int frameSize = crb.frameMap.frameSize(); // new Stx(asRegister(address), new SPARCAddress(sp, frameSize)); new Ldx(new SPARCAddress(g0, 0x123), g0).emit(masm); }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotReturnOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -48,12 +48,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - if (!isStub && (tasm.frameContext != null || !OptEliminateSafepoints.getValue())) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + if (!isStub && (crb.frameContext.hasFrame() || !OptEliminateSafepoints.getValue())) { // Using the same scratch register as LIR_Assembler::return_op // in c1_LIRAssembler_sparc.cpp - SPARCHotSpotSafepointOp.emitCode(tasm, masm, runtime().getConfig(), true, null, SPARC.l0); + SPARCHotSpotSafepointOp.emitCode(crb, masm, runtime().getConfig(), true, null, SPARC.l0); } - ReturnOp.emitCodeHelper(tasm, masm); + ReturnOp.emitCodeHelper(crb, masm); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotSafepointOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -53,17 +53,17 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { Register scratch = ((RegisterValue) temp).getRegister(); - emitCode(tasm, masm, config, false, state, scratch); + emitCode(crb, masm, config, false, state, scratch); } - public static void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { + public static void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm, HotSpotVMConfig config, boolean atReturn, LIRFrameState state, Register scratch) { final int pos = masm.codeBuffer.position(); new Setx(config.safepointPollingAddress, scratch).emit(masm); - tasm.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); + crb.recordMark(atReturn ? MARK_POLL_RETURN_NEAR : MARK_POLL_NEAR); if (state != null) { - tasm.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); + crb.recordInfopoint(pos, state, InfopointReason.SAFEPOINT); } new Ldx(new SPARCAddress(scratch, 0), g0).emit(masm); }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotUnwindOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -48,10 +48,10 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - leaveFrame(tasm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + leaveFrame(crb); - ForeignCallLinkage linkage = tasm.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); + ForeignCallLinkage linkage = crb.foreignCalls.lookupForeignCall(UNWIND_EXCEPTION_TO_CALLER); CallingConvention cc = linkage.getOutgoingCallingConvention(); assert cc.getArgumentCount() == 2; assert exception.equals(cc.getArgument(0)); @@ -61,6 +61,6 @@ new Mov(o7, returnAddress).emit(masm); Register scratch = g5; - SPARCCall.indirectJmp(tasm, masm, scratch, linkage); + SPARCCall.indirectJmp(crb, masm, scratch, linkage); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectStaticCallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -54,13 +54,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - SPARCMove.move(tasm, masm, g5.asValue(Kind.Long), metaspaceMethod); - tasm.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); - // SPARCMove.move(tasm, masm, g3.asValue(Kind.Long), Constant.LONG_0); + SPARCMove.move(crb, masm, g5.asValue(Kind.Long), metaspaceMethod); + crb.recordMark(invokeKind == InvokeKind.Static ? Marks.MARK_INVOKESTATIC : Marks.MARK_INVOKESPECIAL); + // SPARCMove.move(crb, masm, g3.asValue(Kind.Long), Constant.LONG_0); new Setx(nonOopBits, g3, true).emit(masm); - super.emitCode(tasm, masm); + super.emitCode(crb, masm); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotspotDirectVirtualCallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -51,11 +51,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { // The mark for an invocation that uses an inline cache must be placed at the // instruction that loads the Klass from the inline cache. - tasm.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); + crb.recordMark(invokeKind == Virtual ? Marks.MARK_INVOKEVIRTUAL : Marks.MARK_INVOKEINTERFACE); new Setx(HotSpotGraalRuntime.runtime().getConfig().nonOopBits, g3, true).emit(masm); - super.emitCode(tasm, masm); + super.emitCode(crb, masm); } }
--- a/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCIndirectCallOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -57,11 +57,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - tasm.recordMark(Marks.MARK_INLINE_INVOKE); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + crb.recordMark(Marks.MARK_INLINE_INVOKE); Register callReg = asRegister(targetAddress); assert !callReg.equals(METHOD); - SPARCCall.indirectCall(tasm, masm, callReg, callTarget, state); + SPARCCall.indirectCall(crb, masm, callReg, callTarget, state); } @Override
--- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot.test; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.nodes.ConstantNode.*; import static com.oracle.graal.phases.GraalOptions.*; @@ -32,11 +33,11 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.graph.iterators.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.extended.*; import com.oracle.graal.options.*; @@ -207,8 +208,8 @@ CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); // create suites everytime, as we modify options for the compiler final Suites suitesLocal = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites().createSuites(); - final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, - new SpeculationLog(), suitesLocal, new CompilationResult()); + final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, + getProfilingInfo(graph), new SpeculationLog(), suitesLocal, true, new CompilationResult(), CompilationResultBuilderFactory.Default); addMethod(method, compResult); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.hotspot; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.nodes.StructuredGraph.*; import static com.oracle.graal.phases.GraalOptions.*; import static com.oracle.graal.phases.common.InliningUtil.*; @@ -35,12 +36,12 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.CompilerThreadFactory.CompilerThread; -import com.oracle.graal.compiler.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.internal.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; @@ -164,8 +165,8 @@ InlinedBytecodes.add(method.getCodeSize()); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Suites suites = providers.getSuites().getDefaultSuites(); - result = GraalCompiler.compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, plan, optimisticOpts, profilingInfo, method.getSpeculationLog(), suites, - new CompilationResult()); + result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, plan, optimisticOpts, profilingInfo, method.getSpeculationLog(), suites, true, + new CompilationResult(), CompilationResultBuilderFactory.Default); } catch (Throwable e) { throw Debug.handle(e); @@ -235,12 +236,6 @@ HotSpotInstalledCode installedCode = null; try (Scope s = Debug.scope("CodeInstall", new DebugDumpScope(String.valueOf(id), true), codeCache, method)) { installedCode = codeCache.installMethod(method, entryBCI, compResult); - if (Debug.isDumpEnabled()) { - Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); - } - if (Debug.isLogEnabled()) { - Debug.log("%s", backend.getProviders().getDisassembler().disassemble(installedCode)); - } } catch (Throwable e) { throw Debug.handle(e); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Tue Dec 03 18:40:03 2013 +0100 @@ -32,6 +32,7 @@ import com.oracle.graal.api.code.CompilationResult.Infopoint; import com.oracle.graal.api.code.CompilationResult.Mark; import com.oracle.graal.api.meta.*; +import com.oracle.graal.debug.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.bridge.CompilerToVM.CodeInstallResult; @@ -157,10 +158,20 @@ return runtime.getConfig().runtimeCallStackSize; } + public HotSpotInstalledCode logOrDump(HotSpotInstalledCode installedCode, CompilationResult compResult) { + if (Debug.isDumpEnabled()) { + Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); + } + if (Debug.isLogEnabled()) { + Debug.log("%s", disassemble(installedCode)); + } + return installedCode; + } + public HotSpotInstalledCode installMethod(HotSpotResolvedJavaMethod method, int entryBCI, CompilationResult compResult) { HotSpotInstalledCode installedCode = new HotSpotNmethod(method, compResult.getName(), true); runtime.getCompilerToVM().installCode(new HotSpotCompiledNmethod(method, entryBCI, compResult), installedCode, method.getSpeculationLog()); - return installedCode; + return logOrDump(installedCode, compResult); } @Override @@ -171,7 +182,7 @@ if (result != CodeInstallResult.OK) { return null; } - return code; + return logOrDump(code, compResult); } public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) { @@ -180,7 +191,6 @@ } public InstalledCode addExternalMethod(ResolvedJavaMethod method, CompilationResult compResult) { - HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) method; HotSpotInstalledCode icode = new HotSpotNmethod(javaMethod, compResult.getName(), false, true); HotSpotCompiledNmethod compiled = new HotSpotCompiledNmethod(javaMethod, -1, compResult);
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue Dec 03 18:40:03 2013 +0100 @@ -22,13 +22,13 @@ */ package com.oracle.graal.hotspot.stubs; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.hotspot.HotSpotGraalRuntime.*; import java.util.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; @@ -39,6 +39,7 @@ import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; @@ -151,24 +152,20 @@ phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); // The stub itself needs the incoming calling convention. CallingConvention incomingCc = linkage.getIncomingCallingConvention(); - final CompilationResult compResult = GraalCompiler.compileGraph(graph, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null, phasePlan, - OptimisticOptimizations.ALL, new SpeculationLog(), providers.getSuites().getDefaultSuites(), new CompilationResult()); + final CompilationResult compResult = compileGraph(graph, incomingCc, getInstalledCodeOwner(), providers, backend, codeCache.getTarget(), null, phasePlan, OptimisticOptimizations.ALL, + getProfilingInfo(graph), new SpeculationLog(), providers.getSuites().getDefaultSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); assert destroyedRegisters != null; try (Scope s = Debug.scope("CodeInstall")) { Stub stub = Stub.this; HotSpotRuntimeStub installedCode = new HotSpotRuntimeStub(stub); HotSpotCompiledCode hsCompResult = new HotSpotCompiledRuntimeStub(stub, compResult); + CodeInstallResult result = runtime().getCompilerToVM().installCode(hsCompResult, installedCode, null); if (result != CodeInstallResult.OK) { throw new GraalInternalError("Error installing stub %s: %s", Stub.this, result); } - if (Debug.isDumpEnabled()) { - Debug.dump(new Object[]{compResult, installedCode}, "After code installation"); - } - if (Debug.isLogEnabled()) { - Debug.log("%s", providers.getDisassembler().disassemble(installedCode)); - } + ((HotSpotCodeCacheProvider) codeCache).logOrDump(installedCode, compResult); code = installedCode; } catch (Throwable e) { throw Debug.handle(e);
--- a/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.java.decompiler.test/src/com/oracle/graal/java/decompiler/test/TestUtil.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,14 +23,15 @@ package com.oracle.graal.java.decompiler.test; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.PhasePlan.PhasePosition; @@ -53,7 +54,7 @@ GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(metaAccess, foreignCalls, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); - GraalCompiler.compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, - new CompilationResult()); + compileGraph(graph, cc, method, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, getProfilingInfo(graph), new SpeculationLog(), suites, + true, new CompilationResult(), CompilationResultBuilderFactory.Default); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Arithmetic.java Tue Dec 03 18:40:03 2013 +0100 @@ -74,8 +74,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -95,9 +95,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result); } } @@ -120,9 +120,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -152,9 +152,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -183,9 +183,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -214,12 +214,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (sameRegister(result, y)) { - emit(tasm, masm, opcode, result, x, null); + emit(crb, masm, opcode, result, x, null); } else { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } } @@ -248,9 +248,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } @Override @@ -279,8 +279,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, opcode, null, y, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, null, y, state); } @Override @@ -312,7 +312,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { AMD64Address tmp = new AMD64Address(AMD64.rsp); masm.subq(AMD64.rsp, 8); if (opcode == FREM) { @@ -356,7 +356,7 @@ } @SuppressWarnings("unused") - protected static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AMD64Arithmetic opcode, AllocatableValue result) { + protected static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Arithmetic opcode, AllocatableValue result) { switch (opcode) { case INEG: masm.negl(asIntReg(result)); @@ -381,7 +381,7 @@ } } - public static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AMD64Arithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Arithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; if (isRegister(src)) { switch (opcode) { @@ -584,103 +584,103 @@ } else if (isConstant(src)) { switch (opcode) { case IADD: - masm.incrementl(asIntReg(dst), tasm.asIntConst(src)); + masm.incrementl(asIntReg(dst), crb.asIntConst(src)); break; case ISUB: - masm.decrementl(asIntReg(dst), tasm.asIntConst(src)); + masm.decrementl(asIntReg(dst), crb.asIntConst(src)); break; case IMUL: - masm.imull(asIntReg(dst), asIntReg(dst), tasm.asIntConst(src)); + masm.imull(asIntReg(dst), asIntReg(dst), crb.asIntConst(src)); break; case IAND: - masm.andl(asIntReg(dst), tasm.asIntConst(src)); + masm.andl(asIntReg(dst), crb.asIntConst(src)); break; case IOR: - masm.orl(asIntReg(dst), tasm.asIntConst(src)); + masm.orl(asIntReg(dst), crb.asIntConst(src)); break; case IXOR: - masm.xorl(asIntReg(dst), tasm.asIntConst(src)); + masm.xorl(asIntReg(dst), crb.asIntConst(src)); break; case ISHL: - masm.shll(asIntReg(dst), tasm.asIntConst(src) & 31); + masm.shll(asIntReg(dst), crb.asIntConst(src) & 31); break; case ISHR: - masm.sarl(asIntReg(dst), tasm.asIntConst(src) & 31); + masm.sarl(asIntReg(dst), crb.asIntConst(src) & 31); break; case IUSHR: - masm.shrl(asIntReg(dst), tasm.asIntConst(src) & 31); + masm.shrl(asIntReg(dst), crb.asIntConst(src) & 31); break; case LADD: - masm.addq(asLongReg(dst), tasm.asIntConst(src)); + masm.addq(asLongReg(dst), crb.asIntConst(src)); break; case LSUB: - masm.subq(asLongReg(dst), tasm.asIntConst(src)); + masm.subq(asLongReg(dst), crb.asIntConst(src)); break; case LMUL: - masm.imulq(asLongReg(dst), asLongReg(dst), tasm.asIntConst(src)); + masm.imulq(asLongReg(dst), asLongReg(dst), crb.asIntConst(src)); break; case LAND: - masm.andq(asLongReg(dst), tasm.asIntConst(src)); + masm.andq(asLongReg(dst), crb.asIntConst(src)); break; case LOR: - masm.orq(asLongReg(dst), tasm.asIntConst(src)); + masm.orq(asLongReg(dst), crb.asIntConst(src)); break; case LXOR: - masm.xorq(asLongReg(dst), tasm.asIntConst(src)); + masm.xorq(asLongReg(dst), crb.asIntConst(src)); break; case LSHL: - masm.shlq(asLongReg(dst), tasm.asIntConst(src) & 63); + masm.shlq(asLongReg(dst), crb.asIntConst(src) & 63); break; case LSHR: - masm.sarq(asLongReg(dst), tasm.asIntConst(src) & 63); + masm.sarq(asLongReg(dst), crb.asIntConst(src) & 63); break; case LUSHR: - masm.shrq(asLongReg(dst), tasm.asIntConst(src) & 63); + masm.shrq(asLongReg(dst), crb.asIntConst(src) & 63); break; case FADD: - masm.addss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.addss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case FSUB: - masm.subss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.subss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case FMUL: - masm.mulss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.mulss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case FAND: - masm.andps(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src, 16)); + masm.andps(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src, 16)); break; case FOR: - masm.orps(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src, 16)); + masm.orps(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src, 16)); break; case FXOR: - masm.xorps(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src, 16)); + masm.xorps(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src, 16)); break; case FDIV: - masm.divss(asFloatReg(dst), (AMD64Address) tasm.asFloatConstRef(src)); + masm.divss(asFloatReg(dst), (AMD64Address) crb.asFloatConstRef(src)); break; case DADD: - masm.addsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.addsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DSUB: - masm.subsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.subsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DMUL: - masm.mulsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.mulsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DDIV: - masm.divsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src)); + masm.divsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src)); break; case DAND: - masm.andpd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src, 16)); + masm.andpd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src, 16)); break; case DOR: - masm.orpd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src, 16)); + masm.orpd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src, 16)); break; case DXOR: - masm.xorpd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleConstRef(src, 16)); + masm.xorpd(asDoubleReg(dst), (AMD64Address) crb.asDoubleConstRef(src, 16)); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -688,123 +688,123 @@ } else { switch (opcode) { case IADD: - masm.addl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.addl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case ISUB: - masm.subl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.subl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IAND: - masm.andl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.andl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IMUL: - masm.imull(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.imull(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IOR: - masm.orl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.orl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case IXOR: - masm.xorl(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.xorl(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case LADD: - masm.addq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.addq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LSUB: - masm.subq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.subq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LMUL: - masm.imulq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.imulq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LAND: - masm.andq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.andq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LOR: - masm.orq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.orq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case LXOR: - masm.xorq(asLongReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.xorq(asLongReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case FADD: - masm.addss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.addss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case FSUB: - masm.subss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.subss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case FMUL: - masm.mulss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.mulss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case FDIV: - masm.divss(asFloatReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.divss(asFloatReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case DADD: - masm.addsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.addsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case DSUB: - masm.subsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.subsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case DMUL: - masm.mulsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.mulsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case DDIV: - masm.divsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.divsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case SQRT: - masm.sqrtsd(asDoubleReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.sqrtsd(asDoubleReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case I2B: - masm.movsxb(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movsxb(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case I2S: - masm.movsxw(asIntReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movsxw(asIntReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case I2L: - masm.movslq(asLongReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movslq(asLongReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case F2D: - masm.cvtss2sd(asDoubleReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.cvtss2sd(asDoubleReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case D2F: - masm.cvtsd2ss(asFloatReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.cvtsd2ss(asFloatReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case I2F: - masm.cvtsi2ssl(asFloatReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.cvtsi2ssl(asFloatReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case I2D: - masm.cvtsi2sdl(asDoubleReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.cvtsi2sdl(asDoubleReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case L2F: - masm.cvtsi2ssq(asFloatReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.cvtsi2ssq(asFloatReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case L2D: - masm.cvtsi2sdq(asDoubleReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.cvtsi2sdq(asDoubleReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case F2I: - masm.cvttss2sil(asIntReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.cvttss2sil(asIntReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case D2I: - masm.cvttsd2sil(asIntReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.cvttsd2sil(asIntReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case F2L: - masm.cvttss2siq(asLongReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.cvttss2siq(asLongReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case D2L: - masm.cvttsd2siq(asLongReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.cvttsd2siq(asLongReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; case MOV_I2F: - masm.movss(asFloatReg(dst), (AMD64Address) tasm.asIntAddr(src)); + masm.movss(asFloatReg(dst), (AMD64Address) crb.asIntAddr(src)); break; case MOV_L2D: - masm.movsd(asDoubleReg(dst), (AMD64Address) tasm.asLongAddr(src)); + masm.movsd(asDoubleReg(dst), (AMD64Address) crb.asLongAddr(src)); break; case MOV_F2I: - masm.movl(asIntReg(dst), (AMD64Address) tasm.asFloatAddr(src)); + masm.movl(asIntReg(dst), (AMD64Address) crb.asFloatAddr(src)); break; case MOV_D2L: - masm.movq(asLongReg(dst), (AMD64Address) tasm.asDoubleAddr(src)); + masm.movq(asLongReg(dst), (AMD64Address) crb.asDoubleAddr(src)); break; default: @@ -814,7 +814,7 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BitManipulationOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -45,7 +45,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { Register dst = ValueUtil.asIntReg(result); if (ValueUtil.isRegister(input)) { Register src = ValueUtil.asRegister(input); @@ -67,7 +67,7 @@ break; } } else { - AMD64Address src = (AMD64Address) tasm.asAddress(input); + AMD64Address src = (AMD64Address) crb.asAddress(input); switch (opcode) { case IPOPCNT: masm.popcntl(dst, src);
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BreakpointOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64BreakpointOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -45,7 +45,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler asm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler asm) { asm.int3(); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ByteSwapOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ByteSwapOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -40,8 +40,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - AMD64Move.move(tasm, masm, result, input); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + AMD64Move.move(crb, masm, result, input); switch (input.getKind()) { case Int: masm.bswapl(ValueUtil.asIntReg(result));
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Call.java Tue Dec 03 18:40:03 2013 +0100 @@ -75,8 +75,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - directCall(tasm, masm, callTarget, null, true, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + directCall(crb, masm, callTarget, null, true, state); } } @@ -91,8 +91,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - indirectCall(tasm, masm, asRegister(targetAddress), callTarget, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + indirectCall(crb, masm, asRegister(targetAddress), callTarget, state); } @Override @@ -125,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - directCall(tasm, masm, callTarget, null, false, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + directCall(crb, masm, callTarget, null, false, state); } } @@ -146,14 +146,14 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - directCall(tasm, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + directCall(crb, masm, callTarget, ((RegisterValue) callTemp).getRegister(), false, state); } } - public static void directCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { + public static void directCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { if (align) { - emitAlignmentForDirectCall(tasm, masm); + emitAlignmentForDirectCall(crb, masm); } int before = masm.codeBuffer.position(); if (scratch != null) { @@ -165,43 +165,43 @@ masm.call(); } int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordDirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); masm.ensureUniquePC(); } - protected static void emitAlignmentForDirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + protected static void emitAlignmentForDirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm) { // make sure that the displacement word of the call ends up word aligned int offset = masm.codeBuffer.position(); - offset += tasm.target.arch.getMachineCodeCallDisplacementOffset(); - int modulus = tasm.target.wordSize; + offset += crb.target.arch.getMachineCodeCallDisplacementOffset(); + int modulus = crb.target.wordSize; if (offset % modulus != 0) { masm.nop(modulus - offset % modulus); } } - public static void directJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target) { + public static void directJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target) { int before = masm.codeBuffer.position(); masm.jmp(0, true); int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, target, null); + crb.recordDirectCall(before, after, target, null); masm.ensureUniquePC(); } - public static void directConditionalJmp(TargetMethodAssembler tasm, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) { + public static void directConditionalJmp(CompilationResultBuilder crb, AMD64MacroAssembler masm, InvokeTarget target, ConditionFlag cond) { int before = masm.codeBuffer.position(); masm.jcc(cond, 0, true); int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, target, null); + crb.recordDirectCall(before, after, target, null); masm.ensureUniquePC(); } - public static void indirectCall(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { + public static void indirectCall(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { int before = masm.codeBuffer.position(); masm.call(dst); int after = masm.codeBuffer.position(); - tasm.recordIndirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordIndirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); masm.ensureUniquePC(); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Compare.java Tue Dec 03 18:40:03 2013 +0100 @@ -47,8 +47,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, opcode, x, y); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, opcode, x, y); } @Override @@ -62,7 +62,7 @@ } } - public static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AMD64Compare opcode, Value x, Value y) { + public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, AMD64Compare opcode, Value x, Value y) { if (isRegister(y)) { switch (opcode) { case ICMP: masm.cmpl(asIntReg(x), asIntReg(y)); break; @@ -74,25 +74,25 @@ } } else if (isConstant(y)) { switch (opcode) { - case ICMP: masm.cmpl(asIntReg(x), tasm.asIntConst(y)); break; - case LCMP: masm.cmpq(asLongReg(x), tasm.asIntConst(y)); break; + case ICMP: masm.cmpl(asIntReg(x), crb.asIntConst(y)); break; + case LCMP: masm.cmpq(asLongReg(x), crb.asIntConst(y)); break; case ACMP: if (((Constant) y).isNull()) { masm.cmpq(asObjectReg(x), 0); break; } else { throw GraalInternalError.shouldNotReachHere("Only null object constants are allowed in comparisons"); } - case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) tasm.asFloatConstRef(y)); break; - case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) tasm.asDoubleConstRef(y)); break; + case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) crb.asFloatConstRef(y)); break; + case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) crb.asDoubleConstRef(y)); break; default: throw GraalInternalError.shouldNotReachHere(); } } else { switch (opcode) { - case ICMP: masm.cmpl(asIntReg(x), (AMD64Address) tasm.asIntAddr(y)); break; - case LCMP: masm.cmpq(asLongReg(x), (AMD64Address) tasm.asLongAddr(y)); break; - case ACMP: masm.cmpptr(asObjectReg(x), (AMD64Address) tasm.asObjectAddr(y)); break; - case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) tasm.asFloatAddr(y)); break; - case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) tasm.asDoubleAddr(y)); break; + case ICMP: masm.cmpl(asIntReg(x), (AMD64Address) crb.asIntAddr(y)); break; + case LCMP: masm.cmpq(asLongReg(x), (AMD64Address) crb.asLongAddr(y)); break; + case ACMP: masm.cmpptr(asObjectReg(x), (AMD64Address) crb.asObjectAddr(y)); break; + case FCMP: masm.ucomiss(asFloatReg(x), (AMD64Address) crb.asFloatAddr(y)); break; + case DCMP: masm.ucomisd(asDoubleReg(x), (AMD64Address) crb.asDoubleAddr(y)); break; default: throw GraalInternalError.shouldNotReachHere(); } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ControlFlow.java Tue Dec 03 18:40:03 2013 +0100 @@ -50,10 +50,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); - } + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + crb.frameContext.leave(crb); masm.ret(0); } } @@ -73,7 +71,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.jcc(condition, destination.label()); } @@ -99,7 +97,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { floatJcc(masm, condition, unorderedIsTrue, destination.label()); } @@ -127,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + tableswitch(crb, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); } } @@ -149,12 +147,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (key.getKind() == Kind.Int) { Register intKey = asIntReg(key); for (int i = 0; i < keyConstants.length; i++) { - if (tasm.codeCache.needsDataPatch(keyConstants[i])) { - tasm.recordDataReferenceInCode(keyConstants[i], 0, true); + if (crb.codeCache.needsDataPatch(keyConstants[i])) { + crb.recordDataReferenceInCode(keyConstants[i], 0, true); } long lc = keyConstants[i].asLong(); assert NumUtil.isInt(lc); @@ -164,14 +162,14 @@ } else if (key.getKind() == Kind.Long) { Register longKey = asLongReg(key); for (int i = 0; i < keyConstants.length; i++) { - masm.cmpq(longKey, (AMD64Address) tasm.asLongConstRef(keyConstants[i])); + masm.cmpq(longKey, (AMD64Address) crb.asLongConstRef(keyConstants[i])); masm.jcc(ConditionFlag.Equal, keyTargets[i].label()); } } else if (key.getKind() == Kind.Object) { Register objectKey = asObjectReg(key); Register temp = asObjectReg(scratch); for (int i = 0; i < keyConstants.length; i++) { - AMD64Move.move(tasm, masm, temp.asValue(Kind.Object), keyConstants[i]); + AMD64Move.move(crb, masm, temp.asValue(Kind.Object), keyConstants[i]); masm.cmpptr(objectKey, temp); masm.jcc(ConditionFlag.Equal, keyTargets[i].label()); } @@ -212,7 +210,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { assert isSorted(lowKeys) && isSorted(highKeys); Label actualDefaultTarget = defaultTarget == null ? new Label() : defaultTarget.label(); @@ -288,8 +286,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - cmove(tasm, masm, result, false, condition, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + cmove(crb, masm, result, false, condition, false, trueValue, falseValue); } } @@ -311,12 +309,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); } } - private static void tableswitch(TargetMethodAssembler tasm, AMD64MacroAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { + private static void tableswitch(CompilationResultBuilder crb, AMD64MacroAssembler 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; @@ -371,7 +369,7 @@ } JumpTable jt = new JumpTable(jumpTablePos, lowKey, highKey, 4); - tasm.compilationResult.addAnnotation(jt); + crb.compilationResult.addAnnotation(jt); } private static void floatJcc(AMD64MacroAssembler masm, ConditionFlag condition, boolean unorderedIsTrue, Label label) { @@ -385,23 +383,23 @@ masm.bind(endLabel); } - private static void cmove(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + private static void cmove(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); - AMD64Move.move(tasm, masm, result, falseValue); - cmove(tasm, masm, result, condition, trueValue); + AMD64Move.move(crb, masm, result, falseValue); + cmove(crb, masm, result, condition, trueValue); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { - cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + cmove(crb, masm, result, ConditionFlag.Parity, trueValue); } else if (!unorderedIsTrue && trueOnUnordered(condition)) { - cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + cmove(crb, masm, result, ConditionFlag.Parity, falseValue); } } } - private static void cmove(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, ConditionFlag cond, Value other) { + private static void cmove(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, ConditionFlag cond, Value other) { if (isRegister(other)) { assert !asRegister(other).equals(asRegister(result)) : "other already overwritten by previous move"; switch (other.getKind()) { @@ -410,7 +408,7 @@ default: throw GraalInternalError.shouldNotReachHere(); } } else { - AMD64Address addr = (AMD64Address) tasm.asAddress(other); + AMD64Address addr = (AMD64Address) crb.asAddress(other); switch (other.getKind()) { case Int: masm.cmovl(cond, asRegister(result), addr); break; case Long: masm.cmovq(cond, asRegister(result), addr); break;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64LIRInstruction.java Tue Dec 03 18:40:03 2013 +0100 @@ -32,9 +32,9 @@ public abstract class AMD64LIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (AMD64MacroAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (AMD64MacroAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm); }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64MathIntrinsicOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -48,7 +48,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { switch (opcode) { case LOG: masm.flog(asDoubleReg(result), asDoubleReg(input), false); break; case LOG10: masm.flog(asDoubleReg(result), asDoubleReg(input), true); break;
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64Move.java Tue Dec 03 18:40:03 2013 +0100 @@ -53,8 +53,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -80,8 +80,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -110,9 +110,9 @@ protected abstract void emitMemAccess(AMD64MacroAssembler masm); @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { if (state != null) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + crb.recordImplicitException(masm.codeBuffer.position(), state); } emitMemAccess(masm); } @@ -270,7 +270,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.leaq(asLongReg(result), address.toAddress()); } } @@ -286,8 +286,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - masm.leaq(asLongReg(result), (AMD64Address) tasm.asAddress(slot)); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + masm.leaq(asLongReg(result), (AMD64Address) crb.asAddress(slot)); } } @@ -300,7 +300,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { masm.membar(barriers); } } @@ -316,8 +316,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + crb.recordImplicitException(masm.codeBuffer.position(), state); masm.nullCheck(asRegister(input)); } @@ -346,31 +346,31 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - compareAndSwap(tasm, masm, result, address, cmpValue, newValue); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + compareAndSwap(crb, masm, result, address, cmpValue, newValue); } } - public static void move(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { reg2reg(masm, result, input); } else if (isStackSlot(result)) { - reg2stack(tasm, masm, result, input); + reg2stack(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isStackSlot(input)) { if (isRegister(result)) { - stack2reg(tasm, masm, result, input); + stack2reg(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isConstant(input)) { if (isRegister(result)) { - const2reg(tasm, masm, result, (Constant) input); + const2reg(crb, masm, result, (Constant) input); } else if (isStackSlot(result)) { - const2stack(tasm, masm, result, (Constant) input); + const2stack(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -404,8 +404,8 @@ } } - private static void reg2stack(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Value input) { - AMD64Address dest = (AMD64Address) tasm.asAddress(result); + private static void reg2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + AMD64Address dest = (AMD64Address) crb.asAddress(result); switch (input.getKind()) { case Int: masm.movl(dest, asRegister(input)); @@ -427,8 +427,8 @@ } } - private static void stack2reg(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Value input) { - AMD64Address src = (AMD64Address) tasm.asAddress(input); + private static void stack2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Value input) { + AMD64Address src = (AMD64Address) crb.asAddress(input); switch (input.getKind()) { case Int: masm.movl(asRegister(result), src); @@ -450,7 +450,7 @@ } } - private static void const2reg(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Constant input) { + private static void const2reg(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Constant input) { /* * Note: we use the kind of the input operand (and not the kind of the result operand) * because they don't match in all cases. For example, an object constant can be loaded to a @@ -459,8 +459,8 @@ */ switch (input.getKind().getStackKind()) { case Int: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); } // Do not optimize with an XOR as this instruction may be between // a CMP and a Jcc in which case the XOR will modify the condition @@ -469,8 +469,8 @@ break; case Long: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); } // Do not optimize with an XOR as this instruction may be between // a CMP and a Jcc in which case the XOR will modify the condition @@ -480,19 +480,19 @@ case Float: // This is *not* the same as 'constant == 0.0f' in the case where constant is -0.0f if (Float.floatToRawIntBits(input.asFloat()) == Float.floatToRawIntBits(0.0f)) { - assert !tasm.codeCache.needsDataPatch(input); + assert !crb.codeCache.needsDataPatch(input); masm.xorps(asFloatReg(result), asFloatReg(result)); } else { - masm.movflt(asFloatReg(result), (AMD64Address) tasm.asFloatConstRef(input)); + masm.movflt(asFloatReg(result), (AMD64Address) crb.asFloatConstRef(input)); } break; case Double: // This is *not* the same as 'constant == 0.0d' in the case where constant is -0.0d if (Double.doubleToRawLongBits(input.asDouble()) == Double.doubleToRawLongBits(0.0d)) { - assert !tasm.codeCache.needsDataPatch(input); + assert !crb.codeCache.needsDataPatch(input); masm.xorpd(asDoubleReg(result), asDoubleReg(result)); } else { - masm.movdbl(asDoubleReg(result), (AMD64Address) tasm.asDoubleConstRef(input)); + masm.movdbl(asDoubleReg(result), (AMD64Address) crb.asDoubleConstRef(input)); } break; case Object: @@ -501,11 +501,11 @@ // flags and interfere with the Jcc. if (input.isNull()) { masm.movq(asRegister(result), 0x0L); - } else if (tasm.target.inlineObjects) { - tasm.recordDataReferenceInCode(input, 0, true); + } else if (crb.target.inlineObjects) { + crb.recordDataReferenceInCode(input, 0, true); masm.movq(asRegister(result), 0xDEADDEADDEADDEADL); } else { - masm.movq(asRegister(result), (AMD64Address) tasm.recordDataReferenceInCode(input, 0, false)); + masm.movq(asRegister(result), (AMD64Address) crb.recordDataReferenceInCode(input, 0, false)); } break; default: @@ -513,9 +513,9 @@ } } - private static void const2stack(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value result, Constant input) { - assert !tasm.codeCache.needsDataPatch(input); - AMD64Address dest = (AMD64Address) tasm.asAddress(result); + private static void const2stack(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value result, Constant input) { + assert !crb.codeCache.needsDataPatch(input); + AMD64Address dest = (AMD64Address) crb.asAddress(result); switch (input.getKind().getStackKind()) { case Int: masm.movl(dest, input.asInt()); @@ -541,10 +541,10 @@ } } - protected static void compareAndSwap(TargetMethodAssembler tasm, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { + protected static void compareAndSwap(CompilationResultBuilder crb, AMD64MacroAssembler masm, AllocatableValue result, AMD64AddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { assert asRegister(cmpValue).equals(AMD64.rax) && asRegister(result).equals(AMD64.rax); - if (tasm.target.isMP) { + if (crb.target.isMP) { masm.lock(); } switch (cmpValue.getKind()) {
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64RestoreRegistersOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -54,17 +54,17 @@ return save.savedRegisters; } - protected void restoreRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Register register, StackSlot input) { + protected void restoreRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, Register register, StackSlot input) { RegisterValue result = register.asValue(input.getKind()); - AMD64Move.move(tasm, masm, result, input); + AMD64Move.move(crb, masm, result, input); } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { Register[] savedRegisters = getSavedRegisters(); for (int i = 0; i < savedRegisters.length; i++) { if (savedRegisters[i] != null) { - restoreRegister(tasm, masm, savedRegisters[i], slots[i]); + restoreRegister(crb, masm, savedRegisters[i], slots[i]); } } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64SaveRegistersOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -66,16 +66,16 @@ this.supportsRemove = supportsRemove; } - protected void saveRegister(TargetMethodAssembler tasm, AMD64MacroAssembler masm, StackSlot result, Register register) { + protected void saveRegister(CompilationResultBuilder crb, AMD64MacroAssembler masm, StackSlot result, Register register) { RegisterValue input = register.asValue(result.getKind()); - AMD64Move.move(tasm, masm, result, input); + AMD64Move.move(crb, masm, result, input); } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { for (int i = 0; i < savedRegisters.length; i++) { if (savedRegisters[i] != null) { - saveRegister(tasm, masm, slots[i], savedRegisters[i]); + saveRegister(crb, masm, slots[i], savedRegisters[i]); } } }
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64TestOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -41,8 +41,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { - emit(tasm, masm, x, y); + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { + emit(crb, masm, x, y); } @Override @@ -51,7 +51,7 @@ assert (x.getKind() == Kind.Int && y.getKind().getStackKind() == Kind.Int) || (x.getKind() == Kind.Long && y.getKind() == Kind.Long) : x + " " + y; } - public static void emit(TargetMethodAssembler tasm, AMD64MacroAssembler masm, Value x, Value y) { + public static void emit(CompilationResultBuilder crb, AMD64MacroAssembler masm, Value x, Value y) { if (isRegister(y)) { switch (x.getKind()) { case Int: @@ -66,10 +66,10 @@ } else if (isConstant(y)) { switch (x.getKind()) { case Int: - masm.testl(asIntReg(x), tasm.asIntConst(y)); + masm.testl(asIntReg(x), crb.asIntConst(y)); break; case Long: - masm.testq(asLongReg(x), tasm.asIntConst(y)); + masm.testq(asLongReg(x), crb.asIntConst(y)); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -77,10 +77,10 @@ } else { switch (x.getKind()) { case Int: - masm.testl(asIntReg(x), (AMD64Address) tasm.asIntAddr(y)); + masm.testl(asIntReg(x), (AMD64Address) crb.asIntAddr(y)); break; case Long: - masm.testq(asLongReg(x), (AMD64Address) tasm.asLongAddr(y)); + masm.testq(asLongReg(x), (AMD64Address) crb.asLongAddr(y)); break; default: throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.amd64/src/com/oracle/graal/lir/amd64/AMD64ZapRegistersOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -56,11 +56,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, AMD64MacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) { for (int i = 0; i < zappedRegisters.length; i++) { if (zappedRegisters[i] != null) { RegisterValue registerValue = zappedRegisters[i].asValue(zapValues[i].getPlatformKind()); - AMD64Move.move(tasm, masm, registerValue, zapValues[i]); + AMD64Move.move(crb, masm, registerValue, zapValues[i]); } } }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILArithmetic.java Tue Dec 03 18:40:03 2013 +0100 @@ -114,7 +114,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitConvert(result, x, to, from); } } @@ -131,8 +131,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -150,8 +150,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -173,8 +173,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -192,8 +192,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -217,7 +217,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { throw GraalInternalError.shouldNotReachHere(); } @@ -242,8 +242,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -270,8 +270,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, opcode, result, y, state); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, opcode, result, y, state); } @Override @@ -282,14 +282,14 @@ } @SuppressWarnings("unused") - protected static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value result) { + protected static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value result) { switch (opcode) { default: throw GraalInternalError.shouldNotReachHere(); } } - public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; if (isRegister(src)) { switch (opcode) { @@ -322,11 +322,11 @@ } if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } - public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, HSAILArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { /** * First check if one of src1 or src2 is an AddressValue. If it is, convert the address to a * register using an lda instruction. We can just reuse the eventual dst register for this. @@ -334,12 +334,12 @@ if (src1 instanceof HSAILAddressValue) { assert (!(src2 instanceof HSAILAddressValue)); masm.emitLda(dst, ((HSAILAddressValue) src1).toAddress()); - emit(tasm, masm, opcode, dst, dst, src2, info); + emit(crb, masm, opcode, dst, dst, src2, info); return; } else if (src2 instanceof HSAILAddressValue) { assert (!(src1 instanceof HSAILAddressValue)); masm.emitLda(dst, ((HSAILAddressValue) src2).toAddress()); - emit(tasm, masm, opcode, dst, src1, dst, info); + emit(crb, masm, opcode, dst, src1, dst, info); return; } int exceptionOffset = -1; @@ -411,7 +411,7 @@ } if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILBitManipulationOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -48,7 +48,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { switch (opcode) { case IPOPCNT: throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILCompare.java Tue Dec 03 18:40:03 2013 +0100 @@ -54,8 +54,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + emit(crb, masm, condition, x, y, z, unordered); } @Override @@ -67,7 +67,7 @@ } @SuppressWarnings("unused") - public static void emit(TargetMethodAssembler tasm, HSAILAssembler masm, Condition condition, Value x, Value y, Value z, boolean unorderedIsTrue) { + public static void emit(CompilationResultBuilder crb, HSAILAssembler masm, Condition condition, Value x, Value y, Value z, boolean unorderedIsTrue) { emitCompare(masm, condition, x, y, unorderedIsTrue); }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILControlFlow.java Tue Dec 03 18:40:03 2013 +0100 @@ -104,11 +104,11 @@ * routines with keys of type Long or Object. Currently we only support the * IntegerSwitchNode so we throw an exception if the key isn't of type int. * - * @param tasm the TargetMethodAssembler + * @param crb the CompilationResultBuilder * @param masm the HSAIL assembler */ @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { if (key.getKind() == Kind.Int) { for (int i = 0; i < keyConstants.length; i++) { // Generate cascading compare and branches for each case. @@ -136,10 +136,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); - } + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + crb.frameContext.leave(crb); masm.exit(); } } @@ -155,7 +153,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitComment("//ForeignCall to " + callName + " would have gone here"); } } @@ -213,8 +211,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, x, y, z, unordered); masm.cbr(masm.nameOf(destination.label())); } } @@ -234,8 +232,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, x, y, z, unordered); masm.cbr(masm.nameOf(destination.label())); } } @@ -255,8 +253,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, x, y, z, unordered); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, x, y, z, unordered); masm.cbr(masm.nameOf(destination.label())); } } @@ -274,7 +272,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.cbr(masm.nameOf(destination.label())); } @@ -297,7 +295,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.cbr(masm.nameOf(destination.label())); } } @@ -323,9 +321,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, left, right, right, false); - cmove(tasm, masm, result, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, left, right, right, false); + cmove(crb, masm, result, false, trueValue, falseValue); } } @@ -339,14 +337,14 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - HSAILCompare.emit(tasm, masm, condition, left, right, right, unorderedIsTrue); - cmove(tasm, masm, result, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + HSAILCompare.emit(crb, masm, condition, left, right, right, unorderedIsTrue); + cmove(crb, masm, result, false, trueValue, falseValue); } } @SuppressWarnings("unused") - private static void cmove(TargetMethodAssembler tasm, HSAILAssembler masm, Value result, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + private static void cmove(CompilationResultBuilder crb, HSAILAssembler masm, Value result, boolean unorderedIsTrue, Value trueValue, Value falseValue) { // Check that we don't overwrite an input operand before it is used. assert (result.getKind() == trueValue.getKind() && result.getKind() == falseValue.getKind()); int width;
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILLIRInstruction.java Tue Dec 03 18:40:03 2013 +0100 @@ -32,9 +32,9 @@ public abstract class HSAILLIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (HSAILAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (HSAILAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, HSAILAssembler masm); }
--- a/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.hsail/src/com/oracle/graal/lir/hsail/HSAILMove.java Tue Dec 03 18:40:03 2013 +0100 @@ -60,8 +60,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -87,8 +87,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -114,8 +114,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -144,9 +144,9 @@ protected abstract void emitMemAccess(HSAILAssembler masm); @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { if (state != null) { - // tasm.recordImplicitException(masm.codeBuffer.position(), state); + // crb.recordImplicitException(masm.codeBuffer.position(), state); throw new InternalError("NYI"); } emitMemAccess(masm); @@ -162,7 +162,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitMembar(barriers); } } @@ -249,13 +249,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitMov(scratch, input); boolean testForNull = (kind == Kind.Object); encodePointer(masm, scratch, base, shift, alignment, testForNull); if (state != null) { throw new InternalError("NYI"); - // tasm.recordImplicitException(masm.codeBuffer.position(), state); + // crb.recordImplicitException(masm.codeBuffer.position(), state); } masm.emitStore(scratch, address.toAddress(), "u32"); } @@ -292,7 +292,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { throw new InternalError("NYI"); } } @@ -308,7 +308,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { throw new InternalError("NYI"); } } @@ -329,7 +329,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { masm.emitAtomicCas(result, address.toAddress(), cmpValue, newValue); } } @@ -361,7 +361,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { // assume any encoded or decoded value could be null boolean testForNull = true; // set up scratch registers to be encoded versions @@ -392,13 +392,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, HSAILAssembler masm) { + public void emitCode(CompilationResultBuilder crb, HSAILAssembler masm) { Debug.log("NullCheckOp unimplemented"); } } @SuppressWarnings("unused") - public static void move(TargetMethodAssembler tasm, HSAILAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, HSAILAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { masm.emitMov(result, input);
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXArithmetic.java Tue Dec 03 18:40:03 2013 +0100 @@ -56,7 +56,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { Variable dst = (Variable) result; Variable src = (Variable) x; if (from == Kind.Long && to == Kind.Int) { @@ -81,8 +81,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -100,8 +100,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -125,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -150,12 +150,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { if (sameRegister(result, y)) { - emit(tasm, masm, opcode, result, x, null); + emit(crb, masm, opcode, result, x, null); } else { - PTXMove.move(tasm, masm, result, x); - emit(tasm, masm, opcode, result, y, null); + PTXMove.move(crb, masm, result, x); + emit(crb, masm, opcode, result, y, null); } } @@ -180,8 +180,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -208,8 +208,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - emit(tasm, masm, opcode, result, y, state); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + emit(crb, masm, opcode, result, y, state); } @Override @@ -219,7 +219,7 @@ } } - public static void emit(TargetMethodAssembler tasm, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; Variable dest = (Variable) dst; @@ -267,11 +267,11 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } - public static void emit(TargetMethodAssembler tasm, PTXMacroAssembler masm, PTXArithmetic opcode, + public static void emit(CompilationResultBuilder crb, PTXMacroAssembler masm, PTXArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { int exceptionOffset = -1; Variable dest = (Variable) dst; @@ -337,7 +337,7 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXBitManipulationOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -46,7 +46,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { Register dst = ValueUtil.asIntReg(result); Register src = ValueUtil.asRegister(input); switch (opcode) {
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXCompare.java Tue Dec 03 18:40:03 2013 +0100 @@ -54,7 +54,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { emit(masm, opcode, condition, x, y, predRegNum); }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXControlFlow.java Tue Dec 03 18:40:03 2013 +0100 @@ -49,10 +49,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); - } + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + crb.frameContext.leave(crb); masm.exit(); } } @@ -63,10 +61,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - if (tasm.frameContext != null) { - tasm.frameContext.leave(tasm); - } + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + crb.frameContext.leave(crb); masm.ret(); } } @@ -84,7 +80,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { masm.bra(masm.nameOf(destination.label()), predRegNum); } @@ -117,8 +113,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - cmove(tasm, masm, result, false, condition, false, trueValue, falseValue, predicate); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + cmove(crb, masm, result, false, condition, false, trueValue, falseValue, predicate); } } @@ -141,25 +137,25 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue, predicate); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue, predicate); } } - private static void cmove(TargetMethodAssembler tasm, PTXMacroAssembler asm, Value result, boolean isFloat, Condition condition, boolean unorderedIsTrue, Value trueValue, Value falseValue, + private static void cmove(CompilationResultBuilder crb, PTXMacroAssembler asm, Value result, boolean isFloat, Condition condition, boolean unorderedIsTrue, Value trueValue, Value falseValue, int predicateRegister) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); - PTXMove.move(tasm, asm, result, falseValue); + PTXMove.move(crb, asm, result, falseValue); cmove(asm, result, trueValue, predicateRegister); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + // cmove(crb, masm, result, ConditionFlag.Parity, trueValue); throw GraalInternalError.unimplemented(); } else if (!unorderedIsTrue && trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + // cmove(crb, masm, result, ConditionFlag.Parity, falseValue); throw GraalInternalError.unimplemented(); } } @@ -218,20 +214,20 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { Kind keyKind = key.getKind(); if (keyKind == Kind.Int || keyKind == Kind.Long) { for (int i = 0; i < keyConstants.length; i++) { - if (tasm.codeCache.needsDataPatch(keyConstants[i])) { - tasm.recordDataReferenceInCode(keyConstants[i], 0, true); + if (crb.codeCache.needsDataPatch(keyConstants[i])) { + crb.recordDataReferenceInCode(keyConstants[i], 0, true); } new Setp(EQ, keyConstants[i], key, predRegNum).emit(masm); masm.bra(masm.nameOf(keyTargets[i].label()), predRegNum); } } else if (keyKind == Kind.Object) { for (int i = 0; i < keyConstants.length; i++) { - PTXMove.move(tasm, masm, scratch, keyConstants[i]); + PTXMove.move(crb, masm, scratch, keyConstants[i]); new Setp(EQ, keyConstants[i], scratch, predRegNum).emit(masm); masm.bra(keyTargets[i].label().toString(), predRegNum); } @@ -276,13 +272,13 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, index, scratch, predRegNum); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + tableswitch(crb, masm, lowKey, defaultTarget, targets, index, scratch, predRegNum); } } @SuppressWarnings("unused") - private static void tableswitch(TargetMethodAssembler tasm, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value value, Value scratch, int predNum) { + private static void tableswitch(CompilationResultBuilder crb, PTXAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Value value, Value scratch, int predNum) { Buffer buf = masm.codeBuffer; // Compare index against jump table bounds @@ -311,7 +307,7 @@ // bra(Value, name); - tasm.compilationResult.addAnnotation(jt); + crb.compilationResult.addAnnotation(jt); } }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXLIRInstruction.java Tue Dec 03 18:40:03 2013 +0100 @@ -32,9 +32,9 @@ public abstract class PTXLIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (PTXMacroAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (PTXMacroAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm); }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -51,7 +51,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Byte: @@ -87,7 +87,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Byte: @@ -122,7 +122,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Byte: @@ -159,7 +159,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) { case Int: @@ -191,7 +191,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { PTXAddress addr = address.toAddress(); switch (kind) {
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMove.java Tue Dec 03 18:40:03 2013 +0100 @@ -49,8 +49,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -76,8 +76,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -103,8 +103,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -129,7 +129,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { throw new InternalError("NYI"); } } @@ -145,7 +145,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { throw new InternalError("NYI"); } } @@ -166,12 +166,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { - compareAndSwap(tasm, masm, result, address, cmpValue, newValue); + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { + compareAndSwap(crb, masm, result, address, cmpValue, newValue); } } - public static void move(TargetMethodAssembler tasm, PTXMacroAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Value input) { if (isVariable(input)) { if (isVariable(result)) { reg2reg(masm, result, input); @@ -180,7 +180,7 @@ } } else if (isConstant(input)) { if (isVariable(result)) { - const2reg(tasm, masm, result, (Constant) input); + const2reg(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -209,25 +209,25 @@ } } - private static void const2reg(TargetMethodAssembler tasm, PTXMacroAssembler masm, Value result, Constant input) { + private static void const2reg(CompilationResultBuilder crb, PTXMacroAssembler masm, Value result, Constant input) { Variable dest = (Variable) result; switch (input.getKind().getStackKind()) { case Int: case Long: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); } new Mov(dest, input).emit(masm); break; case Object: if (input.isNull()) { new Mov(dest, Constant.forLong(0x0L)).emit(masm); - } else if (tasm.target.inlineObjects) { - tasm.recordDataReferenceInCode(input, 0, true); + } else if (crb.target.inlineObjects) { + crb.recordDataReferenceInCode(input, 0, true); new Mov(dest, Constant.forLong(0xDEADDEADDEADDEADL)).emit(masm); } else { - // new Mov(dest, tasm.recordDataReferenceInCode(input, 0, false)); + // new Mov(dest, crb.recordDataReferenceInCode(input, 0, false)); } break; default: @@ -236,7 +236,7 @@ } @SuppressWarnings("unused") - protected static void compareAndSwap(TargetMethodAssembler tasm, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { + protected static void compareAndSwap(CompilationResultBuilder crb, PTXAssembler masm, AllocatableValue result, PTXAddressValue address, AllocatableValue cmpValue, AllocatableValue newValue) { throw new InternalError("NYI"); } }
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXParameterOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -44,8 +44,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { - PTXMacroAssembler masm = (PTXMacroAssembler) tasm.asm; + public void emitCode(CompilationResultBuilder crb) { + PTXMacroAssembler masm = (PTXMacroAssembler) crb.asm; // Emit parameter directives for arguments int argCount = params.length; for (int i = 0; i < argCount; i++) {
--- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXTestOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -44,7 +44,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, PTXMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, PTXMacroAssembler masm) { emit(masm, x, y, predicate); }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCArithmetic.java Tue Dec 03 18:40:03 2013 +0100 @@ -63,8 +63,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -81,8 +81,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, null); } } @@ -101,8 +101,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -131,8 +131,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -160,8 +160,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -189,8 +189,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, null); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -215,9 +215,9 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { assert !(x instanceof SPARCAddressValue); - emit(tasm, masm, opcode, result, x, y, null); + emit(crb, masm, opcode, result, x, y, null); } @Override @@ -249,8 +249,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, result, x, y, scratch1, scratch2, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, result, x, y, scratch1, scratch2, state); } @Override @@ -260,18 +260,18 @@ } } - public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, LIRFrameState info) { int exceptionOffset = -1; if (isConstant(src1)) { switch (opcode) { case ISUB: - assert isSimm13(tasm.asIntConst(src1)); - new Add(asIntReg(src2), -(tasm.asIntConst(src1)), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src1)); + new Add(asIntReg(src2), -(crb.asIntConst(src1)), asIntReg(dst)).emit(masm); break; case IAND: throw GraalInternalError.unimplemented(); case IDIV: - assert isSimm13(tasm.asIntConst(src1)); + assert isSimm13(crb.asIntConst(src1)); throw GraalInternalError.unimplemented(); // new Sdivx(masm, asIntReg(src1), asIntReg(src2), // asIntReg(dst)); @@ -285,85 +285,85 @@ } else if (isConstant(src2)) { switch (opcode) { case IADD: - assert isSimm13(tasm.asIntConst(src2)); - new Add(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Add(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case ISUB: - assert isSimm13(tasm.asIntConst(src2)); - new Sub(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sub(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IMUL: - assert isSimm13(tasm.asIntConst(src2)); - new Mulx(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Mulx(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IDIV: - assert isSimm13(tasm.asIntConst(src2)); + assert isSimm13(crb.asIntConst(src2)); new Signx(asIntReg(src1), asIntReg(src1)).emit(masm); - new Sdivx(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + new Sdivx(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IAND: - assert isSimm13(tasm.asIntConst(src2)); - new And(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new And(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case ISHL: - assert isSimm13(tasm.asIntConst(src2)); - new Sll(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sll(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case ISHR: - assert isSimm13(tasm.asIntConst(src2)); - new Sra(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sra(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IUSHR: - assert isSimm13(tasm.asIntConst(src2)); - new Srl(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Srl(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IOR: - assert isSimm13(tasm.asIntConst(src2)); - new Or(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Or(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case IXOR: - assert isSimm13(tasm.asIntConst(src2)); - new Xor(asIntReg(src1), tasm.asIntConst(src2), asIntReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Xor(asIntReg(src1), crb.asIntConst(src2), asIntReg(dst)).emit(masm); break; case LADD: - assert isSimm13(tasm.asIntConst(src2)); - new Add(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Add(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LSUB: - assert isSimm13(tasm.asIntConst(src2)); - new Sub(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sub(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LMUL: - assert isSimm13(tasm.asIntConst(src2)); - new Mulx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Mulx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LDIV: throw GraalInternalError.unimplemented(); case LUDIV: throw GraalInternalError.unimplemented(); case LAND: - assert isSimm13(tasm.asIntConst(src2)); - new And(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new And(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LOR: - assert isSimm13(tasm.asIntConst(src2)); - new Or(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Or(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LXOR: - assert isSimm13(tasm.asIntConst(src2)); - new Xor(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Xor(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LSHL: - assert isSimm13(tasm.asIntConst(src2)); - new Sllx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sllx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LSHR: - assert isSimm13(tasm.asIntConst(src2)); - new Srax(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Srax(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case LUSHR: - assert isSimm13(tasm.asIntConst(src2)); - new Srlx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(dst)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Srlx(asLongReg(src1), crb.asIntConst(src2), asLongReg(dst)).emit(masm); break; case FADD: case FMUL: @@ -477,11 +477,11 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } - public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, Value scratch1, Value scratch2, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src1, Value src2, Value scratch1, Value scratch2, LIRFrameState info) { int exceptionOffset = -1; if (isConstant(src1)) { switch (opcode) { @@ -491,9 +491,9 @@ } else if (isConstant(src2)) { switch (opcode) { case LREM: - assert isSimm13(tasm.asIntConst(src2)); - new Sdivx(asLongReg(src1), tasm.asIntConst(src2), asLongReg(scratch1)).emit(masm); - new Mulx(asLongReg(scratch1), tasm.asIntConst(src2), asLongReg(scratch2)).emit(masm); + assert isSimm13(crb.asIntConst(src2)); + new Sdivx(asLongReg(src1), crb.asIntConst(src2), asLongReg(scratch1)).emit(masm); + new Mulx(asLongReg(scratch1), crb.asIntConst(src2), asLongReg(scratch2)).emit(masm); new Sub(asLongReg(src1), asLongReg(scratch2), asLongReg(dst)).emit(masm); break; case LUREM: @@ -513,12 +513,12 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } } @SuppressWarnings("unused") - public static void emit(TargetMethodAssembler tasm, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src, LIRFrameState info) { + public static void emit(CompilationResultBuilder crb, SPARCAssembler masm, SPARCArithmetic opcode, Value dst, Value src, LIRFrameState info) { int exceptionOffset = -1; if (isRegister(src)) { switch (opcode) { @@ -574,7 +574,7 @@ if (info != null) { assert exceptionOffset != -1; - tasm.recordImplicitException(exceptionOffset, info); + crb.recordImplicitException(exceptionOffset, info); } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBitManipulationOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -57,7 +57,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { Register dst = asIntReg(result); if (isRegister(input)) { Register src = asRegister(input); @@ -130,20 +130,20 @@ throw GraalInternalError.shouldNotReachHere(); } - } else if (isConstant(input) && isSimm13(tasm.asIntConst(input))) { + } else if (isConstant(input) && isSimm13(crb.asIntConst(input))) { switch (opcode) { case IPOPCNT: - new Popc(tasm.asIntConst(input), dst).emit(masm); + new Popc(crb.asIntConst(input), dst).emit(masm); break; case LPOPCNT: - new Popc(tasm.asIntConst(input), dst).emit(masm); + new Popc(crb.asIntConst(input), dst).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); } } else { throw GraalInternalError.shouldNotReachHere(); - // SPARCAddress src = (SPARCAddress) tasm.asAddress(input); + // SPARCAddress src = (SPARCAddress) crb.asAddress(input); // switch (opcode) { // case IPOPCNT: // new Ldsw(src, tmp).emit(masm);
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCBreakpointOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -52,7 +52,7 @@ @Override @SuppressWarnings("unused") - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { new Trap(masm, ST_RESERVED_FOR_USER_0); } }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCByteSwapOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -40,8 +40,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - SPARCMove.move(tasm, masm, result, input); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + SPARCMove.move(crb, masm, result, input); switch (input.getKind()) { case Int: // masm.bswapl(ValueUtil.asIntReg(result));
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCall.java Tue Dec 03 18:40:03 2013 +0100 @@ -75,8 +75,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - directCall(tasm, masm, callTarget, null, true, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + directCall(crb, masm, callTarget, null, true, state); } } @@ -91,8 +91,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - indirectCall(tasm, masm, asRegister(targetAddress), callTarget, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + indirectCall(crb, masm, asRegister(targetAddress), callTarget, state); } @Override @@ -125,8 +125,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - directCall(tasm, masm, callTarget, null, false, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + directCall(crb, masm, callTarget, null, false, state); } } @@ -138,12 +138,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - directCall(tasm, masm, callTarget, o7, false, state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + directCall(crb, masm, callTarget, o7, false, state); } } - public static void directCall(TargetMethodAssembler tasm, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { + public static void directCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, InvokeTarget callTarget, Register scratch, boolean align, LIRFrameState info) { if (align) { // We don't need alignment on SPARC. } @@ -157,28 +157,28 @@ new Call(0).emit(masm); } int after = masm.codeBuffer.position(); - tasm.recordDirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordDirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); new Nop().emit(masm); // delay slot masm.ensureUniquePC(); } - public static void indirectJmp(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Register dst, InvokeTarget target) { + public static void indirectJmp(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget target) { int before = masm.codeBuffer.position(); new Sethix(0L, dst, true).emit(masm); new Jmp(new SPARCAddress(dst, 0)).emit(masm); int after = masm.codeBuffer.position(); - tasm.recordIndirectCall(before, after, target, null); + crb.recordIndirectCall(before, after, target, null); new Nop().emit(masm); // delay slot masm.ensureUniquePC(); } - public static void indirectCall(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { + public static void indirectCall(CompilationResultBuilder crb, SPARCMacroAssembler masm, Register dst, InvokeTarget callTarget, LIRFrameState info) { int before = masm.codeBuffer.position(); new Jmpl(dst, 0, o7).emit(masm); int after = masm.codeBuffer.position(); - tasm.recordIndirectCall(before, after, callTarget, info); - tasm.recordExceptionHandlers(after, info); + crb.recordIndirectCall(before, after, callTarget, info); + crb.recordExceptionHandlers(after, info); new Nop().emit(masm); // delay slot masm.ensureUniquePC(); }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCCompare.java Tue Dec 03 18:40:03 2013 +0100 @@ -49,8 +49,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emit(tasm, masm, opcode, x, y); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emit(crb, masm, opcode, x, y); } @Override @@ -62,7 +62,7 @@ } } - public static void emit(TargetMethodAssembler tasm, SPARCMacroAssembler masm, SPARCCompare opcode, Value x, Value y) { + public static void emit(CompilationResultBuilder crb, SPARCMacroAssembler masm, SPARCCompare opcode, Value x, Value y) { if (isRegister(y)) { switch (opcode) { case ICMP: @@ -87,12 +87,12 @@ assert isConstant(y); switch (opcode) { case ICMP: - assert isSimm13(tasm.asIntConst(y)); - new Cmp(asIntReg(x), tasm.asIntConst(y)).emit(masm); + assert isSimm13(crb.asIntConst(y)); + new Cmp(asIntReg(x), crb.asIntConst(y)).emit(masm); break; case LCMP: - assert isSimm13(tasm.asIntConst(y)); - new Cmp(asLongReg(x), tasm.asIntConst(y)).emit(masm); + assert isSimm13(crb.asIntConst(y)); + new Cmp(asLongReg(x), crb.asIntConst(y)).emit(masm); break; case ACMP: if (((Constant) y).isNull()) { @@ -102,10 +102,10 @@ throw GraalInternalError.shouldNotReachHere("Only null object constants are allowed in comparisons"); } case FCMP: - // masm.ucomiss(asFloatReg(x), (AMD64Address) tasm.asFloatConstRef(y)); + // masm.ucomiss(asFloatReg(x), (AMD64Address) crb.asFloatConstRef(y)); // break; case DCMP: - // masm.ucomisd(asDoubleReg(x), (AMD64Address) tasm.asDoubleConstRef(y)); + // masm.ucomisd(asDoubleReg(x), (AMD64Address) crb.asDoubleConstRef(y)); // break; default: throw GraalInternalError.shouldNotReachHere();
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCControlFlow.java Tue Dec 03 18:40:03 2013 +0100 @@ -54,7 +54,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { assert kind == Kind.Int || kind == Kind.Long || kind == Kind.Object; CC cc = kind == Kind.Int ? CC.Icc : CC.Xcc; switch (condition) { @@ -123,8 +123,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - cmove(tasm, masm, result, false, condition, false, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + cmove(crb, masm, result, false, condition, false, trueValue, falseValue); } } @@ -146,32 +146,32 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - cmove(tasm, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + cmove(crb, masm, result, true, condition, unorderedIsTrue, trueValue, falseValue); } } - private static void cmove(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { + private static void cmove(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, boolean isFloat, ConditionFlag condition, boolean unorderedIsTrue, Value trueValue, Value falseValue) { // check that we don't overwrite an input operand before it is used. assert !result.equals(trueValue); - SPARCMove.move(tasm, masm, result, falseValue); - cmove(tasm, masm, result, condition, trueValue); + SPARCMove.move(crb, masm, result, falseValue); + cmove(crb, masm, result, condition, trueValue); if (isFloat) { if (unorderedIsTrue && !trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, trueValue); + // cmove(crb, masm, result, ConditionFlag.Parity, trueValue); throw GraalInternalError.unimplemented(); } else if (!unorderedIsTrue && trueOnUnordered(condition)) { - // cmove(tasm, masm, result, ConditionFlag.Parity, falseValue); + // cmove(crb, masm, result, ConditionFlag.Parity, falseValue); throw GraalInternalError.unimplemented(); } } } - private static void cmove(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, ConditionFlag cond, Value other) { + private static void cmove(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, ConditionFlag cond, Value other) { if (!isRegister(other)) { - SPARCMove.move(tasm, masm, result, other); + SPARCMove.move(crb, masm, result, other); throw new InternalError("result should be scratch"); } assert !asRegister(other).equals(asRegister(result)) : "other already overwritten by previous move"; @@ -246,14 +246,14 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - emitCodeHelper(tasm, masm); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + emitCodeHelper(crb, masm); } - public static void emitCodeHelper(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public static void emitCodeHelper(CompilationResultBuilder crb, SPARCMacroAssembler masm) { new Ret().emit(masm); // On SPARC we always leave the frame (in the delay slot). - tasm.frameContext.leave(tasm); + crb.frameContext.leave(crb); } } @@ -275,12 +275,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (key.getKind() == Kind.Int) { Register intKey = asIntReg(key); for (int i = 0; i < keyConstants.length; i++) { - if (tasm.codeCache.needsDataPatch(keyConstants[i])) { - tasm.recordDataReferenceInCode(keyConstants[i], 0, true); + if (crb.codeCache.needsDataPatch(keyConstants[i])) { + crb.recordDataReferenceInCode(keyConstants[i], 0, true); } long lc = keyConstants[i].asLong(); assert NumUtil.isInt(lc); @@ -292,7 +292,7 @@ Register longKey = asLongReg(key); Register temp = asLongReg(scratch); for (int i = 0; i < keyConstants.length; i++) { - SPARCMove.move(tasm, masm, temp.asValue(Kind.Long), keyConstants[i]); + SPARCMove.move(crb, masm, temp.asValue(Kind.Long), keyConstants[i]); new Cmp(longKey, temp).emit(masm); new Bpe(CC.Xcc, keyTargets[i].label()).emit(masm); new Nop().emit(masm); // delay slot @@ -301,7 +301,7 @@ Register objectKey = asObjectReg(key); Register temp = asObjectReg(scratch); for (int i = 0; i < keyConstants.length; i++) { - SPARCMove.move(tasm, masm, temp.asValue(Kind.Object), keyConstants[i]); + SPARCMove.move(crb, masm, temp.asValue(Kind.Object), keyConstants[i]); new Cmp(objectKey, temp).emit(masm); new Bpe(CC.Ptrcc, keyTargets[i].label()).emit(masm); new Nop().emit(masm); // delay slot @@ -344,7 +344,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { assert isSorted(lowKeys) && isSorted(highKeys); Label actualDefaultTarget = defaultTarget == null ? new Label() : defaultTarget.label(); @@ -422,12 +422,12 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - tableswitch(tasm, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + tableswitch(crb, masm, lowKey, defaultTarget, targets, asIntReg(index), asLongReg(scratch)); } } - private static void tableswitch(TargetMethodAssembler tasm, SPARCAssembler masm, int lowKey, LabelRef defaultTarget, LabelRef[] targets, Register value, Register scratch) { + private static void tableswitch(CompilationResultBuilder crb, SPARCAssembler 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; @@ -455,7 +455,7 @@ int tablePos = buf.position(); JumpTable jt = new JumpTable(tablePos, lowKey, highKey, 4); - tasm.compilationResult.addAnnotation(jt); + crb.compilationResult.addAnnotation(jt); // SPARC: unimp: tableswitch extract throw GraalInternalError.unimplemented();
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCLIRInstruction.java Tue Dec 03 18:40:03 2013 +0100 @@ -32,9 +32,9 @@ public abstract class SPARCLIRInstruction extends LIRInstruction { @Override - public final void emitCode(TargetMethodAssembler tasm) { - emitCode(tasm, (SPARCMacroAssembler) tasm.asm); + public final void emitCode(CompilationResultBuilder crb) { + emitCode(crb, (SPARCMacroAssembler) crb.asm); } - public abstract void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm); + public abstract void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm); }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMathIntrinsicOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -48,7 +48,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { switch (opcode) { case SQRT: new Fsqrtd(asDoubleReg(input), asDoubleReg(result)).emit(masm);
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCMove.java Tue Dec 03 18:40:03 2013 +0100 @@ -51,8 +51,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -78,8 +78,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - move(tasm, masm, getResult(), getInput()); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + move(crb, masm, getResult(), getInput()); } @Override @@ -108,9 +108,9 @@ protected abstract void emitMemAccess(SPARCMacroAssembler masm); @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (state != null) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + crb.recordImplicitException(masm.codeBuffer.position(), state); } emitMemAccess(masm); } @@ -179,7 +179,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { SPARCAddress addr = address.toAddress(); if (addr.hasIndex()) { new Add(addr.getBase(), addr.getIndex(), asLongReg(result)).emit(masm); @@ -198,7 +198,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { new Membar(barriers).emit(masm); } } @@ -214,8 +214,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - tasm.recordImplicitException(masm.codeBuffer.position(), state); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + crb.recordImplicitException(masm.codeBuffer.position(), state); new Ldx(new SPARCAddress(asRegister(input), 0), r0).emit(masm); } @@ -243,7 +243,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { compareAndSwap(masm, address, cmpValue, newValue); } } @@ -259,8 +259,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { - SPARCAddress address = (SPARCAddress) tasm.asAddress(slot); + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { + SPARCAddress address = (SPARCAddress) crb.asAddress(slot); new Add(address.getBase(), address.getDisplacement(), asLongReg(result)).emit(masm); } } @@ -349,24 +349,24 @@ } } - public static void move(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Value input) { + public static void move(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Value input) { if (isRegister(input)) { if (isRegister(result)) { reg2reg(masm, result, input); } else if (isStackSlot(result)) { - reg2stack(tasm, masm, result, input); + reg2stack(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isStackSlot(input)) { if (isRegister(result)) { - stack2reg(tasm, masm, result, input); + stack2reg(crb, masm, result, input); } else { throw GraalInternalError.shouldNotReachHere(); } } else if (isConstant(input)) { if (isRegister(result)) { - const2reg(tasm, masm, result, (Constant) input); + const2reg(crb, masm, result, (Constant) input); } else { throw GraalInternalError.shouldNotReachHere(); } @@ -392,8 +392,8 @@ } } - private static void reg2stack(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Value input) { - SPARCAddress dst = (SPARCAddress) tasm.asAddress(result); + private static void reg2stack(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Value input) { + SPARCAddress dst = (SPARCAddress) crb.asAddress(result); Register src = asRegister(input); switch (input.getKind()) { case Int: @@ -410,8 +410,8 @@ } } - private static void stack2reg(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Value input) { - SPARCAddress src = (SPARCAddress) tasm.asAddress(input); + private static void stack2reg(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Value input) { + SPARCAddress src = (SPARCAddress) crb.asAddress(input); Register dst = asRegister(result); switch (input.getKind()) { case Int: @@ -428,11 +428,11 @@ } } - private static void const2reg(TargetMethodAssembler tasm, SPARCMacroAssembler masm, Value result, Constant input) { + private static void const2reg(CompilationResultBuilder crb, SPARCMacroAssembler masm, Value result, Constant input) { switch (input.getKind().getStackKind()) { case Int: - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); new Setuw(input.asInt(), asRegister(result)).emit(masm); } else { if (input.isDefaultForKind()) { @@ -443,8 +443,8 @@ } break; case Long: { - if (tasm.codeCache.needsDataPatch(input)) { - tasm.recordDataReferenceInCode(input, 0, true); + if (crb.codeCache.needsDataPatch(input)) { + crb.recordDataReferenceInCode(input, 0, true); new Setx(input.asLong(), asRegister(result), true).emit(masm); } else { if (input.isDefaultForKind()) { @@ -458,13 +458,13 @@ case Object: { if (input.isNull()) { new Clr(asRegister(result)).emit(masm); - } else if (tasm.target.inlineObjects) { - tasm.recordDataReferenceInCode(input, 0, true); + } else if (crb.target.inlineObjects) { + crb.recordDataReferenceInCode(input, 0, true); new Setx(0xDEADDEADDEADDEADL, asRegister(result), true).emit(masm); } else { Register dst = asRegister(result); new Rdpc(dst).emit(masm); - tasm.asObjectConstRef(input); + crb.asObjectConstRef(input); new Ldx(new SPARCAddress(dst, 0), dst).emit(masm); throw GraalInternalError.shouldNotReachHere("the patched offset might be too big for the load"); }
--- a/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir.sparc/src/com/oracle/graal/lir/sparc/SPARCTestOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -43,7 +43,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm, SPARCMacroAssembler masm) { + public void emitCode(CompilationResultBuilder crb, SPARCMacroAssembler masm) { if (isRegister(y)) { switch (x.getKind()) { case Int: @@ -58,10 +58,10 @@ } else if (isConstant(y)) { switch (x.getKind()) { case Int: - new Cmp(asIntReg(x), tasm.asIntConst(y)).emit(masm); + new Cmp(asIntReg(x), crb.asIntConst(y)).emit(masm); break; case Long: - new Cmp(asLongReg(x), tasm.asIntConst(y)).emit(masm); + new Cmp(asLongReg(x), crb.asIntConst(y)).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -69,11 +69,11 @@ } else { switch (x.getKind()) { case Int: - new Ldsw((SPARCAddress) tasm.asIntAddr(y), asIntReg(y)).emit(masm); + new Ldsw((SPARCAddress) crb.asIntAddr(y), asIntReg(y)).emit(masm); new Cmp(asIntReg(x), asIntReg(y)).emit(masm); break; case Long: - new Ldx((SPARCAddress) tasm.asLongAddr(y), asLongReg(y)).emit(masm); + new Ldx((SPARCAddress) crb.asLongAddr(y), asLongReg(y)).emit(masm); new Cmp(asLongReg(x), asLongReg(y)).emit(masm); break; default:
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InfopointOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/InfopointOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -41,7 +41,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { - tasm.recordInfopoint(tasm.asm.codeBuffer.position(), state, reason); + public void emitCode(CompilationResultBuilder crb) { + crb.recordInfopoint(crb.asm.codeBuffer.position(), state, reason); } }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIR.java Tue Dec 03 18:40:03 2013 +0100 @@ -136,34 +136,32 @@ firstVariableNumber = num; } - public void emitCode(TargetMethodAssembler tasm) { - if (tasm.frameContext != null) { - tasm.frameContext.enter(tasm); - } + public void emitCode(CompilationResultBuilder crb) { + crb.frameContext.enter(crb); for (Block b : codeEmittingOrder()) { - emitBlock(tasm, b); + emitBlock(crb, b); } } - private void emitBlock(TargetMethodAssembler tasm, Block block) { + private void emitBlock(CompilationResultBuilder crb, Block block) { if (Debug.isDumpEnabled()) { - tasm.blockComment(String.format("block B%d %s", block.getId(), block.getLoop())); + crb.blockComment(String.format("block B%d %s", block.getId(), block.getLoop())); } for (LIRInstruction op : lir(block)) { if (Debug.isDumpEnabled()) { - tasm.blockComment(String.format("%d %s", op.id(), op)); + crb.blockComment(String.format("%d %s", op.id(), op)); } - emitOp(tasm, op); + emitOp(crb, op); } } - private static void emitOp(TargetMethodAssembler tasm, LIRInstruction op) { + private static void emitOp(CompilationResultBuilder crb, LIRInstruction op) { try { try { - op.emitCode(tasm); + op.emitCode(crb); } catch (AssertionError t) { throw new GraalInternalError(t); } catch (RuntimeException t) {
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/LIRInstruction.java Tue Dec 03 18:40:03 2013 +0100 @@ -223,7 +223,7 @@ id = -1; } - public abstract void emitCode(TargetMethodAssembler tasm); + public abstract void emitCode(CompilationResultBuilder crb); public final int id() { return id;
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/StandardOp.java Tue Dec 03 18:40:03 2013 +0100 @@ -94,11 +94,11 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { + public void emitCode(CompilationResultBuilder crb) { if (align) { - tasm.asm.align(tasm.target.wordSize * 2); + crb.asm.align(crb.target.wordSize * 2); } - tasm.asm.bind(label); + crb.asm.bind(label); } public Label getLabel() { @@ -120,8 +120,8 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { - tasm.asm.jmp(destination.label()); + public void emitCode(CompilationResultBuilder crb) { + crb.asm.jmp(destination.label()); } public LabelRef destination() { @@ -209,7 +209,7 @@ } @Override - public void emitCode(TargetMethodAssembler tasm) { + public void emitCode(CompilationResultBuilder crb) { throw new GraalInternalError(this + " should have been replaced"); } }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilder.java Tue Dec 03 18:40:03 2013 +0100 @@ -0,0 +1,281 @@ +/* + * 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.lir.asm; + +import static com.oracle.graal.api.code.ValueUtil.*; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.asm.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.lir.*; + +/** + * Fills in a {@link CompilationResult} as its code is being assembled. + * + * @see CompilationResultBuilderFactory + */ +public class CompilationResultBuilder { + + private static class ExceptionInfo { + + public final int codeOffset; + public final LabelRef exceptionEdge; + + public ExceptionInfo(int pcOffset, LabelRef exceptionEdge) { + this.codeOffset = pcOffset; + this.exceptionEdge = exceptionEdge; + } + } + + public final AbstractAssembler asm; + public final CompilationResult compilationResult; + public final TargetDescription target; + public final CodeCacheProvider codeCache; + public final ForeignCallsProvider foreignCalls; + public final FrameMap frameMap; + + /** + * The object that emits code for managing a method's frame. + */ + public final FrameContext frameContext; + + private List<ExceptionInfo> exceptionInfoList; + + public CompilationResultBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, + CompilationResult compilationResult) { + this.target = codeCache.getTarget(); + this.codeCache = codeCache; + this.foreignCalls = foreignCalls; + this.frameMap = frameMap; + this.asm = asm; + this.compilationResult = compilationResult; + this.frameContext = frameContext; + assert frameContext != null; + } + + public void setFrameSize(int frameSize) { + compilationResult.setFrameSize(frameSize); + } + + private static final CompilationResult.Mark[] NO_REFS = {}; + + public CompilationResult.Mark recordMark(Object id) { + return compilationResult.recordMark(asm.codeBuffer.position(), id, NO_REFS); + } + + public CompilationResult.Mark recordMark(Object id, CompilationResult.Mark... references) { + return compilationResult.recordMark(asm.codeBuffer.position(), id, references); + } + + public void blockComment(String s) { + compilationResult.addAnnotation(new CompilationResult.CodeComment(asm.codeBuffer.position(), s)); + } + + /** + * Sets the {@linkplain CompilationResult#setTargetCode(byte[], int) code} and + * {@linkplain CompilationResult#recordExceptionHandler(int, int) exception handler} fields of + * the compilation result. + */ + public void finish() { + compilationResult.setTargetCode(asm.codeBuffer.close(false), asm.codeBuffer.position()); + + // Record exception handlers if they exist + if (exceptionInfoList != null) { + for (ExceptionInfo ei : exceptionInfoList) { + int codeOffset = ei.codeOffset; + compilationResult.recordExceptionHandler(codeOffset, ei.exceptionEdge.label().position()); + } + } + } + + public void recordExceptionHandlers(int pcOffset, LIRFrameState info) { + if (info != null) { + if (info.exceptionEdge != null) { + if (exceptionInfoList == null) { + exceptionInfoList = new ArrayList<>(4); + } + exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionEdge)); + } + } + } + + public void recordImplicitException(int pcOffset, LIRFrameState info) { + // record an implicit exception point + if (info != null) { + compilationResult.recordInfopoint(pcOffset, info.debugInfo(), InfopointReason.IMPLICIT_EXCEPTION); + assert info.exceptionEdge == null; + } + } + + public void recordDirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { + DebugInfo debugInfo = info != null ? info.debugInfo() : null; + compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, true); + } + + public void recordIndirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { + DebugInfo debugInfo = info != null ? info.debugInfo() : null; + compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, false); + } + + public void recordInfopoint(int pos, LIRFrameState info, InfopointReason reason) { + // infopoints always need debug info + DebugInfo debugInfo = info.debugInfo(); + compilationResult.recordInfopoint(pos, debugInfo, reason); + } + + public AbstractAddress recordDataReferenceInCode(Constant data, int alignment, boolean inlined) { + assert data != null; + int pos = asm.codeBuffer.position(); + Debug.log("Data reference in code: pos = %d, data = %s", pos, data.toString()); + compilationResult.recordDataReference(pos, data, alignment, inlined); + return asm.getPlaceholder(); + } + + public AbstractAddress recordDataReferenceInCode(byte[] data, int alignment) { + assert data != null; + int pos = asm.codeBuffer.position(); + Debug.log("Raw data reference in code: pos = %d, data = %s", pos, data.toString()); + compilationResult.recordDataReference(pos, data, alignment); + return asm.getPlaceholder(); + } + + /** + * Returns the integer value of any constant that can be represented by a 32-bit integer value, + * including long constants that fit into the 32-bit range. + */ + public int asIntConst(Value value) { + assert (value.getKind().isNumericInteger()) && isConstant(value); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + long c = constant.asLong(); + if (!NumUtil.isInt(c)) { + throw GraalInternalError.shouldNotReachHere(); + } + return (int) c; + } + + /** + * Returns the float value of any constant that can be represented by a 32-bit float value. + */ + public float asFloatConst(Value value) { + assert (value.getKind().getStackKind() == Kind.Float && isConstant(value)); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + return constant.asFloat(); + } + + /** + * Returns the long value of any constant that can be represented by a 64-bit long value. + */ + public long asLongConst(Value value) { + assert (value.getKind().getStackKind() == Kind.Long && isConstant(value)); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + return constant.asLong(); + } + + /** + * Returns the double value of any constant that can be represented by a 64-bit float value. + */ + public double asDoubleConst(Value value) { + assert (value.getKind().getStackKind() == Kind.Double && isConstant(value)); + Constant constant = (Constant) value; + assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; + return constant.asDouble(); + } + + /** + * Returns the address of a float constant that is embedded as a data reference into the code. + */ + public AbstractAddress asFloatConstRef(Value value) { + return asFloatConstRef(value, 4); + } + + public AbstractAddress asFloatConstRef(Value value, int alignment) { + assert value.getKind() == Kind.Float && isConstant(value); + return recordDataReferenceInCode((Constant) value, alignment, false); + } + + /** + * Returns the address of a double constant that is embedded as a data reference into the code. + */ + public AbstractAddress asDoubleConstRef(Value value) { + return asDoubleConstRef(value, 8); + } + + public AbstractAddress asDoubleConstRef(Value value, int alignment) { + assert value.getKind() == Kind.Double && isConstant(value); + return recordDataReferenceInCode((Constant) value, alignment, false); + } + + /** + * Returns the address of a long constant that is embedded as a data reference into the code. + */ + public AbstractAddress asLongConstRef(Value value) { + assert value.getKind() == Kind.Long && isConstant(value); + return recordDataReferenceInCode((Constant) value, 8, false); + } + + /** + * Returns the address of an object constant that is embedded as a data reference into the code. + */ + public AbstractAddress asObjectConstRef(Value value) { + assert value.getKind() == Kind.Object && isConstant(value); + return recordDataReferenceInCode((Constant) value, 8, false); + } + + public AbstractAddress asIntAddr(Value value) { + assert value.getKind() == Kind.Int; + return asAddress(value); + } + + public AbstractAddress asLongAddr(Value value) { + assert value.getKind() == Kind.Long; + return asAddress(value); + } + + public AbstractAddress asObjectAddr(Value value) { + assert value.getKind() == Kind.Object; + return asAddress(value); + } + + public AbstractAddress asFloatAddr(Value value) { + assert value.getKind() == Kind.Float; + return asAddress(value); + } + + public AbstractAddress asDoubleAddr(Value value) { + assert value.getKind() == Kind.Double; + return asAddress(value); + } + + public AbstractAddress asAddress(Value value) { + assert isStackSlot(value); + StackSlot slot = asStackSlot(value); + return asm.makeAddress(frameMap.registerConfig.getFrameRegister(), frameMap.offsetForStackSlot(slot)); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/CompilationResultBuilderFactory.java Tue Dec 03 18:40:03 2013 +0100 @@ -0,0 +1,50 @@ +/* + * 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.lir.asm; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.asm.*; +import com.oracle.graal.lir.*; + +/** + * Factory class for creating {@link CompilationResultBuilder}s. + */ +public interface CompilationResultBuilderFactory { + + /** + * Creates a new {@link CompilationResultBuilder}. + */ + CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, + CompilationResult compilationResult); + + /** + * The default factory creates a standard {@link CompilationResultBuilder}. + */ + CompilationResultBuilderFactory Default = new CompilationResultBuilderFactory() { + + public CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, + CompilationResult compilationResult) { + return new CompilationResultBuilder(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult); + } + }; +}
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/FrameContext.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/FrameContext.java Tue Dec 03 18:40:03 2013 +0100 @@ -35,7 +35,7 @@ * <li>stack overflow checking</li> * </ul> */ - void enter(TargetMethodAssembler tasm); + void enter(CompilationResultBuilder crb); /** * Emits code to be executed just prior to returning from a method. This may include: @@ -45,5 +45,10 @@ * <li>destroying the stack frame</li> * </ul> */ - void leave(TargetMethodAssembler tasm); + void leave(CompilationResultBuilder crb); + + /** + * Determines if a frame is set up and torn down by this object. + */ + boolean hasFrame(); }
--- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/asm/TargetMethodAssembler.java Tue Dec 03 16:06:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,299 +0,0 @@ -/* - * Copyright (c) 2011, 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.lir.asm; - -import static com.oracle.graal.api.code.ValueUtil.*; - -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.code.CompilationResult.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.nodes.*; - -public class TargetMethodAssembler { - - private static class ExceptionInfo { - - public final int codeOffset; - public final LabelRef exceptionEdge; - - public ExceptionInfo(int pcOffset, LabelRef exceptionEdge) { - this.codeOffset = pcOffset; - this.exceptionEdge = exceptionEdge; - } - } - - public final AbstractAssembler asm; - public final CompilationResult compilationResult; - public final TargetDescription target; - public final CodeCacheProvider codeCache; - public final ForeignCallsProvider foreignCalls; - public final FrameMap frameMap; - - /** - * The object that emits code for managing a method's frame. If null, no frame is used by the - * method. - */ - public final FrameContext frameContext; - - private List<ExceptionInfo> exceptionInfoList; - - public TargetMethodAssembler(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, - CompilationResult compilationResult) { - this.target = codeCache.getTarget(); - this.codeCache = codeCache; - this.foreignCalls = foreignCalls; - this.frameMap = frameMap; - this.asm = asm; - this.compilationResult = compilationResult; - this.frameContext = frameContext; - } - - public void setFrameSize(int frameSize) { - compilationResult.setFrameSize(frameSize); - } - - private static final CompilationResult.Mark[] NO_REFS = {}; - - public CompilationResult.Mark recordMark(Object id) { - return compilationResult.recordMark(asm.codeBuffer.position(), id, NO_REFS); - } - - public CompilationResult.Mark recordMark(Object id, CompilationResult.Mark... references) { - return compilationResult.recordMark(asm.codeBuffer.position(), id, references); - } - - public void blockComment(String s) { - compilationResult.addAnnotation(new CompilationResult.CodeComment(asm.codeBuffer.position(), s)); - } - - public CompilationResult finishTargetMethod(StructuredGraph graph) { - // Install code, data and frame size - compilationResult.setTargetCode(asm.codeBuffer.close(false), asm.codeBuffer.position()); - - // Record exception handlers if they exist - if (exceptionInfoList != null) { - for (ExceptionInfo ei : exceptionInfoList) { - int codeOffset = ei.codeOffset; - compilationResult.recordExceptionHandler(codeOffset, ei.exceptionEdge.label().position()); - } - } - - if (Debug.isMeterEnabled()) { - List<DataPatch> ldp = compilationResult.getDataReferences(); - DebugMetric[] dms = new DebugMetric[Kind.values().length]; - for (int i = 0; i < dms.length; i++) { - dms[i] = Debug.metric("DataPatches-" + Kind.values()[i].toString()); - } - DebugMetric dmRaw = Debug.metric("DataPatches-raw"); - - for (DataPatch dp : ldp) { - if (dp.constant != null) { - dms[dp.constant.getKind().ordinal()].add(1); - } else { - dmRaw.add(1); - } - } - - Debug.metric("TargetMethods").increment(); - Debug.metric("CodeBytesEmitted").add(compilationResult.getTargetCodeSize()); - Debug.metric("InfopointsEmitted").add(compilationResult.getInfopoints().size()); - Debug.metric("DataPatches").add(ldp.size()); - Debug.metric("ExceptionHandlersEmitted").add(compilationResult.getExceptionHandlers().size()); - } - Debug.log("Finished compiling %s", graph); - return compilationResult; - } - - public void recordExceptionHandlers(int pcOffset, LIRFrameState info) { - if (info != null) { - if (info.exceptionEdge != null) { - if (exceptionInfoList == null) { - exceptionInfoList = new ArrayList<>(4); - } - exceptionInfoList.add(new ExceptionInfo(pcOffset, info.exceptionEdge)); - } - } - } - - public void recordImplicitException(int pcOffset, LIRFrameState info) { - // record an implicit exception point - if (info != null) { - compilationResult.recordInfopoint(pcOffset, info.debugInfo(), InfopointReason.IMPLICIT_EXCEPTION); - assert info.exceptionEdge == null; - } - } - - public void recordDirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { - DebugInfo debugInfo = info != null ? info.debugInfo() : null; - compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, true); - } - - public void recordIndirectCall(int posBefore, int posAfter, InvokeTarget callTarget, LIRFrameState info) { - DebugInfo debugInfo = info != null ? info.debugInfo() : null; - compilationResult.recordCall(posBefore, posAfter - posBefore, callTarget, debugInfo, false); - } - - public void recordInfopoint(int pos, LIRFrameState info, InfopointReason reason) { - // infopoints always need debug info - DebugInfo debugInfo = info.debugInfo(); - compilationResult.recordInfopoint(pos, debugInfo, reason); - } - - public AbstractAddress recordDataReferenceInCode(Constant data, int alignment, boolean inlined) { - assert data != null; - int pos = asm.codeBuffer.position(); - Debug.log("Data reference in code: pos = %d, data = %s", pos, data.toString()); - compilationResult.recordDataReference(pos, data, alignment, inlined); - return asm.getPlaceholder(); - } - - public AbstractAddress recordDataReferenceInCode(byte[] data, int alignment) { - assert data != null; - int pos = asm.codeBuffer.position(); - Debug.log("Raw data reference in code: pos = %d, data = %s", pos, data.toString()); - compilationResult.recordDataReference(pos, data, alignment); - return asm.getPlaceholder(); - } - - /** - * Returns the integer value of any constant that can be represented by a 32-bit integer value, - * including long constants that fit into the 32-bit range. - */ - public int asIntConst(Value value) { - assert (value.getKind().isNumericInteger()) && isConstant(value); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - long c = constant.asLong(); - if (!NumUtil.isInt(c)) { - throw GraalInternalError.shouldNotReachHere(); - } - return (int) c; - } - - /** - * Returns the float value of any constant that can be represented by a 32-bit float value. - */ - public float asFloatConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Float && isConstant(value)); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - return constant.asFloat(); - } - - /** - * Returns the long value of any constant that can be represented by a 64-bit long value. - */ - public long asLongConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Long && isConstant(value)); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - return constant.asLong(); - } - - /** - * Returns the double value of any constant that can be represented by a 64-bit float value. - */ - public double asDoubleConst(Value value) { - assert (value.getKind().getStackKind() == Kind.Double && isConstant(value)); - Constant constant = (Constant) value; - assert !codeCache.needsDataPatch(constant) : constant + " should be in a DataPatch"; - return constant.asDouble(); - } - - /** - * Returns the address of a float constant that is embedded as a data reference into the code. - */ - public AbstractAddress asFloatConstRef(Value value) { - return asFloatConstRef(value, 4); - } - - public AbstractAddress asFloatConstRef(Value value, int alignment) { - assert value.getKind() == Kind.Float && isConstant(value); - return recordDataReferenceInCode((Constant) value, alignment, false); - } - - /** - * Returns the address of a double constant that is embedded as a data reference into the code. - */ - public AbstractAddress asDoubleConstRef(Value value) { - return asDoubleConstRef(value, 8); - } - - public AbstractAddress asDoubleConstRef(Value value, int alignment) { - assert value.getKind() == Kind.Double && isConstant(value); - return recordDataReferenceInCode((Constant) value, alignment, false); - } - - /** - * Returns the address of a long constant that is embedded as a data reference into the code. - */ - public AbstractAddress asLongConstRef(Value value) { - assert value.getKind() == Kind.Long && isConstant(value); - return recordDataReferenceInCode((Constant) value, 8, false); - } - - /** - * Returns the address of an object constant that is embedded as a data reference into the code. - */ - public AbstractAddress asObjectConstRef(Value value) { - assert value.getKind() == Kind.Object && isConstant(value); - return recordDataReferenceInCode((Constant) value, 8, false); - } - - public AbstractAddress asIntAddr(Value value) { - assert value.getKind() == Kind.Int; - return asAddress(value); - } - - public AbstractAddress asLongAddr(Value value) { - assert value.getKind() == Kind.Long; - return asAddress(value); - } - - public AbstractAddress asObjectAddr(Value value) { - assert value.getKind() == Kind.Object; - return asAddress(value); - } - - public AbstractAddress asFloatAddr(Value value) { - assert value.getKind() == Kind.Float; - return asAddress(value); - } - - public AbstractAddress asDoubleAddr(Value value) { - assert value.getKind() == Kind.Double; - return asAddress(value); - } - - public AbstractAddress asAddress(Value value) { - assert isStackSlot(value); - StackSlot slot = asStackSlot(value); - return asm.makeAddress(frameMap.registerConfig.getFrameRegister(), frameMap.offsetForStackSlot(slot)); - } -}
--- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java Tue Dec 03 16:06:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,161 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.truffle.hotspot.amd64; - -import com.oracle.graal.amd64.*; -import com.oracle.graal.api.code.CallingConvention.Type; -import com.oracle.graal.api.code.*; -import com.oracle.graal.api.meta.*; -import com.oracle.graal.asm.*; -import com.oracle.graal.asm.amd64.*; -import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; -import com.oracle.graal.compiler.gen.*; -import com.oracle.graal.compiler.target.*; -import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.*; -import com.oracle.graal.hotspot.amd64.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.asm.*; -import com.oracle.graal.nodes.*; -import com.oracle.graal.phases.tiers.*; -import com.oracle.graal.truffle.*; -import com.oracle.graal.truffle.hotspot.amd64.util.*; -import com.oracle.truffle.api.*; -import com.oracle.truffle.api.frame.*; - -/** - * Backend that decorates an existing {@link AMD64HotSpotBackend}, injecting special code into - * {@link OptimizedCallTarget#call(PackedFrame, Arguments)} for making a tail-call to the entry - * point of the target callee. - */ -class AMD64HotSpotTruffleBackend extends Backend { - - private final AMD64HotSpotBackend original; - - private HotSpotResolvedJavaMethod optimizedCallTargetCall; - - public AMD64HotSpotTruffleBackend(AMD64HotSpotBackend original) { - super(original.getProviders()); - this.original = original; - } - - private ResolvedJavaMethod getInstrumentedMethod() throws GraalInternalError { - if (optimizedCallTargetCall == null) { - try { - optimizedCallTargetCall = (HotSpotResolvedJavaMethod) getProviders().getMetaAccess().lookupJavaMethod( - OptimizedCallTarget.class.getDeclaredMethod("call", PackedFrame.class, Arguments.class)); - optimizedCallTargetCall.setDontInline(); - } catch (NoSuchMethodException | SecurityException e) { - throw new GraalInternalError(e); - } - } - return optimizedCallTargetCall; - } - - @Override - public SuitesProvider getSuites() { - return original.getSuites(); - } - - @Override - public DisassemblerProvider getDisassembler() { - return original.getDisassembler(); - } - - @Override - public FrameMap newFrameMap() { - return original.newFrameMap(); - } - - @Override - public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) { - return original.newLIRGenerator(graph, frameMap, cc, lir); - } - - @Override - protected AbstractAssembler createAssembler(FrameMap frameMap) { - return null; - } - - @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { - return original.newAssembler(lirGen, compilationResult); - } - - @Override - public boolean shouldAllocateRegisters() { - return original.shouldAllocateRegisters(); - } - - @Override - public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) { - AMD64MacroAssembler asm = (AMD64MacroAssembler) tasm.asm; - FrameMap frameMap = tasm.frameMap; - RegisterConfig regConfig = frameMap.registerConfig; - HotSpotVMConfig config = original.getRuntime().getConfig(); - Label verifiedStub = new Label(); - - // Emit the prefix - original.emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub); - - if (getInstrumentedMethod().equals(installedCodeOwner)) { - // Inject code for {@link OptimizedCallTarget#call(PackedFrame, Arguments)} - injectCode(asm, config); - } - - // Emit code for the LIR - original.emitCodeBody(installedCodeOwner, tasm, lirGen); - - // Emit the suffix - original.emitCodeSuffix(installedCodeOwner, tasm, lirGen, asm, frameMap); - } - - private void injectCode(AMD64MacroAssembler asm, HotSpotVMConfig config) { - HotSpotProviders providers = original.getRuntime().getHostProviders(); - Register thisRegister = providers.getCodeCache().getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, Kind.Object)[0]; - Register spillRegister = AMD64.r10; // TODO(mg): fix me - AMD64Address nMethodAddress = new AMD64Address(thisRegister, OptimizedCallTargetFieldInfo.getCompiledMethodFieldOffset()); - if (config.useCompressedOops) { - asm.movl(spillRegister, nMethodAddress); - AMD64HotSpotMove.decodePointer(asm, spillRegister, providers.getRegisters().getHeapBaseRegister(), config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment()); - } else { - asm.movq(spillRegister, nMethodAddress); - } - Label doProlog = new Label(); - - asm.cmpq(spillRegister, 0); - asm.jcc(ConditionFlag.Equal, doProlog); - - AMD64Address codeBlobAddress = new AMD64Address(spillRegister, OptimizedCallTargetFieldInfo.getCodeBlobFieldOffset()); - asm.movq(spillRegister, codeBlobAddress); - asm.cmpq(spillRegister, 0); - asm.jcc(ConditionFlag.Equal, doProlog); - - AMD64Address verifiedEntryPointAddress = new AMD64Address(spillRegister, config.nmethodEntryOffset); - asm.movq(spillRegister, verifiedEntryPointAddress); - asm.jmp(spillRegister); - - asm.bind(doProlog); - } -}
--- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java Tue Dec 03 16:06:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.truffle.hotspot.amd64; - -import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.target.*; -import com.oracle.graal.hotspot.amd64.*; -import com.oracle.graal.truffle.*; - -/** - * Factory to create a Truffle-specialized AMD64 HotSpot backend. - */ -@ServiceProvider(TruffleBackendFactory.class) -public class AMD64HotSpotTruffleBackendFactory implements TruffleBackendFactory { - - @Override - public Backend createBackend(Backend original) { - return new AMD64HotSpotTruffleBackend((AMD64HotSpotBackend) original); - } - - public String getArchitecture() { - return "AMD64"; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java Tue Dec 03 18:40:03 2013 +0100 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.truffle.hotspot.amd64; + +import com.oracle.graal.amd64.*; +import com.oracle.graal.api.code.CallingConvention.Type; +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; +import com.oracle.graal.api.runtime.*; +import com.oracle.graal.asm.*; +import com.oracle.graal.asm.amd64.*; +import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.amd64.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.asm.*; +import com.oracle.graal.truffle.*; +import com.oracle.graal.truffle.hotspot.*; + +@ServiceProvider(OptimizedCallTargetInstrumentationFactory.class) +public class AMD64OptimizedCallTargetInstrumentationFactory implements OptimizedCallTargetInstrumentationFactory { + + public CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, + CompilationResult compilationResult) { + return new OptimizedCallTargetInstrumentation(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult) { + @Override + protected void injectTailCallCode(HotSpotVMConfig config, HotSpotRegistersProvider registers) { + @SuppressWarnings("hiding") + AMD64MacroAssembler asm = (AMD64MacroAssembler) this.asm; + Register thisRegister = codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, Kind.Object)[0]; + Register spillRegister = AMD64.r10; // TODO(mg): fix me + AMD64Address nMethodAddress = new AMD64Address(thisRegister, getFieldOffset("installedCode", OptimizedCallTarget.class)); + int verifiedEntryPoint = asm.codeBuffer.position(); + if (config.useCompressedOops) { + asm.movl(spillRegister, nMethodAddress); + asm.nop(AMD64HotSpotBackend.PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE - (asm.codeBuffer.position() - verifiedEntryPoint)); + AMD64HotSpotMove.decodePointer(asm, spillRegister, registers.getHeapBaseRegister(), config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment()); + } else { + asm.movq(spillRegister, nMethodAddress); + asm.nop(AMD64HotSpotBackend.PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE - (asm.codeBuffer.position() - verifiedEntryPoint)); + } + Label doProlog = new Label(); + + asm.cmpq(spillRegister, 0); + asm.jcc(ConditionFlag.Equal, doProlog); + + AMD64Address codeBlobAddress = new AMD64Address(spillRegister, getFieldOffset("codeBlob", HotSpotInstalledCode.class)); + asm.movq(spillRegister, codeBlobAddress); + asm.cmpq(spillRegister, 0); + asm.jcc(ConditionFlag.Equal, doProlog); + + AMD64Address verifiedEntryPointAddress = new AMD64Address(spillRegister, config.nmethodEntryOffset); + asm.movq(spillRegister, verifiedEntryPointAddress); + asm.jmp(spillRegister); + + asm.bind(doProlog); + } + }; + } + + public void setInstrumentedMethod(ResolvedJavaMethod method) { + HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; + hsMethod.setDontInline(); + } + + public String getArchitecture() { + return "AMD64"; + } +}
--- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/util/OptimizedCallTargetFieldInfo.java Tue Dec 03 16:06:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.truffle.hotspot.amd64.util; - -import java.lang.reflect.*; - -import sun.misc.*; - -import com.oracle.graal.graph.*; -import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.truffle.*; - -public class OptimizedCallTargetFieldInfo { - - private static final Unsafe unsafe = UnsafeAccess.unsafe; - private static int compiledMethodFieldOffset = -1; - private static int codeBlobFieldOffset = -1; - - public static int getCodeBlobFieldOffset() { - if (codeBlobFieldOffset == -1) { - codeBlobFieldOffset = getFieldOffset("codeBlob", HotSpotInstalledCode.class); - } - return codeBlobFieldOffset; - } - - public static int getCompiledMethodFieldOffset() { - if (compiledMethodFieldOffset == -1) { - compiledMethodFieldOffset = getFieldOffset("installedCode", OptimizedCallTarget.class); - } - return compiledMethodFieldOffset; - - } - - private static int getFieldOffset(String name, Class container) { - try { - container.getDeclaredField(name).setAccessible(true); - Field field = container.getDeclaredField(name); - return (int) unsafe.objectFieldOffset(field); - } catch (NoSuchFieldException | SecurityException e) { - throw GraalInternalError.shouldNotReachHere(); - } - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java Tue Dec 03 18:40:03 2013 +0100 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.truffle.hotspot; + +import java.lang.reflect.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.CompilationResult.Mark; +import com.oracle.graal.asm.*; +import com.oracle.graal.graph.*; +import com.oracle.graal.hotspot.*; +import com.oracle.graal.hotspot.bridge.*; +import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.asm.*; +import com.oracle.graal.truffle.*; +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.frame.*; + +/** + * Mechanism for injecting special code into + * {@link OptimizedCallTarget#call(PackedFrame, Arguments)} . + */ +public abstract class OptimizedCallTargetInstrumentation extends CompilationResultBuilder { + + public OptimizedCallTargetInstrumentation(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, + CompilationResult compilationResult) { + super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult); + } + + @Override + public Mark recordMark(Object id) { + Mark mark = super.recordMark(id); + if (Integer.valueOf(Marks.MARK_VERIFIED_ENTRY).equals(id)) { + HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig(); + HotSpotRegistersProvider registers = HotSpotGraalRuntime.runtime().getHostProviders().getRegisters(); + injectTailCallCode(config, registers); + } + return mark; + } + + protected static int getFieldOffset(String name, Class declaringClass) { + try { + declaringClass.getDeclaredField(name).setAccessible(true); + Field field = declaringClass.getDeclaredField(name); + return (int) UnsafeAccess.unsafe.objectFieldOffset(field); + } catch (NoSuchFieldException | SecurityException e) { + throw GraalInternalError.shouldNotReachHere(); + } + } + + /** + * Injects code into the verified entry point of that makes a tail-call to the target callee. + */ + protected abstract void injectTailCallCode(HotSpotVMConfig config, HotSpotRegistersProvider registers); +}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.truffle; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.truffle.TruffleCompilerOptions.*; import java.lang.reflect.*; @@ -32,10 +33,12 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.compiler.*; import com.oracle.graal.compiler.target.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; @@ -160,8 +163,12 @@ public static void installOptimizedCallTargetCallMethod() { Providers providers = getGraalProviders(); MetaAccessProvider metaAccess = providers.getMetaAccess(); + CodeCacheProvider codeCache = providers.getCodeCache(); ResolvedJavaMethod resolvedCallMethod = metaAccess.lookupJavaMethod(getCallMethod()); - providers.getCodeCache().setDefaultMethod(resolvedCallMethod, compileMethod(resolvedCallMethod)); + CompilationResult compResult = compileMethod(resolvedCallMethod); + try (Scope s = Debug.scope("CodeInstall", codeCache, resolvedCallMethod)) { + codeCache.setDefaultMethod(resolvedCallMethod, compResult); + } } private static Method getCallMethod() { @@ -174,16 +181,15 @@ return method; } - private static Backend instrumentBackend(Backend original) { - String arch = original.getTarget().arch.getName(); - - for (TruffleBackendFactory factory : ServiceLoader.loadInstalled(TruffleBackendFactory.class)) { + private static CompilationResultBuilderFactory getOptimizedCallTargetInstrumentationFactory(String arch, ResolvedJavaMethod method) { + for (OptimizedCallTargetInstrumentationFactory factory : ServiceLoader.loadInstalled(OptimizedCallTargetInstrumentationFactory.class)) { if (factory.getArchitecture().equals(arch)) { - return factory.createBackend(original); + factory.setInstrumentedMethod(method); + return factory; } } - - return original; + // No specialization of OptimizedCallTarget on this platform. + return CompilationResultBuilderFactory.Default; } private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) { @@ -199,8 +205,9 @@ phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, graph.method(), false); Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); - return GraalCompiler.compileGraph(graph, cc, javaMethod, providers, instrumentBackend(backend), providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, - new SpeculationLog(), suites, new CompilationResult()); + CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod); + return compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, getProfilingInfo(graph), + new SpeculationLog(), suites, true, new CompilationResult(), factory); } private static Providers getGraalProviders() {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTargetInstrumentationFactory.java Tue Dec 03 18:40:03 2013 +0100 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.truffle; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.lir.asm.*; +import com.oracle.truffle.api.*; +import com.oracle.truffle.api.frame.*; + +/** + * A service for creating a specialized {@link CompilationResultBuilder} used to inject code into + * {@link OptimizedCallTarget#call(PackedFrame, Arguments)}. + */ +public interface OptimizedCallTargetInstrumentationFactory extends CompilationResultBuilderFactory { + + /** + * Gets the architecture supported by this factory. + */ + String getArchitecture(); + + /** + * Notifies this object of the method that is being instrumented. + */ + void setInstrumentedMethod(ResolvedJavaMethod method); +}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleBackendFactory.java Tue Dec 03 16:06:39 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.truffle; - -import com.oracle.graal.compiler.target.*; - -public interface TruffleBackendFactory { - - Backend createBackend(Backend original); - - /** - * Gets the CPU architecture of this backend. - */ - String getArchitecture(); -}
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Tue Dec 03 16:06:39 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Tue Dec 03 18:40:03 2013 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.truffle; import static com.oracle.graal.api.code.CodeUtil.*; +import static com.oracle.graal.compiler.GraalCompiler.*; import static com.oracle.graal.truffle.TruffleCompilerOptions.*; import java.io.*; @@ -41,6 +42,7 @@ import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.debug.internal.*; import com.oracle.graal.java.*; +import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.spi.*; import com.oracle.graal.phases.*; @@ -221,8 +223,8 @@ CodeCacheProvider codeCache = providers.getCodeCache(); CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); CompilationResult compilationResult = new CompilationResult(graph.method().toString()); - result = GraalCompiler.compileGraphNoScope(graph, cc, graph.method(), providers, backend, codeCache.getTarget(), null, plan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, - compilationResult); + result = compileGraph(graph, cc, graph.method(), providers, backend, codeCache.getTarget(), null, plan, OptimisticOptimizations.ALL, getProfilingInfo(graph), new SpeculationLog(), suites, + false, compilationResult, CompilationResultBuilderFactory.Default); } catch (Throwable e) { throw Debug.handle(e); } @@ -243,25 +245,21 @@ result.setAssumptions(newAssumptions); - InstalledCode compiledMethod = null; + InstalledCode installedCode = null; try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache()); TimerCloseable a = CodeInstallationTime.start()) { - InstalledCode installedCode = providers.getCodeCache().addMethod(graph.method(), result); - if (installedCode != null) { - Debug.dump(new Object[]{result, installedCode}, "After code installation"); - } - compiledMethod = installedCode; + installedCode = providers.getCodeCache().addMethod(graph.method(), result); } catch (Throwable e) { throw Debug.handle(e); } for (AssumptionValidAssumption a : validAssumptions) { - a.getAssumption().registerInstalledCode(compiledMethod); + a.getAssumption().registerInstalledCode(installedCode); } if (Debug.isLogEnabled()) { - Debug.log(providers.getCodeCache().disassemble(result, compiledMethod)); + Debug.log(providers.getCodeCache().disassemble(result, installedCode)); } - return compiledMethod; + return installedCode; } private PhasePlan createPhasePlan(final GraphBuilderConfiguration config) {
--- a/mx/projects Tue Dec 03 16:06:39 2013 +0100 +++ b/mx/projects Tue Dec 03 18:40:03 2013 +0100 @@ -153,7 +153,7 @@ # graal.hotspot.ptx project@com.oracle.graal.hotspot.ptx@subDir=graal project@com.oracle.graal.hotspot.ptx@sourceDirs=src -project@com.oracle.graal.hotspot.ptx@dependencies=com.oracle.graal.ptx,com.oracle.graal.compiler.ptx +project@com.oracle.graal.hotspot.ptx@dependencies=com.oracle.graal.ptx,com.oracle.graal.compiler.ptx,com.oracle.graal.hotspot project@com.oracle.graal.hotspot.ptx@checkstyle=com.oracle.graal.graph project@com.oracle.graal.hotspot.ptx@annotationProcessors=com.oracle.graal.service.processor project@com.oracle.graal.hotspot.ptx@javaCompliance=1.7 @@ -403,7 +403,7 @@ # graal.compiler.ptx project@com.oracle.graal.compiler.ptx@subDir=graal project@com.oracle.graal.compiler.ptx@sourceDirs=src -project@com.oracle.graal.compiler.ptx@dependencies=com.oracle.graal.lir.ptx,com.oracle.graal.hotspot +project@com.oracle.graal.compiler.ptx@dependencies=com.oracle.graal.lir.ptx,com.oracle.graal.compiler project@com.oracle.graal.compiler.ptx@checkstyle=com.oracle.graal.graph project@com.oracle.graal.compiler.ptx@javaCompliance=1.7 project@com.oracle.graal.compiler.ptx@workingSets=Graal,PTX @@ -667,10 +667,19 @@ project@com.oracle.graal.truffle.test@javaCompliance=1.7 project@com.oracle.graal.truffle.test@workingSets=Graal,Truffle,Test +# graal.truffle.hotspot +project@com.oracle.graal.truffle.hotspot@subDir=graal +project@com.oracle.graal.truffle.hotspot@sourceDirs=src +project@com.oracle.graal.truffle.hotspot@dependencies=com.oracle.graal.truffle,com.oracle.graal.hotspot +project@com.oracle.graal.truffle.hotspot@checkstyle=com.oracle.graal.graph +project@com.oracle.graal.truffle.hotspot@javaCompliance=1.7 +project@com.oracle.graal.truffle.hotspot@annotationProcessors=com.oracle.graal.service.processor +project@com.oracle.graal.truffle.hotspot@workingSets=Graal,Truffle + # graal.truffle.hotspot.amd64 project@com.oracle.graal.truffle.hotspot.amd64@subDir=graal project@com.oracle.graal.truffle.hotspot.amd64@sourceDirs=src -project@com.oracle.graal.truffle.hotspot.amd64@dependencies=com.oracle.graal.truffle,com.oracle.graal.hotspot.amd64 +project@com.oracle.graal.truffle.hotspot.amd64@dependencies=com.oracle.graal.truffle.hotspot,com.oracle.graal.hotspot.amd64 project@com.oracle.graal.truffle.hotspot.amd64@checkstyle=com.oracle.graal.graph project@com.oracle.graal.truffle.hotspot.amd64@javaCompliance=1.7 project@com.oracle.graal.truffle.hotspot.amd64@annotationProcessors=com.oracle.graal.service.processor
--- a/src/cpu/x86/vm/nativeInst_x86.cpp Tue Dec 03 16:06:39 2013 +0100 +++ b/src/cpu/x86/vm/nativeInst_x86.cpp Tue Dec 03 18:40:03 2013 +0100 @@ -472,6 +472,7 @@ // // In C2 the 5+ byte sized instruction is enforced by code in MachPrologNode::emit. // In C1 the restriction is enforced by CodeEmitter::method_entry +// In Graal, the restriction is enforced by HotSpotFrameContext.enter(...) // void NativeJump::patch_verified_entry(address entry, address verified_entry, address dest) { // complete jump instruction (to be inserted) is in code_buffer;
--- a/src/share/vm/code/nmethod.cpp Tue Dec 03 16:06:39 2013 +0100 +++ b/src/share/vm/code/nmethod.cpp Tue Dec 03 18:40:03 2013 +0100 @@ -1523,15 +1523,15 @@ assert(state == not_entrant, "other cases may need to be handled differently"); } #ifdef GRAAL - if (_graal_installed_code != NULL) { - // Break the link between nmethod and HotSpotInstalledCode such that the nmethod can subsequently be flushed safely. - HotSpotInstalledCode::set_codeBlob(_graal_installed_code, 0); - } + if (_graal_installed_code != NULL) { + // Break the link between nmethod and HotSpotInstalledCode such that the nmethod can subsequently be flushed safely. + HotSpotInstalledCode::set_codeBlob(_graal_installed_code, 0); + } #endif if (TraceCreateZombies) { ResourceMark m; - tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", this, this->method()->name_and_sig_as_C_string(), (state == not_entrant) ? "not entrant" : "zombie"); + tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", this, this->method() ? this->method()->name_and_sig_as_C_string() : "null", (state == not_entrant) ? "not entrant" : "zombie"); } NMethodSweeper::report_state_change(this);
--- a/src/share/vm/graal/graalCompilerToVM.cpp Tue Dec 03 16:06:39 2013 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Tue Dec 03 18:40:03 2013 +0100 @@ -856,8 +856,8 @@ // a ResourceMark and the buffer expands within the scope of the mark, // the buffer becomes garbage when that scope is exited. Experience shows that // the disassembled code is typically about 10x the code size so a fixed buffer - // sized to 20x code size should be sufficient. - int bufferSize = cb->code_size() * 20; + // sized to 20x code size plus a fixed amount for header info should be sufficient. + int bufferSize = cb->code_size() * 20 + 1024; char* buffer = NEW_RESOURCE_ARRAY(char, bufferSize); stringStream st(buffer, bufferSize); if (cb->is_nmethod()) {