michael@0: /* -*- Mode: Javascript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: michael@0: "use strict"; michael@0: michael@0: loadRelativeToScript('utility.js'); michael@0: loadRelativeToScript('annotations.js'); michael@0: loadRelativeToScript('loadCallgraph.js'); michael@0: michael@0: if (typeof scriptArgs[0] != 'string') michael@0: throw "Usage: computeGCFunctions.js "; michael@0: michael@0: var start = "Time: " + new Date; michael@0: michael@0: var callgraph_filename = scriptArgs[0]; michael@0: var gcFunctions_filename = scriptArgs[1] || "gcFunctions.txt"; michael@0: var gcFunctionsList_filename = scriptArgs[2] || "gcFunctions.lst"; michael@0: var gcEdges_filename = scriptArgs[3] || "gcEdges.txt"; michael@0: var suppressedFunctionsList_filename = scriptArgs[4] || "suppressedFunctions.lst"; michael@0: michael@0: loadCallgraph(callgraph_filename); michael@0: michael@0: printErr("Writing " + gcFunctions_filename); michael@0: redirect(gcFunctions_filename); michael@0: for (var name in gcFunctions) { michael@0: print(""); michael@0: print("GC Function: " + name + "|" + readableNames[name][0]); michael@0: do { michael@0: name = gcFunctions[name]; michael@0: if (name in readableNames) michael@0: print(" " + readableNames[name][0]); michael@0: else michael@0: print(" " + name); michael@0: } while (name in gcFunctions); michael@0: } michael@0: michael@0: printErr("Writing " + gcFunctionsList_filename); michael@0: redirect(gcFunctionsList_filename); michael@0: for (var name in gcFunctions) { michael@0: for (var readable of readableNames[name]) michael@0: print(name + "|" + readable); michael@0: } michael@0: michael@0: // gcEdges is a list of edges that can GC for more specific reasons than just michael@0: // calling a function that is in gcFunctions.txt. michael@0: // michael@0: // Right now, it is unused. It was meant for ~AutoCompartment when it might michael@0: // wrap an exception, but anything held live across ~AC will have to be held michael@0: // live across the corresponding constructor (and hence the whole scope of the michael@0: // AC), and in that case it'll be held live across whatever could create an michael@0: // exception within the AC scope. So ~AC edges are redundant. I will leave the michael@0: // stub machinery here for now. michael@0: printErr("Writing " + gcEdges_filename); michael@0: redirect(gcEdges_filename); michael@0: for (var block in gcEdges) { michael@0: for (var edge in gcEdges[block]) { michael@0: var func = gcEdges[block][edge]; michael@0: print([ block, edge, func ].join(" || ")); michael@0: } michael@0: } michael@0: michael@0: printErr("Writing " + suppressedFunctionsList_filename); michael@0: redirect(suppressedFunctionsList_filename); michael@0: for (var name in suppressedFunctions) { michael@0: print(name); michael@0: }