summaryrefslogtreecommitdiffhomepage
path: root/src
AgeCommit message (Collapse)Author
2021-08-21etc.c: clear `mrb_value` if `sizeof(void*)` is bigger than `sizeof(mrb_float)`.Yukihiro "Matz" Matsumoto
2021-08-21boxing_word.h: embed `mrb_float` in `mrb_value` if possible.Yukihiro "Matz" Matsumoto
Embedding reduce memory consumption, sacrificing precision. It clips least significant 2 bits from `mrb_float`, so if you need to keep float precision, define `MRB_USE_FLOAT_FULL_PRECISION`. `MRB_WORD_BOXING` and `MRB_INT64`: `mrb_float` (`double`) is embedded in `mrb_value` clipped last 2 bits. `MRB_WORD_BOXING` and `MRB_INT64` and `MRB_USE_FLOAT_FULL_PRECISION`: `mrb_float` is allocated in the heaps wrapped by `struct RFloat`. `MRB_WORD_BOXING` and `MRB_INT32` and `MRB_USE_FLOAT32`: `mrb_float` (`float`) is embedded in `mrb_value` clipped last 2 bits. In addition, to reserve bit space in the `mrb_value`, maximum inline symbol length become 4 (instead of 5) in the configuration. `MRB_WORD_BOXING` and `MRB_INT32`: Assume `MRB_USE_FLOAT_FULL_PRECISION` and allocate Float values in heap.
2021-08-19symbol.c: reduce memory by avoiding alignment gaps.Yukihiro "Matz" Matsumoto
In additions: * use bitmap for flags * BER integer compression for length
2021-08-19gc.c: remove unused `struct`s from `RVALUE`.Yukihiro "Matz" Matsumoto
2021-08-18string.c: `mrb_str_to_cstr()` should always return a mutable string.Yukihiro "Matz" Matsumoto
2021-08-18debug.c: export integer compressing functions.Yukihiro "Matz" Matsumoto
- mrb_packed_int_len() - mrb_packed_int_encode() - mrb_packed_int_decode()
2021-08-14error.c: the error message may contain `NUL` character.Yukihiro "Matz" Matsumoto
2021-08-13Check the class with `I` specifier of `mrb_get_args()`dearblue
Previously, the `I` specifier only checked if the object was `MRB_TT_ISTRUCT`. So it was at risk of getting pointers to different C structs if multiple classes were to use the `MRB_TT_ISTRUCT` instance. Change this behavior and change the C argument corresponding to the `I` specifier to `(void *, struct RClass)`. This change is not compatible with the previous mruby. Please note that if the user uses the previous specifications, `SIGSEGV` may occur or the machine stack may be destroyed. resolve #5527
2021-08-12Revert "Drop unnecessary upper procs linked from class/module/def syntax"Yukihiro "Matz" Matsumoto
Fix #5528 This reverts commit 59201b59046b9e73c309508350cd3c0fafd20e4d; #5497
2021-08-12class.c: `const_missing` do not have to be in the backtrace; ref #5528Yukihiro "Matz" Matsumoto
2021-08-11codedump.c: print local variable name for `ADDI/SUBI/ instructions.Yukihiro "Matz" Matsumoto
Recent peephole optimization made `ADDI/SUBI` destinations possibly local variables.
2021-08-07codedump.c: print two operands `R(x)` and `R(x+1)` for clarity.Yukihiro "Matz" Matsumoto
2021-08-06numeric.c: fix a bug regarding `MRB_INT_MIN`.Yukihiro "Matz" Matsumoto
2021-08-04numeric.c: fix a bug in left shift of negative integer.Yukihiro "Matz" Matsumoto
`-1 * (1<<63)` causes overflow, but `-1<<63` is a valid value.
2021-08-03numeric.c: check zero division before modulo.Yukihiro "Matz" Matsumoto
2021-08-03Revert "numeric.c: simplifies `int_mod` definition."Yukihiro "Matz" Matsumoto
This reverts commit 3738d62a86a54524d5d7738ddbafe4700ca6a889. The change changed the behavior with floating point numbers.
2021-08-03numeric.c: simplifies `int_mod` definition.Yukihiro "Matz" Matsumoto
2021-08-03Replace `mrb_fixnum_value()` with `mrb_int_value()`.Yukihiro "Matz" Matsumoto
Use `mrb_fixnum_value()` only when you are absolutely sure that the value is within `Fixnum` range, i.e. 31 bits signed integer at least.
2021-08-03Replace `fixnum` references with `int`.Yukihiro "Matz" Matsumoto
The `Fixnum` class is no longer provided by `mruby`.
2021-08-03numeric.c: rename `fixdivmod` to `intdivmod`.Yukihiro "Matz" Matsumoto
2021-08-02numeric.c: simpler integer modulo calculation.Yukihiro "Matz" Matsumoto
2021-08-02numeric.c: use C's modulo operator if both operands are positive.Yukihiro "Matz" Matsumoto
2021-08-02numeric.c: refactor integer bit shift operations.Yukihiro "Matz" Matsumoto
2021-07-30codedump.c: instruction length should be `ilen`, not `iseq`.Yukihiro "Matz" Matsumoto
2021-07-28debug.c: uses most space efficient packed map for line information.Yukihiro "Matz" Matsumoto
2021-07-26debug.c: small refactoring.Yukihiro "Matz" Matsumoto
2021-07-26debug.c: remove type cast warnings.Yukihiro "Matz" Matsumoto
2021-07-26fmt_fp.c: add implicit cast from `mrb_float` to `int8_t`.Yukihiro "Matz" Matsumoto
2021-07-26vm.c: fix integer type error in `mrb_protect_error`.Yukihiro "Matz" Matsumoto
2021-07-25Remove redundant include headers.Yukihiro "Matz" Matsumoto
- stdlib.h - stddef.h - stdint.h - stdarg.h - limits.h - float.h
2021-07-17Explicit write barrier for bindingdearblue
2021-07-17codedump.c: update some instructions.Yukihiro "Matz" Matsumoto
- OP_GETGV - OP_SETGV - OP_GETSV - OP_SETSV - OP_GETIV - OP_SETIV - OP_GETCV - OP_SETCV - OP_GETCONST - OP_SETCONST - OP_GETMCNST - OP_SETMCNST - OP_GETUPVAR - OP_SETUPVAR
2021-07-12load.c: call `mrb_top_run()` from `mrb_load_proc()`; fix #5504Yukihiro "Matz" Matsumoto
So that the function behave consistently with `mrb_load_proc()`.
2021-07-10numeric.c: `self` should always be an integer in `__coerce_step_counter`.Yukihiro "Matz" Matsumoto
2021-07-10Update internal methods not to be listed in backtraces.Yukihiro "Matz" Matsumoto
- String#__lines - Array#__ary_eq - Array#__ary_cmp - Hash#__delete - Kernel#__case_eqq - Integer#__coerce_step_counter
2021-07-09Do not include `stdint.h` before `mruby.h`dearblue
2021-07-09debug.h: use `uint8_t` instead of `char` for BER compressed binary.Yukihiro "Matz" Matsumoto
A change in `load.c` is left uncommitted.
2021-07-09debug.h: use `uint8_t` instead of `char` for BER compressed binary.Yukihiro "Matz" Matsumoto
2021-07-09cdump.c: avoid uninitialized local variable.Yukihiro "Matz" Matsumoto
2021-07-09range.c: avoid implicit conversion from `mrb_float` to `mrb_int`.Yukihiro "Matz" Matsumoto
2021-07-08range.c: should not include internal `__num_to_a` in the backtrace.Yukihiro "Matz" Matsumoto
2021-07-08backtrace.c: skip C method without `mid` set.Yukihiro "Matz" Matsumoto
That means it's a method not to be included in the backtrace, for example `raise`.
2021-07-08debug.c: new debug line information format `mrb_debug_line_packed_map`.Yukihiro "Matz" Matsumoto
It uses BER number compression of delta of instruction positions and line numbers. BER compression is a variable length number representation. * `mrb_debug_line_ary`: array of line numbers represented in `uint16_t`. `[lineno, lineno, ...]` * `mrb_debug_line_flat_map`: array of `mrb_irep_debug_info_line`, which is `struct {uint32_t pos; uint16_t lineno}`, for each line. * `mrb_debug_line_packed_map` [new]: sequence of BER compressed 2 numbers, `pos_delta, lineno_delta`. Deltas are differences from previous values (starting `0`). `line_entry_counts` represents total length of a packed map string for this type.
2021-07-03vm.c: `OP_DEF` to push a symbol to `a` register.Yukihiro "Matz" Matsumoto
The code generator no longer need to emit `OP_LOADSYM` after `OP_DEF`. `doc/opcode.md` is also updated.
2021-07-02vm.c: need to adjust `pc` for `OP_EXT[123]`.Yukihiro "Matz" Matsumoto
2021-07-02error.c: `mrb_obj_as_string` and `mrb_inspect` may return non-object (`undef`).Yukihiro "Matz" Matsumoto
2021-06-30Revert "Remove `OP_EXT[123]` from operands."Yukihiro "Matz" Matsumoto
This reverts commit fd10c7231906ca48cb35892d2a86460004b62249. I thought it was OK to restrict index value within 1 byte, but in some cases index value could be 16 bits (2 bytes). I had several ideas to address the issue, but reverting `fd10c72` is the easiest way. The biggest reason is `mruby/c` still supports `OP_EXT[123]`, so that they don't need any additional work.
2021-06-28Drop unnecessary upper procs linked from class/module/def syntaxdearblue
It does not need to hold an anonymous proc for constant search. Also, this change can be expected to cause an anonymous proc to be GC'd. This is useful for metaprogramming that makes heavy use of the `class`/`module`/`def` syntax in the `class_eval`/`eval` method. Example: - code ```ruby p ObjectSpace.count_objects String.class_eval do def a end end p ObjectSpace.count_objects String.class_eval do eval <<~CODE def b end CODE end p ObjectSpace.count_objects ``` - result of building mruby-head (d63c0df6b) with `build_config/default.rb` ``` {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...} {:TOTAL=>1024, :FREE=>259, :T_PROC=>497, :T_ENV=>62, ...} {:TOTAL=>1024, :FREE=>255, :T_PROC=>500, :T_ENV=>63, ...} ``` - result of building mruby with this patch and `build_config/default.rb` ``` {:TOTAL=>1024, :FREE=>264, :T_PROC=>494, :T_ENV=>60, ...} {:TOTAL=>1024, :FREE=>262, :T_PROC=>495, :T_ENV=>61, ...} {:TOTAL=>1024, :FREE=>261, :T_PROC=>496, :T_ENV=>61, ...} ```
2021-06-26Fixed finding variables from `proc` in `binding.eval` faileddearblue
Previously the following code did not produce the expected results: ```ruby bx = binding block = bx.eval("a = 1; proc { a }") bx.eval("a = 2") p block.call # Expect 2 but return 1 due to a bug ``` The previous implementation of `Binding#eval` evaluated the code and then merged the top layer variables. This patch will parse and expand the variable space before making a call to `eval`. This means that the call to `Binding#eval` will do the parsing twice. In addition, the following changes will be made: - Make `mrb_parser_foreach_top_variable()`, `mrb_binding_extract_proc()` and `mrb_binding_extract_env()` functions private global functions. - Remove the `posthook` argument from `mrb_exec_irep()`. The `posthook` argument was introduced to implement the `binding` method. This patch is unnecessary because it uses a different implementation method. ref #5362 fixed #5491
2021-06-25class.c: call `method_added` hooks on alias definitions; #2339Yukihiro "Matz" Matsumoto