Force code execution on selected AST nodes

54 views
Skip to first unread message

Ν P

unread,
Feb 9, 2023, 12:46:33 PM2/9/23
to v8-dev
Hello v8-dev@, 

I would like to force-execute some AST paths if those paths meet a set of conditions. For example when I encounter a node with an API named 'XXX', I want this line of code to always execute. For clarification, I will be using the phrases "execute" and "generate bytecode" interchangeably.

What I tried:
- Flag the desired node in the AST(ast.cc) and try to access it during bytecode (bytecode-generator.cc). The problem is that the node is not parsed in some cases during bytecode, so I cannot force it to execute (ie. previous if-conditions haven't been met so the desired node is never allocated).
- Try to connect the node I want with the parent conditions through the AST, so I can nullify the conditions and execute the node in every case. The problem here is during AST creation, I don't have access to the parent nodes, because of the nature the nodes are explored (node->next()).

Questions:
1.Is there a way to traverse the AST "backwards" (something like node->parent())
2.Is there a way to "flag" a node as "always execute bytecode for that node", even if the previous branch conditions haven't been met? 
3.Is there a way to keep the whole AST during bytecode generation and not prune the parts that are unreachable? So, if I have a pointer to a specific AST node from before and I didn't see it execute, I will generate the bytecode for that node and add it to the final bytecode?

Thank you very much for your time and effort. Let me know if my questions are not clear enough, so I can elaborate more.

Reply all
Reply to author
Forward
0 new messages