Skip to content

Remove ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND. #2408

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 1 commit into from
Jun 20, 2018
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
5 changes: 2 additions & 3 deletions jerry-core/ecma/base/ecma-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,8 @@ typedef enum
/* Types between 0 - 12 are ecma_object_type_t which can have a built-in flag. */

ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE = 13, /**< declarative lexical environment */
ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND = 14, /**< object-bound lexical environment */
ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND = 15, /**< object-bound lexical environment
* with provideThis flag */
ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND = 14, /**< object-bound lexical environment
* with provideThis flag */

ECMA_LEXICAL_ENVIRONMENT_TYPE_START = ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< first lexical
* environment type */
Expand Down
34 changes: 3 additions & 31 deletions jerry-core/ecma/base/ecma-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,14 @@ ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer
*/
ecma_object_t *
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
ecma_object_t *binding_obj_p, /**< binding object */
bool provide_this) /**< provideThis flag */
ecma_object_t *binding_obj_p) /**< binding object */
{
JERRY_ASSERT (binding_obj_p != NULL
&& !ecma_is_lexical_environment (binding_obj_p));

ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();

uint16_t type;

if (provide_this)
{
type = ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND;
}
else
{
type = ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND;
}
uint16_t type = ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND;

new_lexical_environment_p->type_flags_refs = type;

Expand Down Expand Up @@ -358,23 +348,6 @@ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical en
object_p->property_list_or_bound_object_cp);
} /* ecma_get_property_list */

/**
* Get lexical environment's 'provideThis' property
*
* @return true - if it has 'this' property
* false - otherwise
*/
inline bool JERRY_ATTR_PURE
ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound lexical environment */
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

return ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND;
} /* ecma_get_lex_env_provide_this */

/**
* Get lexical environment's bound object.
*
Expand All @@ -385,8 +358,7 @@ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-boun
{
JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

return ECMA_GET_NON_NULL_POINTER (ecma_object_t,
object_p->property_list_or_bound_object_cp);
Expand Down
4 changes: 1 addition & 3 deletions jerry-core/ecma/base/ecma-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,7 @@ ecma_collection_iterator_next (ecma_value_t *iterator_p);
/* ecma-helpers.c */
ecma_object_t *ecma_create_object (ecma_object_t *prototype_object_p, size_t ext_object_size, ecma_object_type_t type);
ecma_object_t *ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p);
ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p,
bool provide_this);
ecma_object_t *ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p);
bool JERRY_ATTR_PURE ecma_is_lexical_environment (const ecma_object_t *object_p);
bool JERRY_ATTR_PURE ecma_get_object_extensible (const ecma_object_t *object_p);
void ecma_set_object_extensible (ecma_object_t *object_p, bool is_extensible);
Expand All @@ -311,7 +310,6 @@ ecma_lexical_environment_type_t JERRY_ATTR_PURE ecma_get_lex_env_type (const ecm
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_outer_reference (const ecma_object_t *object_p);
ecma_property_header_t JERRY_ATTR_PURE *ecma_get_property_list (const ecma_object_t *object_p);
ecma_object_t JERRY_ATTR_PURE *ecma_get_lex_env_binding_object (const ecma_object_t *object_p);
bool JERRY_ATTR_PURE ecma_get_lex_env_provide_this (const ecma_object_t *object_p);

ecma_property_value_t *
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
Expand Down
39 changes: 12 additions & 27 deletions jerry-core/ecma/operations/ecma-lex-env.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ecma_init_global_lex_env (void)
{
ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL);

JERRY_CONTEXT (ecma_global_lex_env_p) = ecma_create_object_lex_env (NULL, glob_obj_p, false);
JERRY_CONTEXT (ecma_global_lex_env_p) = ecma_create_object_lex_env (NULL, glob_obj_p);

ecma_deref_object (glob_obj_p);
} /* ecma_init_global_lex_env */
Expand Down Expand Up @@ -94,8 +94,7 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);

Expand Down Expand Up @@ -136,8 +135,7 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);

Expand Down Expand Up @@ -204,8 +202,7 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);

Expand All @@ -218,10 +215,8 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
{
return completion;
}
else
{
JERRY_ASSERT (ecma_is_value_boolean (completion));
}

JERRY_ASSERT (ecma_is_value_boolean (completion));
}

return ECMA_VALUE_EMPTY;
Expand Down Expand Up @@ -252,8 +247,7 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);

Expand Down Expand Up @@ -322,8 +316,7 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);

Expand Down Expand Up @@ -351,20 +344,12 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

if (ecma_get_lex_env_provide_this (lex_env_p))
{
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_ref_object (binding_obj_p);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_ref_object (binding_obj_p);

return ecma_make_object_value (binding_obj_p);
}
else
{
return ECMA_VALUE_UNDEFINED;
}
return ecma_make_object_value (binding_obj_p);
}
} /* ecma_op_implicit_this_value */

Expand Down
3 changes: 1 addition & 2 deletions jerry-core/ecma/operations/ecma-reference.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ ecma_op_resolve_reference_value (ecma_object_t *lex_env_p, /**< starting lexical
}
else
{
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);

ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);

Expand Down
4 changes: 1 addition & 3 deletions jerry-core/vm/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2300,9 +2300,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */

object_p = ecma_get_object_from_value (result);

with_env_p = ecma_create_object_lex_env (frame_ctx_p->lex_env_p,
object_p,
true);
with_env_p = ecma_create_object_lex_env (frame_ctx_p->lex_env_p, object_p);

ecma_deref_object (object_p);

Expand Down