Mercurial > hg > graal-compiler
changeset 23090:9496d2b81bc2
Fix GraalCompiler initialization should be done asynchronously in the compiler thread.
author | Christian Humer <christian.humer@oracle.com> |
---|---|
date | Wed, 25 Nov 2015 21:40:38 +0100 |
parents | 767a0f088814 |
children | ee40de319a24 |
files | graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java |
diffstat | 2 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Thu Nov 26 11:31:19 2015 +0100 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Wed Nov 25 21:40:38 2015 +0100 @@ -160,11 +160,20 @@ @Override public TruffleCompiler getTruffleCompiler() { if (truffleCompiler == null) { - truffleCompiler = DefaultTruffleCompiler.create(this); + initializeTruffleCompiler(); } return truffleCompiler; } + private void initializeTruffleCompiler() { + synchronized (this) { + // might occur for multiple compiler threads at the same time. + if (truffleCompiler == null) { + truffleCompiler = DefaultTruffleCompiler.create(this); + } + } + } + @Override public RootCallTarget createCallTarget(RootNode rootNode) { return createCallTargetImpl(null, rootNode); @@ -281,7 +290,6 @@ @Override public void compile(OptimizedCallTarget optimizedCallTarget, boolean mayBeAsynchronous) { - /* Ensure compiler is created. */ getTruffleCompiler(); super.compile(optimizedCallTarget, mayBeAsynchronous);
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Thu Nov 26 11:31:19 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/GraalTruffleRuntime.java Wed Nov 25 21:40:38 2015 +0100 @@ -344,7 +344,7 @@ protected void doCompile(OptimizedCallTarget optimizedCallTarget) { boolean success = true; try (Scope s = Debug.scope("Truffle", new TruffleDebugJavaMethod(optimizedCallTarget))) { - truffleCompiler.compileMethod(optimizedCallTarget); + getTruffleCompiler().compileMethod(optimizedCallTarget); } catch (Throwable e) { optimizedCallTarget.notifyCompilationFailed(e); success = false;