From 9f1ce566016a1d46c7a9c5236e645f1945c56033 Mon Sep 17 00:00:00 2001 From: "yang.zhao2" Date: Fri, 29 Nov 2024 18:31:57 +0800 Subject: [PATCH] fix: remove force_inline and watchpoint free function call --- quickjs.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/quickjs.c b/quickjs.c index d787b8ca..ae8e16ad 100644 --- a/quickjs.c +++ b/quickjs.c @@ -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; @@ -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; @@ -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) @@ -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)) { @@ -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; @@ -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; @@ -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; @@ -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); @@ -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)