diff options
author | Aaron Patterson <[email protected]> | 2024-04-17 16:30:41 -0700 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2024-04-18 09:06:33 -0700 |
commit | 147ca9585ede559fd68e162cbbbaba84f009c9a1 (patch) | |
tree | fea2464e46cedbdcd6b6882f908948fd7313647d /imemo.c | |
parent | 8e08556fa7f2b6e9c43b040f2aea06dccead5d13 (diff) |
Implement equality for CI comparison when CC searching
When we're searching for CCs, compare the argc and flags for CI rather
than comparing pointers. This means we don't need to store a reference
to the CI, and it also naturally "de-duplicates" CC objects.
We can observe the effect with the following code:
```ruby
require "objspace"
hash = {}
p ObjectSpace.memsize_of(Hash)
eval ("a".."zzz").map { |key|
"hash.merge(:#{key} => 1)"
}.join("; ")
p ObjectSpace.memsize_of(Hash)
```
On master:
```
$ ruby -v test.rb
ruby 3.4.0dev (2024-04-15T16:21:41Z master d019b3baec) [arm64-darwin23]
test.rb:3: warning: assigned but unused variable - hash
3424
527736
```
On this branch:
```
$ make runruby
compiling vm.c
linking miniruby
builtin_binary.inc updated
compiling builtin.c
linking static-library libruby.3.4-static.a
ln -sf ../../rbconfig.rb .ext/arm64-darwin23/rbconfig.rb
linking ruby
ld: warning: ignoring duplicate libraries: '-ldl', '-lobjc', '-lpthread'
RUBY_ON_BUG='gdb -x ./.gdbinit -p' ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems ./test.rb
2240
2368
```
Co-authored-by: John Hawthorn <[email protected]>
Diffstat (limited to 'imemo.c')
-rw-r--r-- | imemo.c | 1 |
1 files changed, 0 insertions, 1 deletions
@@ -196,7 +196,6 @@ cc_table_mark_i(ID id, VALUE ccs_ptr, void *data) VM_ASSERT((VALUE)data == ccs->entries[i].cc->klass); VM_ASSERT(vm_cc_check_cme(ccs->entries[i].cc, ccs->cme)); - rb_gc_mark_movable((VALUE)ccs->entries[i].ci); rb_gc_mark_movable((VALUE)ccs->entries[i].cc); } return ID_TABLE_CONTINUE; |