aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-10-18 21:15:36 -0700
committeralon@honor <none@none>2010-10-18 21:15:36 -0700
commit890130e93bc1128d7b5fbdcc512e243ef78cd712 (patch)
tree161ed3d2fd17a4858e82d1c751861598a95c474a
parentbaa2806fdd6c01df82058bf523a767e88d7049ae (diff)
fix bug with size of small structures, and parsing them
-rw-r--r--src/analyzer.js4
-rw-r--r--src/enzymatic.js3
-rw-r--r--src/intertyper.js4
-rw-r--r--src/settings.js2
-rw-r--r--tests/runner.py23
5 files changed, 27 insertions, 9 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index 4a692826..d1039e1c 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -197,7 +197,9 @@ function analyzer(data) {
} else if (dedup(diffs).length == 1) {
type.flatFactor = diffs[0];
}
- type.flatSize = Runtime.alignMemory(type.flatSize); // final padding at end
+ if (type.flatSize > QUANTUM_SIZE) {
+ type.flatSize = Runtime.alignMemory(type.flatSize); // final padding at end
+ }
type.needsFlattening = (this.flatFactor != 1);
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)));
diff --git a/src/enzymatic.js b/src/enzymatic.js
index bb4458fe..d940030e 100644
--- a/src/enzymatic.js
+++ b/src/enzymatic.js
@@ -42,6 +42,7 @@ Substrate.prototype = {
zyme.forwardItems = bind(this, this.addItems);
this.zymes[name_] = zyme;
if (!zyme.process) zyme.process = Zyme.prototype.process;
+ return zyme;
},
solve: function() {
@@ -83,7 +84,7 @@ Substrate.prototype = {
dprint('New results: ' + (outputs.length + that.results.length - currResultCount) + ' out of ' + (that.results.length + outputs.length));
} catch (e) {
print("Exception, current selected are: " + inputs.map(dump).join('\n\n'));
- print("Stack: " + dump(new Error().stack));
+ print("Stack: " + new Error().stack);
throw e;
}
hadProcessing = true;
diff --git a/src/intertyper.js b/src/intertyper.js
index cb92e9ea..d5d41c3a 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -38,7 +38,7 @@ function intertyper(data) {
});
// Line tokenizer
- substrate.addZyme('Tokenizer', {
+ var tokenizer = substrate.addZyme('Tokenizer', {
processItem: function(item, inner) {
var lineText = item.lineText + " ";
var tokens = [];
@@ -238,7 +238,7 @@ function intertyper(data) {
fields = [item.tokens[3].text];
} else if (item.tokens[3].text != 'opaque') {
if (item.tokens[3].type == '<') { // type <{ i8 }> XXX - check spec
- item.tokens[3] = item.tokens[3].item[0];
+ item.tokens[3] = tokenizer.processItem({ lineText: '{ ' + item.tokens[3].item[0].tokens[0].text + ' }' }, true)[0].tokens[0];
}
var subTokens = item.tokens[3].tokens;
subTokens.push({text:','});
diff --git a/src/settings.js b/src/settings.js
index 3018a32f..221a9e84 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -34,7 +34,7 @@ EXCEPTION_DEBUG = 1; // Print out exceptions in emscriptened code
EXECUTION_TIMEOUT = -1; // Throw an exception after X seconds - useful to debug infinite loops
// Compiler debugging options
-DEBUG_TAGS_SHOWING = ['enzymatic', 'relooping'];
+DEBUG_TAGS_SHOWING = ['enzymatic', 'types'];
// Some useful items:
// gconst
// types
diff --git a/tests/runner.py b/tests/runner.py
index 191d5bcf..aa23acd9 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -538,8 +538,8 @@ if 'benchmark' not in sys.argv:
#include <stdio.h>
static const double grid[4][2] = {
- {-3/3.,-1/3.},{+1/3.,-3/3.},
- {-1/3.,+3/3.},{+3/3.,+1/3.}
+ {-3/3.,-1/3.},{+1/3.,-3/3.},
+ {-1/3.,+3/3.},{+3/3.,+1/3.}
};
int main() {
@@ -845,6 +845,17 @@ if 'benchmark' not in sys.argv:
struct B { char buffer[62]; int last; char laster; char laster2; };
+ struct Bits {
+ unsigned short A : 1;
+ unsigned short B : 1;
+ unsigned short C : 1;
+ unsigned short D : 1;
+ unsigned short x1 : 1;
+ unsigned short x2 : 1;
+ unsigned short x3 : 1;
+ unsigned short x4 : 1;
+ };
+
int main() {
hashtable t;
@@ -854,15 +865,19 @@ if 'benchmark' not in sys.argv:
printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", int(b), int(&(b->buffer)), int(&(b->buffer[0])), int(&(b->buffer[1])), int(&(b->buffer[2])),
int(&(b->last)), int(&(b->laster)), int(&(b->laster2)), ES_SIZEOF(B));
+ // Part 3 - bitfields, and small structures
+ Bits *b2 = NULL;
+ printf("*%d*\\n", ES_SIZEOF(Bits));
+
return 0;
}
'''
if QUANTUM_SIZE == 1:
# Compressed memory
- self.do_test(src, '*4,0,1,2,2,3|5,0,1,1,2,3,3,4|6,0,5,0,1,1,2,3,3,4*\n*0,0,0,1,2,62,63,64,65*')
+ self.do_test(src, '*4,0,1,2,2,3|5,0,1,1,2,3,3,4|6,0,5,0,1,1,2,3,3,4*\n*0,0,0,1,2,62,63,64,65*\n*1*')
else:
# Bloated memory; same layout as C/C++
- self.do_test(src, '*16,0,4,8,8,12|20,0,4,4,8,12,12,16|24,0,20,0,4,4,8,12,12,16*\n*0,0,0,1,2,64,68,69,72*')
+ self.do_test(src, '*16,0,4,8,8,12|20,0,4,4,8,12,12,16|24,0,20,0,4,4,8,12,12,16*\n*0,0,0,1,2,64,68,69,72*\n*2*')
def test_fannkuch(self):
results = [ (1,0), (2,1), (3,2), (4,4), (5,7), (6,10), (7, 16), (8,22) ]