| Age | Commit message (Collapse) | Author |
|
It may cause broken reference count numbers.
|
|
Remove code duplication.
|
|
Get object properties after `mrb_get_args()`
|
|
Since they are basically duplicated functionality. `mrb_as_float` is now
a macro defined using `mrb_ensure_float_type`; #5620
|
|
|
|
It should only call `to_f` for Rational and Complex numbers.
Ref #5540 #5613 #5620
|
|
That reduce memory consumption by iv/mt tables.
|
|
ref. #5613
I checked with Valgrind, and the methods that can cause use-after-free are `Array#rotate`, `Array#rotate!`, and `String#byteslice`.
Since `String#rindex` uses `RSTRING_LEN()` indirectly inside the function, no reference to the out-of-bounds range is generated.
|
|
|
|
|
|
|
|
Since `mrb_to_integer` and `mrb_to_float` does not convert the object
but checks types, they are named so by historical reason. We introduced
properly named functions.
This commit obsoletes the following functions:
* mrb_to_integer()
* mrb_to_int()
* mrb_to_float()
Use `mrb_ensure_int_type()` instead for the first 2 functions. Use
`mrb_ensure_float_type()` for the last.
|
|
mruby have removed `to_int` implicit conversion, so `mrb_to_integer`
should not call `to_i` for conversion.
|
|
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
|
|
|
|
|
|
|
|
|
Avoid losing the upper digits for mruby binary
|
|
The function may invoke the garbage collection and it requires
`mrb_state` to run.
|
|
- `rlen` keeps 16 bits.
- `ilen` keeps 32 bits.
Note that this change will break mruby binary format compatibility.
|
|
The existence of this member reduces memory and execution time.
|
|
|
|
|
|
|
|
|
|
It used to return wrong value for 14 positional arguments.
|
|
|
|
Now `iv_get()` returns `pos+1` if it finds the entry, so you don't need
to call `iv_put()`. You can replace the entry value by assigning to
`t->ptr[pos-1]`.
|
|
|
|
Instead embed deleted flag in the key (`mrb_sym` only occupies 30bits).
|
|
`iv_size()` is approximated by the allocated table size.
|
|
|
|
|
|
|
|
This is a fundamentally simplified reimplementation of #5317
by @shuujii
Instead of having array of `struct iv_elem`, we have sequences of keys
and values packed in single chunk of malloc'ed memory. We don't have to
worry about gaps from alignment, especially on 64 bit architecture,
where `sizeof(struct iv_elem)` probably consumes 16 bytes, but
`sizeof(mrb_sym)+sizeof(mrb_value)` is 12 bytes.
In addition, this change could improve memory access locality.
close #5317
|
|
|
|
Make "N for M" into the form "given N, expected M".
As I worked, I noticed that the `argnum_error()` function had a part to include the method name in the message.
I think this part is no longer needed by https://github.com/mruby/mruby/pull/5394.
- Before this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: 'each': wrong number of arguments (1 for 0) (ArgumentError)
```
- After this patch
```console
% bin/mruby -e '[1, 2, 3].each 0'
trace (most recent call last):
[1] -e:1
-e:1:in each: wrong number of arguments (given 1, expected 0) (ArgumentError)
```
|
|
The `__id__` method implemented in the C function has `MRB_ARGS_NONE()` specified, but it is also effective in the following cases.
```ruby
p nil.__id__ opts: 1 rescue p :a
p nil.method(:__id__).call 1 rescue p :b
p nil.method(:__id__).call opts: 1 rescue p :c
p nil.method(:__id__).to_proc.call 1 rescue p :d
p nil.method(:__id__).to_proc.call opts: 1 rescue p :e
p nil.method(:__id__).unbind.bind_call nil, 1 rescue p :f
p nil.method(:__id__).unbind.bind_call nil, opts: 1 rescue p :g
p nil.__send__ :__id__, 1 rescue p :h
p nil.__send__ :__id__, opts: 1 rescue p :i
```
After applying this patch, all items will output symbols in the same way as CRuby.
For this purpose, add `MRB_PROC_NOARG` to `struct RProc::flags`.
|
|
Fixes keywords are lost with the `OP_SENDB`
|
|
There was a discrepancy in the actual behavior, assertions, and documentation.
Therefore, I modified it based on the actual behavior.
|
|
If a splat argument was passed, it could write out of range on the VM stack.
```console
% bin/mruby -e 'def m(*args, **opts, &blk) p [args, opts, blk] end; m(*%w(X Y Z), r: 1, g: 2, b: 3) {}'
[["X", "Y", "Z"], {}, #<Proc:0x80077d7d0>]
```
|
|
|
|
|
|
Improved `Class#new` method
|
|
For `MRB_NAN_BOXING` and `MRB_WORD_BOXING`.
|
|
Integers out of 32 bit range will be allocated in the heap.
|
|
The number of registers used is reduced.
Also, previously `R6` and` R7` were used, which exceeded the limit of `new_irep.nregs = 6`.
This could cause the VM stack to overrun.
|
|
`mrb_static_assert()` extends the macro function to take one or two arguments.
If the argument is other than that, an error will occur.
References:
- static_assert のメッセージ省略を許可 - cpprefjp C++日本語リファレンス
https://cpprefjp.github.io/lang/cpp17/extending_static_assert.html
- c - Overloading Macro on Number of Arguments - Stack Overflow
https://stackoverflow.com/a/11763277
|
|
|