Skip to content

Primitive this values of accessors should not be coerced in strict mode #3854

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 5, 2020

Conversation

dbatyai
Copy link
Member

@dbatyai dbatyai commented Jun 4, 2020

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai [email protected]

@dbatyai dbatyai added bug Undesired behaviour ecma core Related to core ECMA functionality labels Jun 4, 2020

if (JERRY_UNLIKELY (!ecma_is_value_object (object)))
if (JERRY_UNLIKELY (!ecma_is_value_object (base)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part is always true if the second part is true.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this case is extremely unlikely, I added the first condition to reduce the number of checks when base is an object, which is more likely. I can remove it if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a very hoth path, and this is checked twice. What about moving the ecma_is_value_prop_name part before this, and combine this part with the rest?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunatley the errors must be thrown in this order, the base object needs to be checked first, followed by the property name. The checks could be reduced by adding a completely separate code path for the non-object case and duplicating/factoring out the property name coercion. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a key function of vm, so in this case I would not mind the extra binary size.

JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (object));

object_p = ecma_get_object_from_value (object);
ecma_op_ordinary_object_prevent_extensions (object_p);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this standard?

Copy link
Member Author

@dbatyai dbatyai Jun 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been added as part of #2917, it seems to me that it's correct.

Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dbatyai dbatyai requested review from rerobika and galpeter June 5, 2020 13:38
Copy link
Member

@rerobika rerobika left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rerobika rerobika merged commit cae6cd0 into jerryscript-project:master Jun 5, 2020
@dbatyai dbatyai deleted the accessor_this branch June 10, 2020 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour ecma core Related to core ECMA functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants