Missing callback for unary in conditional
Opened this issue · 2 comments
Hello,
I have the following sample Jalangi2 analysis:
((sandbox) => {
function MyAnalysis() {
this.unary = function(iid, op, left) {
console.log('unary', op, left, arguments);
};
this.conditional = function(iid, cond) {
console.log('cond', arguments);
};
}
sandbox.analysis = (new MyAnalysis());
})(J$)
And test program:
function foo(input) {
!input;
if(!input) {
return 'oh no';
}
};
foo();
When I run the analysis with Jalangi2 I get the expected output:
unary ! undefined [Arguments] { '0': 10, '1': '!', '2': undefined, '3': true }
unary ! undefined [Arguments] { '0': 18, '1': '!', '2': undefined, '3': true }
cond [Arguments] { '0': 8, '1': true }
But when I run it with NodeProf.js I get this output:
unary ! undefined [Arguments] { '0': 3, '1': '!', '2': undefined, '3': true }
cond [Arguments] { '0': 4, '1': undefined }
It misses a callback for unary
inside the conditional, and the result
argument of conditional is undefined
instead of true
.
Hi @BarrensZeppelin,
I think what happens here is due to graal-js optimizing away the unary operation for simple conditions. If you change the condition to e.g. if(!!input)
the unary callback will be invoked.
These optimizations (or simplifications) happen when the AST is built and generally cannot be disabled, maybe @eleinadani knows whether the current behavior exposed to NodeProf is correct or not (missing materialization of nodes).
Hi, just noticed the same issue. Is there any walkaround for it?