Haiyang-Sun / nodeprof.js

Instrumentation framework for Node.js compliant to ECMAScript 2020 based on GraalVM.
Apache License 2.0
53 stars 22 forks source link

Distinguish between pre and post-increment operators #28

Open cristianstaicu opened 5 years ago

cristianstaicu commented 5 years ago

Hey,

When encountering a self-increment operator like x++, NodeProf translates it into five callbacks/hook invocations: read, literal, binaryPre, binary, write. Is that intended? Jalangi invokes additional hooks: unaryPres and unary and sometimes even additional binary ones.

Moreover, there is no way to distinguish between x++ and ++x. As I understand, Jalangi employs some weird hack for this: it performs the write and then re-reads the value and does a x-1 binary operation in the case of x++.

For more details about this issue check this example analysis and the output on a simple test case both on NodeProf and on Jalangi2: https://www.dropbox.com/sh/rfkubnia8tns2jp/AACUArk9WalFR0VoPWxpzhfDa?dl=0

Best, Cris

Haiyang-Sun commented 5 years ago

We didn't have a use case that needs to distinguish x++ or ++x. One possible solution is to add some additional information in the binary callback to distinguish them. We would not necessarily provide exactly the same events as Jalangi if we can capture the same thing with fewer events.