summaryrefslogtreecommitdiffhomepage
path: root/include
AgeCommit message (Collapse)Author
2020-10-16mruby 3.0.0-preview.Hiroshi Mimaki
2020-10-12Revert "Add a new function `mrb_exc_protect()`."Yukihiro "Matz" Matsumoto
This reverts commit 8746a6fe4e7bda8a0fbc0eaece9314ec51a0c255. We already have `mrb_protect()`, `mrb_ensure()` and `mrb_rescue()` functions. If you need to handle exceptions from C functions, use those functions above.
2020-10-12Add a new function `mrb_exc_protect()`.Yukihiro "Matz" Matsumoto
`mrb_exc_protect()` takes two C functions, `body` to be executed first, and `resc` to be executed when an error happens during `body` execution. Since `mrb_exc_protect()` should be compiled with the proper compiler, we will not see the problem like #5088 that was caused by `setjmp()` and `throw` mixture.
2020-10-12Cause error explicitly from `MRB_TRY()` with `cxx_exception`; ref #5088Yukihiro "Matz" Matsumoto
`MRB_TRY()` does not work when compiled by C compiler with `cxx_exception` configuration. We should explicitly warn.
2020-10-12Unify `mrb_str_to_str` to `mrb_obj_as_string`.Yukihiro "Matz" Matsumoto
Redirect `mrb_str_to_str` to `mrb_obj_as_string` via C macro. Inspired by #5082
2020-10-12Clarify the meaning of `MRB_IREP_STATIC`; ref #5084Yukihiro "Matz" Matsumoto
2020-10-12Remove duplicated constant `IREP_TT_SFLAG`; #5084Yukihiro "Matz" Matsumoto
2020-10-12Add `const` modifier to `table` in `mrb_kwargs`; #5084Yukihiro "Matz" Matsumoto
The fix was proposed by @dearblue
2020-10-12Fix `mrb_int_mul_overflow()` to check either operand being zero.Yukihiro "Matz" Matsumoto
2020-10-12Restore old function names for compatibility; ref #5070Yukihiro "Matz" Matsumoto
- `mrb_check_intern()` to return `mrb_value` - `mrb_intern_check()` to return `mrb_sym` [NEW] Other new functions: - `mrb_intern_check_cstr()` - `mrb_intern_check_str()`
2020-10-12Restore old function names for compatibility; fix #5070Yukihiro "Matz" Matsumoto
Rename new functions: - `mrb_convert_type(mrb,val,type,tname,method)` => `mrb_type_convert(mrb,val,type,tname,method)` - `mrb_check_convert_type(mrb,val,type,tname,method)` => `mrb_type_convert_check(mrb,val,type,tname,method)` Old names are defined by macros (support `tname` drop and `char*` => `mrb_sym` conversion).
2020-10-12Fix integer casting on 64 bit platforms.Yukihiro "Matz" Matsumoto
On platforms where `sizeof(long)` is 4, casting `(long)` can lose data or sign information.
2020-10-12Avoid `unsigned int`; Use `mrb_int` instead.Yukihiro "Matz" Matsumoto
2020-10-12Explain `MRB_USE_MALLOC_TRIM`; ref #5069Yukihiro "Matz" Matsumoto
2020-10-12Change some `int` variables to `mrb_int`.Yukihiro "Matz" Matsumoto
To silence some warnings. This change cancels part of 7ef3604134.
2020-10-12Update `mrb_get_args()` keyword argument support [incompatible]Yukihiro "Matz" Matsumoto
* `mrb_kwargs` structure reordered (`values` and `rest` come last) * take symbols instead of C `char*`
2020-10-12Silence warnings from implicit integer conversions.Yukihiro "Matz" Matsumoto
Caused from combination of `mrb_int`, `int` and `size_t`..
2020-10-12Change float representation in `mrb` binary files.Yukihiro "Matz" Matsumoto
From human readable (ASCII) string representation to binary dump of IEEE754 in little endian.
2020-10-12Replace the implementation of method tables in classes/modules.Yukihiro "Matz" Matsumoto
They are basically the copy of instance variable tables. On my Linux box, memory consumption of `mrbtest` measured by `valgrind` is: - old: 17,683,830 bytes - new: 14,283,749 bytes
2020-10-12Raname `mrb_exc_new_str_lit()` to `mrb_exc_new_lit()`.Yukihiro "Matz" Matsumoto
It uses `mrb_str_new_lit()` internally, but it doesn't need to express it in the name of the function (macro).
2020-10-12Add `mrb_integer()` definition for `MRB_NAN_BOXING`.Yukihiro "Matz" Matsumoto
2020-10-12Reorganize `Integer` system.Yukihiro "Matz" Matsumoto
- Integrate `Fixnum` and `Integer` - Remove `Integral` - `int / int -> int` - Replace `mrb_fixnum()` to `mrb_int()` - Replace `mrb_fixnum_value()` to `mrb_int_value()`. - Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12Change the return type of `mrb_check_intern()` and friends.Yukihiro "Matz" Matsumoto
They used to return `mrb_value` but now return `mrb_sym` for consistency with other `intern` functions. If symbols are not defined, `check` functions return `0`, instead of `nil` in the past. It causes API incompatibility but I believe few people use those functions out of the core, and those changes are very easy to handle, hopefully.
2020-10-12Remove `MRB_NO_FLOAT_INLINE` and `MRB_WBOX_FLOAT_INLINE` configuration.Yukihiro "Matz" Matsumoto
They are not used from the beginning.
2020-10-12Make division by zero cause `ZeroDivisionError`.Yukihiro "Matz" Matsumoto
As described in ISO 15.2.30.
2020-10-12Rename `MRB_TT_FIXNUM` to `MRB_TT_INTEGER`.Yukihiro "Matz" Matsumoto
We still have `#define MRB_TT_FIXNUM MRB_TT_INTEGER` for compatibility.
2020-10-12Integrate `Fixnum` class into `Integer` classdearblue
* The `Fixnum` constant is now an alias for the `Integer` class. * Remove `struct mrb_state::fixnum_class` member. If necessary, use `struct mrb_state::integer_class` instead.
2020-10-12Make `Proc#parameters` to support keyword arguments; fix #5066Yukihiro "Matz" Matsumoto
TODO: Unlike CRuby, mruby's `Proc#parameters` does not distinguish required keyword arguments and optional keyword arguments currently.
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-12Rename `MRB_METHOD_T_STRUCT` to `MRB_USE_METHOD_T_STRUCT`.Yukihiro "Matz" Matsumoto
It's the first change of renaming configuration options to `MRB_XXX` to `MRB_USE_XXX` or `MRB_NO_XXX`.
2020-10-12Change default `mrb_value` representation to `MRB_WORD_BOXING`.Yukihiro "Matz" Matsumoto
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-12Add static check for `MRB_USE_FLOAT` and `MRB_WITHOUT_FLOAT`.Yukihiro "Matz" Matsumoto
2020-10-12Simplify `NaN` boxing definitions.Yukihiro "Matz" Matsumoto
Remove `#ifdef` from `union mrb_value_`.
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-12Revert 4c001673bYukihiro "Matz" Matsumoto
Probably I misunderstand strict aliasing rule of C++. The fix in 4c001673b was other way around.
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-12Simplify `mrb_value` structure for `MRB_NAN_BOXING`.Yukihiro "Matz" Matsumoto
2020-10-12Refine `MRB_NAN_BOXING` on 32bit architecture.Yukihiro "Matz" Matsumoto
You don't need pointer tweaking on 32bit architecture, where pointers fit in 32bit (lower half of mrb_value).
2020-10-12Change default boxing scheme from `MRB_NO_BOXING`.Yukihiro "Matz" Matsumoto
On 64bit platforms: `MRB_NAN_BOXING` On 32bit platforms: `MRB_WORD_BOXING` On debugging: `MRB_NO_BOXING`
2020-10-12Pack `mrb_value` into `uint64_t` when `MRB_NAN_BOXING`.Yukihiro "Matz" Matsumoto
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-12Upgrade `RITE_VM_VERSION` to `0300` (means mruby 3.0).Yukihiro "Matz" Matsumoto