aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyzer.js25
-rw-r--r--src/jsifier.js6
-rw-r--r--src/parseTools.js8
-rw-r--r--src/settings.js4
-rw-r--r--tests/runner.py14
5 files changed, 30 insertions, 27 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index dd14b09a..28c2aa97 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -298,14 +298,6 @@ function analyzer(data) {
// Tools
- function cleanLabel(label) {
- if (label[0] == 'B') {
- return label.substr(5);
- } else {
- return label;
- }
- }
-
function replaceLabels(line, labelIds, toLabelId) {
var ret = [];
function process(item) {
@@ -461,7 +453,12 @@ function analyzer(data) {
}
if (!RELOOP) return emulated();
- if (entries.length > 1) return emulated();
+ // === 'splitter' ===
+
+ if (entries.length > 1) {
+ return emulated();
+ }
+
var entry = entries[0];
assert(entry);
dprint('relooping', 'makeBlock: ' + entry + ',' + labels.length + ' labels');
@@ -513,16 +510,12 @@ function analyzer(data) {
// Verify that no external can reach an internal
var inLabels = set(getLabelIds(internals));
- var fail = false;
externals.forEach(function(external) {
- if (fail || values(setIntersect(external.outLabels, inLabels)).length > 0) {
- fail = true;
+ if (values(setIntersect(external.outLabels, inLabels)).length > 0) {
+ dprint('relooping', 'Found an external that wants to reach an internal, fallback to |return emulated()|?');
+ throw "Spaghetti label flow";
}
});
- if (fail) {
- dprint('relooping', 'Found an external that wants to reach an internal, fallback to flow emulation');
- return emulated();
- }
dprint('relooping', function() { return ' Creating reloop: Inner: ' + dump(getLabelIds(internals)) + ', Exxer: ' + dump(currExitLabels) });
diff --git a/src/jsifier.js b/src/jsifier.js
index 69bc7d1e..1f41f5d7 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -291,7 +291,7 @@ function JSify(data) {
}
ret += '\n';
} else if (block.type == 'reloop') {
- ret += indent + block.entry + ': while(1) {\n';
+ ret += indent + block.entry + ': while(1) { // ' + block.entry + '\n';
ret += walkBlock(block.inner, indent + ' ');
ret += indent + '}\n';
ret += walkBlock(block.outer, indent);
@@ -428,7 +428,7 @@ function JSify(data) {
if (label[0] == 'B') {
if (label[1] == 'R') {
assert(oldLabel);
- return '__label__ = ' + getLabelId(oldLabel) + '; /* ' + label + ' */' + // TODO: optimize away
+ return '__label__ = ' + getLabelId(oldLabel) + '; /* ' + cleanLabel(oldLabel) + ' */ ' + // TODO: optimize away
'break ' + label.substr(5) + ';';
} else if (label[1] == 'C') {
return 'continue ' + label.substr(5) + ';';
@@ -436,7 +436,7 @@ function JSify(data) {
return ';'; // Returning no text might confuse this parser
}
} else {
- return '__label__ = ' + getLabelId(label) + '; /* ' + label + ' */ break;';
+ return '__label__ = ' + getLabelId(label) + '; /* ' + cleanLabel(label) + ' */ break;';
}
}
diff --git a/src/parseTools.js b/src/parseTools.js
index da26727e..e08f3d41 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -425,3 +425,11 @@ function getNativeFieldSize(field, alone) {
return size;
}
+function cleanLabel(label) {
+ if (label[0] == 'B') {
+ return label.substr(5);
+ } else {
+ return label;
+ }
+}
+
diff --git a/src/settings.js b/src/settings.js
index 5e6f16f7..176d6667 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -18,8 +18,8 @@ GUARD_SIGNS = 1; // Whether we make sure to convert unsigned values to signed va
// needed in some kinds of code.
// Code embetterments
-OPTIMIZE = 1; // Optimize llvm operations into js commands
-RELOOP = 0; // Recreate js native loops from llvm data XXX - disabled pending optimizing rewrite
+OPTIMIZE = 0; // Optimize llvm operations into js commands
+RELOOP = 0; // Recreate js native loops from llvm data
// Generated code debugging options
SAFE_HEAP = 0; // Check each write to the heap against a list of blocked addresses
diff --git a/tests/runner.py b/tests/runner.py
index 915e795d..0319feaf 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -29,7 +29,7 @@ def timeout_run(proc, timeout, note):
class T(unittest.TestCase):
def do_test(self, src, expected_output, args=[], output_nicerizer=None, output_processor=None, no_build=False, main_file=None):
if not no_build:
- print 'Running test:', inspect.stack()[1][3], '[%s%s]' % (COMPILER.split(os.sep)[-1], ',reloop' if RELOOP else '')
+ print 'Running test:', inspect.stack()[1][3], '[%s%s]' % (COMPILER.split(os.sep)[-1], ',reloop&optimize' if RELOOP else '')
global DEBUG
dirname = TEMP_DIR + '/tmp' # tempfile.mkdtemp(dir=TEMP_DIR)
if not os.path.exists(dirname):
@@ -68,7 +68,7 @@ class T(unittest.TestCase):
output = Popen([LLVM_DIS, filename + '.o', '-o=' + filename + '.o.llvm'], stdout=PIPE, stderr=STDOUT).communicate()[0]
if DEBUG: print output
# Run Emscripten
- emscripten_settings = ['{ "QUANTUM_SIZE": %d, "RELOOP": %d }' % (QUANTUM_SIZE, RELOOP)]
+ emscripten_settings = ['{ "QUANTUM_SIZE": %d, "RELOOP": %d, "OPTIMIZE": %d }' % (QUANTUM_SIZE, RELOOP, OPTIMIZE)]
out = open(filename + '.o.js', 'w') if not OUTPUT_TO_SCREEN else None
timeout_run(Popen([EMSCRIPTEN, filename + '.o.llvm', PARSER_ENGINE] + emscripten_settings, stdout=out, stderr=STDOUT), 240, 'Compiling')
output = open(filename + '.o.js').read()
@@ -829,7 +829,7 @@ class T(unittest.TestCase):
self.do_test(path_from_root(['tests', 'sauer']), '*\nTemp is 33\n9\n5\nhello, everyone\n*', main_file='command.cpp')
# Generate tests for all our compilers
-def make_test(compiler, reloop):
+def make_test(compiler, embetter):
class TT(T):
def setUp(self):
global COMPILER
@@ -837,11 +837,13 @@ def make_test(compiler, reloop):
global QUANTUM_SIZE
QUANTUM_SIZE = compiler['quantum_size']
global RELOOP
- RELOOP = reloop
+ RELOOP = embetter
+ global OPTIMIZE
+ OPTIMIZE = embetter
return TT
-for reloop in [0,1]:
+for embetter in [0,1]:
for name in COMPILERS.keys():
- exec('T_%s_%d = make_test(COMPILERS["%s"],%d)' % (name, reloop, name, reloop))
+ exec('T_%s_%d = make_test(COMPILERS["%s"],%d)' % (name, embetter, name, embetter))
del T # T is just a shape for the specific subclasses, we don't test it itself
if __name__ == '__main__':