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

We need an equivalence between DAST and bytecode interpreters #24

Open
adri09070 opened this issue Sep 27, 2022 · 0 comments · May be fixed by #29
Open

We need an equivalence between DAST and bytecode interpreters #24

adri09070 opened this issue Sep 27, 2022 · 0 comments · May be fixed by #29

Comments

@adri09070
Copy link
Contributor

adri09070 commented Sep 27, 2022

Now that the DAST interpreter looks quite stable, it would be good to have an equivalence between this interpreter and the bytecode interpreter.

This would allow to switch interpreters when we want in the debugger. If we debug a program and we want a higher granularity, we would be able to resume our debugging process from the same instruction but with the DAST interpreter. On the contrary, when we want to switch back to the bytecode interpreter to have a lower granularity, we would be able to do so.

I did a quick comparison between the 2 interpreters and it looks possible to me.

Bytecode VS DAST:

  • pc:

    • pcs are different according to context VS pcs are common between all contexts
    • one step = one bytecode = several bytes = several pcs VS one step = one node = one pc
      -> the equivalence between the bytecode pcs and the AST nodes could be done via the OcBcToASTCache
  • value stack: is the same for Bytecode and DAST, except that the exception involved is the first value on the stack for bytecode contexts whereas the exception is not on the stack but is an attribute of DASTContext.

  • context stack:

    • class Context VS class DASTContext (DASTMethodContext and DASTBlockContext):
      ° pc: VS no pc but nodes: (nodes to be executed) VS currentNode: -> the equivalence could be done via the OCBcToASTCache I think
      ° setSender:receiver:method:arguments: VS sender:/ parent: (I'm not sure to grasp what the difference between the 2 is) receiver: methodOrBlock: (DASTClosure that wraps RBMethodNode or RBBlockNode) -> method contains CompiledCodeand we can get an AST node from that. On the contrary, from an AST node, we can get the compiledMethod for RBMethodNode; and compiledBlock for RBBlockNode via its closure (RBBlockNode>>#evaluate)
      ° setSender:receiver:method:closure:startpc: VS sender:/ parent: receiver: methodOrBlock:
      ° at:put: / stackp: VS stack:
      ° exception = 1st element on the stack VS instance variable (unhandledException:
      ° nothing VS messageNode -> Thanks to the pc of the sender context and the OCBcToASTCache, we can get the message node
      ° Nothing VS isDead: (false by default)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant