Support function object retrieval for async functions (#4668)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2021-05-11 12:22:37 +02:00
committed by GitHub
parent a58884c169
commit e042998f02
8 changed files with 141 additions and 62 deletions
+2 -1
View File
@@ -621,7 +621,7 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context
}
JERRY_ASSERT (frame_ctx_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_NON_ARROW_FUNC);
proto_p = ecma_op_get_prototype_from_constructor (VM_FRAME_CTX_GET_FUNCTION_OBJECT (frame_ctx_p),
proto_p = ecma_op_get_prototype_from_constructor (frame_ctx_p->shared_p->function_object_p,
default_proto_id);
}
@@ -645,6 +645,7 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context
/* Copy shared data and frame context. */
vm_frame_ctx_shared_t *new_shared_p = &(executable_object_p->shared);
*new_shared_p = *(frame_ctx_p->shared_p);
new_shared_p->status_flags &= (uint32_t) ~VM_FRAME_CTX_SHARED_HAS_ARG_LIST;
vm_frame_ctx_t *new_frame_ctx_p = &(executable_object_p->frame_ctx);
*new_frame_ctx_p = *frame_ctx_p;
+1 -4
View File
@@ -57,6 +57,7 @@ typedef enum
typedef struct
{
const ecma_compiled_code_t *bytecode_header_p; /**< currently executed byte-code data */
ecma_object_t *function_object_p; /**< function obj */
uint32_t status_flags; /**< combination of vm_frame_ctx_shared_flags_t bits */
} vm_frame_ctx_shared_t;
@@ -66,16 +67,12 @@ typedef struct
typedef struct
{
vm_frame_ctx_shared_t header; /**< shared data header */
ecma_object_t *function_object_p; /**< function obj */
const ecma_value_t *arg_list_p; /**< arguments list */
uint32_t arg_list_len; /**< arguments list length */
} vm_frame_ctx_shared_args_t;
#if JERRY_ESNEXT
#define VM_FRAME_CTX_GET_FUNCTION_OBJECT(frame_ctx_p) \
(((vm_frame_ctx_shared_args_t *) (frame_ctx_p)->shared_p)->function_object_p)
/**
* Shared data extended with computed class fields
*/
+5 -2
View File
@@ -290,6 +290,7 @@ vm_run_global (const ecma_compiled_code_t *bytecode_p) /**< pointer to bytecode
vm_frame_ctx_shared_t shared;
shared.bytecode_header_p = bytecode_p;
shared.function_object_p = NULL;
shared.status_flags = 0;
#if JERRY_BUILTIN_REALMS
@@ -386,6 +387,7 @@ vm_run_eval (ecma_compiled_code_t *bytecode_data_p, /**< byte-code data */
vm_frame_ctx_shared_t shared;
shared.bytecode_header_p = bytecode_data_p;
shared.function_object_p = NULL;
shared.status_flags = (parse_opts & ECMA_PARSE_DIRECT_EVAL) ? VM_FRAME_CTX_SHARED_DIRECT_EVAL : 0;
ecma_value_t completion_value = vm_run (&shared, this_binding, lex_env_p);
@@ -427,6 +429,7 @@ vm_run_module (ecma_module_t *module_p) /**< module to be executed */
vm_frame_ctx_shared_t shared;
shared.bytecode_header_p = module_p->u.compiled_code_p;
shared.function_object_p = &module_p->header.object;
shared.status_flags = 0;
return vm_run (&shared, ECMA_VALUE_UNDEFINED, module_p->scope_p);
@@ -540,7 +543,7 @@ vm_get_class_function (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
if (frame_ctx_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_NON_ARROW_FUNC)
{
return VM_FRAME_CTX_GET_FUNCTION_OBJECT (frame_ctx_p);
return frame_ctx_p->shared_p->function_object_p;
}
ecma_environment_record_t *environment_record_p = ecma_op_get_environment_record (frame_ctx_p->lex_env_p);
@@ -2117,7 +2120,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
case VM_OC_RUN_FIELD_INIT:
{
JERRY_ASSERT (frame_ctx_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_NON_ARROW_FUNC);
result = opfunc_init_class_fields (ecma_make_object_value (VM_FRAME_CTX_GET_FUNCTION_OBJECT (frame_ctx_p)),
result = opfunc_init_class_fields (ecma_make_object_value (frame_ctx_p->shared_p->function_object_p),
frame_ctx_p->this_binding);
if (ECMA_IS_VALUE_ERROR (result))