-
Notifications
You must be signed in to change notification settings - Fork 3.4k
/
Copy pathbatching.diff
44 lines (40 loc) · 1.71 KB
/
batching.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
diff --git a/src/jsifier.js b/src/jsifier.js
index df2ae43..9f8d06a 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -108,6 +108,7 @@ function JSify(data, functionsOnly, givenFunctions) {
}
});
+/*
// TODO: batch small functions
for (var i = 0; i < data.unparsedFunctions.length; i++) {
var func = data.unparsedFunctions[i];
@@ -119,6 +120,7 @@ function JSify(data, functionsOnly, givenFunctions) {
if (DEBUG_MEMORY) MemoryDebugger.tick('func ' + func.ident);
}
func = null; // Do not hold on to anything from inside that loop (JS function scoping..)
+*/
data.unparsedFunctions = null;
// Actors
@@ -1107,8 +1109,22 @@ function JSify(data, functionsOnly, givenFunctions) {
print(postParts[0]);
// Print out global variables and postsets TODO: batching
- JSify(analyzer(intertyper(data.unparsedGlobalss[0].lines, true)), true, Functions);
+//printErr('pre globals!'); sleep(1);
+var MAX_BATCH_SIZE = 1000;//Infinity;
+ while (data.unparsedGlobalss[0].lines.length > 0) {
+ var currLines = [], currSize = 0;
+ while (data.unparsedGlobalss[0].lines.length > 0 && (currSize == 0 || currSize + data.unparsedGlobalss[0].lines[0].length <= MAX_BATCH_SIZE)) {
+ currLines.push(data.unparsedGlobalss[0].lines.shift());
+ currSize += currLines[currLines.length-1].length;
+ }
+//printErr('zz batch size: ' + currSize);
+ JSify(analyzer(intertyper(currLines, true)), true, Functions);
+ }
+throw "ok!";
+printErr('post globals 1! '); sleep(10);
+ currLines = [];
data.unparsedGlobalss = null;
+printErr('post globals 2!'); sleep(10);
print(Functions.generateIndexing()); // done last, as it may rely on aliases set in postsets
print(postParts[1]);