Commit 9b53840
committed
src: track cppgc wrappers with CppgcWrapperList in Environment
This allows us to perform cleanups of cppgc wrappers that rely
on a living Environment during Environment shutdown. Otherwise
the cleanup may happen during object destruction, which can
be triggered by GC after Enivronment shutdown, leading to invalid
access to Environment.
The general pattern for this type of non-trivial destruction is
designed to be:
```
class MyWrap final : CPPGC_MIXIN(MyWrap) {
public:
~MyWrap() { this->Clean(); }
void CleanEnvResource(Environment* env) override {
// Do cleanup that relies on a living Environemnt. This would be
// called by CppgcMixin::Clean() first during Environment shutdown,
// while the Environment is still alive. If the destructor calls
// Clean() again later during garbage collection that happens after
// Environment shutdown, CleanEnvResource() would be skipped, preventing
// invalid access to the Environment.
}
}
```
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 5c83957 commit 9b53840
4 files changed
+87
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1050 | 1050 | | |
1051 | 1051 | | |
1052 | 1052 | | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1053 | 1064 | | |
1054 | 1065 | | |
1055 | 1066 | | |
| |||
1204 | 1215 | | |
1205 | 1216 | | |
1206 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
1207 | 1220 | | |
1208 | 1221 | | |
1209 | 1222 | | |
| |||
1215 | 1228 | | |
1216 | 1229 | | |
1217 | 1230 | | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
1218 | 1252 | | |
1219 | 1253 | | |
1220 | 1254 | | |
| |||
| 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 | |
|---|---|---|---|
| |||
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
| 1302 | + | |
| 1303 | + | |
1302 | 1304 | | |
1303 | 1305 | | |
1304 | 1306 | | |
| |||
| 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