aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-02 13:46:14 -0700
committeralon@honor <none@none>2010-10-02 13:46:14 -0700
commit6dcf85c6b014dbc6fc32de186a16b651fcc29b92 (patch)
tree990f76d3d1f3d788515378fa75248ba91f263727 /src
parent51d1c32a775cbb4ac578911fe1ae03b064a792bd (diff)
dlmalloc test
Diffstat (limited to 'src')
-rw-r--r--src/library.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/library.js b/src/library.js
index ad8e440f..68ad805a 100644
--- a/src/library.js
+++ b/src/library.js
@@ -194,6 +194,10 @@ var Library = {
},
sbrk: function(bytes) {
+ // Implement a Linux-like 'memory area' for our 'process'.
+ // Changes the size of the memory area by |bytes|; returns the
+ // address of the previous top ('break') of the memory area
+
// We need to make sure no one else allocates unfreeable memory!
// We must control this entirely. So we don't even need to do
// unfreeable allocations - the HEAP is ours, from HEAPTOP up.
@@ -201,11 +205,15 @@ var Library = {
// sbrk gets a negative increment in |bytes|...
var self = arguments.callee;
if (!self.HEAPTOP) {
+ HEAPTOP = alignMemoryPage(HEAPTOP);
self.HEAPTOP = HEAPTOP;
+ self.DATASIZE = 0;
} else {
assert(self.HEAPTOP == HEAPTOP, "Noone should touch the heap!");
}
- return alignMemoryPage(HEAPTOP);
+ var ret = HEAPTOP + self.DATASIZE;
+ self.DATASIZE += alignMemoryPage(bytes);
+ return ret; // previous break location
},
// time.h