Mercurial > hg > truffle
changeset 18981:48b79b8e18f1
fix TruffleBoundary usage in SLCallUntilOptimizedBuiltin
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Tue, 27 Jan 2015 23:19:40 +0100 |
parents | ae0eb836e6f4 |
children | 479d2d030bf3 5ff49be5a02c |
files | graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLCallUntilOptimizedBuiltin.java |
diffstat | 1 files changed, 26 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLCallUntilOptimizedBuiltin.java Tue Jan 27 23:14:40 2015 +0100 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/builtins/SLCallUntilOptimizedBuiltin.java Tue Jan 27 23:19:40 2015 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2015, 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 @@ -25,8 +25,8 @@ import java.util.concurrent.*; import com.oracle.graal.truffle.*; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.*; -import com.oracle.truffle.api.CompilerDirectives.*; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.nodes.*; @@ -49,29 +49,43 @@ @Child private IndirectCallNode indirectCall = Truffle.getRuntime().createIndirectCallNode(); @Specialization - @TruffleBoundary public SLFunction callUntilCompiled(VirtualFrame frame, SLFunction function) { OptimizedCallTarget target = ((OptimizedCallTarget) function.getCallTarget()); for (int i = 0; i < MAX_CALLS; i++) { - if (((GraalTruffleRuntime) Truffle.getRuntime()).isCompiling(target) || target.isValid()) { + if (isCompiling(target)) { break; } else { indirectCall.call(frame, target, EMPTY_ARGS); } } + waitForCompilation(target); + + // call one more in compiled + indirectCall.call(frame, target, EMPTY_ARGS); + + checkTarget(target); + + return function; + } + + @TruffleBoundary + private static void checkTarget(OptimizedCallTarget target) throws SLAssertionError { + if (!target.isValid()) { + throw new SLAssertionError("Function " + target + " invalidated."); + } + } + + @TruffleBoundary + private static void waitForCompilation(OptimizedCallTarget target) { try { ((GraalTruffleRuntime) Truffle.getRuntime()).waitForCompilation(target, 640000); } catch (ExecutionException | TimeoutException e) { throw new RuntimeException(e); } - - // call one more in compiled - indirectCall.call(frame, target, EMPTY_ARGS); + } - if (!target.isValid()) { - throw new SLAssertionError("Function " + target + " invalidated."); - } - - return function; + @TruffleBoundary + private static boolean isCompiling(OptimizedCallTarget target) { + return ((GraalTruffleRuntime) Truffle.getRuntime()).isCompiling(target) || target.isValid(); } }