Skip to content

ROM-able ISEQ revisited#1338

Closed
kyab wants to merge 1 commit into
mruby:masterfrom
kyab:rom_iseq2
Closed

ROM-able ISEQ revisited#1338
kyab wants to merge 1 commit into
mruby:masterfrom
kyab:rom_iseq2

Conversation

@kyab

@kyab kyab commented Jul 3, 2013

Copy link
Copy Markdown
Contributor

This is second version of #880. Related issues are #944, #964.

In my environment(using default gembox, clang, x64),
total heap allocation till end of mrb_open() was reduced around 13kb (183514bytes to 170654bytes).

  • Bytecode format now has endian field.
  • mrbc has new option -E<endian>. Only effective with -B(C-func).
  • Default for -E is "neutral", which means copy all iseq(same as current).
  • In build_config, you can specify endian :little, or endian :big in each target. This value is used for -E option on running mrbc.
  • Currently CRC are checked even for C-func. I would update to skip CRC check if it is OK.
  • I do not have Big-endian device. Only little endian was tested.

test code.

#include <stdio.h>
#include <stdlib.h>

#include "mruby.h"

size_t total = 0;

void *myallocf(mrb_state *mrb, void *p, size_t size, void *ud){
    if (size == 0){
        free(p);
        return NULL;
    }else{
        //printf("alloc size=%ld, p=%p\n",size,p);
        total += size;
        void *ret = realloc(p, size);
        return ret;
    }
}

int main(int argc, const char * argv[])
{
    mrb_state *mrb = mrb_open_allocf(myallocf, NULL);
    printf("total : %zu bytes\n", total);
    mrb_close(mrb);

    return 0;
}

@jcspencer

Copy link
Copy Markdown

Any news on merging?

@kyab

kyab commented Feb 28, 2014

Copy link
Copy Markdown
Contributor Author

Maybe my changes to code are unacceptable, or saving 10kb or so is not important now, or matz has more great idea:-).

I myself think this PR is not so bad and safe.
I'll make this better if someone give me direction.

@matz

matz commented Aug 18, 2020

Copy link
Copy Markdown
Member

mruby iseq are now ROM-able.

@matz matz closed this Aug 18, 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

Successfully merging this pull request may close these issues.

3 participants