Mercurial > hg > truffle
changeset 12531:7d5c3ffbee64
Refactoring of the frame prologue injection
author | Matthias Grimmer <grimmer@ssw.jku.at> |
---|---|
date | Wed, 23 Oct 2013 12:46:58 +0200 |
parents | ecd85445f77a |
children | 9b1cc2628961 |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/util/OptimizedCallTargetFieldInfo.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetSubstitutions.java |
diffstat | 5 files changed, 24 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Wed Oct 23 12:45:57 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotCodeCacheProvider.java Wed Oct 23 12:46:58 2013 +0200 @@ -174,7 +174,7 @@ return code; } - public InstalledCode addDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) { + public InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult) { HotSpotResolvedJavaMethod hotspotMethod = (HotSpotResolvedJavaMethod) method; return installMethod(hotspotMethod, StructuredGraph.INVOCATION_ENTRY_BCI, compResult); }
--- a/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/util/OptimizedCallTargetFieldInfo.java Wed Oct 23 12:45:57 2013 +0200 +++ b/graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/util/OptimizedCallTargetFieldInfo.java Wed Oct 23 12:46:58 2013 +0200 @@ -38,32 +38,26 @@ public static int getCodeBlobFieldOffset() { if (codeBlobFieldOffset == -1) { - try { - HotSpotInstalledCode.class.getDeclaredField("codeBlob").setAccessible(true); - Field codeBlobField = HotSpotInstalledCode.class.getDeclaredField("codeBlob"); - codeBlobFieldOffset = (int) unsafe.objectFieldOffset(codeBlobField); - } catch (NoSuchFieldException | SecurityException e) { - throw GraalInternalError.shouldNotReachHere(); - } - return codeBlobFieldOffset; - } else { - return codeBlobFieldOffset; + codeBlobFieldOffset = getFieldOffset("codeBlob", HotSpotInstalledCode.class); } + return codeBlobFieldOffset; } public static int getCompiledMethodFieldOffset() { if (compiledMethodFieldOffset == -1) { - try { - OptimizedCallTarget.class.getDeclaredField("compiledMethod").setAccessible(true); - Field compiledMethodField = OptimizedCallTarget.class.getDeclaredField("compiledMethod"); - compiledMethodFieldOffset = (int) unsafe.objectFieldOffset(compiledMethodField); - } catch (NoSuchFieldException | SecurityException e) { - throw GraalInternalError.shouldNotReachHere(); - } - return compiledMethodFieldOffset; - } else { - return compiledMethodFieldOffset; + compiledMethodFieldOffset = getFieldOffset("compiledMethod", 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(); } } - }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Oct 23 12:45:57 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Oct 23 12:46:58 2013 +0200 @@ -62,16 +62,8 @@ private Replacements truffleReplacements; private ArrayList<String> includes; private ArrayList<String> excludes; - private final CodeCacheProvider codeCacheProvider; - private final ResolvedJavaMethod callMethod; - private final CompilationResult callCompilationResult; private GraalTruffleRuntime() { - Providers providers = getGraalProviders(); - MetaAccessProvider metaAccess = providers.getMetaAccess(); - codeCacheProvider = providers.getCodeCache(); - callMethod = metaAccess.lookupJavaMethod(getCallMethod()); - callCompilationResult = compileMethod(callMethod, providers); installOptimizedCallTargetCallMethod(); } @@ -165,8 +157,11 @@ } } - public void installOptimizedCallTargetCallMethod() { - codeCacheProvider.addDefaultMethod(callMethod, callCompilationResult); + public static void installOptimizedCallTargetCallMethod() { + Providers providers = getGraalProviders(); + MetaAccessProvider metaAccess = providers.getMetaAccess(); + ResolvedJavaMethod resolvedCallMethod = metaAccess.lookupJavaMethod(getCallMethod()); + providers.getCodeCache().setDefaultMethod(resolvedCallMethod, compileMethod(resolvedCallMethod)); } private static Method getCallMethod() { @@ -179,7 +174,8 @@ return method; } - private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod, Providers providers) { + private static CompilationResult compileMethod(ResolvedJavaMethod javaMethod) { + Providers providers = getGraalProviders(); MetaAccessProvider metaAccess = providers.getMetaAccess(); Suites suites = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites().createSuites(); suites.getHighTier().findPhase(InliningPhase.class).remove();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Wed Oct 23 12:45:57 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Wed Oct 23 12:46:58 2013 +0200 @@ -71,16 +71,12 @@ @Override public Object call(PackedFrame caller, Arguments args) { - return callHelper(caller, args); - } - - private Object callHelper(PackedFrame caller, Arguments args) { if (compiledMethod != null && compiledMethod.isValid()) { TruffleRuntime runtime = Truffle.getRuntime(); if (runtime instanceof GraalTruffleRuntime) { OUT.printf("[truffle] reinstall OptimizedCallTarget.call code with frame prolog shortcut."); OUT.println(); - ((GraalTruffleRuntime) runtime).installOptimizedCallTargetCallMethod(); + GraalTruffleRuntime.installOptimizedCallTargetCallMethod(); } } if (TruffleCallTargetProfiling.getValue()) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetSubstitutions.java Wed Oct 23 12:45:57 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/substitutions/OptimizedCallTargetSubstitutions.java Wed Oct 23 12:46:58 2013 +0200 @@ -37,9 +37,6 @@ public static native Object call(OptimizedCallTarget target, PackedFrame caller, Arguments args); @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false) - public static native Object callHelper(OptimizedCallTarget target, PackedFrame caller, Arguments args); - - @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false) public static native Object interpreterCall(OptimizedCallTarget target, PackedFrame caller, Arguments args); @MacroSubstitution(macro = NeverInlineMacroNode.class, isStatic = false)