aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-05 12:24:46 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-11-06 10:26:10 -0800
commit33cdfe5819e789cb9a98b8b7f66447ceab861f84 (patch)
tree602ae78dc7437a1cd3d87b6bb46dcb598416d9e6 /src/modules.js
parent13b82208767b3af7a8716356c07b6eac26da5ac3 (diff)
split js compiler into three passes, to facilitate future parallization
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/modules.js b/src/modules.js
index ba9f9482..d100b8d4 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -205,7 +205,10 @@ var Types = {
}, this);
},
- needAnalysis: {} // Types noticed during parsing, that need analysis
+ needAnalysis: {}, // Types noticed during parsing, that need analysis
+
+ preciseI64MathUsed: false // Set to true if we actually use precise i64 math: If PRECISE_I64_MATH is set, and also such math is actually
+ // needed (+,-,*,/,% - we do not need it for bitops)
};
var Functions = {
@@ -213,7 +216,7 @@ var Functions = {
currFunctions: [],
// All functions that will be implemented in this file
- implementedFunctions: null,
+ implementedFunctions: [],
// All the function idents seen so far
allIdents: [],
@@ -221,6 +224,8 @@ var Functions = {
indexedFunctions: {},
nextIndex: 2, // Start at a non-0 (even, see below) value
+ blockAddresses: {}, // maps functions to a map of block labels to label ids
+
// Mark a function as needing indexing, and returns the index
getIndex: function(ident) {
var ret = this.indexedFunctions[ident];
@@ -296,3 +301,30 @@ function cDefine(key) {
return key in C_DEFINES ? C_DEFINES[key] : ('0 /* XXX missing C define ' + key + ' */');
}
+var PassManager = {
+ serialize: function() {
+ print('\n//FORWARDED_DATA:' + JSON.stringify({
+ Types: Types,
+ Variables: Variables,
+ Functions: Functions
+ }));
+ },
+ load: function(json) {
+ var data = JSON.parse(json);
+ for (var i in data.Types) {
+ Types[i] = data.Types[i];
+ }
+ for (var i in data.Variables) {
+ Variables[i] = data.Variables[i];
+ }
+ for (var i in data.Functions) {
+ Functions[i] = data.Functions[i];
+ }
+ print('\n//LOADED_DATA:' + phase + ':' + JSON.stringify({
+ Types: Types,
+ Variables: Variables,
+ Functions: Functions
+ }));
+ }
+};
+