diff options
author | alon@honor <none@none> | 2010-10-08 21:54:49 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-08 21:54:49 -0700 |
commit | 597a3dc5c2c02aca72df52e6e06002b510b7453a (patch) | |
tree | d8fe08a393dfecbb139f372441f942ee230a5a10 /src | |
parent | 7ae56ec8ee8e7c1166afaa7c7305fd73996c483f (diff) |
fix bug with last commit, and better GUARD_MEMORY option
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/library.js | 4 | ||||
-rw-r--r-- | src/runtime.js | 5 | ||||
-rw-r--r-- | src/settings.js | 5 |
4 files changed, 10 insertions, 6 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index cd118644..d21e44d4 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -65,8 +65,8 @@ function JSify(data) { } function alignStruct(values, type) { + // XXX Need to add padding at the end of structures, using alignMemory()? dprint('types', 'alignStruct: ' + dump(type)); - // XXX hardcoded ptr impl var ret = []; var typeData = TYPES[type]; assertTrue(typeData); diff --git a/src/library.js b/src/library.js index 3d91926a..09c4d8f1 100644 --- a/src/library.js +++ b/src/library.js @@ -155,8 +155,8 @@ var Library = { llvm_umul_with_overflow_i32: function(x, y) { return { - f1: x*y, - f2: 0, // We never overflow... for now + f0: x*y, + f1: 0, // We never overflow... for now }; }, 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; diff --git a/src/settings.js b/src/settings.js index 660671fd..d79869f1 100644 --- a/src/settings.js +++ b/src/settings.js @@ -18,8 +18,9 @@ GUARD_SIGNS = 1; // Whether we make sure to convert unsigned values to signed va // needed in some kinds of code. GUARD_LABELS = 0; // Whether we should throw if we encounter a bad __label__, i.e., // if code flow runs into a fault -GUARD_STACK = 1; // Whether we should check that each allocation to the stack does not - // exceed it's size +GUARD_MEMORY = 1; // Whether we should check that each allocation to the stack does not + // exceed it's size, whether all allocations (stack and static) are + // of positive size, etc. // Code embetterments OPTIMIZE = 0; // Optimize llvm operations into js commands |