| Age | Commit message (Collapse) | Author |
|
|
|
Fix `SIGSEGV` with mruby-method + mruby-catch
|
|
- `mrb_num_div_int(mrb,x,y)` -> `mrb_div_int(mrb,x,y)`
- `mrb_num_div_flo(mrb,x,y)` -> `mrb_div_flo(x,y)`
They are internal function not supposed to be used outside of the core.
|
|
Previously, the following code would cause a `SIGSEGV`.
```ruby
mm = method(:throw)
define_method(:throw, ->(*args) { mm.call(*args) })
catch { |tag| throw tag }
```
I think the reason is in the `mrb_yield_with_class()` function:
- Even if a C function is called, `CI_ACC_SKIP` is used
- `cipop()` is not done if globally jumping from a C function
|
|
Add new pool value type `IREP_TT_BIGINT` and generate integer overflow
error in the VM. In the future, `mruby` will support `Bignum` for
integers bigger than `mrb_int` (probably using `mpz`).
|
|
- Added to `mruby-binding-core`
- `Binding#local_variable_defined?`
- `Binding#local_variable_get`
- `Binding#local_variable_set`
- `Binding#local_variables`
- `Binding#receiver`
- `Binding#source_location`
- `Binding#inspect`
- Added to `mruby-proc-binding`
- `Proc#binding`
The reason for separating `Proc#binding` is that core-mrbgems has a method that returns a closure object to minimize possible problems with being able to manipulate internal variables.
By separating it as different mrbgem, each user can judge this problem and incorporate it arbitrarily.
|
|
|
|
|
|
We have introduced following new instructions.
* `OP_LAMBDA16`
* `OP_BLOCK16`
* `OP_METHOD16`
* `OP_EXEC16`
Each instruction uses 16 bits operand for `reps` index. Since new
instructions are added, `mruby/c` VM should be updated.
Due to new instructions, dump format compatibility is lost, we have
increased `RITE_BINARY_MAJOR_VER`.
In addition, we have decreased the size of `refcnt` in `mrb_irep` from
`uint32_t` to `uint16_t`, which is reasonably big enough.
|
|
Remove unnecessary `ci0` variables; ref #5272
|
|
|
|
The following macros will be removed:
- `ENSURE_STACK_INIT_SIZE`
- `RESCUE_STACK_INIT_SIZE`
- `MRB_ECALL_DEPTH_MAX`
|
|
|
|
|
|
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
|
|
|
|
Instead of including `mruby/presym.h` everywhere, we provided the
fallback `mruby/presym.inc` under `include/mruby` directory, and specify
`-I<build-dir>/include` before `-I<top-dir>/include` in `presym.rake`.
So even when someone drops `-I<build-dir>/include` in compiler options,
it just compiles without failure.
|
|
https://github.com/shuujii/mruby into shuujii-avoid-including-presym.inc-in-existing-header-files
|
|
When I `#call` the "proc" object created by the `mrb_proc_new_cfunc()` function from Ruby space, the return value did not go into the correct stack position.
This can destroy the calling variable.
This issue is now caused by #5272. sorry.
|
|
Addressed an issue where existing programs linking `libmruby.a` could only
be built by adding `<build-dir>/include` to compiler's include path.
|
|
This enhances self-containment.
- Changed the `mrb_callinfo::pc` field to point to itself.
Previously it indicated the return destination of the previous call level.
`mrb_callinfo::pc` will now hold the address to its own `proc->body.irep->iseq`.
- Removed `mrb_callinfo::err` field.
This is because `mrb_callinfo::pc - 1` is semantically the same as the previous `err`.
- The `pc0` and `pc_save` variables in `mrb_vm_exec()` are no longer needed and have been deleted.
- It removes the argument because `cipush()` doesn't need to save the previous `pc`.
|
|
This enhances self-containment.
Previously `mrb_context::stack` had the current call level stack, but now it owns it.
The `mrb_context::stack` field, which is no longer needed, will be removed.
|
|
If there is `env`, `env->c` means `target_class`.
|
|
But you still cannot cross C function boundary.
|
|
Negative integer `>-65535` had wrong value, e,g, `p(-40550)` printed
`4294926746` since Nov. 2020, sigh.
|
|
|
|
|
|
|
|
Follow commit 7150c6753933f12a2ba63769fb7b3a44cfcddd3d .
|
|
Jump target address is `operand (16bit)` + `address of next instruction`.
In addition, `ilen` was made `uint32_t` so that `iseq` length limitation
of 65536 is removed. Only jump target address should be within signed
16bit (-32768 .. 32767).
|
|
| Previous Name | New Name |
|------------------------------|-------------------------|
| MRB_ENABLE_ALL_SYMBOLS | MRB_USE_ALL_SYMBOLS |
| MRB_ENABLE_SYMBOLL_ALL | MRB_USE_ALL_SYMBOLS |
| MRB_ENABLE_CXX_ABI | MRB_USE_CXX_ABI |
| MRB_ENABLE_CXX_EXCEPTION | MRB_USE_CXX_EXCEPTION |
| MRB_ENABLE_DEBUG_HOOK | MRB_USE_DEBUG_HOOK |
| MRB_DISABLE_DIRECT_THREADING | MRB_NO_DIRECT_THREADING |
| MRB_DISABLE_STDIO | MRB_NO_STDIO |
| ENABLE_LINENOISE | MRB_USE_LINENOISE |
| ENABLE_READLINE | MRB_USE_READLINE |
| DISABLE_MIRB_UNDERSCORE | MRB_NO_MIRB_UNDERSCORE |
| DISABLE_GEMS | MRB_NO_GEMS |
* `MRB_ENABLE_SYMBOLL_ALL` seems to be a typo, so it is fixed.
* `MRB_` prefix is added to those without.
* The previous names can also be used for compatibility.
|
|
|
|
|
|
### ASAN report (`MRB_INT32`)
```console
$ bin/mruby -ve '-0x40000000'
mruby 3.0.0preview (2020-10-16)
00001 NODE_SCOPE:
00001 NODE_BEGIN:
00001 NODE_NEGATE:
00001 NODE_INT 40000000 base 16
irep 0x6070000001e0 nregs=2 nlocals=1 pools=0 syms=0 reps=0 iseq=9
file: -e
/mruby/src/codedump.c:173:49: runtime error: left shift of 49152 by 16 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mruby/src/codedump.c:173:49 in
1 000 OP_LOADI32 R1 -1073741824
1 006 OP_RETURN R1
1 008 OP_STOP
/mruby/src/vm.c:1138:7: runtime error: left shift of 49152 by 16 places cannot be represented in type 'mrb_int' (aka 'int')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mruby/src/vm.c:1138:7 in
```
|
|
|
|
To be also able to build mruby without presym in the future. However,
`MRB_QSYM` has been removed and changed as follows:
### Example
| Type | Symbol | Previous Style | New Style |
|---------------------------|--------|------------------|----------------|
| Operator | & | MRB_QSYM(and) | MRB_OPSYM(and) |
| Class Variable | @@foo | MRB_QSYM(00_foo) | MRB_CVSYM(foo) |
| Instance Variable | @foo | MRB_QSYM(0_foo) | MRB_IVSYM(foo) |
| Method with Bang | foo! | MRB_QSYM(foo_b) | MRB_SYM_B(foo) |
| Method with Question mark | foo? | MRB_QSYM(foo_p) | MRB_SYM_Q(foo) |
| Mmethod with Equal | foo= | MRB_QSYM(foo_e) | MRB_SYM_E(foo) |
This change makes it possible to define, for example, `MRB_IVSYM(foo)` as
`mrb_intern_lit(mrb, "@" "foo")`, which is useful if we support building
without presym in the future.
|
|
|
|
That loads 32 bit integer bypassing pool access.
|
|
New instructions:
* OP_LOADL16
* OP_LOADSYM16
* OP_STRING16
Size of pools, symbols are `int16_t` but offset representation in the
bytecode was 8 bits. Size of child `irep` array is `int16_t`, too but
this change does not address it.
|
|
The "a"/"*" specifier of the `mrb_get_args()` function will now return `const mrb_value *`.
This is because it is difficult for the caller to check if it is an array object and write-barrier if necessary.
And it requires calling `mrb_ary_modify()` on the unmodified array object, which is also difficult (this is similar to #5087).
|
|
To allow C++ compilation. Fix suggested by @dearblue.
|
|
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).
|
|
|
|
|
|
The mixture causes warnings on 64 bit Windows (VC).
|
|
You can now use `NEXT` within `switch` statement like 7c087eb.
|
|
|
|
On non-`gcc` compatible environment, `NEXT` is translated to `break`.
|
|
To silence some warnings. This change cancels part of 7ef3604134.
|
|
In the past code, the current `callinfo (ci)` was modified, thus it was
possible to pop `ci` beyond the `cibase`, that could cause out of memory
bound access for the code like the following:
```ruby
def m2
lambda {
Proc.new {
return :return # return from the method
}
}.call.call
:never_reached
end
p m2
```
|