summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2022-01-06Merge pull request #5628 from dearblue/super-kwargsYukihiro "Matz" Matsumoto
Fixing keyword arguments with `super`
2022-01-05class.c: cancel #5620 which is no longer needed since #5622Yukihiro "Matz" Matsumoto
This reverts commit d3b7601af96c9e0eeba4c89359289661c755a74a.
2022-01-05object.c: Call functions directly from `mrb_ensure_int_type()`; #5622Yukihiro "Matz" Matsumoto
2022-01-05Fixing keyword arguments with `super`dearblue
fix #5627
2022-01-03Merge pull request #5625 from dearblue/proc_newYukihiro "Matz" Matsumoto
Assign after `mrb_irep_incref()` in `mrb_proc_new()`
2022-01-02Merge pull request #5622 from dearblue/to_fYukihiro "Matz" Matsumoto
Call functions directly from `mrb_ensure_float_type()`
2022-01-02Merge pull request #5620 from dearblue/adjust-stacksYukihiro "Matz" Matsumoto
Adjusting the stack for after it enters the virtual machine
2022-01-02Assign after `mrb_irep_incref()` in `mrb_proc_new()`dearblue
ref. 28ccc664e5dcd3f9d55173e9afde77c4705a9ab6
2022-01-01proc.c: should not reference `irep` when copying failed.Yukihiro "Matz" Matsumoto
It may cause broken reference count numbers.
2021-12-31Call functions directly from `mrb_ensure_float_type()`dearblue
ref. commit 7f40b645d2773c8f50c48ae4adf90488e164da55 Currently, the build configurations `MRB_USE_COMPLEX` and `MRB_USE_RATIONAL` are not listed in the documentation. In other words, they are hidden settings. They are defined in `mrbgems/mruby-{complex,rational}/mrbgem.rake`. So this patch assumes that it is safe to refer to these functions in core-gems directly from core functions. However, applications that link with `libmruby_core.a` will have compatibility issues. In fact, `mrbgems/mruby-bin-mrbc` links with `libmruby_core.a`, so I had to prepare a dummy function.
2021-12-31vm.c: use `prepare_missing` in `mrb_funcall_with_block`Yukihiro "Matz" Matsumoto
Remove code duplication.
2021-12-31Merge pull request #5619 from dearblue/propertiesYukihiro "Matz" Matsumoto
Get object properties after `mrb_get_args()`
2021-12-31numeric.c: merge `mrb_as_float` implementation to `mrb_ensure_float_type`.Yukihiro "Matz" Matsumoto
Since they are basically duplicated functionality. `mrb_as_float` is now a macro defined using `mrb_ensure_float_type`; #5620
2021-12-31object.c: add conversion to Float from Rational, Complex; #5620Yukihiro "Matz" Matsumoto
2021-12-31numeric.c: `mrb_as_float` should not call `to_f` for generic objects.Yukihiro "Matz" Matsumoto
It should only call `to_f` for Rational and Complex numbers. Ref #5540 #5613 #5620
2021-12-31class.c, variable,c: replace `size_t` by `int`.Yukihiro "Matz" Matsumoto
That reduce memory consumption by iv/mt tables.
2021-12-30Adjusting the stack for after it enters the virtual machinedearblue
ref. #5613. I mentioned in #5540 that there was no reentrant to the virtual machine, but in fact it was still a possibility at that point. Also, the variable `ci` needs to be recalculated at the same time.
2021-12-30Get object properties after `mrb_get_args()`dearblue
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.
2021-12-29object.c: move string to float conversion to `mrb_f_float`.Yukihiro "Matz" Matsumoto
2021-12-29string.c: reorganize `str_convert_range` using `mrb_ensure_int_type`Yukihiro "Matz" Matsumoto
2021-12-29string.c: use `mrb_as_int` macro.Yukihiro "Matz" Matsumoto
2021-12-29object.c: introduce `mrb_ensure_{int,float}_type`.Yukihiro "Matz" Matsumoto
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.
2021-12-29object.c: avoid implicit `to_i` and `to_f` calls.Yukihiro "Matz" Matsumoto
mruby have removed `to_int` implicit conversion, so `mrb_to_integer` should not call `to_i` for conversion.
2021-12-29array.c: fix `mrb_ary_shift_m` initialization bug.Yukihiro "Matz" Matsumoto
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
2021-12-27class.c: remove `mt_elem` structure to avoid alignment gaps.Yukihiro "Matz" Matsumoto
2021-12-27variable.c: need to initialize `size` of iv table.Yukihiro "Matz" Matsumoto
2021-12-20vm.c: fix a half-baked implementation of `OP_SETIDX`; ref #5608Yukihiro "Matz" Matsumoto
2021-12-20codedump.c: adjust the position of local variable labels.Yukihiro "Matz" Matsumoto
2021-12-15Merge pull request #5599 from dearblue/loss-digitsYukihiro "Matz" Matsumoto
Avoid losing the upper digits for mruby binary
2021-12-14proc.c: add `mrb_state` argument to `mrb_proc_copy()`.Yukihiro "Matz" Matsumoto
The function may invoke the garbage collection and it requires `mrb_state` to run.
2021-12-13Avoid losing the upper digits for mruby binarydearblue
- `rlen` keeps 16 bits. - `ilen` keeps 32 bits. Note that this change will break mruby binary format compatibility.
2021-12-13variable.c: resurrect `size` member in `iv_tbl`.Yukihiro "Matz" Matsumoto
The existence of this member reduces memory and execution time.
2021-12-13class.c: increase first allocated page size.Yukihiro "Matz" Matsumoto
2021-12-13class.c: implement method cache (off by default).Yukihiro "Matz" Matsumoto
2021-12-08vm.c (check_method_noarg): the value at `kidx` may not be a hash.Yukihiro "Matz" Matsumoto
2021-12-08vm.c: use `check_method_noarg()` to reduce code duplication; ref #5584Yukihiro "Matz" Matsumoto
2021-12-08vm.c: fix `mrb_ci_kidx`.Yukihiro "Matz" Matsumoto
It used to return wrong value for 14 positional arguments.
2021-12-08variable.c: fix clang integer warning.Yukihiro "Matz" Matsumoto
2021-12-07variable.c: avoid redundant iv scan in `mrb_mod_cv_set()`.Yukihiro "Matz" Matsumoto
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]`.
2021-12-04variable.c: reduce array access in iv hash table.Yukihiro "Matz" Matsumoto
2021-12-03variable.c: avoid `mrb_undef_value()` for delete entries.Yukihiro "Matz" Matsumoto
Instead embed deleted flag in the key (`mrb_sym` only occupies 30bits).
2021-12-03variable.c: remove `size` member from `iv_tbl` to reduce memory.Yukihiro "Matz" Matsumoto
`iv_size()` is approximated by the allocated table size.
2021-12-03variable.c: first iv allocation size should be 4 instead of 1.Yukihiro "Matz" Matsumoto
2021-12-03variable.c: should not access `NULL[0]` to avoid asan warnings.Yukihiro "Matz" Matsumoto
2021-12-01codedump.c: print `OP_EXT` explicitly again for debugging purpose.Yukihiro "Matz" Matsumoto
2021-12-01variable.c: reduce memory usage of instance variable tableYukihiro "Matz" Matsumoto
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
2021-11-29vm.c: remove duplicate code in VM.Yukihiro "Matz" Matsumoto
2021-11-28Align "wrong number of arguments" messagesdearblue
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) ```
2021-11-26Check more `MRB_ARGS_NONE()`dearblue
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`.
2021-11-20Merge pull request #5578 from dearblue/OP_SENDBYukihiro "Matz" Matsumoto
Fixes keywords are lost with the `OP_SENDB`