summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2020-10-12Update vm.cLanza
2020-10-12Rename float configuration option names.Yukihiro "Matz" Matsumoto
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
2020-10-12Add assertion we can pack function pointers in `mrb_method_t`.Yukihiro "Matz" Matsumoto
If this assertion fails, you have to define `MRB_USE_METHOD_T_STRUCT`.
2020-10-12Skip array embedding if `MRB_NO_BOXING` and `MRB_32BIT`; fix #4382Yukihiro "Matz" Matsumoto
On some platforms, `sizeof(mrb_value) > sizeof(void*)*3`, which makes `MRB_ARY_EMBED_LEN_MAX` zero. And zero sized array cause compile errors.
2020-10-12Rename `OP_JUW` instruction to `OP_JMPUW`.Yukihiro "Matz" Matsumoto
2020-10-12Fix typo `_hander` -> `_handler`.Yukihiro "Matz" Matsumoto
2020-10-12Adjust PR #5060 to the latest `mruby3` branch.Yukihiro "Matz" Matsumoto
2020-10-12Suppress warnings for C++dearblue
Variables in jump destination block separate declaration and assignment.
2020-10-12Restore the variable `pc` after `longjmp()`dearblue
Changes made after `setjmp()` are destroyed and need reassignment. This problem is now caused by the addition of the `OP_JUW` instruction. When actually building on FreeBSD 12.1 with `clang10 -fsanitize=address`, mrbtest "NameError#name [15.2.31.2.1]" is failed. However, qualifying `pc` with `volatile` slows down significantly and increases the object code. Suppress them by qualifying only the variables that restore `pc`.
2020-10-12Replace global jump with catch handler implementationdearblue
When a global jump occurs, look at the catch handler table to determine where to jump. In that case, `pc` already shows the following instruction, but since the table shows `begin_offset ... end_offset`, the comparison is done with `begin_offset < pc && pc <= end_offset`. If there is a corresponding handler, move `pc` to `handler.target_offset` and continue running the VM. When a global jump across `ensure` is made by `return`, `break`, `next`, `redo` and `retry`, the extended `RBreak` object saves and restores the C-level execution position. This extended `RBreak` can have tag information, which makes it a pseudo coroutine (the "tag" mimics CRuby). The implementation of pseudo coroutines by `RBreak` is summarized by `CHECKPOINT_RESTORE ... CHECKPOINT_MAIN ... CHECKPOINT_END` and `throw_tagged_break` / `unwind_ensure` macros. The restart of processing is branched by `RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)`. - Not only `rescue` blocks but also `ensure` blocks are now sandwiched between `OP_EXCEPT` and `OP_RAISEIF`. - Remove the function `ecall()`. It is no longer necessary to re-enter the VM to perform an "ensure block". This will resolves #1888. - Added instruction `OP_JUW` (Jump while UnWind). It jumps unconditionally like `OP_JMP`, but searches the catch handler table and executes the ensure block. Since it searches the catch handler table, it is much heavier than `OP_JMP`.
2020-10-12Removed push/pop instructions for rescue/ensuredearblue
`OP_PUSHERR`, `OP_POPERR`, `OP_EPUSH` and `OP_EPOP` are removed.
2020-10-12Extended `OP_EXCEPT` and `OP_RAISE` (`OP_RAISEIF`) instructionsdearblue
- `OP_EXCEPT` checks if `mrb->exc` is `NULL`, `MRB_TT_EXCEPTION` or `MRB_TT_BREAK`. If `mrb->exc` is `NULL`, it will be replaced with `nil`. - If `OP_RAISE` is `nil`, it does nothing and the immediately following instruction is executed (like `OP_NOP`). Also, in case of `RBreak` object, it moves to the processing for `break`. With this change, the instruction name is changed from `OP_RAISE` to `OP_RAISEIF`.
2020-10-12Extended mruby binary formatdearblue
The catch handler table is combined with iseq block. This is to prevent the structure from growing by adding a field for the catch handler table to the `mrb_irep` structure. "iseq block" and "catch handler table": [number of catch handler table (2 bytes)] [number of byte code (4 bytes)] [iseq (any bytes)] [catch handlers (multiple of 7 bytes)] catch handler: [catch type (1 byte)] [begin offset (2 bytes)] [end offset (2 bytes)] [target offset (2 bytes)] catch type: enum mrb_catch_type (0 = rescue, 1 = ensure) begin offset: Includes the specified instruction address end offset: Does not include the specified instruction address target offset: replaces pc with the specified instruction address This table is not expanded by `read_irep_record_1()`. The necessary elements are expanded one by one when used.
2020-10-12Initialize `kdict` in `OP_ENTER` in `vm.c`.Yukihiro "Matz" Matsumoto
2020-10-12Rename `union mrb_value` to `union mrb_value_`.Yukihiro "Matz" Matsumoto
Since some compiler complains when we `typedef` `mrb_value`.
2020-10-12Simplify `mrb_value` structure for `MRB_WORD_BOXING`.Yukihiro "Matz" Matsumoto
2020-10-12Remove `mc_clear_by_id`.Yukihiro "Matz" Matsumoto
Clearing all method cache using `memset` is faster than conditional clear by method id.
2020-10-12Do not call `mrb_mc_clear_by_class` at `mrb` finalization.Yukihiro "Matz" Matsumoto
2020-10-12Use `memset()` to clear method cache.Yukihiro "Matz" Matsumoto
2020-10-12Add `const` specifier to `cipush()`; ref #5052Yukihiro "Matz" Matsumoto
2020-10-12Use hash table instead of segment list for instance variables.Yukihiro "Matz" Matsumoto
2020-10-12Rename `mrb_hash_modify` to `hash_modify`.Yukihiro "Matz" Matsumoto
Since it's an internal static function.
2020-10-12Use `mrb_field_write_barrier` instead of `mrb_write_barrier` for `push`.Yukihiro "Matz" Matsumoto
When the array is very big, the simpler `mrb_write_barrier` causes calling `gc_mark_children` for big arrays repeatedly. That would hinder performance very badly.
2020-10-12Check `lv` before printing local variable names.Yukihiro "Matz" Matsumoto
2020-10-12Fix the bug by the combination with `MRB_64BIT` and `MRB_INT32`.Yukihiro "Matz" Matsumoto
Which is caused by `MRB_NAN_BOXING`.
2020-10-12You don't need to keep index in local variables info in `irep`.Yukihiro "Matz" Matsumoto
2020-10-12Enable method cache by default.Yukihiro "Matz" Matsumoto
Introduced `MRB_NO_METHOD_CACHE` which is inverse of `MRB_METHOD_CACHE` that should be enabled intestinally. In addition, the default cache is made bigger (128 -> 256).
2020-10-12Call `#initialize_copy` from `init_copy` only if it's redefined.Yukihiro "Matz" Matsumoto
2020-10-12Skip `mrb_get_args()` in `mrb_ary_push()`.Yukihiro "Matz" Matsumoto
2020-10-12Split `MRB_BINARY_FORMAT` to major and minor.Yukihiro "Matz" Matsumoto
The minor versions should be upper compatible. So mere opcode, section addition can be done without breaking compiled binary.
2020-10-12Remove `OP_EXT[123]` from operands.Yukihiro "Matz" Matsumoto
2020-10-12Constify `irep` struct for `Class#new`.Yukihiro "Matz" Matsumoto
2020-10-12Add `const` qualifier to generated `Proc` structures.Yukihiro "Matz" Matsumoto
2020-10-12Should not mark red (i.e. ROM allocated) objects.Yukihiro "Matz" Matsumoto
2020-10-12Use `int` instead of `mrb_int` for arena index.Yukihiro "Matz" Matsumoto
2020-10-12Use `%u` instead of `%d` to dump symbol IDs.Yukihiro "Matz" Matsumoto
2020-10-12Avoid use of designated initializer for the sake of `cxx_abi`.Yukihiro "Matz" Matsumoto
2020-10-12Add casts to silence warnings.Yukihiro "Matz" Matsumoto
2020-10-12Clarify the use of `MRB_64BIT` and `MRB_INT64` in `dump.c` and `load.c`.Yukihiro "Matz" Matsumoto
- `MRB_64BIT`: the size of a pointer is 64 bits - `MRB_INT64`: the size of `mrb_int` is 64 bits
2020-10-12Fix `dump.c` for `MRB_INT32` env.Yukihiro "Matz" Matsumoto
2020-10-12Enable NUL (`\0`) again.Yukihiro "Matz" Matsumoto
2020-10-12Generate C struct from `irep` instead of binary dump.Yukihiro "Matz" Matsumoto
2020-10-12Generate C source file to represent `mrb_irep` structures.Yukihiro "Matz" Matsumoto
Type `mrbc -S -B<init> -o<outfile> <rbfiles...>` to generate the C source code that holds compiled `mrb_irep`. Appending the following code to the bottom of the generated code, `mruby` executes the compiled code: ```C int main() { mrb_state *mrb = mrb_open(); struct RProc *p = mrb_proc_new(mrb, &init_irep); mrb_vm_run(mrb, p, mrb_top_self(mrb), 0); mrb_close(mrb); return 0; } ``` Eventually static compile should use this representation, instead of `uint8_t` array that holds `mrb` data, so that we can skip interpreting `mrb` data.
2020-10-12Removed alignment pragma from `-B` output from `mrbc`.Yukihiro "Matz" Matsumoto
We no longer need 4 bytes alignment after we moved to the byte oriented instructions.
2020-10-12Replace entire `irep->pool`.Yukihiro "Matz" Matsumoto
Changes: - `pool format is completely replaced - supported types: `STR`, `INT32`, `INT64`, `FLOAT` - `FLOAT` may be replaced by binary representation in the future - insert `NUL` after string literals in `mrb` files - `irep->pool` no longer store values in `mrb_value` - instead it stores in `mrb_pool_value` - less allocation - `mrb_irep` can be stored in ROM
2020-10-12Rename `struct mrb_locals` to `struct mrb_lvinfo`.Yukihiro "Matz" Matsumoto
That stands for "local variable information".
2020-10-12Add `irep` C struct dump from `mrbc` with `-S` option.Yukihiro "Matz" Matsumoto
But we need more work: - recursive `irep` dump (`irep->reps`) - pool values dump (`irep->pool`)
2020-10-12Avoid use of designated initializers to generate `irep` struct.Yukihiro "Matz" Matsumoto
Since it's not supported on VC without `/std:c++latest`. That means it doesn't work for `cxx_api` build on Windows VC.
2020-10-12Make `call_irep` static.Yukihiro "Matz" Matsumoto
2020-10-12Use `static const struct mrb_irep each_irep` to ininitalize `each`.Yukihiro "Matz" Matsumoto