Skip to content
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

Read global and sticky from [[OriginalFlags]] in RegExpBuiltinExec #494

Merged
merged 1 commit into from
Apr 7, 2016

Conversation

littledan
Copy link
Member

This closes #489. RegExpBuiltinExec reads other flags from
[[OriginalFlags]], based on the fact that it is operating on a RegExp
instance. In ES2015, however, it accessed 'global' and 'sticky' via
property accesses. This patch changes RegExpBuiltinExec to access
those flags via [[OriginalFlags]] as well.

This closes tc39#489. RegExpBuiltinExec reads other flags from
[[OriginalFlags]], based on the fact that it is operating on a RegExp
instance. In ES2015, however, it accessed 'global' and 'sticky' via
property accesses. This patch changes RegExpBuiltinExec to access
those flags via [[OriginalFlags]] as well.
kisg pushed a commit to paul99/v8mips that referenced this pull request Apr 4, 2016
- RegExp.prototype.toString() doesn't have any special handling of
  RegExp instances and simply calls the source and flags getters
- Use the original values of global and sticky, rather than based
  on the current flag getters, as specified in
  tc39/ecma262#494

[email protected],adamk
LOG=Y
BUG=v8:4602

Review URL: https://codereview.chromium.org/1846303002

Cr-Commit-Position: refs/heads/master@{#35225}
@bterlson bterlson merged commit 91d1236 into tc39:master Apr 7, 2016
jugglinmike added a commit to bocoup/es6draft that referenced this pull request May 3, 2016
The ES2016 draft modifies the semantics of RegExpBuiltinExec to infer
"global" and "sticky" using the regular expression object's
[[OriginalFlags]] internal slot [1]. Update the algorithm accordingly.

This change removes two observable operations. An existing regression
test relied on one of these operations (accessing the `global` property)
during the evaluation of `RegExp.prototype[@@replace]`. Update the
regression test to use a different mechanism to assert the same
semantics.

[1] tc39/ecma262#494
jugglinmike added a commit to bocoup/test262 that referenced this pull request May 3, 2016
The RegExpBuiltinExec internal operation was modified in March of 2016
[1]: instead of referencing the `global` and `sticky` properties of the
"this" value, the algorithm now infers those values from the object's
[[OriginalFlags]] internal slot.

This change invalidated a number of tests. In cases where the change
resulted in an observable behavior, update the tests to assert the
latest specification text. In cases where the change removed a
previously-observable behavior, remove the files completely.

Specification text change set:

>        1. Assert: Type(_S_) is String.
>        1. Let _length_ be the number of code units in _S_.
>        1. Let _lastIndex_ be ? ToLength(? Get(_R_, `"lastIndex"`)).
>      - 1. Let _global_ be ToBoolean(? Get(_R_, `"global"`)).
>      - 1. Let _sticky_ be ToBoolean(? Get(_R_, `"sticky"`)).
>      + 1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
>      + 1. If _flags_ contains `"g"`, let _global_ be *true*, else let _global_ be *false*.
>      + 1. If _flags_ contains `"y"`, let _sticky_ be *true*, else let _sticky_ be *false*.
>        1. If _global_ is *false* and _sticky_ is *false*, let _lastIndex_ be 0.
>        1. Let _matcher_ be the value of _R_'s [[RegExpMatcher]] internal slot.
>      - 1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
>        1. If _flags_ contains `"u"`, let _fullUnicode_ be *true*, else let _fullUnicode_ be *false*.
>        1. Let _matchSucceeded_ be *false*.
>        1. Repeat, while _matchSucceeded_ is *false*

[1] tc39/ecma262#494
jugglinmike added a commit to jugglinmike/es6draft that referenced this pull request May 3, 2016
The ES2016 draft modifies the semantics of RegExpBuiltinExec to infer
"global" and "sticky" using the regular expression object's
[[OriginalFlags]] internal slot [1]. Update the algorithm accordingly.

This change removes two observable operations. An existing regression
test relied on one of these operations (accessing the `global` property)
during the evaluation of `RegExp.prototype[@@replace]`. Update the
regression test to use a different mechanism to assert the same
semantics.

[1] tc39/ecma262#494
leobalter pushed a commit to tc39/test262 that referenced this pull request May 9, 2016
The RegExpBuiltinExec internal operation was modified in March of 2016
[1]: instead of referencing the `global` and `sticky` properties of the
"this" value, the algorithm now infers those values from the object's
[[OriginalFlags]] internal slot.

This change invalidated a number of tests. In cases where the change
resulted in an observable behavior, update the tests to assert the
latest specification text. In cases where the change removed a
previously-observable behavior, remove the files completely.

Specification text change set:

>        1. Assert: Type(_S_) is String.
>        1. Let _length_ be the number of code units in _S_.
>        1. Let _lastIndex_ be ? ToLength(? Get(_R_, `"lastIndex"`)).
>      - 1. Let _global_ be ToBoolean(? Get(_R_, `"global"`)).
>      - 1. Let _sticky_ be ToBoolean(? Get(_R_, `"sticky"`)).
>      + 1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
>      + 1. If _flags_ contains `"g"`, let _global_ be *true*, else let _global_ be *false*.
>      + 1. If _flags_ contains `"y"`, let _sticky_ be *true*, else let _sticky_ be *false*.
>        1. If _global_ is *false* and _sticky_ is *false*, let _lastIndex_ be 0.
>        1. Let _matcher_ be the value of _R_'s [[RegExpMatcher]] internal slot.
>      - 1. Let _flags_ be the value of _R_'s [[OriginalFlags]] internal slot.
>        1. If _flags_ contains `"u"`, let _fullUnicode_ be *true*, else let _fullUnicode_ be *false*.
>        1. Let _matchSucceeded_ be *false*.
>        1. Repeat, while _matchSucceeded_ is *false*

[1] tc39/ecma262#494
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.

Use [[OriginalFlags]] from within RegExpBuiltinExec?
2 participants