Remove block result (#4799)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
@@ -765,9 +765,9 @@ ecma_gc_mark_executable_object (ecma_object_t *object_p) /**< object */
|
||||
register_p++;
|
||||
}
|
||||
|
||||
if (ecma_is_value_object (executable_object_p->frame_ctx.block_result))
|
||||
if (ecma_is_value_object (executable_object_p->iterator))
|
||||
{
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (executable_object_p->frame_ctx.block_result));
|
||||
ecma_gc_set_object_visited (ecma_get_object_from_value (executable_object_p->iterator));
|
||||
}
|
||||
} /* ecma_gc_mark_executable_object */
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
{
|
||||
if (generator_object_p->extended_object.u.cls.u2.executable_obj_flags & ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD)
|
||||
{
|
||||
ecma_value_t iterator = generator_object_p->frame_ctx.block_result;
|
||||
ecma_value_t iterator = generator_object_p->iterator;
|
||||
ecma_value_t next_method = generator_object_p->frame_ctx.stack_top_p[-1];
|
||||
|
||||
bool done = false;
|
||||
@@ -120,7 +120,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
}
|
||||
|
||||
ECMA_EXECUTABLE_OBJECT_RESUME_EXEC (generator_object_p);
|
||||
generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
generator_object_p->iterator = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
JERRY_ASSERT (generator_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
|
||||
|| ecma_is_value_object (generator_object_p->frame_ctx.stack_top_p[-1]));
|
||||
@@ -175,7 +175,7 @@ ecma_builtin_generator_prototype_object_do (vm_executable_object_t *generator_ob
|
||||
|
||||
ecma_deref_object (ecma_get_object_from_value (iterator));
|
||||
generator_object_p->extended_object.u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
|
||||
generator_object_p->frame_ctx.block_result = iterator;
|
||||
generator_object_p->iterator = iterator;
|
||||
|
||||
if (generator_object_p->frame_ctx.stack_top_p[0] != ECMA_VALUE_UNDEFINED)
|
||||
{
|
||||
|
||||
@@ -107,7 +107,7 @@ ecma_async_yield_call (ecma_value_t function, /**< function (takes reference) */
|
||||
}
|
||||
|
||||
ecma_object_t *return_obj_p = ecma_get_object_from_value (function);
|
||||
ecma_value_t iterator = async_generator_object_p->frame_ctx.block_result;
|
||||
ecma_value_t iterator = async_generator_object_p->iterator;
|
||||
ecma_value_t result;
|
||||
|
||||
if (argument == ECMA_VALUE_EMPTY)
|
||||
@@ -136,7 +136,7 @@ static ecma_value_t
|
||||
ecma_async_yield_throw (vm_executable_object_t *async_generator_object_p, /**< async generator */
|
||||
ecma_value_t value) /**< thrown value */
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (async_generator_object_p->frame_ctx.block_result);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (async_generator_object_p->iterator);
|
||||
ecma_value_t result = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_THROW);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
@@ -204,7 +204,7 @@ ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**<
|
||||
{
|
||||
case ECMA_ASYNC_GENERATOR_DO_NEXT:
|
||||
{
|
||||
result = ecma_op_iterator_next (async_generator_object_p->frame_ctx.block_result,
|
||||
result = ecma_op_iterator_next (async_generator_object_p->iterator,
|
||||
async_generator_object_p->frame_ctx.stack_top_p[-1],
|
||||
task_p->operation_value);
|
||||
|
||||
@@ -256,7 +256,7 @@ ecma_async_generator_run (vm_executable_object_t *async_generator_object_p) /**<
|
||||
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (result));
|
||||
|
||||
async_generator_object_p->extended_object.u.cls.u2.executable_obj_flags &= ECMA_AWAIT_CLEAR_MASK;
|
||||
async_generator_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
async_generator_object_p->iterator = ECMA_VALUE_UNDEFINED;
|
||||
async_generator_object_p->frame_ctx.byte_code_p = opfunc_resume_executable_object_with_throw;
|
||||
|
||||
JERRY_ASSERT (async_generator_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
|
||||
@@ -401,7 +401,7 @@ ecma_await_continue (vm_executable_object_t *executable_object_p, /**< executabl
|
||||
}
|
||||
case ECMA_AWAIT_YIELD_RETURN:
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (executable_object_p->frame_ctx.block_result);
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (executable_object_p->iterator);
|
||||
ecma_value_t result = ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_RETURN);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (result))
|
||||
|
||||
@@ -307,8 +307,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
|
||||
{
|
||||
if (ECMA_AWAIT_GET_STATE (executable_object_p) <= ECMA_AWAIT_YIELD_END)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (executable_object_p->frame_ctx.block_result));
|
||||
executable_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
JERRY_ASSERT (ecma_is_value_object (executable_object_p->iterator));
|
||||
executable_object_p->iterator = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
JERRY_ASSERT (executable_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
|
||||
|| ecma_is_value_object (executable_object_p->frame_ctx.stack_top_p[-1]));
|
||||
@@ -349,8 +349,8 @@ ecma_process_promise_async_reaction_job (ecma_job_promise_async_reaction_t *job_
|
||||
|
||||
if (ECMA_AWAIT_GET_STATE (executable_object_p) <= ECMA_AWAIT_YIELD_END)
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_object (executable_object_p->frame_ctx.block_result));
|
||||
executable_object_p->frame_ctx.block_result = ECMA_VALUE_UNDEFINED;
|
||||
JERRY_ASSERT (ecma_is_value_object (executable_object_p->iterator));
|
||||
executable_object_p->iterator = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
JERRY_ASSERT (executable_object_p->frame_ctx.stack_top_p[-1] == ECMA_VALUE_UNDEFINED
|
||||
|| ecma_is_value_object (executable_object_p->frame_ctx.stack_top_p[-1]));
|
||||
|
||||
@@ -30,7 +30,7 @@ extern "C"
|
||||
/**
|
||||
* Jerry snapshot format version.
|
||||
*/
|
||||
#define JERRY_SNAPSHOT_VERSION (69u)
|
||||
#define JERRY_SNAPSHOT_VERSION (70u)
|
||||
|
||||
/**
|
||||
* Flags for jerry_generate_snapshot and jerry_generate_function_snapshot.
|
||||
|
||||
@@ -352,8 +352,8 @@
|
||||
VM_OC_SET_BYTECODE_PTR) \
|
||||
CBC_OPCODE (CBC_RETURN, CBC_NO_FLAG, -1, \
|
||||
VM_OC_RETURN | VM_OC_GET_STACK) \
|
||||
CBC_OPCODE (CBC_RETURN_WITH_BLOCK, CBC_NO_FLAG, 0, \
|
||||
VM_OC_RETURN) \
|
||||
CBC_OPCODE (CBC_RETURN_FUNCTION_END, CBC_NO_FLAG, 0, \
|
||||
VM_OC_RETURN_FUNCTION_END) \
|
||||
CBC_OPCODE (CBC_RETURN_WITH_LITERAL, CBC_HAS_LITERAL_ARG, 0, \
|
||||
VM_OC_RETURN | VM_OC_GET_LITERAL) \
|
||||
CBC_OPCODE (CBC_SET_LITERAL_PROPERTY, CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2, 0, \
|
||||
|
||||
@@ -314,7 +314,9 @@ typedef struct
|
||||
(PARSER_IS_BASIC_OPCODE (op) ? cbc_flags[(op)] : cbc_ext_flags[PARSER_GET_EXT_OPCODE (op)])
|
||||
|
||||
#define PARSER_OPCODE_IS_RETURN(op) \
|
||||
((op) == CBC_RETURN || (op) == CBC_RETURN_WITH_BLOCK || (op) == CBC_RETURN_WITH_LITERAL)
|
||||
((op) == CBC_RETURN \
|
||||
|| (op) == CBC_RETURN_FUNCTION_END \
|
||||
|| (op) == CBC_RETURN_WITH_LITERAL)
|
||||
|
||||
#define PARSER_ARGS_EQ(op, types) \
|
||||
((PARSER_GET_FLAGS (op) & CBC_ARG_TYPES) == (types))
|
||||
|
||||
@@ -3169,7 +3169,7 @@ parser_parse_statements (parser_context_t *context_p) /**< context */
|
||||
}
|
||||
#endif /* JERRY_ESNEXT */
|
||||
|
||||
parser_emit_cbc (context_p, CBC_RETURN_WITH_BLOCK);
|
||||
parser_emit_cbc (context_p, CBC_RETURN_FUNCTION_END);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -1277,7 +1277,7 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
|
||||
if (!(context_p->status_flags & PARSER_NO_END_LABEL))
|
||||
{
|
||||
*dst_p++ = CBC_RETURN_WITH_BLOCK;
|
||||
*dst_p++ = CBC_RETURN_FUNCTION_END;
|
||||
|
||||
#if JERRY_ESNEXT
|
||||
if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
|
||||
@@ -2150,8 +2150,8 @@ parser_parse_source (void *source_p, /**< source code */
|
||||
parser_branch_t branch;
|
||||
parser_emit_cbc_forward_branch (&context, CBC_JUMP_FORWARD, &branch);
|
||||
|
||||
scanner_create_variables (&context, SCANNER_CREATE_VARS_NO_OPTS);
|
||||
parser_emit_cbc (&context, CBC_RETURN_WITH_BLOCK);
|
||||
scanner_create_variables (&context, SCANNER_CREATE_VARS_IS_MODULE);
|
||||
parser_emit_cbc (&context, CBC_RETURN_FUNCTION_END);
|
||||
|
||||
parser_set_branch_to_current_position (&context, &branch);
|
||||
}
|
||||
|
||||
@@ -2001,7 +2001,7 @@ scanner_is_context_needed (parser_context_t *context_p, /**< context */
|
||||
: info_p->type == SCANNER_TYPE_FUNCTION));
|
||||
|
||||
uint32_t scope_stack_reg_top = (check_type != PARSER_CHECK_GLOBAL_CONTEXT ? context_p->scope_stack_reg_top
|
||||
: 0);
|
||||
: 1); /* block result */
|
||||
#else /* !JERRY_ESNEXT */
|
||||
JERRY_ASSERT (check_type == PARSER_CHECK_BLOCK_CONTEXT);
|
||||
JERRY_ASSERT (info_p->type == SCANNER_TYPE_BLOCK);
|
||||
@@ -2333,6 +2333,8 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
JERRY_ASSERT (info_type == SCANNER_TYPE_FUNCTION
|
||||
|| !(option_flags & (SCANNER_CREATE_VARS_IS_FUNCTION_ARGS | SCANNER_CREATE_VARS_IS_FUNCTION_BODY)));
|
||||
|
||||
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
|
||||
|
||||
if (info_type == SCANNER_TYPE_FUNCTION && !(option_flags & SCANNER_CREATE_VARS_IS_FUNCTION_BODY))
|
||||
{
|
||||
JERRY_ASSERT (context_p->scope_stack_p == NULL);
|
||||
@@ -2349,6 +2351,11 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
|
||||
context_p->scope_stack_p = scope_stack_p;
|
||||
scope_stack_end_p = scope_stack_p + context_p->scope_stack_size;
|
||||
|
||||
if (option_flags & (SCANNER_CREATE_VARS_IS_SCRIPT | SCANNER_CREATE_VARS_IS_MODULE))
|
||||
{
|
||||
scope_stack_reg_top++; /* block result */
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2359,8 +2366,6 @@ scanner_create_variables (parser_context_t *context_p, /**< context */
|
||||
scope_stack_p += context_p->scope_stack_top;
|
||||
}
|
||||
|
||||
uint32_t scope_stack_reg_top = context_p->scope_stack_reg_top;
|
||||
|
||||
literal.char_p = info_p->source_p - 1;
|
||||
|
||||
while (next_data_p[0] != SCANNER_STREAM_TYPE_END)
|
||||
|
||||
@@ -284,8 +284,9 @@ typedef enum
|
||||
{
|
||||
SCANNER_CREATE_VARS_NO_OPTS = 0, /**< no options */
|
||||
SCANNER_CREATE_VARS_IS_SCRIPT = (1 << 0), /**< create variables for script or direct eval */
|
||||
SCANNER_CREATE_VARS_IS_FUNCTION_ARGS = (1 << 1), /**< create variables for function arguments */
|
||||
SCANNER_CREATE_VARS_IS_FUNCTION_BODY = (1 << 2), /**< create variables for function body */
|
||||
SCANNER_CREATE_VARS_IS_MODULE = (1 << 1), /**< create variables for module */
|
||||
SCANNER_CREATE_VARS_IS_FUNCTION_ARGS = (1 << 2), /**< create variables for function arguments */
|
||||
SCANNER_CREATE_VARS_IS_FUNCTION_BODY = (1 << 3), /**< create variables for function body */
|
||||
} scanner_create_variables_flags_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -639,6 +639,7 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context
|
||||
executable_object_p->extended_object.u.cls.type = class_type;
|
||||
executable_object_p->extended_object.u.cls.u2.executable_obj_flags = 0;
|
||||
ECMA_SET_INTERNAL_VALUE_ANY_POINTER (executable_object_p->extended_object.u.cls.u3.head, NULL);
|
||||
executable_object_p->iterator = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
JERRY_ASSERT (!(frame_ctx_p->status_flags & VM_FRAME_CTX_DIRECT_EVAL));
|
||||
|
||||
@@ -646,6 +647,7 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p, /**< 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;
|
||||
new_shared_p->status_flags |= VM_FRAME_CTX_SHARED_EXECUTABLE;
|
||||
|
||||
vm_frame_ctx_t *new_frame_ctx_p = &(executable_object_p->frame_ctx);
|
||||
*new_frame_ctx_p = *frame_ctx_p;
|
||||
@@ -690,7 +692,7 @@ opfunc_create_executable_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context
|
||||
ecma_deref_if_object (*new_registers_p++);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (new_frame_ctx_p->block_result == ECMA_VALUE_UNDEFINED);
|
||||
JERRY_ASSERT (*VM_GET_EXECUTABLE_ITERATOR (new_frame_ctx_p) == ECMA_VALUE_UNDEFINED);
|
||||
|
||||
new_frame_ctx_p->this_binding = ecma_copy_value_if_not_object (new_frame_ctx_p->this_binding);
|
||||
|
||||
@@ -767,7 +769,7 @@ opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, /*
|
||||
ecma_ref_if_object (*register_p++);
|
||||
}
|
||||
|
||||
ecma_ref_if_object (executable_object_p->frame_ctx.block_result);
|
||||
ecma_ref_if_object (executable_object_p->iterator);
|
||||
|
||||
JERRY_ASSERT (ECMA_EXECUTABLE_OBJECT_IS_SUSPENDED (executable_object_p));
|
||||
|
||||
@@ -828,7 +830,7 @@ opfunc_resume_executable_object (vm_executable_object_t *executable_object_p, /*
|
||||
ecma_deref_if_object (*register_p++);
|
||||
}
|
||||
|
||||
ecma_deref_if_object (executable_object_p->frame_ctx.block_result);
|
||||
ecma_deref_if_object (executable_object_p->iterator);
|
||||
|
||||
return result;
|
||||
} /* opfunc_resume_executable_object */
|
||||
@@ -876,7 +878,6 @@ opfunc_async_create_and_await (vm_frame_ctx_t *frame_ctx_p, /**< frame context *
|
||||
ecma_value_t value, /**< awaited value (takes reference) */
|
||||
uint16_t extra_flags) /**< extra flags */
|
||||
{
|
||||
JERRY_ASSERT (frame_ctx_p->block_result == ECMA_VALUE_UNDEFINED);
|
||||
JERRY_ASSERT (CBC_FUNCTION_GET_TYPE (frame_ctx_p->shared_p->bytecode_header_p->status_flags) == CBC_FUNCTION_ASYNC
|
||||
|| (CBC_FUNCTION_GET_TYPE (frame_ctx_p->shared_p->bytecode_header_p->status_flags)
|
||||
== CBC_FUNCTION_ASYNC_ARROW));
|
||||
@@ -902,7 +903,7 @@ opfunc_async_create_and_await (vm_frame_ctx_t *frame_ctx_p, /**< frame context *
|
||||
result = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, promise_p);
|
||||
|
||||
JERRY_ASSERT (ecma_is_value_object (result));
|
||||
executable_object_p->frame_ctx.block_result = result;
|
||||
executable_object_p->iterator = result;
|
||||
|
||||
return result;
|
||||
} /* opfunc_async_create_and_await */
|
||||
@@ -1523,8 +1524,8 @@ opfunc_assign_super_reference (ecma_value_t **vm_stack_top_p, /**< vm stack top
|
||||
}
|
||||
else if (opcode_data & VM_OC_PUT_BLOCK)
|
||||
{
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->block_result = result;
|
||||
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = result;
|
||||
}
|
||||
|
||||
*vm_stack_top_p = stack_top_p;
|
||||
|
||||
@@ -48,6 +48,8 @@ typedef enum
|
||||
VM_FRAME_CTX_SHARED_NON_ARROW_FUNC = (1 << 4), /**< non-arrow function */
|
||||
VM_FRAME_CTX_SHARED_HERITAGE_PRESENT = (1 << 5), /**< class heritage present */
|
||||
VM_FRAME_CTX_SHARED_HAS_CLASS_FIELDS = (1 << 6), /**< has class fields */
|
||||
VM_FRAME_CTX_SHARED_EXECUTABLE = (1 << 7), /**< frame is an executable object constructed
|
||||
* with opfunc_create_executable_object */
|
||||
#endif /* JERRY_ESNEXT */
|
||||
} vm_frame_ctx_shared_flags_t;
|
||||
|
||||
@@ -112,7 +114,6 @@ typedef struct vm_frame_ctx_t
|
||||
ecma_object_t *lex_env_p; /**< current lexical environment */
|
||||
struct vm_frame_ctx_t *prev_context_p; /**< previous context */
|
||||
ecma_value_t this_binding; /**< this binding */
|
||||
ecma_value_t block_result; /**< block result */
|
||||
uint16_t context_depth; /**< current context depth */
|
||||
uint8_t status_flags; /**< combination of vm_frame_ctx_flags_t bits */
|
||||
uint8_t call_operation; /**< perform a call or construct operation */
|
||||
@@ -130,11 +131,19 @@ typedef struct vm_frame_ctx_t
|
||||
#define VM_GET_REGISTER(frame_ctx_p, i) (((ecma_value_t *) ((frame_ctx_p) + 1))[i])
|
||||
|
||||
/**
|
||||
* Get the executable object.
|
||||
* Calculate the executable object from a vm_executable_object frame context.
|
||||
*/
|
||||
#define VM_GET_EXECUTABLE_OBJECT(frame_ctx_p) \
|
||||
((ecma_extended_object_t *) ((uintptr_t) (frame_ctx_p) - (uintptr_t) offsetof (vm_executable_object_t, frame_ctx)))
|
||||
|
||||
/**
|
||||
* Calculate the shared_part from a vm_executable_object frame context.
|
||||
*/
|
||||
#define VM_GET_EXECUTABLE_ITERATOR(frame_ctx_p) \
|
||||
((ecma_value_t *) ((uintptr_t) (frame_ctx_p) \
|
||||
- (uintptr_t) offsetof (vm_executable_object_t, frame_ctx) \
|
||||
+ (uintptr_t) offsetof (vm_executable_object_t, iterator)))
|
||||
|
||||
/**
|
||||
* Generator frame context.
|
||||
*/
|
||||
@@ -142,6 +151,7 @@ typedef struct
|
||||
{
|
||||
ecma_extended_object_t extended_object; /**< extended object part */
|
||||
vm_frame_ctx_shared_t shared; /**< shared part */
|
||||
ecma_value_t iterator; /**< executable object's iterator */
|
||||
vm_frame_ctx_t frame_ctx; /**< frame context part */
|
||||
} vm_executable_object_t;
|
||||
|
||||
|
||||
+40
-35
@@ -46,6 +46,9 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
JERRY_STATIC_ASSERT ((sizeof (vm_frame_ctx_t) % sizeof (ecma_value_t)) == 0,
|
||||
sizeof_vm_frame_ctx_must_be_sizeof_ecma_value_t_aligned);
|
||||
|
||||
/**
|
||||
* Get the value of object[property].
|
||||
*
|
||||
@@ -657,8 +660,8 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->block_result = completion_value;
|
||||
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = completion_value;
|
||||
}
|
||||
}
|
||||
} /* vm_super_call */
|
||||
@@ -749,8 +752,8 @@ vm_spread_operation (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->block_result = completion_value;
|
||||
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = completion_value;
|
||||
}
|
||||
|
||||
/* EXT_OPCODE, SPREAD_OPCODE, BYTE_ARG */
|
||||
@@ -839,8 +842,8 @@ opfunc_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->block_result = completion_value;
|
||||
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = completion_value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,8 +1006,8 @@ opfunc_construct (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
else \
|
||||
{ \
|
||||
JERRY_ASSERT (opcode_data & VM_OC_PUT_BLOCK); \
|
||||
ecma_free_value (frame_ctx_p->block_result); \
|
||||
frame_ctx_p->block_result = (value); \
|
||||
ecma_free_value (VM_GET_REGISTER (frame_ctx_p, 0)); \
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = (value); \
|
||||
opcode_data &= (uint32_t) ~VM_OC_PUT_BLOCK; \
|
||||
}
|
||||
|
||||
@@ -1207,8 +1210,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
case VM_OC_POP_BLOCK:
|
||||
{
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->block_result = *(--stack_top_p);
|
||||
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = *(--stack_top_p);
|
||||
continue;
|
||||
}
|
||||
case VM_OC_PUSH:
|
||||
@@ -2663,7 +2666,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
|
||||
async_generator_object_p->u.cls.u2.executable_obj_flags |= ECMA_EXECUTABLE_OBJECT_DO_AWAIT_OR_YIELD;
|
||||
frame_ctx_p->block_result = left_value;
|
||||
*VM_GET_EXECUTABLE_ITERATOR (frame_ctx_p) = left_value;
|
||||
|
||||
frame_ctx_p->call_operation = VM_EXEC_RETURN;
|
||||
frame_ctx_p->byte_code_p = byte_code_p;
|
||||
@@ -2672,7 +2675,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
case VM_OC_AWAIT:
|
||||
{
|
||||
if (JERRY_UNLIKELY (frame_ctx_p->block_result == ECMA_VALUE_UNDEFINED))
|
||||
if (JERRY_UNLIKELY (!(frame_ctx_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_EXECUTABLE)))
|
||||
{
|
||||
frame_ctx_p->call_operation = VM_EXEC_RETURN;
|
||||
frame_ctx_p->byte_code_p = byte_code_p;
|
||||
@@ -2722,13 +2725,15 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
{
|
||||
JERRY_ASSERT (VM_GET_REGISTERS (frame_ctx_p) + register_end + frame_ctx_p->context_depth == stack_top_p);
|
||||
|
||||
result = frame_ctx_p->block_result;
|
||||
frame_ctx_p->block_result = ECMA_VALUE_UNDEFINED;
|
||||
|
||||
if (result == ECMA_VALUE_UNDEFINED)
|
||||
if (!(frame_ctx_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_EXECUTABLE))
|
||||
{
|
||||
result = ecma_op_create_promise_object (ECMA_VALUE_EMPTY, ECMA_VALUE_UNDEFINED, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = *VM_GET_EXECUTABLE_ITERATOR (frame_ctx_p);
|
||||
*VM_GET_EXECUTABLE_ITERATOR (frame_ctx_p) = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
vm_stack_context_type_t context_type = VM_GET_CONTEXT_TYPE (stack_top_p[-1]);
|
||||
|
||||
@@ -3113,18 +3118,25 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
left_value = ECMA_VALUE_UNDEFINED;
|
||||
break;
|
||||
}
|
||||
case VM_OC_RETURN_FUNCTION_END:
|
||||
{
|
||||
if (CBC_FUNCTION_GET_TYPE (bytecode_header_p->status_flags) == CBC_FUNCTION_SCRIPT)
|
||||
{
|
||||
result = VM_GET_REGISTER (frame_ctx_p, 0);
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
goto error;
|
||||
}
|
||||
case VM_OC_RETURN:
|
||||
{
|
||||
JERRY_ASSERT (opcode == CBC_RETURN
|
||||
|| opcode == CBC_RETURN_WITH_BLOCK
|
||||
|| opcode == CBC_RETURN_WITH_LITERAL);
|
||||
|
||||
if (opcode == CBC_RETURN_WITH_BLOCK)
|
||||
{
|
||||
left_value = frame_ctx_p->block_result;
|
||||
frame_ctx_p->block_result = ECMA_VALUE_UNDEFINED;
|
||||
}
|
||||
|
||||
result = left_value;
|
||||
left_value = ECMA_VALUE_UNDEFINED;
|
||||
goto error;
|
||||
@@ -4319,7 +4331,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
| (ECMA_AWAIT_FOR_NEXT << ECMA_AWAIT_STATE_SHIFT));
|
||||
|
||||
if (CBC_FUNCTION_GET_TYPE (bytecode_header_p->status_flags) == CBC_FUNCTION_ASYNC_GENERATOR
|
||||
|| frame_ctx_p->block_result != ECMA_VALUE_UNDEFINED)
|
||||
|| (frame_ctx_p->shared_p->status_flags & VM_FRAME_CTX_SHARED_EXECUTABLE))
|
||||
{
|
||||
ecma_extended_object_t *executable_object_p = VM_GET_EXECUTABLE_OBJECT (frame_ctx_p);
|
||||
result = ecma_promise_async_await (executable_object_p, result);
|
||||
@@ -4794,8 +4806,8 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
}
|
||||
else if (opcode_data & VM_OC_PUT_BLOCK)
|
||||
{
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->block_result = result;
|
||||
ecma_fast_free_value (VM_GET_REGISTER (frame_ctx_p, 0));
|
||||
VM_GET_REGISTERS (frame_ctx_p)[0] = result;
|
||||
}
|
||||
|
||||
free_both_values:
|
||||
@@ -4878,7 +4890,6 @@ error:
|
||||
if (frame_ctx_p->context_depth == 0)
|
||||
{
|
||||
/* In most cases there is no context. */
|
||||
ecma_fast_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->call_operation = VM_NO_EXEC_OP;
|
||||
return result;
|
||||
}
|
||||
@@ -4985,7 +4996,6 @@ error:
|
||||
}
|
||||
|
||||
finish:
|
||||
ecma_free_value (frame_ctx_p->block_result);
|
||||
frame_ctx_p->call_operation = VM_NO_EXEC_OP;
|
||||
return result;
|
||||
}
|
||||
@@ -5148,7 +5158,7 @@ vm_init_module_scope (ecma_module_t *module_p) /**< module without scope */
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (opcode == CBC_RETURN_WITH_BLOCK);
|
||||
JERRY_ASSERT (opcode == CBC_RETURN_FUNCTION_END);
|
||||
return ECMA_VALUE_EMPTY;
|
||||
}
|
||||
}
|
||||
@@ -5179,7 +5189,6 @@ vm_init_exec (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
const ecma_compiled_code_t *bytecode_header_p = shared_p->bytecode_header_p;
|
||||
|
||||
frame_ctx_p->prev_context_p = JERRY_CONTEXT (vm_top_context_p);
|
||||
frame_ctx_p->block_result = ECMA_VALUE_UNDEFINED;
|
||||
frame_ctx_p->context_depth = 0;
|
||||
frame_ctx_p->status_flags = (uint8_t) ((shared_p->status_flags & VM_FRAME_CTX_DIRECT_EVAL)
|
||||
| (bytecode_header_p->status_flags & VM_FRAME_CTX_IS_STRICT));
|
||||
@@ -5356,11 +5365,7 @@ vm_run (vm_frame_ctx_shared_t *shared_p, /**< shared data */
|
||||
frame_size = (size_t) (args_p->register_end + args_p->stack_limit);
|
||||
}
|
||||
|
||||
frame_size = frame_size * sizeof (ecma_value_t) + sizeof (vm_frame_ctx_t);
|
||||
frame_size = (frame_size + sizeof (uintptr_t) - 1) / sizeof (uintptr_t);
|
||||
|
||||
/* Use JERRY_MAX() to avoid array declaration with size 0. */
|
||||
JERRY_VLA (uintptr_t, stack, frame_size);
|
||||
JERRY_VLA (ecma_value_t, stack, frame_size + (sizeof (vm_frame_ctx_t) / sizeof (ecma_value_t)));
|
||||
|
||||
frame_ctx_p = (vm_frame_ctx_t *) stack;
|
||||
|
||||
|
||||
@@ -152,6 +152,7 @@ typedef enum
|
||||
VM_OC_ASSIGN_PROP_THIS, /**< assign prop this */
|
||||
|
||||
VM_OC_RETURN, /**< return */
|
||||
VM_OC_RETURN_FUNCTION_END, /**< return at the end of a function/script */
|
||||
VM_OC_THROW, /**< throw */
|
||||
VM_OC_THROW_REFERENCE_ERROR, /**< throw reference error */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user