MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxMeasureSlot

Function fxMeasureSlot

xs/sources/xsSnapshot.c:1161–1233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1159}
1160
1161void fxMeasureSlot(txMachine* the, txSnapshot* snapshot, txSlot* slot, txSize* chunkSize)
1162{
1163 switch (slot->kind) {
1164 case XS_STRING_KIND:
1165 fxMeasureChunk(the, snapshot, slot->value.string, chunkSize);
1166 break;
1167 case XS_BIGINT_KIND:
1168 fxMeasureChunk(the, snapshot, slot->value.bigint.data, chunkSize);
1169 break;
1170 case XS_ARGUMENTS_SLOPPY_KIND:
1171 case XS_ARGUMENTS_STRICT_KIND:
1172 case XS_ARRAY_KIND:
1173 case XS_STACK_KIND:
1174 if (slot->value.array.address)
1175 fxMeasureChunkArray(the, snapshot, slot->value.array.address, chunkSize);
1176 break;
1177 case XS_ARRAY_BUFFER_KIND:
1178 if (slot->value.arrayBuffer.address)
1179 fxMeasureChunk(the, snapshot, slot->value.arrayBuffer.address, chunkSize);
1180 break;
1181
1182 case XS_CODE_KIND:
1183 fxMeasureChunk(the, snapshot, slot->value.code.address, chunkSize);
1184 break;
1185
1186 case XS_REGEXP_KIND:
1187 if (slot->value.regexp.code)
1188 fxMeasureChunk(the, snapshot, slot->value.regexp.code, chunkSize);
1189 if (slot->value.regexp.data)
1190 fxMeasureChunk(the, snapshot, slot->value.regexp.data, chunkSize);
1191 break;
1192 case XS_KEY_KIND:
1193 if (slot->value.key.string)
1194 fxMeasureChunk(the, snapshot, slot->value.key.string, chunkSize);
1195 break;
1196 case XS_GLOBAL_KIND:
1197 case XS_MAP_KIND:
1198 case XS_SET_KIND:
1199 fxMeasureChunk(the, snapshot, slot->value.table.address, chunkSize);
1200 break;
1201
1202 case XS_HOST_KIND:
1203#if mxMacOSX || mxLinux
1204 if (slot->value.host.variant.destructor) {
1205 txDestructor destructor;
1206 Dl_info info;
1207 if (slot->flag & XS_HOST_HOOKS_FLAG)
1208 destructor = slot->value.host.variant.hooks->destructor;
1209 else
1210 destructor = slot->value.host.variant.destructor;
1211 if (dladdr(destructor, &info) && info.dli_sname) {
1212 mxAssert(0, "# snapshot: no host destructor: %s!\n", info.dli_sname);
1213 }
1214 else {
1215 mxAssert(0, "# snapshot: no host destructor!\n");
1216 }
1217 }
1218#else

Callers 2

fxMeasureChunkArrayFunction · 0.70
fxWriteSnapshotFunction · 0.70

Calls 2

fxMeasureChunkArrayFunction · 0.85
fxMeasureChunkFunction · 0.70

Tested by

no test coverage detected