Skip to content

Commit 35c0869

Browse files
committed
Improve resolve reference.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 1e4531c commit 35c0869

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

jerry-core/ecma/operations/ecma-objects.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,19 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
7474

7575
const ecma_object_type_t type = ecma_get_object_type (obj_p);
7676

77-
switch (type)
77+
if (unlikely (type == ECMA_OBJECT_TYPE_ARGUMENTS))
7878
{
79-
case ECMA_OBJECT_TYPE_GENERAL:
80-
case ECMA_OBJECT_TYPE_FUNCTION:
81-
case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION:
82-
case ECMA_OBJECT_TYPE_ARRAY:
83-
case ECMA_OBJECT_TYPE_STRING:
84-
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
85-
{
86-
return ecma_op_general_object_get (obj_p, property_name_p);
87-
}
79+
return ecma_op_arguments_object_get (obj_p, property_name_p);
80+
}
8881

89-
case ECMA_OBJECT_TYPE_ARGUMENTS:
90-
{
91-
return ecma_op_arguments_object_get (obj_p, property_name_p);
92-
}
93-
default:
94-
{
95-
JERRY_ASSERT (false);
82+
JERRY_ASSERT (type == ECMA_OBJECT_TYPE_GENERAL
83+
|| type == ECMA_OBJECT_TYPE_FUNCTION
84+
|| type == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION
85+
|| type == ECMA_OBJECT_TYPE_ARRAY
86+
|| type == ECMA_OBJECT_TYPE_STRING
87+
|| type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
9688

97-
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
98-
}
99-
}
89+
return ecma_op_general_object_get (obj_p, property_name_p);
10090
} /* ecma_op_object_get */
10191

10292
/**

jerry-core/ecma/operations/ecma-reference.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#include "ecma-exceptions.h"
18+
#include "ecma-function-object.h"
1819
#include "ecma-gc.h"
1920
#include "ecma-globals.h"
2021
#include "ecma-helpers.h"
@@ -106,9 +107,24 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical
106107

107108
ecma_property_t *property_p = ecma_op_object_get_property (binding_obj_p, name_p);
108109

109-
if (property_p != NULL)
110+
if (likely (property_p != NULL))
110111
{
111-
return ecma_op_object_get (binding_obj_p, name_p);
112+
if (ECMA_PROPERTY_GET_TYPE (property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA)
113+
{
114+
return ecma_fast_copy_value (ecma_get_named_data_property_value (property_p));
115+
}
116+
117+
ecma_object_t *getter_p = ecma_get_named_accessor_property_getter (property_p);
118+
119+
if (getter_p == NULL)
120+
{
121+
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
122+
}
123+
124+
return ecma_op_function_call (getter_p,
125+
ecma_make_object_value (binding_obj_p),
126+
NULL,
127+
0);
112128
}
113129
}
114130

0 commit comments

Comments
 (0)