From 25f58894ef4c29e351caab3ef824f608554be99f Mon Sep 17 00:00:00 2001 From: Zoltan Herczeg Date: Mon, 28 Nov 2016 13:10:49 +0100 Subject: [PATCH] Improve the performance of resolve reference. (#1453) JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com --- jerry-core/ecma/operations/ecma-reference.c | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jerry-core/ecma/operations/ecma-reference.c b/jerry-core/ecma/operations/ecma-reference.c index 55929925e..77ecf2250 100644 --- a/jerry-core/ecma/operations/ecma-reference.c +++ b/jerry-core/ecma/operations/ecma-reference.c @@ -19,6 +19,7 @@ #include "ecma-gc.h" #include "ecma-globals.h" #include "ecma-helpers.h" +#include "ecma-lcache.h" #include "ecma-lex-env.h" #include "ecma-objects.h" #include "ecma-reference.h" @@ -88,6 +89,30 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); + ecma_property_t *property_p = ecma_lcache_lookup (binding_obj_p, name_p); + + if (property_p != NULL) + { + ecma_property_value_t *prop_value_p = ECMA_PROPERTY_VALUE_PTR (property_p); + + if (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA) + { + return ecma_fast_copy_value (prop_value_p->value); + } + + JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR); + + ecma_object_t *getter_p = ecma_get_named_accessor_property_getter (prop_value_p); + + if (getter_p == NULL) + { + return ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED); + } + + ecma_value_t base_value = ecma_make_object_value (binding_obj_p); + return ecma_op_function_call (getter_p, base_value, NULL, 0); + } + ecma_value_t prop_value = ecma_op_object_find (binding_obj_p, name_p); if (ecma_is_value_found (prop_value))