diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/runtime.js | 7 | ||||
-rw-r--r-- | src/settings.js | 5 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/runtime.js b/src/runtime.js index 0b809d6b..c99d9d6f 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -30,10 +30,7 @@ RuntimeGenerator = { }, stackEnter: function(initial) { - if (initial === 0) return ''; // 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 && SKIP_STACK_IN_SMALL) return ''; var ret = 'var __stackBase__ = STACKTOP; STACKTOP += ' + initial; if (ASSERTIONS) { ret += '; assert(STACKTOP < STACK_MAX)'; @@ -45,7 +42,7 @@ RuntimeGenerator = { }, stackExit: function(initial) { - if (initial === 0) return ''; // See comment in stackEnter + if (initial === 0 && SKIP_STACK_IN_SMALL) return ''; var ret = ''; if (SAFE_HEAP) { ret += 'for (var i = __stackBase__; i < STACKTOP; i++) SAFE_HEAP_CLEAR(i);'; diff --git a/src/settings.js b/src/settings.js index 7fd9f17c..0243a191 100644 --- a/src/settings.js +++ b/src/settings.js @@ -38,6 +38,11 @@ INIT_HEAP = 0; // Whether to initialize memory anywhere other than the stack to OPTIMIZE = 0; // Optimize llvm operations into js commands RELOOP = 0; // Recreate js native loops from llvm data USE_TYPED_ARRAYS = 0; // Try to use typed arrays for the heap +SKIP_STACK_IN_SMALL = 1; // When enabled, does not push/pop the stack at all in + // functions that have no basic stack usage. But, they + // may allocate stack later, and in a loop, this can be + // very bad. In particular, when debugging, printf()ing + // a lot can exhaust the stack very fast, with this option. // Generated code debugging options SAFE_HEAP = 0; // Check each write to the heap against a list of blocked addresses |