Commit 86dfeb9
authored
Remove lazy initialized string literals (#122076)
It seems it's not worth it to avoid allocations on the frozen heap - the
lazy string helper has a lock inside (Crst in GetStringLiteral) and it
badly impacts performance for `throw Exception(<string literal>)` code
(as was reported internally) especially under contention.
```cs
static void Foo(bool cond)
{
throw new Exception("Hello");
}
```
```diff
; Method Program:Foo(bool) (FullOpts)
push rbx
sub rsp, 32
mov rcx, 0x7FFBD79E2E10 ; System.Exception
call CORINFO_HELP_NEWSFAST
mov rbx, rax
- mov ecx, 1
- mov rdx, 0x7FFBD7FE0000
- call [CORINFO_HELP_STRCNS]
- mov rdx, rax
mov rcx, rbx
+ mov rdx, 0x28922695108 ; 'Hello'
call [System.Exception:.ctor(System.String):this]
mov rcx, rbx
call CORINFO_HELP_THROW
int3
-; Total bytes of code: 65
+; Total bytes of code: 51
```1 parent 7be0c63 commit 86dfeb9
File tree
31 files changed
+54
-270
lines changed- docs/design/coreclr/botr
- src/coreclr
- System.Private.CoreLib/src/System
- inc
- jit
- tools
- Common/JitInterface
- ThunkGenerator
- aot/jitinterface
- superpmi
- superpmi-shim-collector
- superpmi-shim-counter
- superpmi-shim-simple
- superpmi
- vm
31 files changed
+54
-270
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
872 | 872 | | |
873 | 873 | | |
874 | 874 | | |
875 | | - | |
| 875 | + | |
876 | 876 | | |
877 | 877 | | |
878 | 878 | | |
| |||
Lines changed: 0 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | 13 | | |
28 | 14 | | |
29 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
367 | 367 | | |
368 | 368 | | |
369 | 369 | | |
370 | | - | |
371 | | - | |
372 | 370 | | |
373 | 371 | | |
374 | 372 | | |
| |||
3237 | 3235 | | |
3238 | 3236 | | |
3239 | 3237 | | |
3240 | | - | |
3241 | | - | |
3242 | | - | |
3243 | | - | |
3244 | | - | |
3245 | | - | |
3246 | 3238 | | |
3247 | 3239 | | |
3248 | 3240 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | 559 | | |
563 | 560 | | |
564 | 561 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | | - | |
116 | | - | |
117 | 115 | | |
118 | 116 | | |
119 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
363 | | - | |
| 363 | + | |
364 | 364 | | |
365 | 365 | | |
366 | 366 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
141 | 140 | | |
142 | 141 | | |
143 | 142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1310 | 1310 | | |
1311 | 1311 | | |
1312 | 1312 | | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | 1313 | | |
1323 | 1314 | | |
1324 | 1315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4057 | 4057 | | |
4058 | 4058 | | |
4059 | 4059 | | |
4060 | | - | |
| 4060 | + | |
4061 | 4061 | | |
4062 | 4062 | | |
4063 | 4063 | | |
| |||
0 commit comments