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

feat(hog): Hog bytecode function STL #24653

Merged
merged 19 commits into from
Aug 29, 2024
Merged

feat(hog): Hog bytecode function STL #24653

merged 19 commits into from
Aug 29, 2024

Conversation

mariusandra
Copy link
Collaborator

@mariusandra mariusandra commented Aug 28, 2024

Problem

Final go at getting arrayMap, arrayExists and arrayFilter working.

Changes

  • Creates a "STL, but in Hog": we compile a bunch of .hog files into bytecode and embed them in the VMs
  • Adds arrayMap.hog, arrayExists.hog and arrayFilter.hog STL functions
  • Creates a concept of "chunks", so we can execute bytecode off the main path
  • Adds bin/hog --out file.hog that prints the bytecode into stdout
  • Makes sure functions/lambdas do not survive the JSON barrier

How did you test this code?

Added several tests

Alternatives considered

  • feat(hog): arrayMap, arrayExists, arrayFilter #24643 - implemeting arrayMap in native python/typescript and letting it call back into Hog when it needs to run a closure. This worked, but we could no longer serialize and resume the VM, if a native function is somewhere in the call stack. Seemed like a weird constraint to impose and explain.
  • feat(hog): inline STL #24636 - inlining the STL functions into each compiled bytecode. We can still do this perhaps, but functions like arrayMap seem universal enough that the VM should know about them. No need to bloat every bytecode that uses it. There were some implementation quirks making it difficult (e.g. functions can't call each other)

Copy link
Contributor

github-actions bot commented Aug 28, 2024

Size Change: 0 B

Total Size: 1.08 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 1.08 MB

compressed-size-action

@mariusandra mariusandra marked this pull request as ready for review August 29, 2024 00:04
@mariusandra mariusandra requested review from a team, Gilbert09 and benjackwhite August 29, 2024 10:20
@mariusandra mariusandra merged commit 00bab5e into master Aug 29, 2024
87 checks passed
@mariusandra mariusandra deleted the bytecode-inline-stl branch August 29, 2024 12:28
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

Successfully merging this pull request may close these issues.

2 participants