Skip to content

Commit

Permalink
fix: remove force_inline and watchpoint free function call
Browse files Browse the repository at this point in the history
  • Loading branch information
yang.zhao2 committed Nov 29, 2024
1 parent db482ee commit 9f1ce56
Showing 1 changed file with 9 additions and 34 deletions.
43 changes: 9 additions & 34 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,17 +633,14 @@ static JSInlineCache *init_ic(JSContext *ctx);
static int rebuild_ic(JSContext *ctx, JSInlineCache *ic);
static int resize_ic_hash(JSContext *ctx, JSInlineCache *ic);
static int free_ic(JSRuntime *rt, JSInlineCache *ic);
static int ic_delete_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape, JSAtom atom);
static int ic_free_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape);

static int ic_delete_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape, JSAtom atom, bool force);
static int ic_watchpoint_delete_handler(JSRuntime* rt, JSInlineCacheRingSlot *ref, uint8_t offset, JSAtom atom, JSInlineCacheRingSlot *target);

static int js_shape_delete_watchpoints(JSRuntime *rt, JSShape *shape, JSInlineCacheRingSlot *target);
static JSInlineCacheWatchpoint *js_shape_create_watchpoint(JSRuntime *rt, JSShape *shape, JSInlineCacheRingSlot *ptr, uint8_t offset, JSAtom atom);
static void add_ic_slot(JSContext *ctx, JSInlineCacheUpdate *icu,
JSAtom atom, JSObject *object, uint32_t prop_offset, JSObject* prototype);

static force_inline uint32_t get_ic_prop_offset(const JSInlineCacheUpdate *icu,
static uint32_t get_ic_prop_offset(const JSInlineCacheUpdate *icu,
JSShape *shape, JSObject **prototype)
{
uint32_t i, cache_offset = icu->offset;
Expand Down Expand Up @@ -7159,7 +7156,7 @@ static int JS_SetPrototypeInternal(JSContext *ctx, JSValue obj,
if (js_shape_prepare_update(ctx, p, NULL))
return -1;
sh = p->shape;
ic_free_shape_proto_watchpoints(ctx->rt, sh);
ic_delete_shape_proto_watchpoints(ctx->rt, sh, JS_ATOM_NULL, TRUE);
if (sh->proto)
JS_FreeValue(ctx, JS_MKPTR(JS_TAG_OBJECT, sh->proto));
sh->proto = proto;
Expand Down Expand Up @@ -7532,7 +7529,7 @@ JSValue JS_GetProperty(JSContext *ctx, JSValue this_obj, JSAtom prop)
return JS_GetPropertyInternal2(ctx, this_obj, prop, this_obj, NULL, FALSE);
}

static force_inline JSValue JS_GetPropertyInternalWithIC(JSContext *ctx, JSValue obj,
static inline JSValue JS_GetPropertyInternalWithIC(JSContext *ctx, JSValue obj,
JSAtom prop, JSValue this_obj,
JSInlineCacheUpdate *icu,
BOOL throw_ref_error)
Expand Down Expand Up @@ -8482,7 +8479,7 @@ static int delete_property(JSContext *ctx, JSObject *p, JSAtom atom)
pr->flags = 0;
pr->atom = JS_ATOM_NULL;
pr1->u.value = JS_UNDEFINED;
ic_delete_shape_proto_watchpoints(ctx->rt, sh, atom);
ic_delete_shape_proto_watchpoints(ctx->rt, sh, atom, FALSE);
/* compact the properties if too many deleted properties */
if (sh->deleted_prop_count >= 8 &&
sh->deleted_prop_count >= ((unsigned)sh->prop_count / 2)) {
Expand Down Expand Up @@ -8903,7 +8900,7 @@ static int JS_SetPropertyInternal2(JSContext *ctx, JSValue obj, JSAtom prop,
}
goto generic_create_prop;
} else {
ic_delete_shape_proto_watchpoints(ctx->rt, p->shape, prop);
ic_delete_shape_proto_watchpoints(ctx->rt, p->shape, prop, FALSE);
pr = add_property(ctx, p, prop, JS_PROP_C_W_E);
if (unlikely(!pr))
goto fail;
Expand Down Expand Up @@ -8969,7 +8966,7 @@ int JS_SetProperty(JSContext *ctx, JSValue this_obj, JSAtom prop, JSValue val)
}

// XXX(bnoordhuis) only used by OP_put_field_ic, maybe inline at call site
static force_inline int JS_SetPropertyInternalWithIC(JSContext *ctx, JSValue this_obj,
static inline int JS_SetPropertyInternalWithIC(JSContext *ctx, JSValue this_obj,
JSAtom prop, JSValue val, int flags,
JSInlineCacheUpdate *icu) {
uint32_t tag, offset;
Expand Down Expand Up @@ -55992,7 +55989,7 @@ int ic_watchpoint_delete_handler(JSRuntime* rt, JSInlineCacheRingSlot *ref, uint
return 0;
}

int ic_delete_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape, JSAtom atom) {
int ic_delete_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape, JSAtom atom, bool force) {
struct list_head *el, *el1;
JSObject *p;
JSInlineCacheRingSlot *cr;
Expand All @@ -56002,7 +55999,7 @@ int ic_delete_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape, JSAtom atom
if (p->shape->watchpoint)
list_for_each_safe(el, el1, p->shape->watchpoint) {
JSInlineCacheWatchpoint *o = list_entry(el, JSInlineCacheWatchpoint, link);
if (o->atom == atom) {
if (force || o->atom == atom) {
cr = (JSInlineCacheRingSlot *)o->ref;
sh = cr->shape[o->offset];
ic_watchpoint_delete_handler(rt, cr, o->offset, o->atom, NULL);
Expand All @@ -56016,28 +56013,6 @@ int ic_delete_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape, JSAtom atom
return 0;
}

int ic_free_shape_proto_watchpoints(JSRuntime *rt, JSShape *shape) {
struct list_head *el, *el1;
JSObject *p;
JSInlineCacheRingSlot *cr;
JSShape *sh;
p = shape->proto;
while(likely(p)) {
if (p->shape->watchpoint)
list_for_each_safe(el, el1, p->shape->watchpoint) {
JSInlineCacheWatchpoint *o = list_entry(el, JSInlineCacheWatchpoint, link);
cr = (JSInlineCacheRingSlot *)o->ref;
sh = cr->shape[o->offset];
ic_watchpoint_delete_handler(rt, cr, o->offset, o->atom, NULL);
js_free_shape_null(rt, shape);
list_del(el);
js_free_rt(rt, o);
}
p = p->shape->proto;
}
return 0;
}

/* CallSite */

static void js_callsite_finalizer(JSRuntime *rt, JSValue val)
Expand Down

0 comments on commit 9f1ce56

Please sign in to comment.