aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 9daab820..9bedfe68 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -61,8 +61,16 @@ var RuntimeGenerator = {
// An allocation that cannot normally be free'd (except through sbrk, which once
// called, takes control of STATICTOP)
staticAlloc: function(size) {
+ if (ASSERTIONS) size = '(assert(!staticSealed),' + size + ')'; // static area must not be sealed
var ret = RuntimeGenerator.alloc(size, 'STATIC', INIT_HEAP);
- if (USE_TYPED_ARRAYS) ret += '; if (STATICTOP >= TOTAL_MEMORY) enlargeMemory();'
+ return ret;
+ },
+
+ // allocation on the top of memory, adjusted dynamically by sbrk
+ dynamicAlloc: function(size) {
+ if (ASSERTIONS) size = '(assert(DYNAMICTOP > 0),' + size + ')'; // dynamic area must be ready
+ var ret = RuntimeGenerator.alloc(size, 'DYNAMIC', INIT_HEAP);
+ if (USE_TYPED_ARRAYS) ret += '; if (DYNAMICTOP >= TOTAL_MEMORY) enlargeMemory();'
return ret;
},
@@ -466,6 +474,7 @@ var Runtime = {
Runtime.stackAlloc = unInline('stackAlloc', ['size']);
Runtime.staticAlloc = unInline('staticAlloc', ['size']);
+Runtime.dynamicAlloc = unInline('dynamicAlloc', ['size']);
Runtime.alignMemory = unInline('alignMemory', ['size', 'quantum']);
Runtime.makeBigInt = unInline('makeBigInt', ['low', 'high', 'unsigned']);
@@ -529,3 +538,9 @@ function reSign(value, bits, ignore, sig) {
return value;
}
+// The address globals begin at. Very low in memory, for code size and optimization opportunities.
+// Above 0 is static memory, starting with globals.
+// Then the stack.
+// Then 'dynamic' memory for sbrk.
+Runtime.GLOBAL_BASE = Runtime.alignMemory(1);
+