Implement proper arguments support (#4289)

- Store arguments in a register when possible
- Create separate arguments object for function argument initializer when necessary

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2020-10-16 11:02:36 +02:00
committed by GitHub
parent 650269feca
commit 841d536fce
16 changed files with 647 additions and 179 deletions
@@ -37,13 +37,16 @@
* Arguments object creation operation.
*
* See also: ECMA-262 v5, 10.6
*
* @return ecma value of arguments object
* Returned value must be freed with ecma_free_value
*/
void
ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function */
ecma_object_t *lex_env_p, /**< lexical environment the Arguments
ecma_value_t
ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, /**< shared context data */
ecma_object_t *lex_env_p) /**< lexical environment the Arguments
* object is created for */
vm_frame_ctx_shared_args_t *shared_p) /**< shared context data */
{
ecma_object_t *func_obj_p = shared_p->function_object_p;
const ecma_compiled_code_t *bytecode_data_p = shared_p->header.bytecode_header_p;
uint16_t formal_params_number;
@@ -136,17 +139,7 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
}
}
uint8_t prop_flags = ((bytecode_data_p->status_flags & CBC_CODE_FLAGS_STRICT_MODE) ? ECMA_PROPERTY_FIXED
: ECMA_PROPERTY_FLAG_WRITABLE);
ecma_property_value_t *prop_value_p;
prop_value_p = ecma_create_named_data_property (lex_env_p,
ecma_get_magic_string (LIT_MAGIC_STRING_ARGUMENTS),
prop_flags,
NULL);
prop_value_p->value = ecma_make_object_value (obj_p);
ecma_deref_object (obj_p);
return ecma_make_object_value (obj_p);
} /* ecma_op_create_arguments_object */
/**
@@ -20,9 +20,8 @@
#include "ecma-helpers.h"
#include "vm-defines.h"
void
ecma_op_create_arguments_object (ecma_object_t *func_obj_p, ecma_object_t *lex_env_p,
vm_frame_ctx_shared_args_t *shared_p);
ecma_value_t
ecma_op_create_arguments_object (vm_frame_ctx_shared_args_t *shared_p, ecma_object_t *lex_env_p);
ecma_value_t
ecma_op_arguments_object_delete (ecma_object_t *object_p, ecma_string_t *property_name_p, bool is_throw);
@@ -25,7 +25,6 @@
#include "ecma-lex-env.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-arguments-object.h"
#include "ecma-proxy-object.h"
#include "ecma-symbol-object.h"
#include "jcontext.h"
@@ -879,11 +878,9 @@ 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.arg_list_p = arguments_list_p;
shared_args.arg_list_len = arguments_list_len;
#if ENABLED (JERRY_ESNEXT)
shared_args.function_object_p = func_obj_p;
#endif /* ENABLED (JERRY_ESNEXT) */
/* Entering Function Code (ECMA-262 v5, 10.4.3) */
ecma_extended_object_t *ext_func_p = (ecma_extended_object_t *) func_obj_p;
@@ -946,11 +943,6 @@ ecma_op_function_call_simple (ecma_object_t *func_obj_p, /**< Function object */
{
shared_args.header.status_flags |= VM_FRAME_CTX_SHARED_FREE_LOCAL_ENV;
scope_p = ecma_create_decl_lex_env (scope_p);
if (JERRY_UNLIKELY (status_flags & CBC_CODE_FLAGS_IS_ARGUMENTS_NEEDED))
{
ecma_op_create_arguments_object (func_obj_p, scope_p, &shared_args);
}
}
ecma_value_t ret_value;