diff --git a/.hgignore b/.hgignore index 895885254eab..7aa79886a2da 100644 --- a/.hgignore +++ b/.hgignore @@ -43,6 +43,7 @@ _OPT\.OBJ/ ^js/src/autom4te.cache$ # SpiderMonkey test result logs ^js/src/tests/results-.*\.(html|txt)$ +^js/src/devtools/rootAnalysis/t/out # Java HTML5 parser classes ^parser/html/java/(html|java)parser/ diff --git a/js/src/devtools/rootAnalysis/analyze.py b/js/src/devtools/rootAnalysis/analyze.py index 5d41828ca02c..69482dab7b71 100755 --- a/js/src/devtools/rootAnalysis/analyze.py +++ b/js/src/devtools/rootAnalysis/analyze.py @@ -242,7 +242,7 @@ if args.tag and not args.buildcommand: if args.jobs is not None: data['jobs'] = args.jobs if not data.get('jobs'): - data['jobs'] = subprocess.check_output(['nproc', '--ignore=1']) + data['jobs'] = subprocess.check_output(['nproc', '--ignore=1']).strip() if args.buildcommand: data['buildcommand'] = args.buildcommand @@ -286,7 +286,7 @@ for step in steps: for (i, name) in out_indexes(command): data[name] = outfiles[outfile] outfile += 1 - assert len(outfiles) == outfile, 'step \'%s\': mismatched number of output files and params' % step + assert len(outfiles) == outfile, 'step \'%s\': mismatched number of output files (%d) and params (%d)' % (step, outfile, len(outfiles)) if args.step: steps = steps[steps.index(args.step):] diff --git a/js/src/devtools/rootAnalysis/explain.py b/js/src/devtools/rootAnalysis/explain.py index ec7ef1949b1d..dc8b76f5c687 100755 --- a/js/src/devtools/rootAnalysis/explain.py +++ b/js/src/devtools/rootAnalysis/explain.py @@ -3,6 +3,8 @@ import re import argparse +from collections import defaultdict + parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('rootingHazards', nargs='?', default='rootingHazards.txt') parser.add_argument('gcFunctions', nargs='?', default='gcFunctions.txt') @@ -22,7 +24,7 @@ try: # Map from a GC function name to the list of hazards resulting from # that GC function - hazardousGCFunctions = {} + hazardousGCFunctions = defaultdict(list) # List of tuples (gcFunction, index of hazard) used to maintain the # ordering of the hazards @@ -53,7 +55,7 @@ try: # Function names are surrounded by single quotes. Field calls # are unquoted. current_gcFunction = m.group(2) - hazardousGCFunctions.setdefault(current_gcFunction, []).append(line) + hazardousGCFunctions[current_gcFunction].append(line) hazardOrder.append((current_gcFunction, len(hazardousGCFunctions[current_gcFunction]) - 1)) num_hazards += 1 continue @@ -84,12 +86,13 @@ try: if current_func: gcExplanations[current_func] = explanation - for gcFunction, index in hazardOrder: - gcHazards = hazardousGCFunctions[gcFunction] - if gcFunction in gcExplanations: - print >>hazards, (gcHazards[index] + gcExplanations[gcFunction]) - else: - print >>hazards, gcHazards[index] + for gcFunction, index in hazardOrder: + gcHazards = hazardousGCFunctions[gcFunction] + + if gcFunction in gcExplanations: + print >>hazards, (gcHazards[index] + gcExplanations[gcFunction]) + else: + print >>hazards, gcHazards[index] except IOError as e: print 'Failed: %s' % str(e) diff --git a/js/src/devtools/rootAnalysis/loadCallgraph.js b/js/src/devtools/rootAnalysis/loadCallgraph.js index a221d7143764..7661aad8e53a 100644 --- a/js/src/devtools/rootAnalysis/loadCallgraph.js +++ b/js/src/devtools/rootAnalysis/loadCallgraph.js @@ -53,13 +53,8 @@ function addGCFunction(caller, reason) function addCallEdge(caller, callee, suppressed) { - if (!(caller in calleeGraph)) - calleeGraph[caller] = []; - calleeGraph[caller].push({callee:callee, suppressed:suppressed}); - - if (!(callee in callerGraph)) - callerGraph[callee] = []; - callerGraph[callee].push({caller:caller, suppressed:suppressed}); + addToKeyedList(calleeGraph, caller, {callee:callee, suppressed:suppressed}); + addToKeyedList(callerGraph, callee, {caller:caller, suppressed:suppressed}); } // Map from identifier to full "mangled|readable" name. Or sometimes to a