# HG changeset patch # User twisti # Date 1382629904 25200 # Node ID 0f34a60d0bc6078ddbbbfc2902339e976ef02b1f # Parent 86c74ef1b6f596d9b8f8e733e04ad8752a5f9885# Parent ae412befde21a86d8bb1db00cd5bce648882b62c Merge diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java --- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotBackend.java Thu Oct 24 08:51:44 2013 -0700 @@ -252,7 +252,7 @@ /** * @param installedCodeOwner see {@link Backend#emitCode} */ - protected void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { + public void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { HotSpotProviders providers = getProviders(); if (installedCodeOwner != null && !isStatic(installedCodeOwner.getModifiers())) { tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY); @@ -282,14 +282,14 @@ /** * @param installedCodeOwner see {@link Backend#emitCode} */ - protected void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) { + public void emitCodeBody(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen) { lirGen.lir.emitCode(tasm); } /** * @param installedCodeOwner see {@link Backend#emitCode} */ - protected void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { + public void emitCodeSuffix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, LIRGenerator lirGen, AMD64MacroAssembler asm, FrameMap frameMap) { HotSpotProviders providers = getProviders(); HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext; if (frameContext != null && !frameContext.isStub) { diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java --- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackend.java Thu Oct 24 08:51:44 2013 -0700 @@ -29,27 +29,35 @@ 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.*; /** - * Subclass of {@link AMD64HotSpotBackend} that injects special code into + * 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 AMD64HotSpotBackend { +class AMD64HotSpotTruffleBackend extends Backend { + + private final AMD64HotSpotBackend original; private HotSpotResolvedJavaMethod optimizedCallTargetCall; - public AMD64HotSpotTruffleBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) { - super(runtime, providers); + public AMD64HotSpotTruffleBackend(AMD64HotSpotBackend original) { + super(original.getProviders()); + this.original = original; } private ResolvedJavaMethod getInstrumentedMethod() throws GraalInternalError { @@ -66,34 +74,88 @@ } @Override - protected void emitCodePrefix(ResolvedJavaMethod installedCodeOwner, TargetMethodAssembler tasm, AMD64MacroAssembler asm, RegisterConfig regConfig, HotSpotVMConfig config, Label verifiedStub) { - super.emitCodePrefix(installedCodeOwner, tasm, asm, regConfig, config, verifiedStub); - if (getInstrumentedMethod().equals(installedCodeOwner)) { - HotSpotProviders providers = 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(); + 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(); - asm.cmpq(spillRegister, 0); - asm.jcc(ConditionFlag.Equal, doProlog); + // 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); + } - AMD64Address codeBlobAddress = new AMD64Address(spillRegister, OptimizedCallTargetFieldInfo.getCodeBlobFieldOffset()); - asm.movq(spillRegister, codeBlobAddress); - asm.cmpq(spillRegister, 0); - asm.jcc(ConditionFlag.Equal, doProlog); + 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(); - AMD64Address verifiedEntryPointAddress = new AMD64Address(spillRegister, config.nmethodEntryOffset); - asm.movq(spillRegister, verifiedEntryPointAddress); - asm.jmp(spillRegister); + asm.cmpq(spillRegister, 0); + asm.jcc(ConditionFlag.Equal, doProlog); - asm.bind(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); } } diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java --- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64HotSpotTruffleBackendFactory.java Thu Oct 24 08:51:44 2013 -0700 @@ -23,18 +23,22 @@ package com.oracle.graal.truffle.hotspot.amd64; import com.oracle.graal.api.runtime.*; -import com.oracle.graal.hotspot.*; +import com.oracle.graal.compiler.target.*; import com.oracle.graal.hotspot.amd64.*; -import com.oracle.graal.hotspot.meta.*; +import com.oracle.graal.truffle.*; /** * Factory to create a Truffle-specialized AMD64 HotSpot backend. */ -@ServiceProvider(HotSpotBackendFactory.class) -public class AMD64HotSpotTruffleBackendFactory extends AMD64HotSpotBackendFactory { +@ServiceProvider(TruffleBackendFactory.class) +public class AMD64HotSpotTruffleBackendFactory implements TruffleBackendFactory { @Override - protected AMD64HotSpotBackend createBackend(HotSpotGraalRuntime runtime, HotSpotProviders providers) { - return new AMD64HotSpotTruffleBackend(runtime, providers); + public Backend createBackend(Backend original) { + return new AMD64HotSpotTruffleBackend((AMD64HotSpotBackend) original); + } + + public String getArchitecture() { + return "AMD64"; } } diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/PartialEvaluationTest.java Thu Oct 24 08:51:44 2013 -0700 @@ -102,7 +102,7 @@ compilable.call(null, arguments); } while (compilable.inline()); - StructuredGraph graph = Debug.scope("TruffleCompilation", new DebugDumpScope("TruffleCompilation: " + compilable), new Callable() { + StructuredGraph graph = Debug.scope("TruffleCompilation", new TruffleDebugJavaMethod(compilable), new Callable() { @Override public StructuredGraph call() { diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Thu Oct 24 08:51:44 2013 -0700 @@ -174,6 +174,18 @@ return method; } + private static Backend instrumentBackend(Backend original) { + String arch = original.getTarget().arch.getName(); + + for (TruffleBackendFactory factory : ServiceLoader.loadInstalled(TruffleBackendFactory.class)) { + if (factory.getArchitecture().equals(arch)) { + return factory.createBackend(original); + } + } + + return original; + } + private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) { Providers providers = getGraalProviders(); MetaAccessProvider metaAccess = providers.getMetaAccess(); @@ -187,8 +199,8 @@ 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, backend, providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suites, - new CompilationResult()); + return GraalCompiler.compileGraph(graph, cc, javaMethod, providers, instrumentBackend(backend), providers.getCodeCache().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, + new SpeculationLog(), suites, new CompilationResult()); } private static Providers getGraalProviders() { diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/PartialEvaluator.java Thu Oct 24 08:51:44 2013 -0700 @@ -104,7 +104,7 @@ final StructuredGraph graph = new StructuredGraph(executeHelperMethod); - Debug.scope("createGraph", graph, new Runnable() { + Debug.scope("createGraph", new Runnable() { @Override public void run() { diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleBackendFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleBackendFactory.java Thu Oct 24 08:51:44 2013 -0700 @@ -0,0 +1,35 @@ +/* + * 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(); +} diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Thu Oct 24 08:51:44 2013 -0700 @@ -95,7 +95,7 @@ } public InstalledCode compile(final OptimizedCallTarget compilable) { - Object[] debug = new Object[]{new DebugDumpScope("Truffle: " + compilable)}; + Object[] debug = new Object[]{new TruffleDebugJavaMethod(compilable)}; return Debug.scope("Truffle", debug, new Callable() { @Override @@ -132,14 +132,17 @@ } public InstalledCode compileMethodHelper(final StructuredGraph graph, final GraphBuilderConfiguration config, final Assumptions assumptions) { - return compileMethodHelper(graph, config, null, assumptions); + return Debug.scope("Truffle", graph, new Callable() { + public InstalledCode call() throws Exception { + return compileMethodHelper(graph, config, null, assumptions); + } + }); } public InstalledCode compileMethodHelper(final StructuredGraph graph, final GraphBuilderConfiguration config, final OptimizedCallTarget compilable, final Assumptions assumptions) { final PhasePlan plan = createPhasePlan(config); - final TruffleIRJavaMethod truffleJavaMethod = new TruffleIRJavaMethod(providers.getMetaAccess(), compilable); - Debug.scope("TruffleFinal", graph, new Runnable() { + Debug.scope("TruffleFinal", new Runnable() { @Override public void run() { @@ -152,7 +155,7 @@ @Override public CompilationResult call() { try (TimerCloseable a = CompilationTime.start()) { - return Debug.scope("GraalCompiler", new Object[]{truffleJavaMethod, providers.getCodeCache()}, new Callable() { + return Debug.scope("GraalCompiler", new Object[]{providers.getCodeCache()}, new Callable() { public CompilationResult call() { CodeCacheProvider codeCache = providers.getCodeCache(); CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); @@ -181,7 +184,7 @@ result.setAssumptions(newAssumptions); - InstalledCode compiledMethod = Debug.scope("CodeInstall", new Object[]{truffleJavaMethod, providers.getCodeCache()}, new Callable() { + InstalledCode compiledMethod = Debug.scope("CodeInstall", new Object[]{providers.getCodeCache()}, new Callable() { @Override public InstalledCode call() throws Exception { diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleDebugJavaMethod.java Thu Oct 24 08:51:44 2013 -0700 @@ -0,0 +1,132 @@ +/* + * 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 static com.oracle.graal.api.meta.MetaUtil.*; + +import com.oracle.graal.api.meta.*; +import com.oracle.graal.debug.*; +import com.oracle.truffle.api.impl.*; + +/** + * Enables a Truffle compilable to masquerade as a {@link JavaMethod} for use as a context value in + * {@linkplain Debug#scope(String, Object[], Runnable) debug scopes}. + */ +public class TruffleDebugJavaMethod implements JavaMethod { + private final DefaultCallTarget compilable; + + private static final JavaType declaringClass = new JavaType() { + + public String getName() { + return "LTruffle;"; + } + + public JavaType getComponentType() { + return null; + } + + public JavaType getArrayClass() { + throw new UnsupportedOperationException(); + } + + public Kind getKind() { + return Kind.Object; + } + + public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean equals(Object obj) { + return obj.getClass() == getClass(); + } + + @Override + public int hashCode() { + return getName().hashCode(); + } + }; + + private static final Signature signature = new Signature() { + + public JavaType getReturnType(ResolvedJavaType accessingClass) { + return declaringClass; + } + + public Kind getReturnKind() { + return declaringClass.getKind(); + } + + public JavaType getParameterType(int index, ResolvedJavaType accessingClass) { + throw new IndexOutOfBoundsException(); + } + + public int getParameterSlots(boolean withReceiver) { + return 0; + } + + public Kind getParameterKind(int index) { + throw new IndexOutOfBoundsException(); + } + + public int getParameterCount(boolean receiver) { + return 0; + } + }; + + public TruffleDebugJavaMethod(DefaultCallTarget compilable) { + this.compilable = compilable; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof TruffleDebugJavaMethod) { + TruffleDebugJavaMethod other = (TruffleDebugJavaMethod) obj; + return other.compilable.equals(compilable); + } + return false; + } + + @Override + public int hashCode() { + return compilable.hashCode(); + } + + public Signature getSignature() { + return signature; + } + + public String getName() { + return compilable.toString().replace('.', '_').replace(' ', '_'); + } + + public JavaType getDeclaringClass() { + return declaringClass; + } + + @Override + public String toString() { + return format("Truffle<%n(%p)>", this); + } +} diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleIRJavaMethod.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleIRJavaMethod.java Wed Oct 23 19:50:14 2013 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +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 static com.oracle.graal.api.meta.MetaUtil.*; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.debug.*; -import com.oracle.truffle.api.impl.*; - -/** - * Enables a Truffle compilable to masquerade as a {@link JavaMethod} for use as a context value in - * {@linkplain Debug#scope(String, Object[], Runnable) debug scopes}. - */ -class TruffleIRJavaMethod implements JavaMethod { - private final MetaAccessProvider metaAccess; - private final DefaultCallTarget compilable; - - public TruffleIRJavaMethod(MetaAccessProvider metaAccess, DefaultCallTarget compilable) { - this.metaAccess = metaAccess; - this.compilable = compilable; - } - - public Signature getSignature() { - return metaAccess.parseMethodDescriptor("()V"); - } - - public String getName() { - return compilable.toString().replace('.', '_').replace(' ', '_'); - } - - public JavaType getDeclaringClass() { - return metaAccess.lookupJavaType(getClass()); - } - - @Override - public String toString() { - return format(getClass().getSimpleName() + "<%n(%p)>", this); - } -} diff -r ae412befde21 -r 0f34a60d0bc6 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Wed Oct 23 19:50:14 2013 -0700 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/frame/NewFrameNode.java Thu Oct 24 08:51:44 2013 -0700 @@ -163,7 +163,7 @@ ConstantNode tagDefault = ConstantNode.forByte((byte) 0, graph()); for (int i = 0; i < frameSize; i++) { objectArrayEntryState[i] = objectDefault; - primitiveArrayEntryState[i] = initialValue(frameDescriptor.getSlots().get(i).getKind()); + primitiveArrayEntryState[i] = initialPrimitiveValue(frameDescriptor.getSlots().get(i).getKind()); tagArrayEntryState[i] = tagDefault; } tool.getAssumptions().record(new AssumptionValidAssumption((OptimizedAssumption) frameDescriptor.getVersion())); @@ -186,7 +186,7 @@ tool.replaceWithVirtual(virtualFrame); } - private ValueNode initialValue(FrameSlotKind kind) { + private ValueNode initialPrimitiveValue(FrameSlotKind kind) { Kind graalKind = null; switch (kind) { case Boolean: @@ -208,9 +208,8 @@ graalKind = Kind.Long; break; case Object: - graalKind = Kind.Object; - break; case Illegal: + // won't be stored in the primitive array, so default to long graalKind = Kind.Long; break; default: