aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js40
-rw-r--r--src/library_browser.js31
-rw-r--r--src/library_glut.js37
-rw-r--r--src/library_sdl.js24
-rw-r--r--src/modules.js3
-rw-r--r--src/relooper/Relooper.cpp10
-rw-r--r--src/relooper/test.txt108
-rw-r--r--src/relooper/test2.txt12
-rw-r--r--src/relooper/test3.txt34
-rw-r--r--src/relooper/test4.txt24
-rw-r--r--src/relooper/test5.txt46
-rw-r--r--src/relooper/test6.txt12
-rw-r--r--src/relooper/test_debug.txt12
-rw-r--r--src/relooper/test_fuzz1.txt40
-rw-r--r--src/relooper/test_fuzz2.txt10
-rw-r--r--src/relooper/test_fuzz3.txt2
-rw-r--r--src/relooper/test_fuzz4.txt16
-rw-r--r--src/relooper/test_fuzz5.txt82
-rw-r--r--src/relooper/test_fuzz6.txt186
-rw-r--r--src/relooper/test_inf.txt698
20 files changed, 733 insertions, 694 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index e9bc9a79..ac6c259b 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -14,6 +14,8 @@ var asmLibraryFunctions = [];
var SETJMP_LABEL = -1;
+var INDENTATION = ' ';
+
// JSifier
function JSify(data, functionsOnly, givenFunctions) {
var mainPass = !functionsOnly;
@@ -591,13 +593,13 @@ function JSify(data, functionsOnly, givenFunctions) {
func.JS += 'function ' + func.ident + '(' + paramIdents.join(', ') + ') {\n';
if (PGO) {
- func.JS += ' PGOMonitor.called["' + func.ident + '"] = 1;\n';
+ func.JS += INDENTATION + 'PGOMonitor.called["' + func.ident + '"] = 1;\n';
}
if (ASM_JS) {
// spell out argument types
func.params.forEach(function(param) {
- func.JS += ' ' + param.ident + ' = ' + asmCoercion(param.ident, param.type) + ';\n';
+ func.JS += INDENTATION + param.ident + ' = ' + asmCoercion(param.ident, param.type) + ';\n';
});
// spell out local variables
@@ -611,7 +613,7 @@ function JSify(data, functionsOnly, givenFunctions) {
i += chunkSize;
}
for (i = 0; i < chunks.length; i++) {
- func.JS += ' var ' + chunks[i].map(function(v) {
+ func.JS += INDENTATION + 'var ' + chunks[i].map(function(v) {
var type = getImplementationType(v);
if (!isIllegalType(type) || v.ident.indexOf('$', 1) > 0) { // not illegal, or a broken up illegal
return v.ident + ' = ' + asmInitializer(type); //, func.variables[v.ident].impl);
@@ -627,7 +629,7 @@ function JSify(data, functionsOnly, givenFunctions) {
if (true) { // TODO: optimize away when not needed
if (CLOSURE_ANNOTATIONS) func.JS += '/** @type {number} */';
- func.JS += ' var label = 0;\n';
+ func.JS += INDENTATION + 'var label = 0;\n';
}
if (ASM_JS) {
@@ -636,12 +638,12 @@ function JSify(data, functionsOnly, givenFunctions) {
hasByVal = hasByVal || param.byVal;
});
if (hasByVal) {
- func.JS += ' var tempParam = 0;\n';
+ func.JS += INDENTATION + 'var tempParam = 0;\n';
}
}
// Prepare the stack, if we need one. If we have other stack allocations, force the stack to be set up.
- func.JS += ' ' + RuntimeGenerator.stackEnter(func.initialStack, func.otherStackAllocations) + ';\n';
+ func.JS += INDENTATION + RuntimeGenerator.stackEnter(func.initialStack, func.otherStackAllocations) + ';\n';
// Make copies of by-value params
// XXX It is not clear we actually need this. While without this we fail, it does look like
@@ -654,7 +656,7 @@ function JSify(data, functionsOnly, givenFunctions) {
if (param.byVal) {
var type = removePointing(param.type);
var typeInfo = Types.types[type];
- func.JS += ' ' + (ASM_JS ? '' : 'var ') + 'tempParam = ' + param.ident + '; ' + param.ident + ' = ' + RuntimeGenerator.stackAlloc(typeInfo.flatSize) + ';' +
+ func.JS += INDENTATION + (ASM_JS ? '' : 'var ') + 'tempParam = ' + param.ident + '; ' + param.ident + ' = ' + RuntimeGenerator.stackAlloc(typeInfo.flatSize) + ';' +
makeCopyValues(param.ident, 'tempParam', typeInfo.flatSize, 'null', null, param.byVal) + ';\n';
}
});
@@ -728,12 +730,12 @@ function JSify(data, functionsOnly, givenFunctions) {
}
ret += 'switch(' + asmCoercion('label', 'i32') + ') {\n';
ret += block.labels.map(function(label) {
- return indent + ' case ' + getLabelId(label.ident) + ': ' + (SHOW_LABELS ? '// ' + getOriginalLabelId(label.ident) : '') + '\n'
- + getLabelLines(label, indent + ' ');
+ return indent + INDENTATION + 'case ' + getLabelId(label.ident) + ': ' + (SHOW_LABELS ? '// ' + getOriginalLabelId(label.ident) : '') + '\n'
+ + getLabelLines(label, indent + INDENTATION + INDENTATION);
}).join('\n') + '\n';
if (func.setjmpTable && ASM_JS) {
// emit a label in which we write to the proper local variable, before jumping to the actual label
- ret += ' case ' + SETJMP_LABEL + ': ';
+ ret += INDENTATION + 'case ' + SETJMP_LABEL + ': ';
ret += func.setjmpTable.map(function(triple) { // original label, label we created for right after the setjmp, variable setjmp result goes into
return 'if ((setjmpLabel|0) == ' + getLabelId(triple.oldLabel) + ') { ' + triple.assignTo + ' = threwValue; label = ' + triple.newLabel + ' }\n';
}).join(' else ');
@@ -741,7 +743,7 @@ function JSify(data, functionsOnly, givenFunctions) {
ret += '__THREW__ = threwValue = 0;\n';
ret += 'break;\n';
}
- if (ASSERTIONS) ret += indent + ' default: assert(0' + (ASM_JS ? '' : ', "bad label: " + label') + ');\n';
+ if (ASSERTIONS) ret += indent + INDENTATION + 'default: assert(0' + (ASM_JS ? '' : ', "bad label: " + label') + ');\n';
ret += indent + '}\n';
if (func.setjmpTable && !ASM_JS) {
ret += ' } catch(e) { if (!e.longjmp || !(e.id in mySetjmpIds)) throw(e); setjmpTable[setjmpLabels[e.id]](e.value) }';
@@ -797,13 +799,13 @@ function JSify(data, functionsOnly, givenFunctions) {
}
return ret;
}
- func.JS += walkBlock(func.block, ' ');
+ func.JS += walkBlock(func.block, INDENTATION);
// Finalize function
if (LABEL_DEBUG && functionNameFilterTest(func.ident)) func.JS += " INDENT = INDENT.substr(0, INDENT.length-2);\n";
// Ensure a return in a function with a type that returns, even if it lacks a return (e.g., if it aborts())
if (RELOOP && func.lines.length > 0 && func.returnType != 'void') {
var returns = func.labels.filter(function(label) { return label.lines[label.lines.length-1].intertype == 'return' }).length;
- if (returns == 0) func.JS += ' return ' + asmCoercion('0', func.returnType);
+ if (returns == 0) func.JS += INDENTATION + 'return ' + asmCoercion('0', func.returnType);
}
func.JS += '}\n';
@@ -1121,7 +1123,7 @@ function JSify(data, functionsOnly, givenFunctions) {
ret += value + '{\n';
}
var phiSet = getPhiSetsForLabel(phiSets, targetLabel);
- ret += ' ' + phiSet + makeBranch(targetLabel, item.currLabelId || null) + '\n';
+ ret += INDENTATION + '' + phiSet + makeBranch(targetLabel, item.currLabelId || null) + '\n';
ret += '}\n';
if (RELOOP) {
item.groupedLabels.push({
@@ -1178,7 +1180,7 @@ function JSify(data, functionsOnly, givenFunctions) {
// in an assignment
var disabled = DISABLE_EXCEPTION_CATCHING == 2 && !(item.funcData.ident in EXCEPTION_CATCHING_WHITELIST);
var phiSets = calcPhiSets(item);
- var call_ = makeFunctionCall(item.ident, item.params, item.funcData, item.type, ASM_JS && !disabled);
+ var call_ = makeFunctionCall(item.ident, item.params, item.funcData, item.type, ASM_JS && !disabled, !!item.assignTo || !item.standalone);
var ret;
@@ -1335,7 +1337,7 @@ function JSify(data, functionsOnly, givenFunctions) {
return ret;
});
- function makeFunctionCall(ident, params, funcData, type, forceByPointer) {
+ function makeFunctionCall(ident, params, funcData, type, forceByPointer, hasReturn) {
// We cannot compile assembly. See comment in intertyper.js:'Call'
assert(ident != 'asm', 'Inline assembly cannot be compiled to JavaScript!');
@@ -1463,8 +1465,8 @@ function JSify(data, functionsOnly, givenFunctions) {
}
}
- var returnType;
- if (byPointer || ASM_JS) {
+ var returnType = 'void';
+ if ((byPointer || ASM_JS) && hasReturn) {
returnType = getReturnType(type);
}
@@ -1509,7 +1511,7 @@ function JSify(data, functionsOnly, givenFunctions) {
makeFuncLineActor('getelementptr', function(item) { return finalizeLLVMFunctionCall(item) });
makeFuncLineActor('call', function(item) {
if (item.standalone && LibraryManager.isStubFunction(item.ident)) return ';';
- return makeFunctionCall(item.ident, item.params, item.funcData, item.type) + (item.standalone ? ';' : '');
+ return makeFunctionCall(item.ident, item.params, item.funcData, item.type, false, !!item.assignTo || !item.standalone) + (item.standalone ? ';' : '');
});
makeFuncLineActor('unreachable', function(item) {
diff --git a/src/library_browser.js b/src/library_browser.js
index 925b64e2..d007d9a7 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -426,8 +426,17 @@ mergeInto(LibraryManager.library, {
Browser.mouseMovementX = Browser.getMovementX(event);
Browser.mouseMovementY = Browser.getMovementY(event);
}
- Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
- Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ Browser.mouseX = SDL.mouseX + Browser.mouseMovementX;
+ Browser.mouseY = SDL.mouseY + Browser.mouseMovementY;
+ } else {
+ // just add the mouse delta to the current absolut mouse position
+ // FIXME: ideally this should be clamped against the canvas size and zero
+ Browser.mouseX += Browser.mouseMovementX;
+ Browser.mouseY += Browser.mouseMovementY;
+ }
} else {
// Otherwise, calculate the movement based on the changes
// in the coordinates.
@@ -504,9 +513,12 @@ mergeInto(LibraryManager.library, {
this.windowedHeight = canvas.height;
canvas.width = screen.width;
canvas.height = screen.height;
- var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}};
- flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
- {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}}
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}};
+ flags = flags | 0x00800000; // set SDL_FULLSCREEN flag
+ {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}}
+ }
Browser.updateResizeListeners();
},
@@ -514,9 +526,12 @@ mergeInto(LibraryManager.library, {
var canvas = Module['canvas'];
canvas.width = this.windowedWidth;
canvas.height = this.windowedHeight;
- var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}};
- flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
- {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}}
+ // check if SDL is available
+ if (typeof SDL != "undefined") {
+ var flags = {{{ makeGetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'i32', 0, 1) }}};
+ flags = flags & ~0x00800000; // clear SDL_FULLSCREEN flag
+ {{{ makeSetValue('SDL.screen+Runtime.QUANTUM_SIZE*0', '0', 'flags', 'i32') }}}
+ }
Browser.updateResizeListeners();
}
diff --git a/src/library_glut.js b/src/library_glut.js
index 38cfe55b..36d47787 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -117,9 +117,9 @@ var LibraryGLUT = {
if (48 <= keycode && keycode <= 57)
return keycode; // numeric TODO handle shift?
if (65 <= keycode && keycode <= 90)
- return event['shiftKey'] ? keycode : keycode + 32;
+ return event['shiftKey'] ? keycode : keycode + 32;
if (106 <= keycode && keycode <= 111)
- return keycode - 106 + 42; // *,+-./ TODO handle shift?
+ return keycode - 106 + 42; // *,+-./ TODO handle shift?
switch (keycode) {
case 27: // escape
@@ -227,7 +227,7 @@ var LibraryGLUT = {
} else {
width = GLUT.windowWidth;
height = GLUT.windowHeight;
- // TODO set position
+ // TODO set position
document.removeEventListener('fullscreenchange', GLUT.onFullScreenEventChange, true);
document.removeEventListener('mozfullscreenchange', GLUT.onFullScreenEventChange, true);
document.removeEventListener('webkitfullscreenchange', GLUT.onFullScreenEventChange, true);
@@ -255,13 +255,14 @@ var LibraryGLUT = {
document['cancelFullScreen'] ||
document['mozCancelFullScreen'] ||
document['webkitCancelFullScreen'] ||
- (function() {});
+ (function() {});
CFS.apply(document, []);
}
},
glutGetModifiers: function() { return GLUT.modifiers; },
+ glutInit__deps: ['$Browser'],
glutInit: function(argcp, argv) {
// Ignore arguments
GLUT.initTime = Date.now();
@@ -271,6 +272,12 @@ var LibraryGLUT = {
window.addEventListener("mousemove", GLUT.onMousemove, true);
window.addEventListener("mousedown", GLUT.onMouseButtonDown, true);
window.addEventListener("mouseup", GLUT.onMouseButtonUp, true);
+
+ Browser.resizeListeners.push(function(width, height) {
+ if (GLUT.reshapeFunc) {
+ Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]);
+ }
+ });
__ATEXIT__.push({ func: function() {
window.removeEventListener("keydown", GLUT.onKeydown, true);
@@ -294,21 +301,25 @@ var LibraryGLUT = {
glutGet: function(type) {
switch (type) {
case 100: /* GLUT_WINDOW_X */
- return 0; /* TODO */
+ return 0; /* TODO */
case 101: /* GLUT_WINDOW_Y */
- return 0; /* TODO */
+ return 0; /* TODO */
case 102: /* GLUT_WINDOW_WIDTH */
- return Module['canvas'].width;
+ return Module['canvas'].width;
case 103: /* GLUT_WINDOW_HEIGHT */
- return Module['canvas'].height;
+ return Module['canvas'].height;
+ case 200: /* GLUT_SCREEN_WIDTH */
+ return Module['canvas'].width;
+ case 201: /* GLUT_SCREEN_HEIGHT */
+ return Module['canvas'].height;
case 500: /* GLUT_INIT_WINDOW_X */
- return 0; /* TODO */
+ return 0; /* TODO */
case 501: /* GLUT_INIT_WINDOW_Y */
- return 0; /* TODO */
+ return 0; /* TODO */
case 502: /* GLUT_INIT_WINDOW_WIDTH */
- return GLUT.initWindowWidth;
+ return GLUT.initWindowWidth;
case 503: /* GLUT_INIT_WINDOW_HEIGHT */
- return GLUT.initWindowHeight;
+ return GLUT.initWindowHeight;
case 700: /* GLUT_ELAPSED_TIME */
var now = Date.now();
return now - GLUT.initTime;
@@ -386,10 +397,8 @@ var LibraryGLUT = {
glutReshapeWindow__deps: ['$GLUT', 'glutPostRedisplay'],
glutReshapeWindow: function(width, height) {
GLUT.cancelFullScreen();
- // console.log("glutReshapeWindow: " + width + ", " + height);
Browser.setCanvasSize(width, height);
if (GLUT.reshapeFunc) {
- // console.log("GLUT.reshapeFunc: " + width + ", " + height);
Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]);
}
_glutPostRedisplay();
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 356c9746..176a2fae 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -1385,26 +1385,28 @@ var LibrarySDL = {
// If the user asks us to allocate a channel automatically, get the first
// free one.
if (channel == -1) {
- channel = SDL.channelMinimumNumber;
for (var i = SDL.channelMinimumNumber; i < SDL.numChannels; i++) {
if (!SDL.channels[i].audio) {
channel = i;
break;
}
}
+ if (channel == -1) {
+ Module.printErr('All ' + SDL.numChannels + ' channels in use!');
+ return -1;
+ }
}
-
// We clone the audio node to utilize the preloaded audio buffer, since
// the browser has already preloaded the audio file.
var channelInfo = SDL.channels[channel];
channelInfo.audio = audio = audio.cloneNode(true);
audio.numChannels = info.audio.numChannels;
audio.frequency = info.audio.frequency;
-
// TODO: handle N loops. Behavior matches Mix_PlayMusic
audio.loop = loops != 0;
- if (SDL.channelFinished) {
- audio['onended'] = function() { // TODO: cache these
+ audio['onended'] = function() { // TODO: cache these
+ channelInfo.audio = null;
+ if (SDL.channelFinished) {
Runtime.getFuncWrapper(SDL.channelFinished, 'vi')(channel);
}
}
@@ -1461,7 +1463,6 @@ var LibrarySDL = {
audio.play();
}
audio.volume = channelInfo.volume;
- audio.paused = false;
return channel;
},
Mix_PlayChannelTimed: 'Mix_PlayChannel', // XXX ignore Timing
@@ -1475,6 +1476,8 @@ var LibrarySDL = {
if (info.audio) {
info.audio.pause();
info.audio = null;
+ } else {
+ Module.printErr('No Audio for channel: ' + channel);
}
if (SDL.channelFinished) {
Runtime.getFuncWrapper(SDL.channelFinished, 'vi')(channel);
@@ -1512,6 +1515,12 @@ var LibrarySDL = {
}
audio.volume = SDL.music.volume;
audio['onended'] = _Mix_HaltMusic; // will send callback
+ if (SDL.music.audio) {
+ if (!SDL.music.audio.paused) {
+ Module.printErr('Music is already playing. ' + SDL.music.source);
+ }
+ SDL.music.audio.pause();
+ }
SDL.music.audio = audio;
return 0;
},
@@ -1577,7 +1586,8 @@ var LibrarySDL = {
var info = SDL.channels[channel];
if (info && info.audio) {
info.audio.pause();
- info.audio.paused = true;
+ } else {
+ Module.printErr('Mix_Pause: no sound found for channel: ' + channel);
}
},
diff --git a/src/modules.js b/src/modules.js
index b13ab3c5..d26acbd5 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -114,7 +114,8 @@ var Debugging = {
m = metadataToParentMetadata[m];
assert(m, 'Confused as to parent metadata for llvm #' + l + ', metadata !' + m);
}
- this.llvmLineToSourceFile[l] = metadataToFilename[m];
+ // Normalize Windows path slashes coming from LLVM metadata, so that forward slashes can be assumed as path delimiters.
+ this.llvmLineToSourceFile[l] = metadataToFilename[m].replace(/\\5C/g, '/');
}
this.on = true;
diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp
index 7ceeb2f8..aa7e71a1 100644
--- a/src/relooper/Relooper.cpp
+++ b/src/relooper/Relooper.cpp
@@ -18,6 +18,8 @@ static void PrintDebug(const char *Format, ...);
#define DebugDump(x, ...)
#endif
+#define INDENTATION 1
+
struct Indenter {
static int CurrIndent;
@@ -34,8 +36,8 @@ static int OutputBufferSize = 0;
void PrintIndented(const char *Format, ...) {
assert(OutputBuffer);
- assert(OutputBuffer + Indenter::CurrIndent*2 - OutputBufferRoot < OutputBufferSize);
- for (int i = 0; i < Indenter::CurrIndent*2; i++, OutputBuffer++) *OutputBuffer = ' ';
+ assert(OutputBuffer + Indenter::CurrIndent*INDENTATION - OutputBufferRoot < OutputBufferSize);
+ for (int i = 0; i < Indenter::CurrIndent*INDENTATION; i++, OutputBuffer++) *OutputBuffer = ' ';
va_list Args;
va_start(Args, Format);
int left = OutputBufferSize - (OutputBuffer - OutputBufferRoot);
@@ -47,8 +49,8 @@ void PrintIndented(const char *Format, ...) {
void PutIndented(const char *String) {
assert(OutputBuffer);
- assert(OutputBuffer + Indenter::CurrIndent*2 - OutputBufferRoot < OutputBufferSize);
- for (int i = 0; i < Indenter::CurrIndent*2; i++, OutputBuffer++) *OutputBuffer = ' ';
+ assert(OutputBuffer + Indenter::CurrIndent*INDENTATION - OutputBufferRoot < OutputBufferSize);
+ for (int i = 0; i < Indenter::CurrIndent*INDENTATION; i++, OutputBuffer++) *OutputBuffer = ' ';
int left = OutputBufferSize - (OutputBuffer - OutputBufferRoot);
int needed = strlen(String)+1;
assert(needed < left);
diff --git a/src/relooper/test.txt b/src/relooper/test.txt
index b3535592..6c910846 100644
--- a/src/relooper/test.txt
+++ b/src/relooper/test.txt
@@ -6,11 +6,11 @@
// block A
if (check == 10) {
- atob();
- // block B
- btoc();
+ atob();
+ // block B
+ btoc();
} else {
- atoc();
+ atoc();
}
// block C
@@ -22,9 +22,9 @@ if (check == 10) {
// block A
if (check == 15) {
- // block B
+ // block B
} else {
- // block C
+ // block C
}
// block D
@@ -35,12 +35,12 @@ if (check == 15) {
while(1) {
- // block A
- var check = maybe();
- // block B
- if (!(check == 41)) {
- break;
- }
+ // block A
+ var check = maybe();
+ // block B
+ if (!(check == 41)) {
+ break;
+ }
}
// block C
@@ -51,25 +51,25 @@ while(1) {
// code 1
var $i_0 = 0;var $x_0 = 5;
while(1) {
- // code 2
- if (!($2)) {
- var $x_1 = $x_0;
- label = 18;
- break;
- }
- // code 3
- if ($6) {
- break;
- } else {
- var $i_0 = $7;var $x_0 = $5;
- }
+ // code 2
+ if (!($2)) {
+ var $x_1 = $x_0;
+ label = 18;
+ break;
+ }
+ // code 3
+ if ($6) {
+ break;
+ } else {
+ var $i_0 = $7;var $x_0 = $5;
+ }
}
if (label == 18) {
- // code 7
+ // code 7
}
// code 4
if ($10) {
- // code 5
+ // code 5
}
// code 6
var $x_1 = $13;
@@ -83,15 +83,15 @@ var $x_1 = $13;
// block A...................................................................................................
if (chak()) {
- atob();
- // block B...................................................................................................
- btod();
- // block D
+ atob();
+ // block B...................................................................................................
+ btod();
+ // block D
} else {
- atoc();
- // block C...................................................................................................
- ctod2();
- // block D
+ atoc();
+ // block C...................................................................................................
+ ctod2();
+ // block D
}
@@ -102,11 +102,11 @@ if (chak()) {
// block A
if (!(check == 10)) {
- return C;
+ return C;
}
while(1) {
- // block B
- // block D
+ // block B
+ // block D
}
@@ -117,23 +117,23 @@ while(1) {
// block A
do {
- if (expensive()) {
- label = 33;
- } else {
- // block B
- if (expensive2()) {
- label = 33;
- break;
- }
- // block D
+ if (expensive()) {
+ label = 33;
+ } else {
+ // block B
+ if (expensive2()) {
+ label = 33;
+ break;
}
+ // block D
+ }
} while(0);
if (label == 33) {
- // block C;
+ // block C;
}
while(1) {
- // block E
- // block F
+ // block E
+ // block F
}
@@ -144,12 +144,12 @@ while(1) {
// block A
if (shouldLoop()) {
- while(1) {
- // block B
- if (!(moarLoop())) {
- break;
- }
+ while(1) {
+ // block B
+ if (!(moarLoop())) {
+ break;
}
+ }
}
// block C
diff --git a/src/relooper/test2.txt b/src/relooper/test2.txt
index c77ce491..2f3e5ca1 100644
--- a/src/relooper/test2.txt
+++ b/src/relooper/test2.txt
@@ -1,12 +1,12 @@
ep
do {
- if (ep -> LBB1) {
- LBB1
- if (!(LBB1 -> LBB2)) {
- break;
- }
- LBB2
+ if (ep -> LBB1) {
+ LBB1
+ if (!(LBB1 -> LBB2)) {
+ break;
}
+ LBB2
+ }
} while(0);
LBB3
diff --git a/src/relooper/test3.txt b/src/relooper/test3.txt
index 6049ee48..51199f72 100644
--- a/src/relooper/test3.txt
+++ b/src/relooper/test3.txt
@@ -1,27 +1,27 @@
ep
do {
- if (ep -> LBB1) {
- LBB1
- if (!(LBB1 -> LBB2)) {
- break;
- }
- LBB2
+ if (ep -> LBB1) {
+ LBB1
+ if (!(LBB1 -> LBB2)) {
+ break;
}
+ LBB2
+ }
} while(0);
LBB3
do {
- if (LBB3 -> LBB4) {
- LBB4
- if (!(LBB4 -> LBB5)) {
- break;
- }
- while(1) {
- LBB5
- if (LBB5 -> LBB6) {
- break;
- }
- }
+ if (LBB3 -> LBB4) {
+ LBB4
+ if (!(LBB4 -> LBB5)) {
+ break;
}
+ while(1) {
+ LBB5
+ if (LBB5 -> LBB6) {
+ break;
+ }
+ }
+ }
} while(0);
LBB6
diff --git a/src/relooper/test4.txt b/src/relooper/test4.txt
index 3427ff18..ab7051c1 100644
--- a/src/relooper/test4.txt
+++ b/src/relooper/test4.txt
@@ -1,23 +1,23 @@
//19
do {
- if ( 1 ) {
- //20
- if (!( 1 )) {
- label = 4;
- break;
- }
- //21
- } else {
- label = 4;
+ if ( 1 ) {
+ //20
+ if (!( 1 )) {
+ label = 4;
+ break;
}
+ //21
+ } else {
+ label = 4;
+ }
} while(0);
if (label == 4) {
- //22
+ //22
}
//23
if ( 1 ) {
- //24
+ //24
} else {
- //28
+ //28
}
diff --git a/src/relooper/test5.txt b/src/relooper/test5.txt
index ad769ae7..83755289 100644
--- a/src/relooper/test5.txt
+++ b/src/relooper/test5.txt
@@ -1,32 +1,32 @@
//0
if (check(0)) {
- while(1) {
- //1
- if (!(check(1))) {
- break;
- }
+ while(1) {
+ //1
+ if (!(check(1))) {
+ break;
}
- while(1) {
- //2
- if (!(check(2))) {
- break;
- }
+ }
+ while(1) {
+ //2
+ if (!(check(2))) {
+ break;
}
- //3
+ }
+ //3
} else {
- goingFrom0to4();
- while(1) {
- //4
- if (!(check(4))) {
- break;
- }
+ goingFrom0to4();
+ while(1) {
+ //4
+ if (!(check(4))) {
+ break;
}
- while(1) {
- //5
- if (check(5)) {
- break;
- }
+ }
+ while(1) {
+ //5
+ if (check(5)) {
+ break;
}
- //3
+ }
+ //3
}
diff --git a/src/relooper/test6.txt b/src/relooper/test6.txt
index c5effd08..4f29f292 100644
--- a/src/relooper/test6.txt
+++ b/src/relooper/test6.txt
@@ -1,12 +1,12 @@
//0
do {
- if (check(0)) {
- //1
- if (!(check(1))) {
- break;
- }
- //2
+ if (check(0)) {
+ //1
+ if (!(check(1))) {
+ break;
}
+ //2
+ }
} while(0);
//3
diff --git a/src/relooper/test_debug.txt b/src/relooper/test_debug.txt
index d18ed875..4a42e642 100644
--- a/src/relooper/test_debug.txt
+++ b/src/relooper/test_debug.txt
@@ -116,13 +116,13 @@ int main() {
// Fusing Multiple to Simple
ep
do {
- if (ep -> LBB1) {
- LBB1
- if (!(LBB1 -> LBB2)) {
- break;
- }
- LBB2
+ if (ep -> LBB1) {
+ LBB1
+ if (!(LBB1 -> LBB2)) {
+ break;
}
+ LBB2
+ }
} while(0);
LBB3
diff --git a/src/relooper/test_fuzz1.txt b/src/relooper/test_fuzz1.txt
index b278e240..becbc0d2 100644
--- a/src/relooper/test_fuzz1.txt
+++ b/src/relooper/test_fuzz1.txt
@@ -4,29 +4,29 @@ print('entry'); var label; var state; var decisions = [4, 1, 7, 2, 6, 6, 8]; var
print(5); state = check();
print(6); state = check();
if (state == 7) {
- print(7); state = check();
- label = 3;
+ print(7); state = check();
+ label = 3;
}
L5: while(1) {
- if (label == 3) {
- label = 0;
- print(2); state = check();
+ if (label == 3) {
+ label = 0;
+ print(2); state = check();
+ }
+ print(1); state = check();
+ while(1) {
+ print(3); state = check();
+ if (!(state == 8)) {
+ continue L5;
}
- print(1); state = check();
- while(1) {
- print(3); state = check();
- if (!(state == 8)) {
- continue L5;
- }
- print(8); state = check();
- if (!(state == 4)) {
- label = 3;
- continue L5;
- }
- print(4); state = check();
- if (!(state == 3)) {
- continue L5;
- }
+ print(8); state = check();
+ if (!(state == 4)) {
+ label = 3;
+ continue L5;
}
+ print(4); state = check();
+ if (!(state == 3)) {
+ continue L5;
+ }
+ }
}
diff --git a/src/relooper/test_fuzz2.txt b/src/relooper/test_fuzz2.txt
index 572e819d..02b2c83b 100644
--- a/src/relooper/test_fuzz2.txt
+++ b/src/relooper/test_fuzz2.txt
@@ -2,12 +2,12 @@
print('entry'); var label; var state; var decisions = [4, 1, 4, 3, 4, 1, 2, 5, 1, 3, 5, 5, 1, 5, 2, 4, 4, 3]; var index = 0; function check() { if (index == decisions.length) throw 'HALT'; return decisions[index++] }
if (state == 1) {
- while(1) {
- print(1); state = check();
- }
+ while(1) {
+ print(1); state = check();
+ }
}
while(1) {
- print(3); state = check();
- print(2); state = check();
+ print(3); state = check();
+ print(2); state = check();
}
diff --git a/src/relooper/test_fuzz3.txt b/src/relooper/test_fuzz3.txt
index aeeccf87..b4b1831d 100644
--- a/src/relooper/test_fuzz3.txt
+++ b/src/relooper/test_fuzz3.txt
@@ -4,6 +4,6 @@ print('entry'); var label; var state; var decisions = [3, 3, 4, 1, 2, 1, 2, 4, 4
print(1); state = check();
print(3); state = check();
while(1) {
- print(4); state = check();
+ print(4); state = check();
}
diff --git a/src/relooper/test_fuzz4.txt b/src/relooper/test_fuzz4.txt
index 05a70582..766ebdb6 100644
--- a/src/relooper/tes