Skip to content

Improve resolve reference. #1204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 10 additions & 20 deletions jerry-core/ecma/operations/ecma-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,19 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */

const ecma_object_type_t type = ecma_get_object_type (obj_p);

switch (type)
if (unlikely (type == ECMA_OBJECT_TYPE_ARGUMENTS))
{
case ECMA_OBJECT_TYPE_GENERAL:
case ECMA_OBJECT_TYPE_FUNCTION:
case ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION:
case ECMA_OBJECT_TYPE_ARRAY:
case ECMA_OBJECT_TYPE_STRING:
case ECMA_OBJECT_TYPE_BOUND_FUNCTION:
{
return ecma_op_general_object_get (obj_p, property_name_p);
}
return ecma_op_arguments_object_get (obj_p, property_name_p);
}

case ECMA_OBJECT_TYPE_ARGUMENTS:
{
return ecma_op_arguments_object_get (obj_p, property_name_p);
}
default:
{
JERRY_ASSERT (false);
JERRY_ASSERT (type == ECMA_OBJECT_TYPE_GENERAL
|| type == ECMA_OBJECT_TYPE_FUNCTION
|| type == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION
|| type == ECMA_OBJECT_TYPE_ARRAY
|| type == ECMA_OBJECT_TYPE_STRING
|| type == ECMA_OBJECT_TYPE_BOUND_FUNCTION);

return ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
}
}
return ecma_op_general_object_get (obj_p, property_name_p);
} /* ecma_op_object_get */

/**
Expand Down
20 changes: 18 additions & 2 deletions jerry-core/ecma/operations/ecma-reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
Expand Down Expand Up @@ -106,9 +107,24 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical

ecma_property_t *property_p = ecma_op_object_get_property (binding_obj_p, name_p);

if (property_p != NULL)
if (likely (property_p != NULL))
{
return ecma_op_object_get (binding_obj_p, name_p);
if (ECMA_PROPERTY_GET_TYPE (property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA)
{
return ecma_fast_copy_value (ecma_get_named_data_property_value (property_p));
}

ecma_object_t *getter_p = ecma_get_named_accessor_property_getter (property_p);

if (getter_p == NULL)
{
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}

return ecma_op_function_call (getter_p,
ecma_make_object_value (binding_obj_p),
NULL,
0);
}
}

Expand Down