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

Byte code #518

Merged
merged 6 commits into from
May 15, 2023
Merged

Byte code #518

merged 6 commits into from
May 15, 2023

Conversation

udoprog
Copy link
Collaborator

@udoprog udoprog commented May 14, 2023

Add preliminary support for building and loading byte-code into the Vm from raw bytes, instead of having instructions always being an array of Vec<Inst>.

This has the potential of greatly reducing the size of Rune programs, but it comes with a performance penalty because instructions have to be decoded as they're being executed.

By default, we're still using the old array-based instructions format.

See the difference in in-memory size for the following program:

use std::iter::range;

pub fn main() {
    let it = range(0, 1000);
    let tail = 77;

    'label:
    while true {
        let value = 10;

        for n in it {
            loop {
                let value2 = 20;
                break 'label;
            }

            tail = tail + 1;
        }

        tail = tail + 1;
    }

    tail
}

Byte-code version: 196 bytes.
Instruction array: 2560 bytes.

@udoprog udoprog added the enhancement New feature or request label May 14, 2023
@udoprog udoprog merged commit 1d57177 into main May 15, 2023
@udoprog udoprog deleted the byte-code branch May 15, 2023 00:05
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 this pull request may close these issues.

1 participant