|
1 /* -*- Mode: Javascript; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|
2 |
|
3 "use strict"; |
|
4 |
|
5 loadRelativeToScript('utility.js'); |
|
6 loadRelativeToScript('annotations.js'); |
|
7 loadRelativeToScript('loadCallgraph.js'); |
|
8 |
|
9 if (typeof scriptArgs[0] != 'string') |
|
10 throw "Usage: computeGCFunctions.js <callgraph.txt> <out:gcFunctions.txt> <out:gcFunctions.lst> <out:gcEdges.txt> <out:suppressedFunctions.lst>"; |
|
11 |
|
12 var start = "Time: " + new Date; |
|
13 |
|
14 var callgraph_filename = scriptArgs[0]; |
|
15 var gcFunctions_filename = scriptArgs[1] || "gcFunctions.txt"; |
|
16 var gcFunctionsList_filename = scriptArgs[2] || "gcFunctions.lst"; |
|
17 var gcEdges_filename = scriptArgs[3] || "gcEdges.txt"; |
|
18 var suppressedFunctionsList_filename = scriptArgs[4] || "suppressedFunctions.lst"; |
|
19 |
|
20 loadCallgraph(callgraph_filename); |
|
21 |
|
22 printErr("Writing " + gcFunctions_filename); |
|
23 redirect(gcFunctions_filename); |
|
24 for (var name in gcFunctions) { |
|
25 print(""); |
|
26 print("GC Function: " + name + "|" + readableNames[name][0]); |
|
27 do { |
|
28 name = gcFunctions[name]; |
|
29 if (name in readableNames) |
|
30 print(" " + readableNames[name][0]); |
|
31 else |
|
32 print(" " + name); |
|
33 } while (name in gcFunctions); |
|
34 } |
|
35 |
|
36 printErr("Writing " + gcFunctionsList_filename); |
|
37 redirect(gcFunctionsList_filename); |
|
38 for (var name in gcFunctions) { |
|
39 for (var readable of readableNames[name]) |
|
40 print(name + "|" + readable); |
|
41 } |
|
42 |
|
43 // gcEdges is a list of edges that can GC for more specific reasons than just |
|
44 // calling a function that is in gcFunctions.txt. |
|
45 // |
|
46 // Right now, it is unused. It was meant for ~AutoCompartment when it might |
|
47 // wrap an exception, but anything held live across ~AC will have to be held |
|
48 // live across the corresponding constructor (and hence the whole scope of the |
|
49 // AC), and in that case it'll be held live across whatever could create an |
|
50 // exception within the AC scope. So ~AC edges are redundant. I will leave the |
|
51 // stub machinery here for now. |
|
52 printErr("Writing " + gcEdges_filename); |
|
53 redirect(gcEdges_filename); |
|
54 for (var block in gcEdges) { |
|
55 for (var edge in gcEdges[block]) { |
|
56 var func = gcEdges[block][edge]; |
|
57 print([ block, edge, func ].join(" || ")); |
|
58 } |
|
59 } |
|
60 |
|
61 printErr("Writing " + suppressedFunctionsList_filename); |
|
62 redirect(suppressedFunctionsList_filename); |
|
63 for (var name in suppressedFunctions) { |
|
64 print(name); |
|
65 } |