aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-11-22 21:10:31 -0800
committerAlon Zakai <azakai@mozilla.com>2010-11-22 21:10:31 -0800
commitd3f5cfa7e7544af1754be29c5776d32a5fc08c17 (patch)
tree97aaf50b06390b79c5c4ba1e0fda2299619badb1 /src
parent76c55fb93de2861d19fb7c7664c325554d43ff9c (diff)
strengthen SAFE_HEAP in malloc and on the stack
Diffstat (limited to 'src')
-rw-r--r--src/library.js4
-rw-r--r--src/runtime.js16
2 files changed, 9 insertions, 11 deletions
diff --git a/src/library.js b/src/library.js
index 76c657bd..e39d5a1e 100644
--- a/src/library.js
+++ b/src/library.js
@@ -385,6 +385,10 @@ var Library = {
var now = Date.now();
IHEAP[ptr + indexes[0]] = Math.floor(now/1000); // seconds
IHEAP[ptr + indexes[1]] = Math.floor((now-1000*Math.floor(now/1000))*1000); // microseconds
+#if SAFE_HEAP
+ SAFE_HEAP_ACCESS(ptr + indexes[0], 'i32', true);
+ SAFE_HEAP_ACCESS(ptr + indexes[1], 'i32', true);
+#endif
return 0;
},
diff --git a/src/runtime.js b/src/runtime.js
index 2ad54295..3b7ab23c 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -5,10 +5,7 @@
RuntimeGenerator = {
alloc: function(size, type) {
var ret = type + 'TOP';
-// ret += '; for (var i = 0; i < ' + size + '; i++) HEAP[' + type + 'TOP+i] = 0'; // No need for typed arrays - per the spec, initialized to 0 anyhow
- if (SAFE_HEAP) {
- ret += '; for (var j = 0; j < ' + size + '; j++) SAFE_HEAP_CLEAR(' + type + 'TOP+j);';
- }
+ //ret += '; for (var i = 0; i < ' + size + '; i++) HEAP[' + type + 'TOP+i] = 0'; // No need for typed arrays - per the spec, initialized to 0 anyhow
if (GUARD_MEMORY) {
ret += '; assert(' + size + ' > 0)';
}
@@ -29,14 +26,11 @@ RuntimeGenerator = {
},
stackEnter: function(initial) {
- if (!GUARD_MEMORY && initial === 0) return ''; // XXX Note that we don't even push the stack! This is faster, but
- // means that we don't clear stack allocations done in this function
- // until the parent unwinds its stack. So potentially if we are in
- // a loop, we can use a lot of memory.
+ if (initial === 0) return ''; // XXX Note that we don't even push the stack! This is faster, but
+ // means that we don't clear stack allocations done in this function
+ // until the parent unwinds its stack. So potentially if we are in
+ // a loop, we can use a lot of memory.
var ret = 'var __stackBase__ = STACKTOP; STACKTOP += ' + initial;
- if (SAFE_HEAP) {
- ret += '; for (var i = __stackBase__; i < STACKTOP; i++) SAFE_HEAP_STORE(i, 0, null);';
- }
if (GUARD_MEMORY) {
ret += '; assert(STACKTOP < STACK_MAX)';
}