Why ROM and RubyKaigi 2018 wrap up and new our approach ‣ nvgen ‣ Introduction to mruby’s objects in C ‣ Class objects in depth ‣ Fix to work with ROM ‣ Benchmark ‣ Future works
*ud) ‣use custom allocation function f ‣ mrb_load_state_allocf(mrb_state *mrb, mrb_allocf f, void *ud) ‣ use custom allocation function and initialized VM image
is Class class ‣ RClass have super class and method tables ‣ Similar to RArray, RHash, and so on struct RObject { MRB_OBJECT_HEADER; struct iv_tbl *iv; }; struct RClass { MRB_OBJECT_HEADER; struct iv_tbl *iv; struct kh_mt *mt; struct RClass *super; };
of nvgen ‣nvgen parses the file and get address of functions ‣This method is used by TOPPERS configurator. $ nm nvgen > nvgen.syms $ ./nvgen nvgen.syms > generated.c
is in global variable area or in the heap area ‣Global variable should not be free() ‣Use TLSF malloc instead of standard malloc() ‣With TLSF malloc, we can know the object is in heap or not ‣see github.com/yamanekko/mruby-tlsf for detail
(Black, White, Gray) ‣ We use quad-color GC, add Red ‣ Red are never GCed; objects in ROM are Red ‣ At first of GC cycle, all children of Red objects are marked ‣ VM has a list of Red objects
of objects ‣ flags should be mutable ‣ So an array of flags for ROM’s objects are located in RAM ‣ add macro to read and write them ‣ obj->flags in ROM are indexes of the array
RAM ‣ tables for pre-defined methods are in ROM ‣ using iv_tbl to store pointer of pre-defined method tables ‣ key is __mt2__, which is not used as instance variables