/** * Marks the beginning of a pass. */ void startPass(String passName) { Preconditions.checkState(currentTracer == null); currentPassName = passName; currentTracer = newTracer(passName); }
/** * Marks the beginning of a pass. */ void startPass(String passName) { checkState(currentTracer == null); currentPassName = passName; currentTracer = newTracer(passName); beforePass(passName); }
@Override public CompilerState call() throws Exception { Tracer tracer = newTracer(PassNames.DESERIALIZE_COMPILER_STATE); logger.fine("Deserializing the CompilerState"); CompilerState compilerState = (CompilerState) objectInputStream.readObject(); logger.fine("Finished deserializing CompilerState"); if (compilerState.typeRegistry != null) { logger.fine("Deserializing the TypeRegistry"); compilerState.typeRegistry.restoreContents(objectInputStream); logger.fine("Finished deserializing TypeRegistry"); } stopTracer(tracer, PassNames.DESERIALIZE_COMPILER_STATE); return compilerState; } });
/** * Runs custom passes that are designated to run at a particular time. */ private void runCustomPasses(CustomPassExecutionTime executionTime) { if (options.customPasses != null) { Tracer t = newTracer("runCustomPasses"); try { for (CompilerPass p : options.customPasses.get(executionTime)) { process(p); } } finally { stopTracer(t, "runCustomPasses"); } } }
/** * Generates a report of all warnings and errors found during compilation to stderr. * * <p>Client code must call this method explicitly if it doesn't use one of the convenience * methods that do so automatically. * <p>Always call this method, even if the compiler throws an exception. The report will include * information about the exception. */ public void generateReport() { Tracer t = newTracer("generateReport"); errorManager.generateReport(); stopTracer(t, "generateReport"); }
/** * Runs custom passes that are designated to run at a particular time. */ private void runCustomPasses(CustomPassExecutionTime executionTime) { if (options.customPasses != null) { Tracer t = newTracer("runCustomPasses"); try { for (CompilerPass p : options.customPasses.get(executionTime)) { process(p); } } finally { stopTracer(t, "runCustomPasses"); } } }
@Override public Void call() throws Exception { Tracer tracer = newTracer("orderInputsWithLargeStack"); try { orderInputs(); } finally { stopTracer(tracer, "orderInputsWithLargeStack"); } return null; } });
private void instrumentForCoverageInternal(boolean instrumentBranchCoverage) { Tracer tracer = newTracer("instrumentationPass"); InstrumentOption instrumentOption = InstrumentOption.LINE_ONLY; if (instrumentBranchCoverage) { instrumentOption = InstrumentOption.BRANCH_ONLY; } process(new CoverageInstrumentationPass(this, CoverageReach.ALL, instrumentOption)); stopTracer(tracer, "instrumentationPass"); }
/** Control Flow Analysis. */ ControlFlowGraph<Node> computeCFG() { logger.fine("Computing Control Flow Graph"); Tracer tracer = newTracer("computeCFG"); ControlFlowAnalysis cfa = new ControlFlowAnalysis(this, true, false); process(cfa); stopTracer(tracer, "computeCFG"); return cfa.getCfg(); }
void orderInputsWithLargeStack() { runInCompilerThread( () -> { Tracer tracer = newTracer("orderInputsWithLargeStack"); try { orderInputs(); } finally { stopTracer(tracer, "orderInputsWithLargeStack"); } return null; }); }
/** Control Flow Analysis. */ ControlFlowGraph<Node> computeCFG() { logger.fine("Computing Control Flow Graph"); Tracer tracer = newTracer("computeCFG"); ControlFlowAnalysis cfa = new ControlFlowAnalysis(this, true, false); process(cfa); stopTracer(tracer, "computeCFG"); return cfa.getCfg(); }
@GwtIncompatible("ObjectOutputStream") public void saveState(OutputStream outputStream) throws IOException { // Do not close the outputstream, caller is responsible for closing it. final ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); runInCompilerThread( () -> { Tracer tracer = newTracer("serializeCompilerState"); objectOutputStream.writeObject(new CompilerState(Compiler.this)); if (typeRegistry != null) { typeRegistry.saveContents(objectOutputStream); } stopTracer(tracer, "serializeCompilerState"); return null; }); }
@Override public String[] call() throws Exception { Tracer tracer = newTracer("toSourceArray"); try { int numInputs = inputs.size(); String[] sources = new String[numInputs]; CodeBuilder cb = new CodeBuilder(); for (int i = 0; i < numInputs; i++) { Node scriptNode = inputs.get(i).getAstRoot(Compiler.this); cb.reset(); toSource(cb, i, scriptNode); sources[i] = cb.toString(); } return sources; } finally { stopTracer(tracer, "toSourceArray"); } } });
public void whitespaceOnlyPasses() { Tracer t = newTracer("runWhitespaceOnlyPasses"); try { for (PassFactory pf : getPassConfig().getWhitespaceOnlyPasses()) { pf.create(this).process(externsRoot, jsRoot); } } finally { stopTracer(t, "runWhitespaceOnlyPasses"); } }
public void whitespaceOnlyPasses() { runCustomPasses(CustomPassExecutionTime.BEFORE_CHECKS); Tracer t = newTracer("runWhitespaceOnlyPasses"); try { for (PassFactory pf : getPassConfig().getWhitespaceOnlyPasses()) { pf.create(this).process(externsRoot, jsRoot); } } finally { stopTracer(t, "runWhitespaceOnlyPasses"); } }
/** * Compiles a list of inputs. */ public <T1 extends SourceFile, T2 extends SourceFile> Result compile( List<T1> externs, List<T2> inputs, CompilerOptions options) { // The compile method should only be called once. Preconditions.checkState(jsRoot == null); try { init(externs, inputs, options); if (hasErrors()) { return getResult(); } return compile(); } finally { Tracer t = newTracer("generateReport"); errorManager.generateReport(); stopTracer(t, "generateReport"); } }
/** * Compiles a list of modules. */ public <T extends SourceFile> Result compileModules(List<T> externs, List<JSModule> modules, CompilerOptions options) { // The compile method should only be called once. Preconditions.checkState(jsRoot == null); try { initModules(externs, modules, options); if (hasErrors()) { return getResult(); } return compile(); } finally { Tracer t = newTracer("generateReport"); errorManager.generateReport(); stopTracer(t, "generateReport"); } }
public void transpileAndDontCheck() { Tracer t = newTracer("runTranspileOnlyPasses"); try { for (PassFactory pf : getPassConfig().getTranspileOnlyPasses()) { if (hasErrors()) { return; } pf.create(this).process(externsRoot, jsRoot); } } finally { stopTracer(t, "runTranspileOnlyPasses"); } }
@Override public String call() throws Exception { Tracer tracer = newTracer("toSource"); try { CodeBuilder cb = new CodeBuilder(); if (jsRoot != null) { int i = 0; for (Node scriptNode = jsRoot.getFirstChild(); scriptNode != null; scriptNode = scriptNode.getNext()) { toSource(cb, i++, scriptNode); } } return cb.toString(); } finally { stopTracer(tracer, "toSource"); } } });
/** * Converts the parse tree for each input back to JS code. */ public String[] toSourceArray() { return runInCompilerThread( () -> { Tracer tracer = newTracer("toSourceArray"); try { int numInputs = moduleGraph.getInputCount(); String[] sources = new String[numInputs]; CodeBuilder cb = new CodeBuilder(); int i = 0; for (CompilerInput input : moduleGraph.getAllInputs()) { Node scriptNode = input.getAstRoot(Compiler.this); cb.reset(); toSource(cb, i, scriptNode); sources[i] = cb.toString(); i++; } return sources; } finally { stopTracer(tracer, "toSourceArray"); } }); }