From 386ec44d4dcf35bba85111b4d8bae7e45cc101a3 Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Wed, 15 Sep 2021 11:08:57 +0200 Subject: [PATCH] Double the maximum number of object references (#4768) JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/ecma/base/ecma-globals.h | 30 ++++++++++++----------------- jerry-core/ecma/base/ecma-helpers.c | 5 ++++- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index 2e040342f..aea5422ab 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -815,13 +815,12 @@ typedef enum */ typedef enum { - /* Types between 0 - 12 are ecma_object_type_t which can have a built-in flag. */ - - ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE = 29, /**< declarative lexical environment */ + /* Types between 0 - 12 are ecma_object_type_t. */ + ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE = 13, /**< declarative lexical environment */ #if JERRY_ESNEXT - ECMA_LEXICAL_ENVIRONMENT_CLASS = 30, /**< lexical environment with class */ + ECMA_LEXICAL_ENVIRONMENT_CLASS = 14, /**< lexical environment with class */ #endif /* JERRY_ESNEXT */ - ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND = 31, /**< object-bound lexical environment */ + ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND = 15, /**< object-bound lexical environment */ ECMA_LEXICAL_ENVIRONMENT_TYPE_START = ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< first lexical * environment type */ @@ -875,12 +874,12 @@ typedef enum /** * Ecma object type mask for getting the object type. */ -#define ECMA_OBJECT_TYPE_MASK 0x01fu +#define ECMA_OBJECT_TYPE_MASK 0x00fu /** * Extensible object. */ -#define ECMA_OBJECT_FLAG_EXTENSIBLE 0x20 +#define ECMA_OBJECT_FLAG_EXTENSIBLE 0x10 /** * Declarative lexical environments created for non-closure code blocks @@ -895,7 +894,7 @@ typedef enum /** * Bitshift index for an ecma-object reference count field */ -#define ECMA_OBJECT_REF_SHIFT 6 +#define ECMA_OBJECT_REF_SHIFT 5 /** * Value for increasing or decreasing the object reference counter. @@ -904,11 +903,6 @@ typedef enum #if JERRY_CPOINTER_32_BIT -/** - * Bitmask for an ecma-object reference count field - */ -#define ECMA_OBJECT_REF_MASK (((1u << 26) - 1) << ECMA_OBJECT_REF_SHIFT) - /** * Type of the descriptor field of an object */ @@ -916,11 +910,6 @@ typedef uint32_t ecma_object_descriptor_t; #else /* !JERRY_CPOINTER_32_BIT */ -/** - * Bitmask for an ecma-object reference count field - */ -#define ECMA_OBJECT_REF_MASK (((1u << 10) - 1) << ECMA_OBJECT_REF_SHIFT) - /** * Type of the descriptor field of an object */ @@ -928,6 +917,11 @@ typedef uint16_t ecma_object_descriptor_t; #endif /* JERRY_CPOINTER_32_BIT */ +/** + * Bitmask for an ecma-object reference count field + */ +#define ECMA_OBJECT_REF_MASK ((ecma_object_descriptor_t) (~0u << ECMA_OBJECT_REF_SHIFT)) + /** * Represents non-visited white object */ diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c index 578e970be..e6469d20b 100644 --- a/jerry-core/ecma/base/ecma-helpers.c +++ b/jerry-core/ecma/base/ecma-helpers.c @@ -52,7 +52,10 @@ JERRY_STATIC_ASSERT (ECMA_OBJECT_REF_ONE == (ECMA_OBJECT_FLAG_EXTENSIBLE << 1), ecma_object_ref_one_must_follow_the_extensible_flag); JERRY_STATIC_ASSERT ((ECMA_OBJECT_MAX_REF + ECMA_OBJECT_REF_ONE) == ECMA_OBJECT_REF_MASK, - ecma_object_max_ref_does_not_fill_the_remaining_bits); + ecma_object_max_ref_does_not_fill_the_remaining_bits); + +JERRY_STATIC_ASSERT ((ECMA_OBJECT_REF_MASK & (ECMA_OBJECT_TYPE_MASK | ECMA_OBJECT_FLAG_EXTENSIBLE)) == 0, + ecma_object_ref_mask_overlaps_with_object_type_or_extensible); JERRY_STATIC_ASSERT (ECMA_PROPERTY_FLAGS_MASK == ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ecma_property_flags_mask_must_use_the_configurable_enumerable_writable_flags);