# HG changeset patch # User Christian Humer # Date 1383853631 -3600 # Node ID fb4658e16b5da4c6f658cf054d93332c32869dda # Parent 60142b15ed42454d3eb2a3a651d1831f146c7277 Truffle: some regression fixes to previous cleanup diff -r 60142b15ed42 -r fb4658e16b5d graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Thu Nov 07 19:07:41 2013 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/OptimizedCallTarget.java Thu Nov 07 20:47:11 2013 +0100 @@ -75,10 +75,6 @@ return callHelper(caller, args); } - public CompilationProfile getCompilationProfile() { - return compilationProfile; - } - private Object callHelper(PackedFrame caller, Arguments args) { if (installedCode != null && installedCode.isValid()) { TruffleRuntime runtime = Truffle.getRuntime(); @@ -102,6 +98,10 @@ } } + public CompilationProfile getCompilationProfile() { + return compilationProfile; + } + private Object compiledCodeInvalidated(PackedFrame caller, Arguments args) { invalidate(); return call(caller, args); @@ -130,9 +130,12 @@ private Object interpreterCall(PackedFrame caller, Arguments args) { CompilerAsserts.neverPartOfCompilation(); compilationProfile.reportInterpreterCall(); - if (compilationEnabled) { + if (compilationEnabled && shouldCompile()) { + if (isCompiling()) { + return waitForCompilation(caller, args); + } boolean inlined = shouldInline() && inline(); - if (!inlined && shouldCompile()) { + if (!inlined) { compile(); } } @@ -147,26 +150,31 @@ return TruffleFunctionInlining.getValue(); } - public void compile() { - CompilerAsserts.neverPartOfCompilation(); + private boolean isCompiling() { if (installedCodeTask != null) { - // There is already a compilation running. if (installedCodeTask.isCancelled()) { installedCodeTask = null; - } else { - if (installedCodeTask.isDone()) { - installedCode = receiveInstalledCode(); - } - return; + return false; } + return true; } + return false; + } + public void compile() { this.installedCodeTask = compiler.compile(this); if (!TruffleBackgroundCompilation.getValue()) { installedCode = receiveInstalledCode(); } } + private Object waitForCompilation(PackedFrame caller, Arguments args) { + if (installedCodeTask.isDone()) { + installedCode = receiveInstalledCode(); + } + return executeHelper(caller, args); + } + private InstalledCode receiveInstalledCode() { try { return installedCodeTask.get();