summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-05-29 16:04:53 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-06-09 09:52:46 +0900
commit8f3d4090f037ae35fc9ba6380ee284aec837201f (patch)
treefcdc79400e8c8f05d99e018bde2f3002b3fa2c08 /vm.c
parent77293cef91a9aa424c086ae05f03211d9a8a87d3 (diff)
rb_equal_opt: fully static call data
This changeset reduces the generated binary of rb_equal_opt from 129 bytes to 17 bytes on my machine, according to nm(1).
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3179
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/vm.c b/vm.c
index f2c45f3..7a3ba4a 100644
--- a/vm.c
+++ b/vm.c
@@ -386,7 +386,13 @@ rb_serial_t ruby_vm_global_method_state = 1;
rb_serial_t ruby_vm_global_constant_state = 1;
rb_serial_t ruby_vm_class_serial = 1;
-static const struct rb_callcache *vm_empty_cc;
+static const struct rb_callcache vm_empty_cc = {
+ .flags = (T_IMEMO | (imemo_callcache << FL_USHIFT) | VM_CALLCACHE_UNMARKABLE),
+ .klass = Qfalse,
+ .cme_ = NULL,
+ .call_ = vm_call_general,
+ .aux_.v = 0,
+};
static void thread_free(void *ptr);
@@ -3424,10 +3430,6 @@ Init_vm_objects(void)
vm->frozen_strings = st_init_table_with_size(&rb_fstring_hash_type, 10000);
rb_objspace_gc_enable(vm->objspace);
-
- vm_empty_cc = vm_cc_new(0, NULL, vm_call_general);
- FL_SET_RAW((VALUE)vm_empty_cc, VM_CALLCACHE_UNMARKABLE);
- rb_gc_register_mark_object((VALUE)vm_empty_cc);
}
/* top self */
@@ -3799,7 +3801,7 @@ vm_collect_usage_register(int reg, int isset)
MJIT_FUNC_EXPORTED const struct rb_callcache *
rb_vm_empty_cc(void)
{
- return vm_empty_cc;
+ return &vm_empty_cc;
}
#endif /* #ifndef MJIT_HEADER */