-
-
Notifications
You must be signed in to change notification settings - Fork 940
Expand file tree
/
Copy pathFullBuildTask.java
More file actions
54 lines (44 loc) · 2.14 KB
/
FullBuildTask.java
File metadata and controls
54 lines (44 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package org.jruby.compiler;
import org.jruby.internal.runtime.methods.InterpretedIRMethod;
import org.jruby.ir.IRScope;
import org.jruby.ir.interpreter.InterpreterContext;
import org.jruby.ir.persistence.IRDumper;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;
import java.io.ByteArrayOutputStream;
/**
* Created by headius on 12/8/16.
*/
class FullBuildTask implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(FullBuildTask.class);
private final JITCompiler jitCompiler;
private final Compilable<InterpreterContext> method;
FullBuildTask(JITCompiler jitCompiler, Compilable<InterpreterContext> method) {
this.jitCompiler = jitCompiler;
this.method = method;
}
public void run() {
try {
var scope = method.getIRScope();
var context = scope.getManager().getRuntime().getCurrentContext();
IRScope hardScope = scope.getNearestTopLocalVariableScope();
// define_method may capture something outside itself and we need parents and children to compile
// to agreement with respect to local variable access (e.g. dynscopes).
if (hardScope != scope) hardScope.prepareFullBuild();
method.completeBuild(context, scope.prepareFullBuild());
if (IRRuntimeHelpers.shouldPrintIR(jitCompiler.runtime) && IRRuntimeHelpers.shouldPrintScope(scope)) {
ByteArrayOutputStream baos = IRDumper.printIR(scope, true, true);
LOG.info("Printing full IR for " + scope.getId() + ":\n" + new String(baos.toByteArray()));
}
if (jitCompiler.config.isJitLogging()) JITCompiler.log(context, method, method.getName(), "done building");
} catch (Throwable t) {
if (jitCompiler.config.isJitLogging()) {
//JITCompiler.log(method, method.getName(), "could not build; passes run: " + method.getIRScope().getExecutedPasses(), t);
if (jitCompiler.config.isJitLoggingVerbose()) {
t.printStackTrace();
}
}
}
}
}