solidity icon indicating copy to clipboard operation
solidity copied to clipboard

Make source maps byte-offset based instead of opcode-offset

Open chriseth opened this issue 4 years ago • 3 comments

The source maps currently contain one item per opcode, instead of one item per byte in the assembly. This kind of makes sense because it allows the source maps to be flexible about which push opcode is used for a constant, but it makes it also more difficult because the "pseudo-opcode" AssignImmutable results in multiple opcodes in the end. To make things worse: As soon as one uses verbatim, it is taken as a single opcode by the compiler, but when just seeing the bytecode, it is impossible to tell whether a sequence of opcodes came from a single verbatim or multiple opcodes.

Because of that I would propose to make the source maps byte-based starting from Solidity 0.9.0.

chriseth avatar Sep 21 '21 14:09 chriseth

This sounds good to me. Giving a heads-up to tooling people and perhaps asking for feedback would be nice.

hrkrshnn avatar Sep 22 '21 12:09 hrkrshnn

Maybe we could make it start with a certain string to tell which kind it is and we could also include a version number.

chriseth avatar Sep 22 '21 12:09 chriseth

Decision from design call: We will add a switch (maybe only in stdjson) that defaults to false. If it is true, the source maps will be byte-based and have a string prefix informing about that. The switch will default to true with 0.9.0.

chriseth avatar Oct 06 '21 12:10 chriseth