Skip to content

Commit

Permalink
modified instrumentation so that a script execution can be repeated b…
Browse files Browse the repository at this point in the history
…y returning true from J$.Sr()
  • Loading branch information
ksen007 committed Jun 4, 2013
1 parent 5ae3801 commit e20eedf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
Binary file modified inputs.js
Binary file not shown.
39 changes: 29 additions & 10 deletions src/js/instrument/esnstrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,15 +657,15 @@

var labelCounter = 0;

function wrapFunBodyWithTryCatch(node, body) {
function wrapScriptBodyWithTryCatch(node, body) {
printIidToLoc(node);
var l = labelCounter++;
var ret = replaceInStatement(
"function n() { jalangiLabel"+l+": while(true) { try {"+RP+"1} catch("+PREFIX1+
"e) { console.log("+PREFIX1+"e); console.log("+
PREFIX1+"e.stack); throw "+PREFIX1+
"e; } finally { if ("+logFunctionReturnFunName+"("+
RP+"2)) continue jalangiLabel"+l+";\n else \n return "+logReturnAggrFunName+"();\n }\n }}", body,
"e; } finally { if ("+logScriptExitFunName+"("+
RP+"2)) continue jalangiLabel"+l+";\n else \n break jalangiLabel"+l+";\n }\n }}", body,
getIid()
);
//console.log(JSON.stringify(ret));
Expand All @@ -675,20 +675,38 @@
return ret;
}

function wrapScriptBodyWithTryCatch(node, body) {
function wrapFunBodyWithTryCatch(node, body) {
printIidToLoc(node);
var ret = replaceInStatement("try {"+RP+"1} catch("+PREFIX1+
var l = labelCounter++;
var ret = replaceInStatement(
"function n() { jalangiLabel"+l+": while(true) { try {"+RP+"1} catch("+PREFIX1+
"e) { console.log("+PREFIX1+"e); console.log("+
PREFIX1+"e.stack); throw "+PREFIX1+
"e; } finally { "+logScriptExitFunName+"("+
RP+"2); }",
body,
"e; } finally { if ("+logFunctionReturnFunName+"("+
RP+"2)) continue jalangiLabel"+l+";\n else \n return "+logReturnAggrFunName+"();\n }\n }}", body,
getIid()
);
//console.log(JSON.stringify(ret));

ret = ret[0].body.body;
transferLoc(ret[0], node);
return ret;
}

// function wrapScriptBodyWithTryCatch(node, body) {
// printIidToLoc(node);
// var ret = replaceInStatement("try {"+RP+"1} catch("+PREFIX1+
// "e) { console.log("+PREFIX1+"e); console.log("+
// PREFIX1+"e.stack); throw "+PREFIX1+
// "e; } finally { "+logScriptExitFunName+"("+
// RP+"2); }",
// body,
// getIid()
// );
// transferLoc(ret[0], node);
// return ret;
// }

function prependScriptBody(node, body) {
var path = require('path');
var preFile = path.resolve(__dirname,'../analysis.js');
Expand Down Expand Up @@ -727,7 +745,7 @@
var body = createCallAsScriptEnterStatement(node, modFile).
concat(syncDefuns(node, scope, true)).
concat(body0);
return wrapScriptBodyWithTryCatch(node, body);
return body;
}


Expand Down Expand Up @@ -1031,8 +1049,9 @@

var visitorOps = {
"Program": function(node) {
var body = wrapScriptBodyWithTryCatch(node, node.body)
if (!tryCatch) {
var ret = prependScriptBody(node, node.body);
var ret = prependScriptBody(node, body);
node.body = ret;

}
Expand Down

0 comments on commit e20eedf

Please sign in to comment.