Don't use property list pointer to store Proxy flags (#4415)

Proxy flags (IsCallable, IsConstructor) can't be stored on the
property list compressed pointer. As adding a Proxy to a WeakSet
would add a property to the Proxy object causing failures down the line.

The prototype internal "slot" can be used to store there flags as
it is not used in case of Proxies (as per standard).

JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
This commit is contained in:
Péter Gál authored and GitHub committed 2021-01-07 11:53:59 +01:00
1 parent 128f18a225
commit 61d172aaaf
6 files changed
+120 -31

No files matched your search

@@ -106,7 +106,7 @@ ecma_op_object_is_callable (ecma_object_t *obj_p) /**< ecma object */
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_OBJECT_TYPE_IS_PROXY (type))
{
return ECMA_GET_FIRST_BIT_FROM_POINTER_TAG (obj_p->u1.property_list_cp) != 0;
return ECMA_GET_FIRST_BIT_FROM_POINTER_TAG (obj_p->u2.prototype_cp) != 0;
}
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
@@ -215,7 +215,7 @@ ecma_object_check_constructor (ecma_object_t *obj_p) /**< ecma object */
#if ENABLED (JERRY_BUILTIN_PROXY)
if (ECMA_OBJECT_TYPE_IS_PROXY (type))
{
if (ECMA_GET_SECOND_BIT_FROM_POINTER_TAG (obj_p->u1.property_list_cp) == 0)
if (ECMA_GET_SECOND_BIT_FROM_POINTER_TAG (obj_p->u2.prototype_cp) == 0)
{
return ECMA_ERR_MSG ("Proxy target is not a constructor.");
}
@@ -60,9 +60,8 @@ ecma_proxy_create (ecma_value_t target, /**< proxy target */
/* ES2015: 5 - 6. */
/* ES11+: 3 - 4. */
ecma_object_t *obj_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE),
sizeof (ecma_proxy_object_t),
ECMA_OBJECT_TYPE_PROXY);
/* A Proxy does not have [[Prototype]] value as per standard */
ecma_object_t *obj_p = ecma_create_object (NULL, sizeof (ecma_proxy_object_t), ECMA_OBJECT_TYPE_PROXY);
ecma_proxy_object_t *proxy_obj_p = (ecma_proxy_object_t *) obj_p;
@@ -70,13 +69,13 @@ ecma_proxy_create (ecma_value_t target, /**< proxy target */
/* ES11+: 5. */
if (ecma_op_is_callable (target))
{
ECMA_SET_FIRST_BIT_TO_POINTER_TAG (obj_p->u1.property_list_cp);
ECMA_SET_FIRST_BIT_TO_POINTER_TAG (obj_p->u2.prototype_cp);
/* ES2015: 7.b. */
/* ES11+: 5.b. */
if (ecma_is_constructor (target))
{
ECMA_SET_SECOND_BIT_TO_POINTER_TAG (obj_p->u1.property_list_cp);
ECMA_SET_SECOND_BIT_TO_POINTER_TAG (obj_p->u2.prototype_cp);
}
}