Hey there! I'm running a small JavaScript program using d8, and inspecting
its byte code using the --print-bytecode flag, and I'm trying to find a way
to associate a printed byte code instruction with a line number from my
original script.
I added some logging code to the Visitor methods in bytecode-generator.cc,
which seem to be operating on subclasses of AstNode, like Statement,
Expression, FunctionLiteral, etc. These classes provide various information
such as a position integer that seem correspond to the numbers I see at the
left of each byte code when doing --print-bytecode, plus I can also get a
pretty print of the AST tree with Print() but the association between line
numbers looks lost at this point.
For example, I have the following function defined as the first thing in my
script:
function my_sum(x, y) {
return x + y
}
The generated byte code is:
[generated bytecode for function: my_sum]
Parameter count 3
Frame size 0
19 E> 0x48f6da1f942 @ 0 : a5 StackCheck
30 S> 0x48f6da1f943 @ 1 : 25 02 Ldar a1
39 E> 0x48f6da1f945 @ 3 : 34 03 00 Add a0, [0]
42 S> 0x48f6da1f948 @ 6 : a9 Return
Constant pool (size = 0)
Handler Table (size = 0)
And its the Print() method of such AstNode shows:
FUNC LITERAL at 19
. NAME my_sum
. INFERRED NAME
. PARAMS
. . VAR (0x7fccc2095658) (mode = VAR) "x"
. . VAR (0x7fccc2095688) (mode = VAR) "y"
I would like to somehow determine that i.e. the statements "Ldar a1" and
"Return" belong to line 2.
Can you point me to the code that stores information about the original
line number (presumably this lives somewhere, so v8 can output runtime
errors, etc)? Any pointers or explanations would be very appreciated!
Thanks a lot!
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.