Commit Graph

5216 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto e8a202d461 vm.c: inline callinfo related functions. 2022-07-04 21:15:42 +09:00
Yukihiro "Matz" Matsumoto 03ae46e88d string.c: keep values in local variables to reduce member access. 2022-06-30 10:12:24 +09:00
Yukihiro "Matz" Matsumoto f2bc7c305a array.c (mrb_assoc_new): keep pointer in a local variable.
The optimizer may do the same, but tried to make it clear.
2022-06-30 10:09:34 +09:00
Yukihiro "Matz" Matsumoto e2c4a8cef0 array.c (ary_check_too_big): make the function inline. 2022-06-30 09:57:30 +09:00
Yukihiro "Matz" Matsumoto 580af1cf73 vm.c (mrb_bidx): avoid repeated packing/unpacking argument info. 2022-06-29 07:51:08 +09:00
Yukihiro "Matz" Matsumoto 0b7822581f string.c (str_rindex): use more local variables; ref #5734 2022-06-27 19:04:36 +09:00
Yukihiro "Matz" Matsumoto 7319e744ad src/vm.c: move some inline functions from mruby/proc.h; ref #5732
Those functions are seldom called so no need to be inline functions.
2022-06-27 19:04:35 +09:00
Stephen Jothen 103f8bcad0 Fix out of bounds access by memcmp in String#rindex 2022-06-25 15:09:35 +02:00
Yukihiro "Matz" Matsumoto a3ccda657e Merge pull request #5733 from dearblue/patch-5402
Do not expand "included class" in `mrb_proc_new()`.
2022-06-25 14:48:02 +09:00
dearblue 8bab20ef7c Do not expand "included class" in mrb_proc_new().
If `target_class->tt` is `MRB_TT_ICLASS`, it may cause loss of class inheritance relationships.
This problem is caused by #5402.

ref. #5725
2022-06-25 11:45:18 +09:00
dearblue 1489338145 Use mrb->object_class instead if MRB_PROC_TARGET_CLASS() is NULL
Fix #5725
2022-06-25 11:10:39 +09:00
Ryan Lopopolo 8a5e6f47f2 Match #if at end of vm.c 2022-06-23 22:25:15 -07:00
Ryan Lopopolo 3af82fbb51 Respect MRB_USE_CXX_ABI #define 2022-06-23 21:54:53 -07:00
Ryan Lopopolo c4c37b2069 Fix mismatched braces in extern "C" blocks when compiling as C++
When compiling mruby with `-DMRB_USE_CXX_EXCEPTION`, clang fails to
compile and emits these warnings:

    vendor/mruby/src/vm.c:3066:1: error: extraneous closing brace ('}')
    } /* end of extern "C" */
    ^
    vendor/mruby/src/vm.c:3072:7: error: expected '}'
    #endif
          ^
    vendor/mruby/src/vm.c:3070:12: note: to match this '{'
    extern "C" {
               ^
    2 errors generated.

Fixup the implementation of the `extern "C"` block in `vm.c`.
2022-06-23 21:38:55 -07:00
Yukihiro "Matz" Matsumoto 92be161b1f vm.c (check_target_class): return Object class if target is NULL.
Since #5272 target_class kept in a Proc may be NULL. It crashes
`iij/mruby-require` gem for example; close #5725
2022-06-23 07:54:04 +09:00
Yukihiro "Matz" Matsumoto d2a24a540c hash.c: implement typical part of merge in C. 2022-06-19 22:28:31 +09:00
dearblue cbeb392d7d Fixed possible inconsistency in gc_protect()
If `mrb_realloc()` raises an out-of-memory exception, `arena_capa` will hold the wrong value.
2022-06-14 22:31:45 +09:00
dearblue 56c6dde9c5 Asigns table properties after mrb_calloc()
If GC occurs in `mrb_calloc()` called by `iv_rehash()` or `mt_rehash()`, the object as table data may be destroyed.
2022-06-08 22:10:58 +09:00
Yukihiro "Matz" Matsumoto 8981b2fb28 vm.c (ary_new_from_regs): stack may be reallocated.
Unlike `hash_new_from_regs`, `ary_new_from_regs` do not call
`mrb_funcall` et al directly or indirectly. But since it may invoke the
garbage collection, and hooks for GC may call `mrb_funcall` etc (although
calling them is not encouraged), we care stack reallocation just for the
safety.
2022-05-30 11:52:12 +09:00
Yukihiro "Matz" Matsumoto aa7f98dedb vm.c (hash_new_from_regs): stack may be reallocated. 2022-05-30 01:18:15 +09:00
Yukihiro "Matz" Matsumoto 82b87be4df string.c (mrb_utf8len): retry 7cdef2b0.
C++ requires `extern` declaration before variable definition.
2022-05-29 22:18:59 +09:00
dearblue 23611332d9 Introduced mrb_static_assert_object_size()
Asserts the size of the object structure is less than or equal to 6 words.
2022-05-28 11:08:27 +09:00
Yukihiro "Matz" Matsumoto 82f0ba14a9 Revert "string.c: share UTF-8 length table with mruby-string-ext."
This reverts commit 7cdef2b03e.
This sharing does not with C++ compilers.
2022-05-25 16:07:52 +09:00
Yukihiro "Matz" Matsumoto 7cdef2b03e string.c: share UTF-8 length table with mruby-string-ext. 2022-05-25 11:25:43 +09:00
Yukihiro "Matz" Matsumoto bb99d7b2ca string.c (mrb_utf8len): reduce UTF-8 table size. 2022-05-25 08:04:19 +09:00
Yukihiro "Matz" Matsumoto d7731a95ab string.c (mrb_str_rindex_m): avoid RSTRING_CHAR_LEN() if possible.
Since it scans the string. Use char_backtrack() instead for negative
offset (counting from the tail).
2022-05-24 08:47:07 +09:00
Yukihiro "Matz" Matsumoto 9475521fa3 string.c (char_adjust): simplify and unroll function. 2022-05-23 23:12:40 +09:00
Yukihiro "Matz" Matsumoto 4769ace7e1 string.c (char_backtrack): simplify the code using utf8_islead(). 2022-05-23 23:12:40 +09:00
Yukihiro "Matz" Matsumoto 916fd642fa string.c (mrb_utf8len): unroll a for loop. 2022-05-21 16:14:16 +09:00
Yukihiro "Matz" Matsumoto 54bbc062fb string.c (index,rindex) use single byte version for ASCII strings. 2022-05-21 08:51:11 +09:00
Yukihiro "Matz" Matsumoto 038aa6beb2 strinc.rb (sub, gsub): use byte index instead of char index. 2022-05-19 10:14:59 +09:00
Yukihiro "Matz" Matsumoto 960da4ded4 cdump.c: should dump zero symbol (skip) too.
Zero symbol in the symbol table now means anonymous arguments.
2022-05-16 16:39:56 +09:00
Yukihiro "Matz" Matsumoto c2648ad95d string.c: add byteindex and byterindex methods. 2022-05-16 16:00:00 +09:00
Yukihiro "Matz" Matsumoto 8c985ff851 string.c (mrb_str_index_m): no need to align the position; ref #4569 2022-05-16 14:17:21 +09:00
Yukihiro "Matz" Matsumoto 6c6d8a98fa codedump.c: avoid printing 'local variable names:' header.
If there is no local variable defined in `irep`.
2022-05-12 19:14:40 +09:00
Yukihiro "Matz" Matsumoto 45f61e3879 class.c (mrb_get_args): remove I specifier (istruct); close #5706 2022-05-07 17:35:45 +09:00
Yukihiro "Matz" Matsumoto 457abf4c9e error.c: now mrb_exc_mesg_get() returns a string or nil. 2022-05-06 16:45:17 +09:00
Yukihiro "Matz" Matsumoto 38b69b6014 error.c: protect mrb_print_error() from exceptions.
Now the function can be called when `mrb->jmp` is not set.
2022-05-06 16:26:31 +09:00
Yukihiro "Matz" Matsumoto c3e4ee0bf2 error.c: store error message converted as a string.
This is controversial since this change alters the `raise` behavior.
Previously, when an object that cannot be converted to a string, it just
ignore message when it's printed (using `Exception#inspect`). But after
this change, `raise` (more precisly `Exception.new`) raises TypeError
exception. I think the new behavior is clearer, more intuitive.
2022-05-06 16:21:39 +09:00
dearblue c32cac6e59 Introduce mrb_stack_extend_adjust()
If necessary, adjust the pointer on the VM stack after `mrb_stack_extend()`.
2022-05-04 09:13:56 +09:00
Yukihiro "Matz" Matsumoto 23ce122fc2 vm.c (mrb_funcall_with_block): copy argv before prepare_missing(); fix #5704
Since prepare_missing() may call `missing` method internally.
2022-05-02 18:59:38 +09:00
Yukihiro "Matz" Matsumoto 06c4c76be8 Merge branch 'exception' of https://github.com/dearblue/mruby into dearblue-exception 2022-05-01 20:00:37 +09:00
Yukihiro "Matz" Matsumoto a243cf4d68 codedump.c: adjust integer size.
* uint32_t and ptrdiff_t
* uint16_t and uint8_t
2022-04-30 16:51:38 +09:00
Yukihiro "Matz" Matsumoto 32fb8b19aa class.c: fix integer size mixtures (int, mrb_ssize and mrb_int). 2022-04-28 14:22:11 +09:00
Yukihiro "Matz" Matsumoto 6499efb8dd fmt_fp.c: add type cast to remove a warning. 2022-04-27 13:01:30 +09:00
Yukihiro "Matz" Matsumoto 132d55c924 symbol.c: fix size_t and uint32_t mixture. 2022-04-27 12:52:51 +09:00
Yukihiro "Matz" Matsumoto dd4da14772 symbol.c: remove type mismatch warnings. 2022-04-25 19:14:16 +09:00
Yukihiro "Matz" Matsumoto 118ff0a529 Merge branch 'bigint-gem' of https://github.com/dearblue/mruby into dearblue-bigint-gem 2022-04-25 11:03:39 +09:00
Yukihiro "Matz" Matsumoto f225db4ed6 string.c: move compilation condition to remove unreachable code. 2022-04-25 10:04:39 +09:00
Yukihiro "Matz" Matsumoto 39c8c051f8 numeric.c: mrb_integer_to_str now supports big integers. 2022-04-25 10:03:47 +09:00