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.

generation counter for interned property cache invalidation

+14 -11
+14 -11
src/ant.c
··· 40 40 #include <sys/time.h> 41 41 #include <sys/stat.h> 42 42 #include <sys/resource.h> 43 - #include <execinfo.h> 44 43 #endif 45 44 46 45 #include "modules/fs.h" ··· 176 175 const char *intern_ptr; 177 176 jsoff_t prop_off; 178 177 jsoff_t tail; 178 + uint64_t generation; 179 179 } intern_prop_cache_entry_t; 180 + 181 + static uint64_t intern_prop_cache_gen = 1; 180 182 static intern_prop_cache_entry_t intern_prop_cache[ANT_LIMIT_SIZE_CACHE]; 181 183 182 184 typedef struct promise_handler { ··· 3171 3173 3172 3174 uint32_t cache_slot = (((uintptr_t)interned >> 3) ^ obj_off) & (ANT_LIMIT_SIZE_CACHE - 1); 3173 3175 intern_prop_cache_entry_t *ce = &intern_prop_cache[cache_slot]; 3174 - 3175 - if (ce->obj_off == obj_off && ce->intern_ptr == interned) { 3176 - ce->obj_off = 0; ce->intern_ptr = NULL; 3177 - ce->prop_off = 0; ce->tail = 0; 3178 - } 3176 + if (ce->obj_off == obj_off && ce->intern_ptr == interned) ce->generation = 0; 3179 3177 } 3180 3178 3181 3179 static jsval_t mkprop(struct js *js, jsval_t obj, jsval_t k, jsval_t v, jsoff_t flags) { ··· 5226 5224 5227 5225 static inline jsoff_t lkp_interned(struct js *js, jsval_t obj, const char *search_intern, size_t len) { 5228 5226 jsoff_t obj_off = (jsoff_t)vdata(obj); 5229 - jsoff_t first_prop = loadoff(js, obj_off) & ~(3U | FLAGMASK); 5230 5227 jsoff_t tail = loadoff(js, obj_off + sizeof(jsoff_t) * 2); 5231 5228 5232 5229 uint32_t slot = (((uintptr_t)search_intern >> 3) ^ obj_off) & (ANT_LIMIT_SIZE_CACHE - 1); 5233 5230 intern_prop_cache_entry_t *ce = &intern_prop_cache[slot]; 5234 - if (ce->obj_off == obj_off && ce->intern_ptr == search_intern && ce->tail == tail) return ce->prop_off; 5235 5231 5236 - jsoff_t off = first_prop; 5237 - jsoff_t result = 0; 5232 + if (ce->generation == intern_prop_cache_gen 5233 + && ce->obj_off == obj_off 5234 + && ce->intern_ptr == search_intern 5235 + && ce->tail == tail 5236 + ) return ce->prop_off; 5237 + 5238 + jsoff_t first_prop = loadoff(js, obj_off) & ~(3U | FLAGMASK); 5239 + jsoff_t off = first_prop; jsoff_t result = 0; 5238 5240 5239 5241 while (off < js->brk && off != 0) { 5240 5242 jsoff_t header = loadoff(js, off); ··· 5250 5252 off = next_prop(header); 5251 5253 } 5252 5254 5255 + ce->generation = intern_prop_cache_gen; 5253 5256 ce->obj_off = obj_off; 5254 5257 ce->intern_ptr = search_intern; 5255 5258 ce->prop_off = result; ··· 22888 22891 HASH_ADD(hh, new_desc_registry, key, sizeof(uint64_t), desc); 22889 22892 } 22890 22893 22891 - memset(intern_prop_cache, 0, sizeof(intern_prop_cache)); 22894 + intern_prop_cache_gen++; 22892 22895 collections_gc_update_roots(gc_weak_off_cb, gc_update_val_cb, &cb_ctx); 22893 22896 22894 22897 #undef FWD_OFF