Skip to content

slice helper should check for the ES5array or Proxy in the protototype #3415

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 3 commits into from
Jul 25, 2017

Conversation

akroshg
Copy link
Contributor

@akroshg akroshg commented Jul 21, 2017

This way we can identify if the array's content can be affected. If there is sideeffect expected we can take the slower
to finish the logic.

akroshg added 2 commits July 21, 2017 12:20
Few array apis (reverse, shift, unshift and sort) do fill from prototype
and still take the faster path to complete the respective logic. It is
possible that FillFromPrototype will mutate the current array, in that case taking faster path is wrong and give you wrong results.
However as you already done FillFromPrototype you already mutated the
current object so now you cannot take the slower path as it will create
further deviations.
In order to fix those I have put a precheck which actually looks the
prototype chain and find out if there is any ES5Array or Proxy of any
sort. If we don't have any of those we cannot change the current array's
length or type (I am not talking about native array to var array). With
these check we can safely decide which way we can go.

Added few tests cases to excercise the scenario, where previously we were
taking the faster path and leading to wrong result (we have compliant
gap).
Since the unshift expand to new length. It is possible that the current
array does not have any missing item but it still has accessor on the
proto chain. That setter will not be fired as we were taking the no-side
effect path. Fixed that by forcing to check the proto chain for the
unshift case.
Added test case for more understanding of the scenario.
@akroshg
Copy link
Contributor Author

akroshg commented Jul 21, 2017

@rajatd please have a look at the c6851ea commit. Rest commits are ported from rs3 branch.

@rajatd
Copy link
Contributor

rajatd commented Jul 25, 2017

:shipit:

This way we can identify if the array's content can be affected. If there is sideeffect expected we can take the slower
to finish the logic.
@chakrabot chakrabot merged commit 9aabce2 into chakra-core:release/1.6 Jul 25, 2017
chakrabot pushed a commit that referenced this pull request Jul 25, 2017
…Proxy in the protototype

Merge pull request #3415 from akroshg:nosideeffect

This way we can identify if the array's content can be affected. If there is sideeffect expected we can take the slower path
to finish the logic.
chakrabot pushed a commit that referenced this pull request Jul 25, 2017
…5array or Proxy in the protototype

Merge pull request #3415 from akroshg:nosideeffect

This way we can identify if the array's content can be affected. If there is sideeffect expected we can take the slower path
to finish the logic.
chakrabot pushed a commit that referenced this pull request Jul 25, 2017
…ck for the ES5array or Proxy in the protototype

Merge pull request #3415 from akroshg:nosideeffect

This way we can identify if the array's content can be affected. If there is sideeffect expected we can take the slower path
to finish the logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants