Rework frame context (#4200)
A new shared frame context data is created which allows sharing data between the function call and vm main loop. Furthermore rest arguments and current function object handling is reworked. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -27,7 +27,7 @@ JERRY_STATIC_ASSERT ((sizeof (cbc_uint16_arguments_t) % sizeof (jmem_cpointer_t)
|
||||
*/
|
||||
JERRY_STATIC_ASSERT (CBC_END == 238,
|
||||
number_of_cbc_opcodes_changed);
|
||||
JERRY_STATIC_ASSERT (CBC_EXT_END == 140,
|
||||
JERRY_STATIC_ASSERT (CBC_EXT_END == 141,
|
||||
number_of_cbc_ext_opcodes_changed);
|
||||
|
||||
#if ENABLED (JERRY_PARSER)
|
||||
|
||||
@@ -594,6 +594,8 @@
|
||||
VM_OC_EXT_VAR_EVAL) \
|
||||
CBC_OPCODE (CBC_EXT_COPY_FROM_ARG, CBC_HAS_LITERAL_ARG, 0, \
|
||||
VM_OC_COPY_FROM_ARG) \
|
||||
CBC_OPCODE (CBC_EXT_PUSH_REST_OBJECT, CBC_NO_FLAG, 1, \
|
||||
VM_OC_PUSH_REST_OBJECT) \
|
||||
CBC_OPCODE (CBC_EXT_STRING_CONCAT, CBC_NO_FLAG, -1, \
|
||||
VM_OC_STRING_CONCAT | VM_OC_GET_STACK_STACK | VM_OC_PUT_STACK) \
|
||||
CBC_OPCODE (CBC_EXT_STRING_CONCAT_RIGHT_LITERAL, CBC_HAS_LITERAL_ARG, 0, \
|
||||
@@ -862,9 +864,8 @@ typedef enum
|
||||
CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED = (1u << 5), /**< no need to create a lexical environment */
|
||||
CBC_CODE_FLAGS_STATIC_FUNCTION = (1u << 6), /**< this function is a static snapshot function */
|
||||
CBC_CODE_FLAGS_DEBUGGER_IGNORE = (1u << 7), /**< this function should be ignored by debugger */
|
||||
CBC_CODE_FLAGS_REST_PARAMETER = (1u << 8), /**< this function has rest parameter */
|
||||
CBC_CODE_FLAGS_HAS_TAGGED_LITERALS = (1u << 9), /**< this function has tagged template literal list */
|
||||
CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED = (1u << 10), /**< compiled code needs a lexical block */
|
||||
CBC_CODE_FLAGS_HAS_TAGGED_LITERALS = (1u << 8), /**< this function has tagged template literal list */
|
||||
CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED = (1u << 9), /**< compiled code needs a lexical block */
|
||||
|
||||
/* Bits from bit 12 is reserved for function types (see CBC_FUNCTION_TYPE_SHIFT).
|
||||
* Note: the last bits are used for type flags because < and >= operators can be used to
|
||||
|
||||
@@ -555,13 +555,6 @@ parse_print_literal (ecma_compiled_code_t *compiled_code_p, /**< compiled code *
|
||||
ident_end = args_p->ident_end;
|
||||
}
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_REST_PARAMETER)
|
||||
{
|
||||
argument_end++;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (literal_index < argument_end)
|
||||
{
|
||||
JERRY_DEBUG_MSG (" arg:%d", literal_index);
|
||||
@@ -1437,11 +1430,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
|
||||
function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_NORMAL);
|
||||
}
|
||||
|
||||
if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_REST_PARAMETER;
|
||||
}
|
||||
|
||||
if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
|
||||
{
|
||||
compiled_code_p->status_flags |= CBC_CODE_FLAGS_HAS_TAGGED_LITERALS;
|
||||
@@ -1870,9 +1858,16 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
context_p->status_flags |= PARSER_FUNCTION_HAS_COMPLEX_ARGUMENT;
|
||||
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
(uint16_t) (PARSER_REGISTER_START + context_p->argument_count));
|
||||
if (!(context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM))
|
||||
{
|
||||
parser_emit_cbc_literal (context_p,
|
||||
CBC_PUSH_LITERAL,
|
||||
(uint16_t) (PARSER_REGISTER_START + context_p->argument_count));
|
||||
}
|
||||
else
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_REST_OBJECT);
|
||||
}
|
||||
|
||||
uint32_t flags = (PARSER_PATTERN_BINDING
|
||||
| PARSER_PATTERN_TARGET_ON_STACK
|
||||
@@ -1990,7 +1985,7 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
if (literal_index >= PARSER_REGISTER_START)
|
||||
{
|
||||
opcode = CBC_ASSIGN_SET_IDENT;
|
||||
opcode = CBC_MOV_IDENT;
|
||||
}
|
||||
else if (!scanner_literal_is_created (context_p, literal_index))
|
||||
{
|
||||
@@ -1999,6 +1994,24 @@ parser_parse_function_arguments (parser_context_t *context_p, /**< context */
|
||||
|
||||
parser_emit_cbc_literal (context_p, opcode, literal_index);
|
||||
}
|
||||
else if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
|
||||
{
|
||||
parser_emit_cbc_ext (context_p, CBC_EXT_PUSH_REST_OBJECT);
|
||||
|
||||
uint16_t opcode = CBC_MOV_IDENT;
|
||||
|
||||
if (literal_index < PARSER_REGISTER_START)
|
||||
{
|
||||
opcode = CBC_INIT_ARG_OR_CATCH;
|
||||
|
||||
if (scanner_literal_is_created (context_p, literal_index))
|
||||
{
|
||||
opcode = CBC_ASSIGN_LET_CONST;
|
||||
}
|
||||
}
|
||||
|
||||
parser_emit_cbc_literal (context_p, opcode, literal_index);
|
||||
}
|
||||
else if (has_complex_argument && literal_index < PARSER_REGISTER_START)
|
||||
{
|
||||
uint16_t opcode = CBC_INIT_ARG_OR_FUNC;
|
||||
|
||||
Reference in New Issue
Block a user