aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-08 21:54:49 -0700
committeralon@honor <none@none>2010-10-08 21:54:49 -0700
commit597a3dc5c2c02aca72df52e6e06002b510b7453a (patch)
treed8fe08a393dfecbb139f372441f942ee230a5a10 /src/runtime.js
parent7ae56ec8ee8e7c1166afaa7c7305fd73996c483f (diff)
fix bug with last commit, and better GUARD_MEMORY option
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 08e42362..250eb50a 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -6,6 +6,9 @@ RuntimeGenerator = {
alloc: function(size, type) {
var ret = type + 'TOP';
// ret += '; for (var i = 0; i < ' + size + '; i++) HEAP[' + type + 'TOP+i] = 0';
+ if (GUARD_MEMORY) {
+ ret += '; assert(' + size + ' > 0)';
+ }
ret += '; ' + type + 'TOP += ' + size;
if (QUANTUM_SIZE > 1) {
ret += ';' + RuntimeGenerator.alignMemory(type + 'TOP');
@@ -16,7 +19,7 @@ RuntimeGenerator = {
// An allocation that lives as long as the current function call
stackAlloc: function(size) {
var ret = RuntimeGenerator.alloc(size, 'STACK');
- if (GUARD_STACK) {
+ if (GUARD_MEMORY) {
ret += '; assert(STACKTOP < STACK_ROOT + STACK_MAX)';
}
return ret;