aboutsummaryrefslogtreecommitdiff
path: root/src/runtime.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-09 13:55:35 -0700
committeralon@honor <none@none>2010-10-09 13:55:35 -0700
commiteec779fced0cb0e9df260768d90aa0832f7bef1b (patch)
tree6083c00699840a32f857335b852562d5e5c9a78e /src/runtime.js
parentb7a45a4236221343f96642499d1dfc84f327fb9b (diff)
fix memory alignment/padding of structures | TESTS FIXED
Diffstat (limited to 'src/runtime.js')
-rw-r--r--src/runtime.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime.js b/src/runtime.js
index 250eb50a..346020b0 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -11,7 +11,7 @@ RuntimeGenerator = {
}
ret += '; ' + type + 'TOP += ' + size;
if (QUANTUM_SIZE > 1) {
- ret += ';' + RuntimeGenerator.alignMemory(type + 'TOP');
+ ret += ';' + RuntimeGenerator.alignMemory(type + 'TOP', QUANTUM_SIZE);
}
return ret;
},
@@ -38,8 +38,11 @@ RuntimeGenerator = {
return RuntimeGenerator.alloc(size, 'STATIC');
},
- alignMemory: function(target) {
- return target + ' = Math.ceil(' + target + '/QUANTUM_SIZE)*QUANTUM_SIZE;';
+ alignMemory: function(target, quantum) {
+ if (typeof quantum !== 'number') {
+ quantum = '(quantum ? quantum : QUANTUM_SIZE)';
+ }
+ return target + ' = Math.ceil(' + target + '/' + quantum + ')*' + quantum + ';';
},
};
@@ -56,6 +59,7 @@ function unInline(name_, params) {
Runtime = {
stackAlloc: unInline('stackAlloc', ['size']),
staticAlloc: unInline('staticAlloc', ['size']),
+ alignMemory: unInline('alignMemory', ['size', 'quantum']),
};
function getRuntime() {