Fix the types of builtin prototype objects (#3663)

In ES2015 many builtin prototypes are no longer valid instances of their
respective classes. This change updates affected prototypes to be
regular objects as required.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2020-04-06 12:00:58 +02:00
committed by GitHub
parent 73a78bd223
commit 48fa2ec01b
41 changed files with 372 additions and 272 deletions
+1 -12
View File
@@ -1106,23 +1106,12 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
ecma_dealloc_number (num_p);
break;
}
#if ENABLED (JERRY_ES2015)
case LIT_INTERNAL_MAGIC_STRING_REGEXP_PROTO:
{
jmem_heap_free_block (ECMA_GET_INTERNAL_VALUE_POINTER (void, ext_object_p->u.class_prop.u.value),
ECMA_REGEXP_PROTO_COMPILED_CODE_SIZE);
break;
}
#endif /* ENABLED (JERRY_ES2015) */
case LIT_MAGIC_STRING_REGEXP_UL:
{
ecma_compiled_code_t *bytecode_p = ECMA_GET_INTERNAL_VALUE_ANY_POINTER (ecma_compiled_code_t,
ext_object_p->u.class_prop.u.value);
if (bytecode_p != NULL)
{
ecma_bytecode_deref (bytecode_p);
}
ecma_bytecode_deref (bytecode_p);
break;
}
-7
View File
@@ -940,13 +940,6 @@ typedef struct
* If regexp, the other flags must be RE_FLAG... */
} ecma_compiled_code_t;
/**
* The proper memory size for the RegExp.prototype. We have to align the header's size manually, because
* in the struct, it is aligned to 8 bytes during the compilation.
*/
#define ECMA_REGEXP_PROTO_COMPILED_CODE_SIZE \
(JERRY_ALIGNUP (sizeof (ecma_compiled_code_t), JMEM_ALIGNMENT) + sizeof (ecma_value_t))
/**
* Description of bound function objects.
*/
-22
View File
@@ -1494,28 +1494,6 @@ ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *b
} /* ecma_compiled_code_get_tagged_template_collection */
#endif /* ENABLED (JERRY_ES2015) */
/**
* Helper function to check if the given value is a class
*
* @return pointer to the extended object - if 'this' is a class
* NULL- otherwise
*/
ecma_extended_object_t *
ecma_op_check_object_type_is_class (ecma_value_t this) /**< this value */
{
if (ecma_is_value_object (this))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this);
if (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_CLASS)
{
return (ecma_extended_object_t *) obj_p;
}
}
return NULL;
} /* ecma_op_check_object_type_is_class */
#if ENABLED (JERRY_LINE_INFO) || ENABLED (JERRY_ES2015_MODULE_SYSTEM) || ENABLED (JERRY_ES2015)
/**
* Get the number of formal parameters of the compiled code