MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add weak reference handling for accessor registry

+37 -18
+37 -18
src/ant.c
··· 23131 23131 } 23132 23132 } 23133 23133 23134 + // accessor registry is a weak reference 23135 + // objects only survive if reachable from other roots 23136 + (void)accessor_registry; 23137 + 23134 23138 proxy_data_t *proxy, *proxy_tmp; 23135 23139 HASH_ITER(hh, proxy_registry, proxy, proxy_tmp) { 23136 - (void)fwd_off(ctx, proxy->obj_offset); RSV_VAL(proxy->target); RSV_VAL(proxy->handler); 23140 + RSV_VAL(proxy->target); 23141 + RSV_VAL(proxy->handler); 23137 23142 } 23138 23143 23139 - dynamic_accessors_t *acc, *acc_tmp; 23140 - HASH_ITER(hh, accessor_registry, acc, acc_tmp) { (void)fwd_off(ctx, acc->obj_offset); } 23141 - 23142 23144 descriptor_entry_t *desc, *desc_tmp; 23143 23145 HASH_ITER(hh, desc_registry, desc, desc_tmp) { 23144 23146 if (desc->has_getter) RSV_VAL(desc->getter); 23145 23147 if (desc->has_setter) RSV_VAL(desc->setter); 23146 - (void)fwd_off(ctx, (jsoff_t)(desc->key >> 32)); 23147 23148 } 23148 23149 23149 23150 #undef RSV_OFF ··· 23185 23186 } 23186 23187 23187 23188 proxy_data_t *proxy, *proxy_tmp; 23188 - REHASH_REGISTRY(proxy_registry, proxy, proxy_tmp, new_proxy, obj_offset, sizeof(jsoff_t), { 23189 - FWD_OFF(proxy->obj_offset); FWD_VAL(proxy->target); FWD_VAL(proxy->handler); 23190 - }); 23189 + for (proxy_data_t *new_proxy_registry = NULL, *_once = NULL; !_once; _once = (void*)1, proxy_registry = new_proxy_registry) 23190 + HASH_ITER(hh, proxy_registry, proxy, proxy_tmp) { 23191 + HASH_DEL(proxy_registry, proxy); 23192 + jsoff_t old_off = proxy->obj_offset; 23193 + jsoff_t new_off = fwd_off(ctx, old_off); 23194 + if (new_off == old_off && old_off != 0) { ANT_GC_FREE(proxy); continue; } 23195 + proxy->obj_offset = new_off; 23196 + FWD_VAL(proxy->target); FWD_VAL(proxy->handler); 23197 + HASH_ADD(hh, new_proxy_registry, obj_offset, sizeof(jsoff_t), proxy); 23198 + } 23191 23199 23192 23200 dynamic_accessors_t *acc, *acc_tmp; 23193 - REHASH_REGISTRY(accessor_registry, acc, acc_tmp, new_acc, obj_offset, sizeof(jsoff_t), { 23194 - FWD_OFF(acc->obj_offset); 23195 - }); 23201 + for (dynamic_accessors_t *new_acc_registry = NULL, *_once = NULL; !_once; _once = (void*)1, accessor_registry = new_acc_registry) 23202 + HASH_ITER(hh, accessor_registry, acc, acc_tmp) { 23203 + HASH_DEL(accessor_registry, acc); 23204 + jsoff_t old_off = acc->obj_offset; 23205 + jsoff_t new_off = fwd_off(ctx, old_off); 23206 + if (new_off == old_off && old_off != 0) { free(acc); continue; } 23207 + acc->obj_offset = new_off; 23208 + HASH_ADD(hh, new_acc_registry, obj_offset, sizeof(jsoff_t), acc); 23209 + } 23196 23210 23197 23211 descriptor_entry_t *desc, *desc_tmp; 23198 - REHASH_REGISTRY(desc_registry, desc, desc_tmp, new_desc, key, sizeof(uint64_t), { 23199 - if (desc->has_getter) FWD_VAL(desc->getter); 23200 - if (desc->has_setter) FWD_VAL(desc->setter); 23201 - jsoff_t obj_off = fwd_off(ctx, (jsoff_t)(desc->key >> 32)); 23202 - desc->key = ((uint64_t)obj_off << 32) | (uint32_t)(desc->key & 0xFFFFFFFF); 23203 - desc->obj_off = obj_off; 23204 - }); 23212 + for (descriptor_entry_t *new_desc_registry = NULL, *_once = NULL; !_once; _once = (void*)1, desc_registry = new_desc_registry) 23213 + HASH_ITER(hh, desc_registry, desc, desc_tmp) { 23214 + HASH_DEL(desc_registry, desc); 23215 + jsoff_t old_off = (jsoff_t)(desc->key >> 32); 23216 + jsoff_t new_off = fwd_off(ctx, old_off); 23217 + if (new_off == old_off && old_off != 0) { ANT_GC_FREE(desc); continue; } 23218 + if (desc->has_getter) FWD_VAL(desc->getter); 23219 + if (desc->has_setter) FWD_VAL(desc->setter); 23220 + desc->key = ((uint64_t)new_off << 32) | (uint32_t)(desc->key & 0xFFFFFFFF); 23221 + desc->obj_off = new_off; 23222 + HASH_ADD(hh, new_desc_registry, key, sizeof(uint64_t), desc); 23223 + } 23205 23224 23206 23225 memset(intern_prop_cache, 0, sizeof(intern_prop_cache)); 23207 23226