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

Allow optimization of bytecode #8

Closed
12 tasks done
lausek opened this issue Nov 24, 2020 · 0 comments
Closed
12 tasks done

Allow optimization of bytecode #8

lausek opened this issue Nov 24, 2020 · 0 comments

Comments

@lausek
Copy link
Owner

lausek commented Nov 24, 2020

Constructs that require labels

  • expressions for logical short-circuit (And, Or)
  • branches
  • loops (break, continue)

Optimization cases

  • constant expressions like 1 + 2 are not optimized:
10:    Pushc(0)
11:    Pushc(1)
12:    Add
  • generator could merge these expressions in Branch conditions into Jt:
10:    ...
11:    Not
12:    Jf
13:    ...
  • the generator often emits code like this at the end of Branch (doesn't happen anymore after introduction of LIR?):
25:    ...
26:    Jmp(27)
27:    ....
func:
11:    Pushc(0)
12:    Ret
13:    Pushc(1)
14:    ...

Steps for implementation

  • HIR is a confusing name. change it to HirUnit (?)
  • update code to use module_builder.entry() instead of module_builder.add(ENTRY_POINT)
  • update docs
  • create new type Label
  • create new type LirElement
  • rename current LoweringRuntime to HirLoweringRuntime that transforms HIR -> LIR
    • on each emit try to optimize the last instructions (depending on instruction)
  • create a new runtime LirLoweringRuntime that transforms LIR -> Bytecode
@lausek lausek mentioned this issue Nov 26, 2020
2 tasks
lausek added a commit that referenced this issue Dec 8, 2020
@lausek lausek closed this as completed Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant