boa
boa copied to clipboard
Improve vm trace output
The vm trace output currently has a few issues.
Functions without a name should be identifiable. Currently a function without a name will have printed trace output like this:
----------------- Compiled Output '' ------------------
@jasonwilliams proposed to have some kind of ID for functions that can make them identifiable between the trace of the compiled output and the call frame execution trace. For the proposed output look at this comment: https://github.com/boa-dev/boa/pull/1697#discussion_r741810958
Call Frame outputs are combined when a Call Frame returns
When a Call Frame (function/constructor) returns it is not visible, where one Call Frame ends and where the other one continues:
...
----------------------------------------- Call Frame -----------------------------------------
Time Opcode Operands Top Of Stack
1μs PushLiteral 0 "hello"
3μs Return "hello"
134μs GetPropertyByName 0004: 'test' "hello"
...
In this example, the called function ends after the Return
opcode. The GetPropertyByName
opcode belongs to the caller function that is now running again. This should be clearly visible in the trace output.
Another example. For this JS code:
const a = { b: 5 };
a['b']++;
a.b;
You get something like this. It seems that if the opcode names are too long, the operands jump to a new line:
----------------------Compiled Output: '<main>'-----------------------
Location Count Opcode Operands
000001 0000 PushEmptyObject
000002 0001 Dup
000004 0002 PushInt8
5 000005 0003 Swap
000010 0004 DefineOwnPropertyByName
0000: 'b' 000015 0005 DefInitConst
0000: 'a' 000020 0006 PushLiteral
0 000025 0007 GetName
0000: 'a' 000026 0008 GetPropertyByValue
000027 0009 IncPost
000032 0010 PushLiteral
0 000037 0011 GetName
0000: 'a' 000038 0012 SetPropertyByValue
000039 0013 Pop
000044 0014 GetName
0000: 'a' 000049 0015 GetPropertyByName
0000: 'b'
Literals:
0000: <string> "b"
Names:
0000: b
Functions:
<empty>