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:
@@ -5266,11 +5266,9 @@ jerry_backtrace_get_function (jerry_backtrace_frame_t *frame_p) /**< frame point
|
||||
{
|
||||
vm_frame_ctx_t *context_p = frame_p->context_p;
|
||||
|
||||
if (context_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_HAS_ARG_LIST)
|
||||
if (context_p->shared_p->function_object_p != NULL)
|
||||
{
|
||||
vm_frame_ctx_shared_args_t *shared_args_p = (vm_frame_ctx_shared_args_t *) context_p->shared_p;
|
||||
|
||||
frame_p->function = ecma_make_object_value (shared_args_p->function_object_p);
|
||||
frame_p->function = ecma_make_object_value (context_p->shared_p->function_object_p);
|
||||
return &frame_p->function;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -640,6 +640,7 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
}
|
||||
|
||||
ecma_gc_set_object_visited (executable_object_p->frame_ctx.lex_env_p);
|
||||
ecma_gc_set_object_visited (executable_object_p->shared.function_object_p);
|
||||
|
||||
if (!ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p))
|
||||
{
|
||||
|
||||
@@ -46,7 +46,7 @@ ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shar
|
||||
ecma_object_t *lex_env_p) /**< lexical environment the Arguments
|
||||
* object is created for */
|
||||
{
|
||||
ecma_object_t *func_obj_p = shared_p->function_object_p;
|
||||
ecma_object_t *func_obj_p = shared_p->header.function_object_p;
|
||||
const ecma_compiled_code_t *bytecode_data_p = shared_p->header.bytecode_header_p;
|
||||
uint16_t formal_params_number;
|
||||
|
||||
|
||||
@@ -1040,7 +1040,7 @@ ecma_op_function_call_simple (ecma_object_t *func_obj_p, /**< Function object */
|
||||
|
||||
vm_frame_ctx_shared_args_t shared_args;
|
||||
shared_args.header.status_flags = VM_FRAME_CTX_SHARED_HAS_ARG_LIST;
|
||||
shared_args.function_object_p = func_obj_p;
|
||||
shared_args.header.function_object_p = func_obj_p;
|
||||
shared_args.arg_list_p = arguments_list_p;
|
||||
shared_args.arg_list_len = arguments_list_len;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user