Repository navigation
Commit 0dbdd2f
fix(codegen): root the URL constructor's coerced string across base lowering (Layer 1) (#7453)
* fix(codegen): root the URL constructor's coerced string across base lowering
`js_url_coerce_string` returns a RAW StringHeader pointer, not a
NaN-boxed value, so nothing else keeps it alive. In `new URL(input, base)`
two collection points then stood between it and its use: lowering `base`
runs arbitrary user code, and the second coercion allocates whenever
`base` is not already a string. An evacuating cycle in either window left
the pointer forwarded and `js_url_new_with_base` parsing freed bytes.
Emitted IR before:
%r23 = call js_url_coerce_string(...)
%r24 = call perry_fn__mk() ; user call, may collect
%r25 = call js_url_coerce_string(...) ; may collect
%r26 = call js_url_new_with_base(%r23, %r25)
and after:
%r23 = call js_url_coerce_string(...)
%r24 = call js_gc_temp_root_push(%r23)
%r25 = call perry_fn__mk()
%r26 = call js_url_coerce_string(%r25)
%r27 = call js_gc_temp_root_get(%r24)
%r28 = call js_url_new_with_base(%r27, %r26)
call js_gc_temp_root_truncate(%r24)
UrlPatternNew held its NaN-boxed input in a bare register across the same
window; it now lowers both operands through lower_exprs_rooted.
Latent, as every member of this class is: the value is only wrong if a
collection lands inside the window, and at collection time there is
nothing for the collector to find. The evidence is the IR, per
docs/src/internals/gc-rooting-invariant.md.
* docs: changelog fragment for #7453
---------
Co-authored-by: Ralph Küpper <ralph@skelpo.com>1 parent 45b9f79 commit 0dbdd2f
2 files changed
Lines changed: 36 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | 57 | | |
44 | 58 | | |
45 | 59 | | |
46 | | - | |
| 60 | + | |
| 61 | + | |
47 | 62 | | |
48 | 63 | | |
49 | 64 | | |
50 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
51 | 68 | | |
52 | 69 | | |
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
56 | 73 | | |
57 | 74 | | |
58 | | - | |
59 | | - | |
60 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
61 | 83 | | |
62 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
63 | 90 | | |
64 | 91 | | |
65 | 92 | | |
66 | 93 | | |
67 | 94 | | |
68 | 95 | | |
| 96 | + | |
| 97 | + | |
69 | 98 | | |
70 | 99 | | |
71 | 100 | | |
| |||
0 commit comments