diff options
author | alon@honor <none@none> | 2010-10-21 23:20:08 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-21 23:20:08 -0700 |
commit | d8bda252d5a1a43cb64a8f733fbf59c004017ea6 (patch) | |
tree | 363ab977cb891191e0d9b7e0bbc4e8318df527f4 /src/analyzer.js | |
parent | f57cfb99176a2ec61db5b91aeed1f3ff6a719634 (diff) |
gettimeofday(), and more stuff in Runtime
Diffstat (limited to 'src/analyzer.js')
-rw-r--r-- | src/analyzer.js | 36 |
1 files changed, 3 insertions, 33 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 96f2d509..91b1b884 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -187,39 +187,9 @@ function analyzer(data) { more = true; return; } - // Calculate aligned size, just like C structs should be. TODO: Consider - // requesting that compilation be done with #pragma pack(push) /n #pragma pack(1), - // which would remove much of the complexity here. - type.flatSize = 0; - var diffs = []; - var prev = -1, maxSize = -1; - type.flatIndexes = type.fields.map(function(field) { - var size; - if (isNumberType(field) || isPointerType(field)) { - size = getNativeFieldSize(field, true); // pack char; char; in structs, also char[X]s. - maxSize = Math.max(maxSize, size); - } else if (isStructType(field)) { - size = item.types[field].flatSize; - maxSize = Math.max(maxSize, QUANTUM_SIZE); - } else { - dprint('Unclear type in struct: ' + field + ', in ' + type.name_); - assert(0); - } - var curr = Runtime.alignMemory(type.flatSize, Math.min(QUANTUM_SIZE, size)); // if necessary, place this on aligned memory - type.flatSize = curr + size; - if (prev >= 0) { - diffs.push(curr-prev); - } - prev = curr; - return curr; - }); - type.flatSize = Runtime.alignMemory(type.flatSize, maxSize); - if (diffs.length == 0) { - type.flatFactor = type.flatSize; - } else if (dedup(diffs).length == 1) { - type.flatFactor = diffs[0]; - } - type.needsFlattening = (this.flatFactor != 1); + + Runtime.calculateStructAlignment(type, item.types); + dprint('types', 'type: ' + type.name_ + ' : ' + JSON.stringify(type.fields)); dprint('types', ' has final size of ' + type.flatSize + ', flatting: ' + type.needsFlattening + ' ? ' + (type.flatFactor ? type.flatFactor : JSON.stringify(type.flatIndexes))); }); |