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

Determine value in moving type construction to compiler #183

Closed
stevehalliwell opened this issue Jan 14, 2023 · 3 comments · Fixed by #222
Closed

Determine value in moving type construction to compiler #183

stevehalliwell opened this issue Jan 14, 2023 · 3 comments · Fixed by #222
Labels
enhancement New feature or request

Comments

@stevehalliwell
Copy link
Owner

stevehalliwell commented Jan 14, 2023

Presently the compiler emits bytecode that the vm uses to construct classes at runtime. Would it be possible and beneficial to move that responsibility prior to runtime. This would free up a number of opcodes and simplify the vm, mostly it might push us towards a more typed feature set.

A few opcodes are used for types, Type, Field, Method, Mixin. But these are only used once in most cases, to generate the runtime class object, not in the creation on instances.

@stevehalliwell stevehalliwell added the enhancement New feature or request label Jan 14, 2023
@stevehalliwell
Copy link
Owner Author

Having bytecode to create classes rather than compiler doing all of it, allows for bytecode serialisation being the only requirement for preventing recompile at every run. Presently, I'd prefer tiny recompile times over cached bytecode chunks.

@stevehalliwell
Copy link
Owner Author

class elements

  • vars
    • init chains
    • field names
  • methods
    • funcs with a this
    • method names
  • mixin
    • would require the other type is already compiled, slightly more order restrictive than current
  • signs
    • requires the other type is already compiled, is now a compile time check not runtime
  • init
    • just a special method

The path forward to trying this is get us to a stage where we could emit type info after compile but before vm run. Once that worked replace.

@stevehalliwell
Copy link
Owner Author

Having started some of this the next hurdle is closures. init chains etc. were using closures they run in not just chunk and label/location.

From testing they can just use chunk, nothing we have with test coverage or in current projects uses upvals in methods or init chains. They should be using labelIDs though, but appear to use instruction index at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant