Commit 3c7c3b6
committed
src: track cppgc wrappers with a list in Realm
This allows us to perform cleanups of cppgc wrappers that rely
on a living Realm during Realm shutdown. Otherwise
the cleanup may happen during object destruction, which can
be triggered by GC after Realm shutdown, leading to invalid
access to Realm.
The general pattern for this type of non-trivial destruction is
designed to be:
```
class MyWrap final : CPPGC_MIXIN(MyWrap) {
public:
~MyWrap() { this->Finalize(); }
void Clean(Realm* realm) override {
// Do cleanup that relies on a living Realm. This would be
// called by CppgcMixin::Finalize() first during Realm shutdown,
// while the Realm is still alive. If the destructor calls
// Finalize() again later during garbage collection that happens after
// Realm shutdown, Clean() would be skipped, preventing
// invalid access to the Realm.
}
}
```
In addition, this allows us to trace external memory held by the wrappers
in the heap snapshots if we add synthethic edges between the wrappers
and other nodes in the embdder graph callback, or to perform snapshot
serialization for them.1 parent 4cc69f9 commit 3c7c3b6
4 files changed
+87
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1112 | 1112 | | |
1113 | 1113 | | |
1114 | 1114 | | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
| 1120 | + | |
| 1121 | + | |
| 1122 | + | |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
1115 | 1126 | | |
1116 | 1127 | | |
1117 | 1128 | | |
| |||
1266 | 1277 | | |
1267 | 1278 | | |
1268 | 1279 | | |
| 1280 | + | |
| 1281 | + | |
1269 | 1282 | | |
1270 | 1283 | | |
1271 | 1284 | | |
| |||
1277 | 1290 | | |
1278 | 1291 | | |
1279 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
1280 | 1314 | | |
1281 | 1315 | | |
1282 | 1316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | | - | |
| 50 | + | |
| 51 | + | |
42 | 52 | | |
43 | 53 | | |
44 | 54 | | |
| |||
58 | 68 | | |
59 | 69 | | |
60 | 70 | | |
| 71 | + | |
61 | 72 | | |
62 | 73 | | |
63 | 74 | | |
| |||
88 | 99 | | |
89 | 100 | | |
90 | 101 | | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
91 | 123 | | |
92 | | - | |
| 124 | + | |
93 | 125 | | |
94 | 126 | | |
95 | 127 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1302 | 1302 | | |
1303 | 1303 | | |
1304 | 1304 | | |
| 1305 | + | |
| 1306 | + | |
1305 | 1307 | | |
1306 | 1308 | | |
1307 | 1309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
605 | 611 | | |
606 | 612 | | |
607 | 613 | | |
| |||
897 | 903 | | |
898 | 904 | | |
899 | 905 | | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
900 | 909 | | |
901 | 910 | | |
902 | 911 | | |
903 | 912 | | |
904 | 913 | | |
905 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
906 | 918 | | |
907 | 919 | | |
908 | 920 | | |
| |||
1191 | 1203 | | |
1192 | 1204 | | |
1193 | 1205 | | |
| 1206 | + | |
| 1207 | + | |
1194 | 1208 | | |
1195 | 1209 | | |
1196 | 1210 | | |
| |||
0 commit comments