Commit 337999d
authored
JIT: Handle some "field offset computation" patterns (#81998)
Both during local morph and during VN.
Fix #40021
Saves 3 KB on BasicMinimalApi after #84095 (there's 1111 __GetFieldHelper functions). About 0.04%. There's still a null check kept for each offset computation, which we cannot really get rid of, but NAOT could maybe emit the IL such that there is a dominating null check so that only one is emitted.
Example:
Base:
```
.managed:0000000140347CC0 loc_140347CC0: ; CODE XREF: S_P_CoreLib_System_Collections_Generic_KeyValuePair_2_System_Net_Security_System_Net_Security_SslSessionsCache_SslCredKey__System___Canon_____GetFieldHelper+23↑j
.managed:0000000140347CC0 ; DATA XREF: .rdata:__readonlydata_S_P_CoreLib_System_Collections_Generic_KeyValuePair_2_System_Net_Security_System_Net_Security_SslSessionsCache_SslCredKey__System___Canon_____GetFieldHelper↓o
.managed:0000000140347CC0 lea rax, ??_7Boxed_System_Net_Security_System_Net_Security_SslSessionsCache_SslCredKey@@6b@ ; jumptable 0000000140347CB3 case 0
.managed:0000000140347CC7 mov [r9], rax
.managed:0000000140347CCA cmp [rcx], cl
.managed:0000000140347CCC lea rax, [rcx+8]
.managed:0000000140347CD0 sub rax, rcx
.managed:0000000140347CD3 add rsp, 8
.managed:0000000140347CD7 retn
```
Diff:
```
.managed:0000000140347AA0 loc_140347AA0: ; CODE XREF: S_P_CoreLib_System_Collections_Generic_KeyValuePair_2_System_Net_Security_System_Net_Security_SslSessionsCache_SslCredKey__System___Canon_____GetFieldHelper+23↑j
.managed:0000000140347AA0 ; DATA XREF: .rdata:__readonlydata_S_P_CoreLib_System_Collections_Generic_KeyValuePair_2_System_Net_Security_System_Net_Security_SslSessionsCache_SslCredKey__System___Canon_____GetFieldHelper↓o
.managed:0000000140347AA0 lea rax, ??_7Boxed_System_Net_Security_System_Net_Security_SslSessionsCache_SslCredKey@@6b@ ; jumptable 0000000140347A93 case 0
.managed:0000000140347AA7 mov [r9], rax
.managed:0000000140347AAA cmp [rcx], cl
.managed:0000000140347AAC mov eax, 8
.managed:0000000140347AB1 add rsp, 8
.managed:0000000140347AB5 retn
```
Local morph changes handle the pattern for local structs -- VN changes handle the pattern for classes (and more complicated struct cases, like storing them in locals, which there are a few examples of in #40021).1 parent e0c94f8 commit 337999d
2 files changed
+64
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
650 | 650 | | |
651 | 651 | | |
652 | 652 | | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
653 | 681 | | |
654 | 682 | | |
655 | 683 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4450 | 4450 | | |
4451 | 4451 | | |
4452 | 4452 | | |
4453 | | - | |
| 4453 | + | |
4454 | 4454 | | |
4455 | 4455 | | |
4456 | 4456 | | |
| |||
4462 | 4462 | | |
4463 | 4463 | | |
4464 | 4464 | | |
| 4465 | + | |
| 4466 | + | |
| 4467 | + | |
| 4468 | + | |
| 4469 | + | |
| 4470 | + | |
| 4471 | + | |
| 4472 | + | |
| 4473 | + | |
| 4474 | + | |
| 4475 | + | |
| 4476 | + | |
| 4477 | + | |
| 4478 | + | |
| 4479 | + | |
| 4480 | + | |
| 4481 | + | |
| 4482 | + | |
| 4483 | + | |
| 4484 | + | |
| 4485 | + | |
| 4486 | + | |
| 4487 | + | |
| 4488 | + | |
| 4489 | + | |
| 4490 | + | |
| 4491 | + | |
| 4492 | + | |
| 4493 | + | |
| 4494 | + | |
| 4495 | + | |
| 4496 | + | |
| 4497 | + | |
4465 | 4498 | | |
4466 | 4499 | | |
4467 | 4500 | | |
| |||
4515 | 4548 | | |
4516 | 4549 | | |
4517 | 4550 | | |
4518 | | - | |
| 4551 | + | |
4519 | 4552 | | |
4520 | 4553 | | |
4521 | 4554 | | |
| |||
4830 | 4863 | | |
4831 | 4864 | | |
4832 | 4865 | | |
4833 | | - | |
| 4866 | + | |
4834 | 4867 | | |
4835 | 4868 | | |
4836 | 4869 | | |
| |||
0 commit comments