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:
Zoltan Herczeg
2020-09-21 10:25:17 +02:00
committed by GitHub
parent 55554535b2
commit 4d135bec5d
17 changed files with 311 additions and 181 deletions
+72 -2
View File
@@ -35,12 +35,81 @@
*/
#define VM_MINUS_EQUAL_U16(base, value) (base) = (uint16_t) ((base) - (value))
/**
* Flag bits of vm_frame_ctx_shared_t
*/
typedef enum
{
VM_FRAME_CTX_SHARED_HAS_ARG_LIST = (1 << 0), /**< has argument list */
VM_FRAME_CTX_SHARED_DIRECT_EVAL = (1 << 1), /**< direct eval call */
VM_FRAME_CTX_SHARED_FREE_THIS = (1 << 2), /**< free this binding */
VM_FRAME_CTX_SHARED_FREE_LOCAL_ENV = (1 << 3), /**< free local environment */
#if ENABLED (JERRY_ESNEXT)
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 */
#endif /* ENABLED (JERRY_ESNEXT) */
} vm_frame_ctx_shared_flags_t;
/**
* Shared data between the interpreter and the caller
*/
typedef struct
{
const ecma_compiled_code_t *bytecode_header_p; /**< currently executed byte-code data */
uint32_t status_flags; /**< combination of vm_frame_ctx_shared_flags_t bits */
} vm_frame_ctx_shared_t;
/**
* Shared data extended with arguments
*/
typedef struct
{
vm_frame_ctx_shared_t header; /**< shared data header */
#if ENABLED (JERRY_ESNEXT)
ecma_object_t *function_object_p; /**< function obj */
#endif /* ENABLED (JERRY_ESNEXT) */
const ecma_value_t *arg_list_p; /**< arguments list */
uint32_t arg_list_len; /**< arguments list length */
} vm_frame_ctx_shared_args_t;
#if ENABLED (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
*/
typedef struct
{
vm_frame_ctx_shared_t header; /**< shared data header */
ecma_value_t *computed_class_fields_p; /**< names of the computed class fields */
} vm_frame_ctx_shared_class_fields_t;
/**
* Get the computed class field
*/
#define VM_GET_COMPUTED_CLASS_FIELDS(frame_ctx_p) \
(((vm_frame_ctx_shared_class_fields_t *) ((frame_ctx_p)->shared_p))->computed_class_fields_p)
#endif /* ENABLED (JERRY_ESNEXT) */
/**
* Flag bits of vm_frame_ctx_t
*/
typedef enum
{
VM_FRAME_CTX_DIRECT_EVAL = (1 << 1), /**< direct eval call */
VM_FRAME_CTX_IS_STRICT = (1 << 2), /**< strict mode */
} vm_frame_ctx_flags_t;
/**
* Context of interpreter, related to a JS stack frame
*/
typedef struct vm_frame_ctx_t
{
const ecma_compiled_code_t *bytecode_header_p; /**< currently executed byte-code data */
vm_frame_ctx_shared_t *shared_p; /**< shared information */
const uint8_t *byte_code_p; /**< current byte code pointer */
const uint8_t *byte_code_start_p; /**< byte code start pointer */
ecma_value_t *stack_top_p; /**< stack top pointer */
@@ -53,7 +122,7 @@ typedef struct vm_frame_ctx_t
uint32_t current_line; /**< currently executed line */
#endif /* ENABLED (JERRY_LINE_INFO) */
uint16_t context_depth; /**< current context depth */
uint8_t is_eval_code; /**< eval mode flag */
uint8_t status_flags; /**< combination of vm_frame_ctx_flags_t bits */
uint8_t call_operation; /**< perform a call or construct operation */
/* Registers start immediately after the frame context. */
} vm_frame_ctx_t;
@@ -80,6 +149,7 @@ typedef struct vm_frame_ctx_t
typedef struct
{
ecma_extended_object_t extended_object; /**< extended object part */
vm_frame_ctx_shared_t shared; /**< shared part */
vm_frame_ctx_t frame_ctx; /**< frame context part */
} vm_executable_object_t;