Commit 195a9a4
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 iterate over the wrappers 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 2f35b1f commit 195a9a4
4 files changed
+133
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1041 | 1041 | | |
1042 | 1042 | | |
1043 | 1043 | | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1044 | 1064 | | |
1045 | 1065 | | |
1046 | 1066 | | |
| |||
1195 | 1215 | | |
1196 | 1216 | | |
1197 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
1198 | 1220 | | |
1199 | 1221 | | |
1200 | 1222 | | |
| |||
1206 | 1228 | | |
1207 | 1229 | | |
1208 | 1230 | | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
1209 | 1276 | | |
1210 | 1277 | | |
1211 | 1278 | | |
| |||
1331 | 1398 | | |
1332 | 1399 | | |
1333 | 1400 | | |
| 1401 | + | |
1334 | 1402 | | |
1335 | 1403 | | |
1336 | 1404 | | |
| |||
1341 | 1409 | | |
1342 | 1410 | | |
1343 | 1411 | | |
| 1412 | + | |
1344 | 1413 | | |
1345 | 1414 | | |
1346 | 1415 | | |
| |||
| 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 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
40 | 57 | | |
41 | | - | |
| 58 | + | |
| 59 | + | |
42 | 60 | | |
43 | 61 | | |
44 | 62 | | |
| |||
58 | 76 | | |
59 | 77 | | |
60 | 78 | | |
| 79 | + | |
61 | 80 | | |
62 | 81 | | |
63 | 82 | | |
| |||
88 | 107 | | |
89 | 108 | | |
90 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
91 | 134 | | |
92 | | - | |
| 135 | + | |
93 | 136 | | |
94 | 137 | | |
95 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1290 | 1290 | | |
1291 | 1291 | | |
1292 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
1293 | 1295 | | |
1294 | 1296 | | |
1295 | 1297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
615 | 615 | | |
616 | 616 | | |
617 | 617 | | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
618 | 624 | | |
619 | 625 | | |
620 | 626 | | |
| |||
910 | 916 | | |
911 | 917 | | |
912 | 918 | | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
913 | 922 | | |
914 | 923 | | |
915 | 924 | | |
916 | 925 | | |
917 | 926 | | |
918 | 927 | | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
919 | 931 | | |
920 | 932 | | |
921 | 933 | | |
| |||
1203 | 1215 | | |
1204 | 1216 | | |
1205 | 1217 | | |
| 1218 | + | |
| 1219 | + | |
1206 | 1220 | | |
1207 | 1221 | | |
1208 | 1222 | | |
| |||
0 commit comments