summaryrefslogtreecommitdiffhomepage
path: root/src/variable.c
AgeCommit message (Collapse)Author
2021-12-31class.c, variable,c: replace `size_t` by `int`.Yukihiro "Matz" Matsumoto
That reduce memory consumption by iv/mt tables.
2021-12-27variable.c: need to initialize `size` of iv table.Yukihiro "Matz" Matsumoto
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-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-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-06-17variable.c: add `skip` argument to skip `base` class in lookup.Yukihiro "Matz" Matsumoto
`mrb_vm_const_get` function looks up the constant first in the base class, so that fallback `const_get` need not to search from the base.
2021-06-17variable.c: refactor `mrb_vm_const_get` function.Yukihiro "Matz" Matsumoto
2021-06-17variable.c: skip prepended module for constant lookup.Yukihiro "Matz" Matsumoto
```ruby module M FOO = 'm' end class A FOO = 'a' prepend M end class B < A def foo p FOO end end B.new.foo # should print `m` not `a` ```
2021-04-03chore: fix spellingJohn Bampton
2021-01-26Revert "Minimize the changes in #5277"Yukihiro "Matz" Matsumoto
This reverts commit dc51d89ac22acc60b9bfeed87115863565b74085.
2021-01-22Minimize the changes in #5277Yukihiro "Matz" Matsumoto
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.
2021-01-11Avoid including `presym.inc` in existing header filesKOBAYASHI Shuji
Addressed an issue where existing programs linking `libmruby.a` could only be built by adding `<build-dir>/include` to compiler's include path.
2020-11-12Remove unused argument of `mrb_obj_iv_tbl_memsize`KOBAYASHI Shuji
2020-10-12Use hash table instead of segment list for instance variables.Yukihiro "Matz" Matsumoto
2020-10-12Generate C struct from `irep` instead of binary dump.Yukihiro "Matz" Matsumoto
2020-10-12Add functions that take symbols as arguments.Yukihiro "Matz" Matsumoto
- :
2020-10-12Add `MRB_SYM()` for inline symbols.Yukihiro "Matz" Matsumoto
2020-08-11Fix `mrb_int` and `size_t` combination warnings.Yukihiro "Matz" Matsumoto
2020-07-24Change the logic to calculate object (`iv_tbl`) size; #5045Yukihiro "Matz" Matsumoto
2020-07-24Merge pull request #5045 from dearblue/memsize_ofYukihiro "Matz" Matsumoto
Improve `mruby-os-memsize`
2020-07-24Avoid using FPU with `mruby-os-memsize`; ref #5032dearblue
And, in the calculation of the instance variable size, the fraction was always rounded down because of division of integers, so fix it. At the same time, test items that are no longer passed due to this change are deleted.
2020-07-22Use more `mrb_field_write_barrier` for instance variables.Yukihiro "Matz" Matsumoto
2020-07-13Use object iv table size in calculationRory OConnell
2019-11-16Revert "Implement Ruby2.7's frozen strings from `Symbol#to_s`"KOBAYASHI Shuji
This feature was reverted from Ruby 2.7.
2019-10-20Use `mrb_str_cat_str` instead of `mrb_str_concat` if possibleKOBAYASHI Shuji
2019-10-16Use `mrb_sym_name_len` instead of `mrb_sym_name` in `assign_class_name`KOBAYASHI Shuji
2019-10-08Implement Ruby2.7's frozen strings from `Module#name`KOBAYASHI Shuji
2019-09-26Use type predicate macros instead of `mrb_type` if possibleKOBAYASHI Shuji
For efficiency with `MRB_WORD_BOXING` (implement type predicate macros for all `enum mrb_vtype`).
2019-09-25Rename symbol-to-string functions; close #4684Yukihiro "Matz" Matsumoto
* mrb_sym2name -> mrb_sym_name * mrb_sym2name_len -> mrb_sym_name_len * mrb_sym2str -> mrb_sym_str
2019-09-20Fix compatibility issue of class variables.Yukihiro "Matz" Matsumoto
Singleton class definition do not introduce its own class variable scope in CRuby/JRuby. So should mruby. ``` module Mod1 class << Object.new C = 1 @@cv = 1 p Module.nesting, # => [#<Class:#<Object:0x55cb16e60a50>>, Mod1] constants, # => [:C] class_variables, # => [] Mod1.class_variables # => [:@@cv] end end ```
2019-09-20Add optional argument to `Module#class_variables`.Yukihiro "Matz" Matsumoto
2019-09-09Fix `mod.constants` not to have duplicate constant names; #4698Yukihiro "Matz" Matsumoto
The fix was based on PR from @dearblue
2019-08-11Revert "Should have cleared `mrb->globals` in `mrb_gc_free_gv`; fix #4618"Yukihiro "Matz" Matsumoto
This reverts commit 3dc8d9d7b3d0be2f91fa050a13e3b422500df628.
2019-08-06Should have cleared `mrb->globals` in `mrb_gc_free_gv`; fix #4618Yukihiro "Matz" Matsumoto
2019-08-05Use new specifiers/modifiers of `mrb_vfromat()`KOBAYASHI Shuji
The binary sizes (gems are only `mruby-bin-mruby`) are reduced slightly in my environment than before the introduction of new specifiers/modifiers (5116789a) with this change. ------------+-------------------+-------------------+-------- BINARY | BEFORE (5116789a) | AFTER (This PR) | RATIO ------------+-------------------+-------------------+-------- mruby | 593416 bytes | 593208 bytes | -0.04% libmruby.a | 769048 bytes | 767264 bytes | -0.23% ------------+-------------------+-------------------+-------- BTW, I accidentally changed `tasks/toolchains/visualcpp.rake` at #4613, so I put it back.
2019-06-25Fixed `mrb_iv_remove` with immediate objects; fix #4519Yukihiro "Matz" Matsumoto
The #4520 tried to address the issue, but it changes the type of `mrb_check_frozen` argument; close #4520
2019-06-16Fix cvar, ivar, const and method can be removed to frozen objectKOBAYASHI Shuji
2019-06-10`Kernel#global_variables` should not include undefined `$1`-`$9`KOBAYASHI Shuji
- They are not include in Ruby. - Appear in duplicate when `$1`-`$9` are defined.
2019-05-15Merge pull request #4400 from ↵Yukihiro "Matz" Matsumoto
shuujii/fix-name-assignment-to-frozen-anonymous-class-module Fix name assignment to frozen anonymous class/module
2019-04-24Fix modiying class variable to frozen class/moduleKOBAYASHI Shuji
2019-04-23Fix name assignment to frozen anonymous class/moduleKOBAYASHI Shuji
Fix the following issues: A = Class.new.freeze #=> FrozenError Module.new::B = Class.new.freeze #=> FrozenError String::B = Module.new.freeze #=> FrozenError
2019-04-14Fix wrong size of instance variable if occur out of memorydearblue
2019-04-14Remove pointer check after `mrb_malloc()`dearblue
2019-04-10Merge pull request #4367 from shuujii/extract-frozen-checking-to-functionYukihiro "Matz" Matsumoto
Extract frozen checking to function