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

Add interpreter that uses the Truffle Bytecode DSL #226

Open
wants to merge 63 commits into
base: master
Choose a base branch
from

Conversation

smarr
Copy link
Member

@smarr smarr commented Dec 18, 2024

WIP

smarr added 30 commits December 17, 2024 11:30
- [Hack] add copies to avoid current OpDSL limitations
  - Addition/Subtraction bits
  - EqualsOp, EqualsEqualsPrim, NotMessageNode
- [Hack] the local return translation to produce a value. This is needed to avoid triggering the DSL
- [Hack] implement GlobalCachedReadOp (there’s currently a DSL bug, which prevents the use of the assumption)
- [Hack] add WriteArgument operation, this may not be ok, because on stack replacement apparently may lose the argument array
- [Hack] Add fallback methods for reading non-local variables
- [Hack] Make getting the source safe when a dispatch node is used in the context of an OperationsNode
- [Hack] Make some specializations static by simply using a cached value, may not be ideal for the AST interpreter
- [Hack] Change read node to specialize on frame descriptor, make write not use fd from frame

- add specific ops
  - ReturnNonLocal for BcDSL
  - IsNilOp, NotNilOp
  - IntIncrementNode
  - NonLocalVar Read/Write
  - PushBlock* operations
  - DividePrim, LessThanOrEqualPrim, and DividePrim
  - CharAtOp, MultiplicationPrim, UnequalPrim, <, >, >=
  - AndBoolMsg, OrBoolMsg, WhileFalse/WhileTruePrimitiveNode
  - DoubleDiv, MaxInt, MinInt, IncField, and various more primitives
  - ConcatPrim

- fix basic settings and test setup
- add constructOperation to literals
- add GlobalReadOp
- add NonLocalArgumentReadNode
- add a static version of determineContext
- add missing ValueNonePrim.create()
- implement ifTrue:ifFalse:,..., IfNotNilInlinedLiteralNode, IfMessageNode, IfNil, IfNotNil
- implement Array’s #do: and #doIndexes:, Integer>>#to:do:, Integer>>#downTo:do:, Array>>#putAll:
- implement literal nodes
- handle literals explicitly when processing super expressions
  Since they do not take any arguments, the normal approach doesn’t work, but special casing here seems fine.
- implement SuperSend
- implement SuperExprNode by allowing to emit begin and end from the parent node
- implement field read/write operations
- implement LocalVariable Read/Write, Return Local, and WhileInlinedLiterals
- use Conditional for control flow that needs to push a value

- DSL block design:
 - make sure ReturnNonLocal is emitted as a block to look like it returns a single value
 - make sure to emit a block around a sequence to make sure it appears as a single value

- handle conversion of methods only when assembling the class
  - this avoids issues with inlining. If we do it on method assembling,
    then we convert blocks already to OpDSL methods, which prevents inlining.
    Though, when we do it only at class-assemble time,
    we can handle inlining and trivial methods easily.
  - primitives won’t be converted.

- need to create a new RootNode to have the compatible frame descriptor.
  I tried to just update the old root node, but that doesn’t work,
  because the frame is going to be used very differently.

- make message send compile in OpDSL
  - expose assumptions on the dispatch guard to make it work

- check in the SourceCompiler that we got the right one, based on VmSettings

Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
… the OpDSL

The following should now produce the decisions.json file for generating an optimized interpreter.

ant compile-som -Denable.opdsl-tracing=true
rm state.json
touch state.json
rebench -R rebench.conf opdsl-tracing

Signed-off-by: Stefan Marr <[email protected]>
- added assertion, because it looks like I am not using the arg but it might be implied that it should be arg == 0

Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
This avoids issues with EE.

Signed-off-by: Stefan Marr <[email protected]>
- this became $node, but should be ommitted

Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
smarr added 25 commits December 17, 2024 11:30
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
- add increment expression and field with constant value super instructions
- add missing IncFieldWithExp
- add the string concationation case, but doesn’t avoid double guard on field update

Signed-off-by: Stefan Marr <[email protected]>
… the BytecodeNode for accessing locals in outer contexts

Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
Signed-off-by: Stefan Marr <[email protected]>
- added the replaces annotation on the field read nodes NonLocalReadField, and LocalReadField

Signed-off-by: Stefan Marr <[email protected]>
This is when an arg is turned into an inlined local.

Signed-off-by: Stefan Marr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant