ruby-changes:64514
From: Takashi <ko1@a...>
Date: Wed, 23 Dec 2020 16:51:20 +0900 (JST)
Subject: [ruby-changes:64514] 81a8d1cf09 (master): Skip checking ROBJECT_EMBED
https://git.ruby-lang.org/ruby.git/commit/?id=81a8d1cf09 From 81a8d1cf09d59f0d69143d7896545f849f580a4e Mon Sep 17 00:00:00 2001 From: Takashi Kokubun <takashikkbn@g...> Date: Tue, 22 Dec 2020 23:38:01 -0800 Subject: Skip checking ROBJECT_EMBED when we already check ROBJECT_NUMIV(self) is larger than ROBJECT_EMBED_LEN_MAX at the beginning of the method, because the number of instance variables for the same object doesn't decrease. ``` $ benchmark-driver -v --rbenv 'before --jit;after --jit' --repeat-count=4 --alternate --output=all benchmark_3000.yml before --jit: ruby 3.0.0dev (2020-12-23T06:32:19Z master dbb4f19969) +JIT [x86_64-linux] after --jit: ruby 3.0.0dev (2020-12-23T07:45:42Z master 95e866c098) +JIT [x86_64-linux] last_commit=Skip checking ROBJECT_EMBED Calculating ------------------------------------- before --jit after --jit Optcarrot 3000 frames 102.34091772397872 102.77738408379015 fps 103.37784821624231 105.46530219076179 104.39567016876369 106.43712452152215 105.31782092252713 106.54986150067481 ``` diff --git a/tool/ruby_vm/views/_mjit_compile_ivar.erb b/tool/ruby_vm/views/_mjit_compile_ivar.erb index 21948af..5105584 100644 --- a/tool/ruby_vm/views/_mjit_compile_ivar.erb +++ b/tool/ruby_vm/views/_mjit_compile_ivar.erb @@ -30,14 +30,14 @@ https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/views/_mjit_compile_ivar.erb#L30 fprintf(f, " VM_ASSERT((rb_serial_t)%"PRI_SERIALT_PREFIX"u == RCLASS_SERIAL(RBASIC(obj)->klass));\n", ic_copy->entry->class_serial); fprintf(f, " VM_ASSERT(index < ROBJECT_NUMIV(obj));\n"); % if insn.name == 'setinstancevariable' - fprintf(f, " if (LIKELY(!RB_OBJ_FROZEN_RAW(obj) && %sRB_FL_ANY_RAW(obj, ROBJECT_EMBED))) {\n", status->max_ivar_index >= ROBJECT_EMBED_LEN_MAX ? "!" : ""); + fprintf(f, " if (LIKELY(!RB_OBJ_FROZEN_RAW(obj) && %s)) {\n", status->max_ivar_index >= ROBJECT_EMBED_LEN_MAX ? "true" : "RB_FL_ANY_RAW(obj, ROBJECT_EMBED)"); fprintf(f, " RB_OBJ_WRITE(obj, &ROBJECT(obj)->as.%s, stack[%d]);\n", status->max_ivar_index >= ROBJECT_EMBED_LEN_MAX ? "heap.ivptr[index]" : "ary[index]", b->stack_size - 1); fprintf(f, " }\n"); % else fprintf(f, " VALUE val;\n"); - fprintf(f, " if (LIKELY(%sRB_FL_ANY_RAW(obj, ROBJECT_EMBED) && (val = ROBJECT(obj)->as.%s) != Qundef)) {\n", - status->max_ivar_index >= ROBJECT_EMBED_LEN_MAX ? "!" : "", + fprintf(f, " if (LIKELY(%s && (val = ROBJECT(obj)->as.%s) != Qundef)) {\n", + status->max_ivar_index >= ROBJECT_EMBED_LEN_MAX ? "true" : "RB_FL_ANY_RAW(obj, ROBJECT_EMBED)", status->max_ivar_index >= ROBJECT_EMBED_LEN_MAX ? "heap.ivptr[index]" : "ary[index]"); fprintf(f, " stack[%d] = val;\n", b->stack_size); fprintf(f, " }\n"); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/