v8-code-dump-parser
v0.1.0
Published
Parse v8 --print-code or --print-opt-code output and stringify it back
Downloads
4
Maintainers
Readme
v8-code-dump-parser
Parse V8 dump generated by --print-code
or --print-opt-code
or stringify it back.
API
codeDumpParser(dump)
codeDumpParser.parse(dump)
Parses string into a tree structure.
Turns this:
--- Raw source ---
(a, b) {
return a - b;
};
--- Optimized code ---
optimization_id = 0
source_position = 144
kind = OPTIMIZED_FUNCTION
name = sub
stack_slots = 1
Instructions (size = 111)
0x1649c54c3e80 0 55 push rbp
// ... more code ...
0x1649c54c3edb 91 90 nop
Deoptimization Input Data (deopt points = 4)
index ast id argc pc
0 3 0 35
1 3 0 -1
2 3 0 -1
3 3 0 -1
Safepoints (size = 19)
0x1649c54c3ea3 35 1 (sp -> fp) 0
RelocInfo (size = 14)
0x1649c54c3e9f code target (BUILTIN) (0x1649c5425f80)
0x1649c54c3ea7 position (164)
0x1649c54c3ecd runtime entry (deoptimization bailout 1)
0x1649c54c3ed2 runtime entry (deoptimization bailout 2)
0x1649c54c3ed7 runtime entry (deoptimization bailout 3)
--- End code ---
--- Raw source ---
// ... more ...
into this:
[
{
source: "(a, b) {\n return a - b;\n};",
optimizedCode: {
optimization_id: "0",
source_position: "144",
kind: "OPTIMIZED_FUNCTION",
name: "sub",
stack_slots: "1",
instructions: "Instructions (size = 111)\n0x1649c54c3e80 0 55 push rbp\n// ... more code ...\n0x1649c54c3edb 91 90 nop
safepoints: "Safepoints (size = 19)\n0x1649c54c3ea3 35 1 (sp -> fp) 0",
relocInfo: "RelocInfo (size = 14)\n0x1649c54c3e9f code target (BUILTIN) (0x1649c5425f80)\n0x1649c54c3ea7 position (164)\n0x1649c54c3ecd runtime entry (deoptimization bailout 1)\n0x1649c54c3ed2 runtime entry (deoptimization bailout 2)\n0x1649c54c3ed7 runtime entry (deoptimization bailout 3)"
},
}
// ...
]
codeDumpParser.stringify(sections)
Converts tree structure back into string.
Install
npm install v8-code-dump-parser
License
MIT