summaryrefslogtreecommitdiffhomepage
path: root/src/codedump.c
AgeCommit message (Collapse)Author
2020-10-12Rename `OP_JUW` instruction to `OP_JMPUW`.Yukihiro "Matz" Matsumoto
2020-10-12Fix typo `_hander` -> `_handler`.Yukihiro "Matz" Matsumoto
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-12Check `lv` before printing local variable names.Yukihiro "Matz" Matsumoto
2020-10-12You don't need to keep index in local variables info in `irep`.Yukihiro "Matz" Matsumoto
2020-10-12Remove `OP_EXT[123]` from operands.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-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-12Constify `irep` members.Yukihiro "Matz" Matsumoto
- `pool` - `syms` - `reps`
2020-05-07Add a new instruction `OP_LOADI16`.Yukihiro "Matz" Matsumoto
Which loads 16bit integer to the register. The instruction number should be reorder on massive instruction refactoring. The instruction is added for `mruby/c` which had performance issue with `OP_EXT`. With this instruction, `mruby/c` VM can just raise errors on `OP_EXT` extension instructions.
2019-09-26Fixed `codedump` for human readable symbol format; ref #4684Yukihiro "Matz" Matsumoto
2019-09-25Rename symbol-to-string functions; close #4684Yukihiro "Matz" Matsumoto
* mrb_sym2name -> mrb_sym_name * mrb_sym2name_len -> mrb_sym_name_len * mrb_sym2str -> mrb_sym_str
2019-08-18Prohibit changes to iseq in principledearblue
2019-04-22Use `MRB_ASPEC_XXX()` macro in `codedump()`KOBAYASHI Shuji
2019-04-01Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342Yukihiro "Matz" Matsumoto
The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them.
2019-03-02Print length of the `iseq` in code dump header; fix #4304Yukihiro "Matz" Matsumoto
2018-11-19Adjust codedump output format; ref #4166Yukihiro "Matz" Matsumoto
2018-10-29Fix codedumpertake-cheeze
2018-09-07Clear terminated spacedearblue
2018-08-29Simplified `#ifdef` nesting in `codedump.c`; fix #4089Yukihiro "Matz" Matsumoto
`printf()` and related functions should not be called when `MRB_DISABLE_STDIO` is defined.
2018-08-25Reduce integer casting warnings.Yukihiro "Matz" Matsumoto
2018-08-25Hash splat `**` should not be ignored.Yukihiro "Matz" Matsumoto
Implemented by adding `OP_HASHCAT` that merges hashes.
2018-07-31Removed unused instruction: `OP_KDICT`.Yukihiro "Matz" Matsumoto
2018-07-30Keyword argument implemented.Yukihiro "Matz" Matsumoto
2018-07-30New bytecode implementation of mruby VM.Yukihiro "Matz" Matsumoto
2017-12-15Check if destinations are too distant; fix #3900 fix #3901Yukihiro "Matz" Matsumoto
2017-10-28Format codedump for OP_{LE,LT,GE,GT}.Yukihiro "Matz" Matsumoto
2017-09-29`codedump` to display `OP_CALL`.Yukihiro "Matz" Matsumoto
2017-08-12Reduce integer type mismatch warnings in VC.Yukihiro "Matz" Matsumoto
2017-05-26Distinguish OP_R_NORMAL and OP_R_RETURN.Yukihiro "Matz" Matsumoto
2017-04-18Make `mrb_codedump_all()` to print type of Proc.Yukihiro "Matz" Matsumoto
2017-03-12Enhance OP_RESCUE to take B operand fas matching exception; ref #3487Yukihiro "Matz" Matsumoto
2017-02-08codedump.c: OP_POPERR does not have register access.Yukihiro "Matz" Matsumoto
2016-02-22cosmetic change for OP_EQYukihiro "Matz" Matsumoto
2016-02-05[cppcheck] remove duplicated breakYukihiro "Matz" Matsumoto
2015-11-27include changed from by quotes ("") to by brackets (<>); close #3032Yukihiro "Matz" Matsumoto
2015-11-17DISABLE_STDIO/ENABLE_DEBUG macros to rename; close #3014Yukihiro "Matz" Matsumoto
changes: * rename DISABLE_STDIO -> MRB_DISABLE_STDIO * rename ENABLE_DEBUG -> MRB_ENABLE_DEBUG_HOOK * no more opposite macro definitions (e.g. ENABLE_STDIO, DISABLE_DEBUG). * rewrite above macro references throughout the code. * update documents
2015-10-22align codedump output for OP_JMPYukihiro "Matz" Matsumoto
2015-10-22align codedump output for OP_RETURNYukihiro "Matz" Matsumoto
2015-05-23Move `mrb_codedump_all` to "src/codedump.c".take_cheeze
Related to #2760.