Program: 53583
Project: 53583
Buggy source:
/** 
 * Compiles a particular permutation, based on a precompiled unified AST.
 * @param logger the logger to use
 * @param unifiedAst the result of a {@link #precompile(TreeLogger,ModuleDef,RebindPermutationOracle,String[],String[],JJSOptions,boolean,PrecompilationMetricsArtifact)}
 * @param permutation the permutation to compile
 * @return the output JavaScript
 * @throws UnableToCompleteException if an error other than {@link OutOfMemoryError} occurs
 */
public static PermutationResult compilePermutation(TreeLogger logger,UnifiedAst unifiedAst,Permutation permutation) throws UnableToCompleteException {
  JJSOptions options=unifiedAst.getOptions();
  long startTimeMilliseconds=System.currentTimeMillis();
  Event jjsCompilePermutationEvent=SpeedTracerLogger.start(CompilerEventType.JJS_COMPILE_PERMUTATION,"String_Node_Str",permutation.prettyPrint());
  InternalCompilerException.preload();
  PropertyOracle[] propertyOracles=permutation.getPropertyOracles();
  int permutationId=permutation.getId();
  if (logger.isLoggable(TreeLogger.INFO)) {
    logger.log(TreeLogger.INFO,"String_Node_Str" + permutationId + "String_Node_Str");
  }
  long permStart=System.currentTimeMillis();
  try {
    if (JProgram.isTracingEnabled()) {
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str" + permutation.prettyPrint());
    }
    AST ast=unifiedAst.getFreshAst();
    JProgram jprogram=ast.getJProgram();
    JsProgram jsProgram=ast.getJsProgram();
    Map<StandardSymbolData,JsName> symbolTable=new TreeMap<StandardSymbolData,JsName>(new SymbolData.ClassIdentComparator());
    ResolveRebinds.exec(jprogram,permutation.getOrderedRebindAnswers());
    Multimap<String,Integer> instrumentableLines=null;
    if (System.getProperty("String_Node_Str") != null) {
      instrumentableLines=BaselineCoverageGatherer.exec(jprogram);
    }
    int optimizationLevel=options.getOptimizationLevel();
    if (optimizationLevel == OptionOptimize.OPTIMIZE_LEVEL_DRAFT) {
      draftOptimize(jprogram);
    }
 else {
      optimize(options,jprogram);
    }
    RemoveEmptySuperCalls.exec(jprogram);
    JsoDevirtualizer.exec(jprogram);
    CatchBlockNormalizer.exec(jprogram);
    PostOptimizationCompoundAssignmentNormalizer.exec(jprogram);
    LongCastNormalizer.exec(jprogram);
    LongEmulationNormalizer.exec(jprogram);
    CastNormalizer.exec(jprogram,options.isCastCheckingDisabled());
    ArrayNormalizer.exec(jprogram);
    EqualityNormalizer.exec(jprogram);
    Pruner.exec(jprogram,false);
    ReplaceGetClassOverrides.exec(jprogram);
    jprogram.typeOracle.recomputeAfterOptimizations();
    Pair<? extends JavaToJavaScriptMap,Set<JsNode>> genAstResult=GenerateJavaScriptAST.exec(jprogram,jsProgram,options.getOutput(),symbolTable,propertyOracles);
    JavaToJavaScriptMap jjsmap=genAstResult.getLeft();
    JsNormalizer.exec(jsProgram);
    if (instrumentableLines != null) {
      CoverageInstrumentor.exec(jsProgram,instrumentableLines);
    }
    JsSymbolResolver.exec(jsProgram);
    EvalFunctionsAtTopScope.exec(jsProgram,jjsmap);
    if (optimizationLevel > OptionOptimize.OPTIMIZE_LEVEL_DRAFT) {
      optimizeJs(options,jsProgram,genAstResult.getRight());
      JsDuplicateCaseFolder.exec(jsProgram);
    }
    JsStackEmulator.exec(jprogram,jsProgram,propertyOracles,jjsmap);
    JsCoerceIntShift.exec(jsProgram,logger,propertyOracles);
    SyntheticArtifact dependencies=null;
    if (options.isRunAsyncEnabled()) {
      ByteArrayOutputStream baos=new ByteArrayOutputStream();
      int fragmentsMerge=0;
      int expectedFragmentCount=options.getFragmentCount();
      if (expectedFragmentCount > 0) {
        fragmentsMerge=jprogram.getRunAsyncs().size() + 2 - expectedFragmentCount;
      }
 else {
        fragmentsMerge=options.getFragmentsMerge();
      }
      if (fragmentsMerge > 0) {
        CodeSplitter2.exec(logger,jprogram,jsProgram,jjsmap,fragmentsMerge,chooseDependencyRecorder(options.isSoycEnabled(),baos),findIntegerConfigurationProperty(propertyOracles,logger,CodeSplitter2.LEFTOVERMERGE_SIZE,0));
      }
 else {
        CodeSplitter.exec(logger,jprogram,jsProgram,jjsmap,chooseDependencyRecorder(options.isSoycEnabled(),baos));
      }
      if (baos.size() == 0 && options.isSoycEnabled()) {
        recordNonSplitDependencies(jprogram,baos);
      }
      if (baos.size() > 0) {
        dependencies=new SyntheticArtifact(SoycReportLinker.class,"String_Node_Str" + permutationId + "String_Node_Str",baos.toByteArray());
      }
    }
    boolean isIE6orUnknown=findBooleanProperty(propertyOracles,logger,"String_Node_Str","String_Node_Str",true,false,true);
    boolean isSourceMapsEnabled=findBooleanProperty(propertyOracles,logger,"String_Node_Str","String_Node_Str",true,false,false);
    Map<JsName,String> obfuscateMap=Maps.create();
switch (options.getOutput()) {
case OBFUSCATED:
      obfuscateMap=JsStringInterner.exec(jprogram,jsProgram,isIE6orUnknown);
    JsObfuscateNamer.exec(jsProgram,propertyOracles);
  if (options.shouldRemoveDuplicateFunctions()) {
    if (JsStackEmulator.getStackMode(propertyOracles) == JsStackEmulator.StackMode.STRIP) {
      boolean changed=false;
      for (int i=0; i < jsProgram.getFragmentCount(); i++) {
        JsBlock fragment=jsProgram.getFragmentBlock(i);
        changed=JsDuplicateFunctionRemover.exec(jsProgram,fragment) || changed;
      }
      if (changed) {
        JsUnusedFunctionRemover.exec(jsProgram);
        JsObfuscateNamer.exec(jsProgram,propertyOracles);
      }
    }
  }
break;
case PRETTY:
JsPrettyNamer.exec(jsProgram,propertyOracles);
break;
case DETAILED:
obfuscateMap=JsStringInterner.exec(jprogram,jsProgram,isIE6orUnknown);
JsVerboseNamer.exec(jsProgram,propertyOracles);
break;
default :
throw new InternalCompilerException("String_Node_Str");
}
HandleCrossFragmentReferences.exec(logger,jsProgram,propertyOracles);
VerifySymbolMap.exec(jsProgram,jjsmap,symbolTable);
boolean splitBlocks=isIE6orUnknown;
if (splitBlocks) {
JsIEBlockSizeVisitor.exec(jsProgram);
}
JsBreakUpLargeVarStatements.exec(jsProgram,propertyOracles);
String[] js=new String[jsProgram.getFragmentCount()];
StatementRanges[] ranges=new StatementRanges[js.length];
SizeBreakdown[] sizeBreakdowns=options.isSoycEnabled() || options.isCompilerMetricsEnabled() ? new SizeBreakdown[js.length] : null;
List<Map<Range,SourceInfo>> sourceInfoMaps=new ArrayList<Map<Range,SourceInfo>>();
generateJavaScriptCode(options,jprogram,jsProgram,jjsmap,js,ranges,sizeBreakdowns,sourceInfoMaps,splitBlocks,isSourceMapsEnabled);
PermutationResult toReturn=new PermutationResultImpl(js,permutation,makeSymbolMap(symbolTable,jsProgram),ranges);
CompilationMetricsArtifact compilationMetrics=null;
if (options.isCompilerMetricsEnabled()) {
if (options.isClosureCompilerEnabled()) {
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str");
}
 else {
compilationMetrics=new CompilationMetricsArtifact(permutation.getId());
compilationMetrics.setCompileElapsedMilliseconds(System.currentTimeMillis() - startTimeMilliseconds);
compilationMetrics.setElapsedMilliseconds(System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime());
compilationMetrics.setJsSize(sizeBreakdowns);
compilationMetrics.setPermutationDescription(permutation.prettyPrint());
toReturn.addArtifacts(Lists.create(unifiedAst.getModuleMetrics(),unifiedAst.getPrecompilationMetrics(),compilationMetrics));
}
}
if (options.isClosureCompilerEnabled()) {
if (options.isSoycEnabled()) {
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str");
}
}
 else {
toReturn.addArtifacts(makeSoycArtifacts(logger,permutationId,jprogram,js,sizeBreakdowns,options.isSoycExtra() ? sourceInfoMaps : null,dependencies,jjsmap,obfuscateMap,unifiedAst.getModuleMetrics(),unifiedAst.getPrecompilationMetrics(),compilationMetrics,options.isSoycHtmlDisabled()));
}
if (isSourceMapsEnabled) {
if (options.isClosureCompilerEnabled()) {
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str");
}
 else {
logger.log(TreeLogger.INFO,"String_Node_Str");
toReturn.addArtifacts(SourceMapRecorder.makeSourceMapArtifacts(sourceInfoMaps,permutationId));
}
}
logTrackingStats(logger);
if (logger.isLoggable(TreeLogger.TRACE)) {
logger.log(TreeLogger.TRACE,"String_Node_Str" + (System.currentTimeMillis() - permStart) + "String_Node_Str");
}
return toReturn;
}
 catch (Throwable e) {
throw CompilationProblemReporter.logAndTranslateException(logger,e);
}
 finally {
jjsCompilePermutationEvent.end();
}
}

Fixed version (ground truth):
/** 
 * Compiles a particular permutation, based on a precompiled unified AST.
 * @param logger the logger to use
 * @param unifiedAst the result of a {@link #precompile(TreeLogger,ModuleDef,RebindPermutationOracle,String[],String[],JJSOptions,boolean,PrecompilationMetricsArtifact)}
 * @param permutation the permutation to compile
 * @return the output JavaScript
 * @throws UnableToCompleteException if an error other than {@link OutOfMemoryError} occurs
 */
public static PermutationResult compilePermutation(TreeLogger logger,UnifiedAst unifiedAst,Permutation permutation) throws UnableToCompleteException {
  JJSOptions options=unifiedAst.getOptions();
  long startTimeMilliseconds=System.currentTimeMillis();
  Event jjsCompilePermutationEvent=SpeedTracerLogger.start(CompilerEventType.JJS_COMPILE_PERMUTATION,"String_Node_Str",permutation.prettyPrint());
  InternalCompilerException.preload();
  PropertyOracle[] propertyOracles=permutation.getPropertyOracles();
  int permutationId=permutation.getId();
  if (logger.isLoggable(TreeLogger.INFO)) {
    logger.log(TreeLogger.INFO,"String_Node_Str" + permutationId + "String_Node_Str");
  }
  long permStart=System.currentTimeMillis();
  try {
    if (JProgram.isTracingEnabled()) {
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str");
      System.out.println("String_Node_Str" + permutation.prettyPrint());
    }
    AST ast=unifiedAst.getFreshAst();
    JProgram jprogram=ast.getJProgram();
    JsProgram jsProgram=ast.getJsProgram();
    Map<StandardSymbolData,JsName> symbolTable=new TreeMap<StandardSymbolData,JsName>(new SymbolData.ClassIdentComparator());
    ResolveRebinds.exec(jprogram,permutation.getOrderedRebindAnswers());
    Multimap<String,Integer> instrumentableLines=null;
    if (System.getProperty("String_Node_Str") != null) {
      instrumentableLines=BaselineCoverageGatherer.exec(jprogram);
    }
    int optimizationLevel=options.getOptimizationLevel();
    if (optimizationLevel == OptionOptimize.OPTIMIZE_LEVEL_DRAFT) {
      draftOptimize(jprogram);
    }
 else {
      optimize(options,jprogram);
    }
    RemoveEmptySuperCalls.exec(jprogram);
    JsoDevirtualizer.exec(jprogram);
    CatchBlockNormalizer.exec(jprogram);
    PostOptimizationCompoundAssignmentNormalizer.exec(jprogram);
    LongCastNormalizer.exec(jprogram);
    LongEmulationNormalizer.exec(jprogram);
    CastNormalizer.exec(jprogram,options.isCastCheckingDisabled());
    ArrayNormalizer.exec(jprogram);
    EqualityNormalizer.exec(jprogram);
    Pruner.exec(jprogram,false);
    ReplaceGetClassOverrides.exec(jprogram);
    jprogram.typeOracle.recomputeAfterOptimizations();
    Pair<? extends JavaToJavaScriptMap,Set<JsNode>> genAstResult=GenerateJavaScriptAST.exec(jprogram,jsProgram,options.getOutput(),symbolTable,propertyOracles);
    JavaToJavaScriptMap jjsmap=genAstResult.getLeft();
    JsNormalizer.exec(jsProgram);
    if (instrumentableLines != null) {
      CoverageInstrumentor.exec(jsProgram,instrumentableLines);
    }
    JsSymbolResolver.exec(jsProgram);
    EvalFunctionsAtTopScope.exec(jsProgram,jjsmap);
    if (optimizationLevel > OptionOptimize.OPTIMIZE_LEVEL_DRAFT) {
      optimizeJs(options,jsProgram,genAstResult.getRight());
      JsDuplicateCaseFolder.exec(jsProgram);
    }
    JsStackEmulator.exec(jprogram,jsProgram,propertyOracles,jjsmap);
    JsCoerceIntShift.exec(jsProgram,logger,propertyOracles);
    SyntheticArtifact dependencies=null;
    if (options.isRunAsyncEnabled()) {
      ByteArrayOutputStream baos=new ByteArrayOutputStream();
      int fragmentsMerge=0;
      int expectedFragmentCount=options.getFragmentCount();
      if (expectedFragmentCount > 0) {
        fragmentsMerge=jprogram.getRunAsyncs().size() + 2 - expectedFragmentCount;
      }
 else {
        fragmentsMerge=options.getFragmentsMerge();
      }
      if (fragmentsMerge > 0) {
        CodeSplitter2.exec(logger,jprogram,jsProgram,jjsmap,fragmentsMerge,chooseDependencyRecorder(options.isSoycEnabled(),baos),findIntegerConfigurationProperty(propertyOracles,logger,CodeSplitter2.LEFTOVERMERGE_SIZE,0));
      }
 else {
        CodeSplitter.exec(logger,jprogram,jsProgram,jjsmap,chooseDependencyRecorder(options.isSoycEnabled(),baos));
      }
      if (baos.size() == 0 && options.isSoycEnabled()) {
        recordNonSplitDependencies(jprogram,baos);
      }
      if (baos.size() > 0) {
        dependencies=new SyntheticArtifact(SoycReportLinker.class,"String_Node_Str" + permutationId + "String_Node_Str",baos.toByteArray());
      }
    }
    boolean isIE6orUnknown=findBooleanProperty(propertyOracles,logger,"String_Node_Str","String_Node_Str",true,false,true);
    boolean isSourceMapsEnabled=findBooleanProperty(propertyOracles,logger,"String_Node_Str","String_Node_Str",true,false,false);
    Map<JsName,String> obfuscateMap=Maps.create();
switch (options.getOutput()) {
case OBFUSCATED:
      obfuscateMap=JsStringInterner.exec(jprogram,jsProgram,isIE6orUnknown);
    FreshNameGenerator freshNameGenerator=JsObfuscateNamer.exec(jsProgram,propertyOracles);
  if (options.shouldRemoveDuplicateFunctions() && JsStackEmulator.getStackMode(propertyOracles) == JsStackEmulator.StackMode.STRIP) {
    JsDuplicateFunctionRemover.exec(jsProgram,freshNameGenerator);
  }
break;
case PRETTY:
JsPrettyNamer.exec(jsProgram,propertyOracles);
break;
case DETAILED:
obfuscateMap=JsStringInterner.exec(jprogram,jsProgram,isIE6orUnknown);
JsVerboseNamer.exec(jsProgram,propertyOracles);
break;
default :
throw new InternalCompilerException("String_Node_Str");
}
HandleCrossFragmentReferences.exec(logger,jsProgram,propertyOracles);
VerifySymbolMap.exec(jsProgram,jjsmap,symbolTable);
boolean splitBlocks=isIE6orUnknown;
if (splitBlocks) {
JsIEBlockSizeVisitor.exec(jsProgram);
}
JsBreakUpLargeVarStatements.exec(jsProgram,propertyOracles);
String[] js=new String[jsProgram.getFragmentCount()];
StatementRanges[] ranges=new StatementRanges[js.length];
SizeBreakdown[] sizeBreakdowns=options.isSoycEnabled() || options.isCompilerMetricsEnabled() ? new SizeBreakdown[js.length] : null;
List<Map<Range,SourceInfo>> sourceInfoMaps=new ArrayList<Map<Range,SourceInfo>>();
generateJavaScriptCode(options,jprogram,jsProgram,jjsmap,js,ranges,sizeBreakdowns,sourceInfoMaps,splitBlocks,isSourceMapsEnabled);
PermutationResult toReturn=new PermutationResultImpl(js,permutation,makeSymbolMap(symbolTable,jsProgram),ranges);
CompilationMetricsArtifact compilationMetrics=null;
if (options.isCompilerMetricsEnabled()) {
if (options.isClosureCompilerEnabled()) {
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str");
}
 else {
compilationMetrics=new CompilationMetricsArtifact(permutation.getId());
compilationMetrics.setCompileElapsedMilliseconds(System.currentTimeMillis() - startTimeMilliseconds);
compilationMetrics.setElapsedMilliseconds(System.currentTimeMillis() - ManagementFactory.getRuntimeMXBean().getStartTime());
compilationMetrics.setJsSize(sizeBreakdowns);
compilationMetrics.setPermutationDescription(permutation.prettyPrint());
toReturn.addArtifacts(Lists.create(unifiedAst.getModuleMetrics(),unifiedAst.getPrecompilationMetrics(),compilationMetrics));
}
}
if (options.isClosureCompilerEnabled()) {
if (options.isSoycEnabled()) {
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str");
}
}
 else {
toReturn.addArtifacts(makeSoycArtifacts(logger,permutationId,jprogram,js,sizeBreakdowns,options.isSoycExtra() ? sourceInfoMaps : null,dependencies,jjsmap,obfuscateMap,unifiedAst.getModuleMetrics(),unifiedAst.getPrecompilationMetrics(),compilationMetrics,options.isSoycHtmlDisabled()));
}
if (isSourceMapsEnabled) {
if (options.isClosureCompilerEnabled()) {
logger.log(TreeLogger.WARN,"String_Node_Str" + "String_Node_Str");
}
 else {
logger.log(TreeLogger.INFO,"String_Node_Str");
toReturn.addArtifacts(SourceMapRecorder.makeSourceMapArtifacts(sourceInfoMaps,permutationId));
}
}
logTrackingStats(logger);
if (logger.isLoggable(TreeLogger.TRACE)) {
logger.log(TreeLogger.TRACE,"String_Node_Str" + (System.currentTimeMillis() - permStart) + "String_Node_Str");
}
return toReturn;
}
 catch (Throwable e) {
throw CompilationProblemReporter.logAndTranslateException(logger,e);
}
 finally {
jjsCompilePermutationEvent.end();
}
}