aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-02 14:50:41 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-02 14:50:41 -0800
commit947c6fe1b397b33b1db934a527d482e14ea97a2e (patch)
tree5e21d9809ec5dbd057d58560b38e28196debb26c
parent82bff2906ea63cb6cb37a418abf7ce7a94bb578c (diff)
optimize memory usage in compiler.js, and fixes for emscripten on the web
-rw-r--r--src/compiler.html9
-rw-r--r--src/compiler.js26
2 files changed, 18 insertions, 17 deletions
diff --git a/src/compiler.html b/src/compiler.html
index 2a268e81..fe045356 100644
--- a/src/compiler.html
+++ b/src/compiler.html
@@ -5,8 +5,13 @@ Open the web console to see stderr output
<hr>
<pre id="output"></pre>
<script>
-arguments = ['', '../poppler.ll'];
-//arguments = ['', '../tests/cases/phicubed.ll'];
+ arguments = ['', '../freetype.ll'];
+ //arguments = ['', '../tests/cases/phicubed.ll'];
+
+ var outputElement = document.getElementById('output');
+ print = function(x) {
+ //outputElement.innerHTML += x;
+ };
</script>
<script src="compiler.js">
</script>
diff --git a/src/compiler.js b/src/compiler.js
index 6264b583..32c1120e 100644
--- a/src/compiler.js
+++ b/src/compiler.js
@@ -18,8 +18,6 @@ if (ENVIRONMENT_IS_SHELL) {
read = function(f) { snarf(f) };
}
- load = function(f) { eval.call(globalScope, read(f)) };
-
if (!this['arguments']) {
arguments_ = scriptArgs;
} else {
@@ -27,11 +25,6 @@ if (ENVIRONMENT_IS_SHELL) {
}
} else {
// We are on the web.
- var outputElement = document.getElementById('output');
- print = function(x) {
- outputElement.innerHTML += x;
- };
-
printErr = function(x) {
console.log(x);
};
@@ -43,18 +36,17 @@ if (ENVIRONMENT_IS_SHELL) {
return xhr.responseText;
};
- var that = this;
- load = function(url) {
- // We can't just eval naively, we need properties here to be added to the toplevel global.
- var src = read(url);
- eval.call(globalScope, src);
- };
-
if (this['arguments']) {
arguments_ = arguments;
}
}
+if (!this['load']) {
+ load = function(f) {
+ eval.call(globalScope, read(f));
+ };
+}
+
// Basic utilities
load('utility.js');
@@ -141,7 +133,11 @@ raw = null;
//dprint(JSON.stringify(C_DEFINES));
-JSify(analyzer(intertyper(lines)));
+var intertyped = intertyper(lines);
+lines = null;
+var analyzed = analyzer(intertyped);
+intertyped = null;
+JSify(analyzed);
if (DEBUG_MEMORY) {
print('zzz. last gc: ' + gc());