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.

PROP_CACHE fixes

+27 -3
+1 -1
meson.build
··· 74 74 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 75 75 76 76 version_conf = configuration_data() 77 - version_conf.set('ANT_VERSION', '0.2.1.4') 77 + version_conf.set('ANT_VERSION', '0.2.1.5') 78 78 version_conf.set('ANT_GIT_HASH', git_hash) 79 79 version_conf.set('ANT_BUILD_DATE', build_date) 80 80
+26 -2
src/ant.c
··· 234 234 static const char *INTERN_GET = NULL; 235 235 static const char *INTERN_SET = NULL; 236 236 237 + #define INTERN_PROP_CACHE_SIZE 4096 238 + typedef struct { 239 + jsoff_t obj_off; 240 + const char *intern_ptr; 241 + jsoff_t prop_off; 242 + } intern_prop_cache_entry_t; 243 + static intern_prop_cache_entry_t intern_prop_cache[INTERN_PROP_CACHE_SIZE]; 244 + 237 245 typedef struct map_entry { 238 246 char *key; 239 247 jsval_t value; ··· 3998 4006 static inline jsoff_t lkp_interned(struct js *js, jsval_t obj, const char *search_intern, size_t len) { 3999 4007 jsoff_t obj_off = (jsoff_t)vdata(obj); 4000 4008 4009 + uint32_t cache_slot = (((uintptr_t)search_intern >> 3) ^ obj_off) & (INTERN_PROP_CACHE_SIZE - 1); 4010 + intern_prop_cache_entry_t *ce = &intern_prop_cache[cache_slot]; 4011 + if (ce->obj_off == obj_off && ce->intern_ptr == search_intern) { 4012 + return ce->prop_off; 4013 + } 4014 + 4001 4015 jsoff_t off = loadoff(js, obj_off) & ~(3U | CONSTMASK | ARRMASK); 4002 4016 while (off < js->brk && off != 0) { 4003 4017 jsoff_t koff = loadoff(js, (jsoff_t) (off + sizeof(off))); ··· 4005 4019 if (klen == len) { 4006 4020 const char *stored_intern = get_koff_intern(koff); 4007 4021 if (stored_intern) { 4008 - if (stored_intern == search_intern) return off; 4022 + if (stored_intern == search_intern) { 4023 + ce->obj_off = obj_off; 4024 + ce->intern_ptr = search_intern; 4025 + ce->prop_off = off; 4026 + return off; 4027 + } 4009 4028 } else { 4010 4029 const char *p = (char *) &js->mem[koff + sizeof(koff)]; 4011 4030 const char *new_intern = intern_string(p, klen); 4012 4031 if (new_intern) set_koff_intern(koff, new_intern); 4013 - if (new_intern == search_intern) return off; 4032 + if (new_intern == search_intern) { 4033 + ce->obj_off = obj_off; 4034 + ce->intern_ptr = search_intern; 4035 + ce->prop_off = off; 4036 + return off; 4037 + } 4014 4038 } 4015 4039 } 4016 4040 off = loadoff(js, off) & ~(3U | CONSTMASK | ARRMASK);