Commit 3d91ed0
committed
ZJIT: Prefer T_* guard over checking RBasic::klass
After a8f3c34 ("ZJIT: Add missing guard
on ivar access on T_{DATA,CLASS,MODULE}"), speed on getivar-module.rb in
ruby-bench regressed in speed to about 1/8. It turns out that the new
guard for Class was implemented as a guard over `RBasic::klass`, and the
one extra register pressure for the `rb_cClass` has regalloc spilling
and reloading a local each loop iteration, which is catastrophic for
performance.
`GuardType vN, Class` can be implemented as a check for T_CLASS in
RBasic::flags. It's less register pressure since the numeric value for
T_CLASS is small enough to fit in a native instruction immediate and it
also doesn't add GC marking work.
builtin_type_equivalent() is exactly as wide, so it's correct at any
position in the gen_guard_type() decision tree. Put it before the
runtime_exact_ruby_class() check.1 parent 8aa2322 commit 3d91ed0
1 file changed
+17
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2546 | 2546 | | |
2547 | 2547 | | |
2548 | 2548 | | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
2549 | 2566 | | |
2550 | 2567 | | |
2551 | 2568 | | |
| |||
2586 | 2603 | | |
2587 | 2604 | | |
2588 | 2605 | | |
2589 | | - | |
2590 | | - | |
2591 | | - | |
2592 | | - | |
2593 | | - | |
2594 | | - | |
2595 | | - | |
2596 | | - | |
2597 | | - | |
2598 | | - | |
2599 | | - | |
2600 | | - | |
2601 | | - | |
2602 | | - | |
2603 | | - | |
2604 | | - | |
2605 | | - | |
2606 | 2606 | | |
2607 | 2607 | | |
2608 | 2608 | | |
| |||
0 commit comments