Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve vm trace output #1711

Open
raskad opened this issue Nov 14, 2021 · 1 comment
Open

Improve vm trace output #1711

raskad opened this issue Nov 14, 2021 · 1 comment
Labels
E-Medium Medium difficulty problem enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine.

Comments

@raskad
Copy link
Member

raskad commented Nov 14, 2021

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: #1697 (comment)

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.

@raskad raskad added the vm Issues and PRs related to the Boa Virtual Machine. label Nov 14, 2021
@jasonwilliams jasonwilliams added the E-Medium Medium difficulty problem label Mar 8, 2022
@jasonwilliams jasonwilliams added this to the v0.15.0 milestone Mar 8, 2022
@Razican
Copy link
Member

Razican commented Mar 12, 2022

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>

@Razican Razican modified the milestones: v0.15.0, v0.16.0 Jun 1, 2022
@Razican Razican modified the milestones: v0.16.0, v0.17.0 Sep 19, 2022
@jedel1043 jedel1043 moved this to To do in Boa pre-v1 Nov 8, 2022
@jedel1043 jedel1043 added the enhancement New feature or request label Nov 8, 2022
@Razican Razican modified the milestones: v0.17.0, v0.18.0 Jul 8, 2023
@jedel1043 jedel1043 removed this from the v0.18.0 milestone Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-Medium Medium difficulty problem enhancement New feature or request vm Issues and PRs related to the Boa Virtual Machine.
Projects
Status: To do
Development

No branches or pull requests

4 participants