Support super property reference in object methods/accessors (#3940)

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-07-03 12:16:23 +02:00
committed by GitHub
parent 80716cca90
commit f98d7f24a7
18 changed files with 344 additions and 48 deletions
+3 -1
View File
@@ -1050,10 +1050,12 @@ opfunc_create_implicit_class_constructor (uint8_t opcode) /**< current cbc opcod
/**
* Set the [[HomeObject]] attribute of the given functon object
*/
static inline void JERRY_ATTR_ALWAYS_INLINE
inline void JERRY_ATTR_ALWAYS_INLINE
opfunc_set_home_object (ecma_object_t *func_p, /**< function object */
ecma_object_t *parent_env_p) /**< parent environment */
{
JERRY_ASSERT (ecma_is_lexical_environment (parent_env_p));
if (ecma_get_object_type (func_p) == ECMA_OBJECT_TYPE_FUNCTION)
{
JERRY_ASSERT (!ecma_get_object_is_builtin (func_p));
+3
View File
@@ -147,6 +147,9 @@ opfunc_async_create_and_await (vm_frame_ctx_t *frame_ctx_p, ecma_value_t value,
ecma_value_t
opfunc_create_implicit_class_constructor (uint8_t opcode);
void
opfunc_set_home_object (ecma_object_t *func_p, ecma_object_t *parent_env_p);
void
opfunc_push_class_environment (vm_frame_ctx_t *frame_ctx_p, ecma_value_t **vm_stack_top, ecma_value_t class_name);
+28
View File
@@ -1970,6 +1970,34 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
*stack_top_p++ = result;
continue;
}
case VM_OC_OBJECT_LITERAL_HOME_ENV:
{
if (opcode == CBC_EXT_PUSH_OBJECT_SUPER_ENVIRONMENT)
{
ecma_value_t obj_value = stack_top_p[-1];
ecma_object_t *obj_env_p = ecma_create_object_lex_env (frame_ctx_p->lex_env_p,
ecma_get_object_from_value (obj_value),
ECMA_LEXICAL_ENVIRONMENT_HOME_OBJECT_BOUND);
stack_top_p[-1] = ecma_make_object_value (obj_env_p);
*stack_top_p++ = obj_value;
}
else
{
JERRY_ASSERT (opcode == CBC_EXT_POP_OBJECT_SUPER_ENVIRONMENT);
ecma_deref_object (ecma_get_object_from_value (stack_top_p[-2]));
stack_top_p[-2] = stack_top_p[-1];
stack_top_p--;
}
continue;
}
case VM_OC_SET_HOME_OBJECT:
{
int offset = opcode == CBC_EXT_OBJECT_LITERAL_SET_HOME_OBJECT_COMPUTED ? -1 : 0;
opfunc_set_home_object (ecma_get_object_from_value (stack_top_p[-1]),
ecma_get_object_from_value (stack_top_p[-3 + offset]));
continue;
}
case VM_OC_SUPER_REFERENCE:
{
result = opfunc_form_super_reference (&stack_top_p, frame_ctx_p, left_value, opcode);
+4
View File
@@ -259,6 +259,8 @@ typedef enum
VM_OC_PUSH_SUPER_CONSTRUCTOR, /**< getSuperConstructor operation */
VM_OC_RESOLVE_LEXICAL_THIS, /**< resolve this_binding from from the lexical environment */
VM_OC_SUPER_REFERENCE, /**< push super reference */
VM_OC_SET_HOME_OBJECT, /**< set the [[HomeObject]] environment in an object literal */
VM_OC_OBJECT_LITERAL_HOME_ENV, /**< create/destroy [[HomeObject]] environment of an object literal */
VM_OC_SET_FUNCTION_NAME, /**< set function name property */
VM_OC_PUSH_SPREAD_ELEMENT, /**< push spread element */
@@ -331,6 +333,8 @@ typedef enum
VM_OC_PUSH_SUPER_CONSTRUCTOR = VM_OC_NONE, /**< getSuperConstructor operation */
VM_OC_RESOLVE_LEXICAL_THIS = VM_OC_NONE, /**< resolve this_binding from from the lexical environment */
VM_OC_SUPER_REFERENCE = VM_OC_NONE, /**< push super reference */
VM_OC_SET_HOME_OBJECT = VM_OC_NONE, /**< set the [[HomeObject]] internal property in an object literal */
VM_OC_OBJECT_LITERAL_HOME_ENV = VM_OC_NONE, /**< create/destroy [[HomeObject]] environment of an object literal */
VM_OC_SET_FUNCTION_NAME = VM_OC_NONE, /**< set function name property */
VM_OC_PUSH_SPREAD_ELEMENT = VM_OC_NONE, /**< push spread element */