aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-12-25 17:18:19 -0800
committerAlon Zakai <azakai@mozilla.com>2010-12-25 17:18:19 -0800
commit2f8f8a72fffffdd2b9f4114c0d7e7d8bc941c1d2 (patch)
treefa50bf720b24980b25a1233d8797d089b5eccd17
parentb2fd961d06812c0bfcecc19521a040b8c0a06d24 (diff)
clean up getNativeFieldSize
-rw-r--r--src/library.js10
-rw-r--r--src/parseTools.js31
-rw-r--r--src/runtime.js6
3 files changed, 22 insertions, 25 deletions
diff --git a/src/library.js b/src/library.js
index 87bfd73b..0d5f2c22 100644
--- a/src/library.js
+++ b/src/library.js
@@ -39,7 +39,7 @@ var Library = {
_ZNSo3putEc: 'putchar',
fopen: function(filename, mode) {
- return 1; // XXX
+ return 1; // TODO
},
__01fopen64_: 'fopen',
@@ -85,11 +85,11 @@ var Library = {
},
fileno: function(file) {
- return 1; // XXX
+ return 1; // TODO
},
isatty: function(file) {
- return 0; // XXX
+ return 0; // TODO
},
clearerr: function(stream) {
@@ -135,7 +135,7 @@ var Library = {
strtod__deps: ['isspace', 'isdigit'],
strtod: function(str, endptr) {
- // XXX handles only whitespace + |[0-9]+(.[0.9]+)?|, no e+
+ // FIXME handles only whitespace + |[0-9]+(.[0.9]+)?|, no e+
while (_isspace(str)) str++;
var chr;
var ret = 0;
@@ -258,7 +258,7 @@ var Library = {
},
strtol: function(ptr) {
- // XXX: We ignore the other two params!
+ assert(!arguments[1] && !arguments[2], "We don't support all strtol params yet");
return parseInt(Pointer_stringify(ptr));
},
diff --git a/src/parseTools.js b/src/parseTools.js
index a5a20939..ac212248 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -335,7 +335,7 @@ function parseLLVMFunctionCall(segment) {
assertTrue(['inreg', 'byval'].indexOf(segment[1].text) == -1);
assert(segment[1].text in PARSABLE_LLVM_FUNCTIONS);
while (!segment[2].item) {
- segment.splice(2, 1); // XXX Remove modifiers - should look into them some day
+ segment.splice(2, 1); // Remove modifiers
if (!segment[2]) throw 'Invalid segment!';
}
var ret = {
@@ -452,23 +452,20 @@ function getLabelIds(labels) {
//! @param alone Whether this is inside a structure (so padding is
//! used) or alone (line in char*, where no padding is done).
function getNativeFieldSize(field, alone) {
- var size;
- if (QUANTUM_SIZE > 1) {
- size = {
- 'i1': alone ? 1 : 4, // inside a struct, aligned to 4,
- 'i8': alone ? 1 : 4, // most likely...? XXX
- 'i16': alone ? 2 : 4, // ditto
- 'i32': 4,
- 'i64': 8,
- 'float': 4,
- 'double':8
- }[field]; // XXX 32/64 bit stuff
- if (!size) {
- size = 4; // Must be a pointer XXX 32/64
- }
- } else {
- size = 1;
+ if (QUANTUM_SIZE == 1) return 1;
+ var size = {
+ 'i1': 1,
+ 'i8': 1,
+ 'i16': 2,
+ 'i32': 4,
+ 'i64': 8,
+ 'float': 4,
+ 'double':8
+ }[field];
+ if (!size) {
+ size = QUANTUM_SIZE; // A pointer
}
+ if (!alone) size = Math.max(size, QUANTUM_SIZE);
return size;
}
diff --git a/src/runtime.js b/src/runtime.js
index f6bcdee9..3784c236 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -31,7 +31,7 @@ RuntimeGenerator = {
},
stackEnter: function(initial) {
- if (initial === 0) return ''; // XXX Note that we don't even push the stack! This is faster, but
+ 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.
@@ -41,7 +41,7 @@ RuntimeGenerator = {
}
var initMemory = 'for (var i = __stackBase__; i < STACKTOP; i++) {' + (
USE_TYPED_ARRAYS ?
- 'IHEAP[i] = FHEAP[i] = 0' : // XXX Suboptimal due to type differences?
+ 'IHEAP[i] = FHEAP[i] = 0' : // TODO: Benchmark this. Suboptimal due to type differences?
'HEAP[i] = 0'
) + (SAFE_HEAP ? '; SAFE_HEAP_ACCESS(i, null, true)' : '') + ' }';
ret += '; ' + initMemory;
@@ -49,7 +49,7 @@ RuntimeGenerator = {
},
stackExit: function(initial) {
- if (initial === 0) return ''; // XXX See comment in stackEnter
+ if (initial === 0) return ''; // See comment in stackEnter
var ret = '';
if (SAFE_HEAP) {
ret += 'for (var i = __stackBase__; i < STACKTOP; i++) SAFE_HEAP_CLEAR(i);';