зеркало из https://github.com/github/ruby.git
Check frozen flag on MJIT setinstancevariable
It does not seem to have a significant performance impact, hopefully?
```
$ benchmark-driver -v benchmark.yml --rbenv 'before --jit;after --jit' --repeat-count=24 --output=all
before --jit: ruby 2.7.0dev (2019-09-03T21:02:24Z master 77596fb7a9
) +JIT [x86_64-linux]
after --jit: ruby 2.7.0dev (2019-09-04T01:54:44Z master 7363e22d79) +JIT [x86_64-linux]
Calculating -------------------------------------
before --jit after --jit
Optcarrot Lan_Master.nes 48.44054595799523 71.67010255902900 fps
71.32797692837639 71.97846863769546
72.51921961607691 78.87360980544105
73.54082925611047 79.80408132389941
74.03503843709451 79.85739528572826
74.04863857926493 79.89850834901381
75.30266276129467 80.34607233076015
75.69063990896244 80.88474397425360
75.70458132587405 81.09234267781642
77.39842764662852 82.13766823612643
77.76922944068329 82.20398304840373
81.17984044023393 82.26722630628272
82.85235776076533 82.71375902781254
83.04906099135320 82.75893420702198
83.10214168136230 82.79668965325972
83.71456007558125 82.85131667916379
84.06658306760725 82.95676565411722
84.25690684305728 83.19972846225775
84.27938663923503 83.28510503845854
84.45467716218090 83.41003730434703
84.51563186125925 83.67773614721280
84.56139892968321 84.02082201151110
84.69819452180658 84.10495346787033
84.78125989622576 84.47867803506055
```
Note for backporter:
test_jit's `success_count` would be 1 in Ruby 2.6, since 2.7 introduced
"MJIT recompile" on JIT-ed code cancel.
[Bug #16139]
This commit is contained in:
Родитель
77596fb7a9
Коммит
c14b67b2a8
|
@ -739,6 +739,28 @@ class TestJIT < Test::Unit::TestCase
|
|||
end;
|
||||
end
|
||||
|
||||
def test_inlined_setivar_frozen
|
||||
assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "FrozenError\n", success_count: 2, min_calls: 3)
|
||||
begin;
|
||||
class A
|
||||
def a
|
||||
@a = 1
|
||||
end
|
||||
end
|
||||
|
||||
a = A.new
|
||||
a.a
|
||||
a.a
|
||||
a.a
|
||||
a.freeze
|
||||
begin
|
||||
a.a
|
||||
rescue FrozenError => e
|
||||
p e.class
|
||||
end
|
||||
end;
|
||||
end
|
||||
|
||||
def test_attr_reader
|
||||
assert_eval_with_jit("#{<<~"begin;"}\n#{<<~"end;"}", stdout: "4nil\nnil\n6", success_count: 2, min_calls: 2)
|
||||
begin;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
% # JIT: cache hit path of vm_getivar, or cancel JIT.
|
||||
% if insn.name == 'setinstancevariable'
|
||||
fprintf(f, " VALUE val = stack[%d];\n", b->stack_size - 1);
|
||||
fprintf(f, " if (LIKELY(RB_TYPE_P(obj, T_OBJECT) && ic_serial == RCLASS_SERIAL(RBASIC(obj)->klass) && index < ROBJECT_NUMIV(obj))) {\n");
|
||||
fprintf(f, " if (LIKELY(RB_TYPE_P(obj, T_OBJECT) && ic_serial == RCLASS_SERIAL(RBASIC(obj)->klass) && index < ROBJECT_NUMIV(obj) && !RB_OBJ_FROZEN(obj))) {\n");
|
||||
fprintf(f, " VALUE *ptr = ROBJECT_IVPTR(obj);\n");
|
||||
fprintf(f, " RB_OBJ_WRITE(obj, &ptr[index], val);\n");
|
||||
fprintf(f, " }\n");
|
||||
|
|
Загрузка…
Ссылка в новой задаче