Program: 53429
Project: 53429
Buggy source:
/** 
 * Takes as input an unresolved Java AST (a Java AST wherein all rebind result classes are available and have not yet been pruned down to the set applicable for a particular permutation) that was previously constructed by the Precompiler and from that constructs output Js source code and related information. This Js source and related information is packaged into a Permutation instance and then returned. Permutation compilation is INTENDED to progress as a series of stages: <pre> 1. initialize local state 2. transform unresolved Java AST to resolved Java AST 3. normalize the resolved Java AST 4. optimize the resolved Java AST 5. construct the Js AST 6. normalize the Js AST 7. optimize the Js AST 8. generate Js source 9. construct and return a value </pre> There are some other types of work here (mostly metrics and data gathering) which do not serve the goal of output program construction. This work should really be moved into subclasses or some sort of callback or plugin system so as not to visually pollute the real compile logic.<br /> Significant amounts of visitors implementing the intended above stages are triggered here but in the wrong order. They have been noted for future cleanup.
 */
private PermutationResult compilePermutation(Permutation permutation,UnifiedAst unifiedAst) throws UnableToCompleteException {
  Event jjsCompilePermutationEvent=SpeedTracerLogger.start(CompilerEventType.JJS_COMPILE_PERMUTATION,"String_Node_Str",permutation.getProperties().prettyPrint());
  long permStartMs=System.currentTimeMillis();
  try {
    Event javaEvent=SpeedTracerLogger.start(CompilerEventType.PERMUTATION_JAVA);
    long startTimeMs=System.currentTimeMillis();
    PermutationProperties properties=permutation.getProperties();
    int permutationId=permutation.getId();
    AST ast=unifiedAst.getFreshAst();
    jprogram=ast.getJProgram();
    jsProgram=ast.getJsProgram();
    Map<StandardSymbolData,JsName> symbolTable=new TreeMap<StandardSymbolData,JsName>(new SymbolData.ClassIdentComparator());
    logger.log(TreeLogger.INFO,"String_Node_Str" + permutationId + "String_Node_Str");
    ResolveRebinds.exec(jprogram,permutation.getGwtCreateAnswers());
    Multimap<String,Integer> instrumentableLines=null;
    if (System.getProperty("String_Node_Str") != null) {
      instrumentableLines=BaselineCoverageGatherer.exec(jprogram);
    }
    jprogram.typeOracle.setJsInteropMode(compilerContext.getOptions().getJsInteropMode());
    maybeRecordReferencesAndControlFlow(false);
    CompileTimeConstantsReplacer.exec(jprogram);
    optimizeJava();
    TypeMapper<?> typeMapper=normalizeSemantics();
    postNormalizationOptimizeJava();
    maybeRecordReferencesAndControlFlow(true);
    jprogram.typeOracle.recomputeAfterOptimizations(jprogram.getDeclaredTypes());
    javaEvent.end();
    Event javaScriptEvent=SpeedTracerLogger.start(CompilerEventType.PERMUTATION_JAVASCRIPT);
    Pair<? extends JavaToJavaScriptMap,Set<JsNode>> jjsMapAndInlineableFunctions=GenerateJavaScriptAST.exec(logger,jprogram,jsProgram,compilerContext,typeMapper,symbolTable,properties);
    JavaToJavaScriptMap jjsmap=jjsMapAndInlineableFunctions.getLeft();
    if (System.getProperty("String_Node_Str") != null) {
      CoverageInstrumentor.exec(jsProgram,instrumentableLines);
    }
    JsNormalizer.exec(jsProgram);
    JsSymbolResolver.exec(jsProgram);
    if (options.getNamespace() == JsNamespaceOption.PACKAGE) {
      JsNamespaceChooser.exec(jsProgram,jjsmap);
    }
    EvalFunctionsAtTopScope.exec(jsProgram,jjsmap);
    final Set<JsNode> inlinableJsFunctions=jjsMapAndInlineableFunctions.getRight();
    optimizeJs(inlinableJsFunctions);
    JsStackEmulator.exec(jprogram,jsProgram,properties,jjsmap);
    Pair<SyntheticArtifact,MultipleDependencyGraphRecorder> dependenciesAndRecorder=splitJsIntoFragments(properties,permutationId,jjsmap);
    Map<JsName,JsLiteral> internedLiteralByVariableName=renameJsSymbols(properties,jjsmap);
    JsBreakUpLargeVarStatements.exec(jsProgram,properties.getConfigurationProperties());
    List<JsSourceMap> sourceInfoMaps=new ArrayList<JsSourceMap>();
    boolean isSourceMapsEnabled=properties.isTrueInAnyPermutation("String_Node_Str");
    String[] jsFragments=new String[jsProgram.getFragmentCount()];
    StatementRanges[] ranges=new StatementRanges[jsFragments.length];
    SizeBreakdown[] sizeBreakdowns=options.isJsonSoycEnabled() || options.isSoycEnabled() || options.isCompilerMetricsEnabled() ? new SizeBreakdown[jsFragments.length] : null;
    generateJavaScriptCode(jjsmap,jsFragments,ranges,sizeBreakdowns,sourceInfoMaps,isSourceMapsEnabled || options.isJsonSoycEnabled());
    javaScriptEvent.end();
    PermutationResult permutationResult=new PermutationResultImpl(jsFragments,permutation,makeSymbolMap(symbolTable),ranges);
    addSyntheticArtifacts(unifiedAst,permutation,startTimeMs,permutationId,jjsmap,dependenciesAndRecorder,internedLiteralByVariableName,isSourceMapsEnabled,jsFragments,sizeBreakdowns,sourceInfoMaps,permutationResult);
    return permutationResult;
  }
 catch (  Throwable e) {
    throw CompilationProblemReporter.logAndTranslateException(logger,e);
  }
 finally {
    jjsCompilePermutationEvent.end();
    if (logger.isLoggable(TreeLogger.TRACE)) {
      logger.log(TreeLogger.TRACE,"String_Node_Str" + (System.currentTimeMillis() - permStartMs) + "String_Node_Str");
    }
  }
}

Fixed version (ground truth):
/** 
 * Takes as input an unresolved Java AST (a Java AST wherein all rebind result classes are available and have not yet been pruned down to the set applicable for a particular permutation) that was previously constructed by the Precompiler and from that constructs output Js source code and related information. This Js source and related information is packaged into a Permutation instance and then returned. Permutation compilation is INTENDED to progress as a series of stages: <pre> 1. initialize local state 2. transform unresolved Java AST to resolved Java AST 3. normalize the resolved Java AST 4. optimize the resolved Java AST 5. construct the Js AST 6. normalize the Js AST 7. optimize the Js AST 8. generate Js source 9. construct and return a value </pre> There are some other types of work here (mostly metrics and data gathering) which do not serve the goal of output program construction. This work should really be moved into subclasses or some sort of callback or plugin system so as not to visually pollute the real compile logic.<br /> Significant amounts of visitors implementing the intended above stages are triggered here but in the wrong order. They have been noted for future cleanup.
 */
private PermutationResult compilePermutation(Permutation permutation,UnifiedAst unifiedAst) throws UnableToCompleteException {
  Event jjsCompilePermutationEvent=SpeedTracerLogger.start(CompilerEventType.JJS_COMPILE_PERMUTATION,"String_Node_Str",permutation.getProperties().prettyPrint());
  long permStartMs=System.currentTimeMillis();
  try {
    Event javaEvent=SpeedTracerLogger.start(CompilerEventType.PERMUTATION_JAVA);
    long startTimeMs=System.currentTimeMillis();
    PermutationProperties properties=permutation.getProperties();
    int permutationId=permutation.getId();
    AST ast=unifiedAst.getFreshAst();
    jprogram=ast.getJProgram();
    jsProgram=ast.getJsProgram();
    Map<StandardSymbolData,JsName> symbolTable=new TreeMap<StandardSymbolData,JsName>(new SymbolData.ClassIdentComparator());
    logger.log(TreeLogger.INFO,"String_Node_Str" + permutationId + "String_Node_Str");
    ResolveRebinds.exec(jprogram,permutation.getGwtCreateAnswers());
    Multimap<String,Integer> instrumentableLines=null;
    if (System.getProperty("String_Node_Str") != null) {
      instrumentableLines=BaselineCoverageGatherer.exec(jprogram);
    }
    jprogram.typeOracle.setJsInteropMode(compilerContext.getOptions().getJsInteropMode());
    maybeRecordReferencesAndControlFlow(false);
    CompileTimeConstantsReplacer.exec(jprogram);
    optimizeJava();
    TypeMapper<?> typeMapper=normalizeSemantics();
    postNormalizationOptimizeJava();
    maybeRecordReferencesAndControlFlow(true);
    javaEvent.end();
    Event javaScriptEvent=SpeedTracerLogger.start(CompilerEventType.PERMUTATION_JAVASCRIPT);
    Pair<? extends JavaToJavaScriptMap,Set<JsNode>> jjsMapAndInlineableFunctions=GenerateJavaScriptAST.exec(logger,jprogram,jsProgram,compilerContext,typeMapper,symbolTable,properties);
    JavaToJavaScriptMap jjsmap=jjsMapAndInlineableFunctions.getLeft();
    if (System.getProperty("String_Node_Str") != null) {
      CoverageInstrumentor.exec(jsProgram,instrumentableLines);
    }
    JsNormalizer.exec(jsProgram);
    JsSymbolResolver.exec(jsProgram);
    if (options.getNamespace() == JsNamespaceOption.PACKAGE) {
      JsNamespaceChooser.exec(jsProgram,jjsmap);
    }
    EvalFunctionsAtTopScope.exec(jsProgram,jjsmap);
    final Set<JsNode> inlinableJsFunctions=jjsMapAndInlineableFunctions.getRight();
    optimizeJs(inlinableJsFunctions);
    JsStackEmulator.exec(jprogram,jsProgram,properties,jjsmap);
    Pair<SyntheticArtifact,MultipleDependencyGraphRecorder> dependenciesAndRecorder=splitJsIntoFragments(properties,permutationId,jjsmap);
    Map<JsName,JsLiteral> internedLiteralByVariableName=renameJsSymbols(properties,jjsmap);
    JsBreakUpLargeVarStatements.exec(jsProgram,properties.getConfigurationProperties());
    List<JsSourceMap> sourceInfoMaps=new ArrayList<JsSourceMap>();
    boolean isSourceMapsEnabled=properties.isTrueInAnyPermutation("String_Node_Str");
    String[] jsFragments=new String[jsProgram.getFragmentCount()];
    StatementRanges[] ranges=new StatementRanges[jsFragments.length];
    SizeBreakdown[] sizeBreakdowns=options.isJsonSoycEnabled() || options.isSoycEnabled() || options.isCompilerMetricsEnabled() ? new SizeBreakdown[jsFragments.length] : null;
    generateJavaScriptCode(jjsmap,jsFragments,ranges,sizeBreakdowns,sourceInfoMaps,isSourceMapsEnabled || options.isJsonSoycEnabled());
    javaScriptEvent.end();
    PermutationResult permutationResult=new PermutationResultImpl(jsFragments,permutation,makeSymbolMap(symbolTable),ranges);
    addSyntheticArtifacts(unifiedAst,permutation,startTimeMs,permutationId,jjsmap,dependenciesAndRecorder,internedLiteralByVariableName,isSourceMapsEnabled,jsFragments,sizeBreakdowns,sourceInfoMaps,permutationResult);
    return permutationResult;
  }
 catch (  Throwable e) {
    throw CompilationProblemReporter.logAndTranslateException(logger,e);
  }
 finally {
    jjsCompilePermutationEvent.end();
    if (logger.isLoggable(TreeLogger.TRACE)) {
      logger.log(TreeLogger.TRACE,"String_Node_Str" + (System.currentTimeMillis() - permStartMs) + "String_Node_Str");
    }
  }
}