Open gogo9th opened 3 years ago
async
is not supported and I haven't done any serious thought on how to support it. Is using Babel to translate to ES5.1 an option for you?
Yes, in esnstrument.js
, instead of doing the following:
var newAst = acorn.parse(code, {locations: true, ecmaVersion: 6 });
My code transforms as follows:
function es6Transform(code) {
// console.log('Transforming');
if (typeof(babel) !== 'undefined' && !process.env['NO_ES7']) {
console.log("babel.transform()...");
var res = babel.transform(code, {
retainLines: true,
compact: false,
presets: ['@babel/preset-env'],
plugins: [
[ "@babel/plugin-transform-modules-commonjs",
{ 'strictMode': false },
"@babel/transform-runtime"
],
]
}).code;
console.log("babel.transform() Finished");
if (res && res.indexOf('use strict') != -1) {
res = res.replace(/.use strict.;\n?/, '');
}
//console.log(res);
return res;
} else {
console.log('There is no babel loaded');
return code;
}
}
...
var newAst = acorn.parse(es6Transform(code), {locations: true, allowReturnOutsideFunction: true, ecmaVersion: 6 });
However, I still get an error thrown in this function:
function Sr(iid) {
var tmp, aret, isBacktrack;
if (sandbox.analysis && sandbox.analysis.scriptExit) {
aret = sandbox.analysis.scriptExit(iid, wrappedExceptionVal);
if (aret) {
wrappedExceptionVal = aret.wrappedExceptionVal;
isBacktrack = aret.isBacktrack;
}
}
rollBackSid();
if (wrappedExceptionVal !== undefined) {
tmp = wrappedExceptionVal.exception;
wrappedExceptionVal = undefined;
throw tmp;
}
return isBacktrack;
}
What version are you translating to with Babel? Can you post the code after Babel processing for the above example?
This is a different question, but I cannot instrument the following code:
My understanding is that async is not support in Jalangi, because a single J$ object is shared across all scripts and if they randomly do context-switch due to async, then J$ cannot properly track the sid stack, where each sid is assigned to a single script. Is this correct?