[esnext] Update String.p.matchAll as per spec changes

As per (https://github.com/tc39/proposal-string-matchall/pull/35), the
call to IsRegExp after CreateRegExp was removed and additional
checking was replaced by an Assert.

Updates to Test262 has been submitted:
https://github.com/tc39/test262/pull/1587

Bug: v8:6890
Change-Id: I942b6846bb46cf85b1ea5566f9c19de7d2dbf03e
Reviewed-on: https://chromium-review.googlesource.com/1086419
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Mathias Bynens <mathias@chromium.org>
Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
Cr-Commit-Position: refs/heads/master@{#53539}
This commit is contained in:
peterwmwong 2018-06-04 20:26:25 -05:00 committed by Commit Bot
parent e63f35bcac
commit 8789d804ec

View File

@ -1962,8 +1962,7 @@ TNode<Object> RegExpBuiltinsAssembler::MatchAllIterator(
TNode<Object> maybe_regexp, TNode<String> string,
TNode<BoolT> is_fast_regexp, char const* method_name) {
Label create_iterator(this), if_fast_regexp(this),
if_slow_regexp(this, Label::kDeferred), if_not_regexp(this),
throw_type_error(this, Label::kDeferred);
if_slow_regexp(this, Label::kDeferred), if_not_regexp(this);
// 1. Let S be ? ToString(O).
// Handled by the caller of MatchAllIterator.
@ -2044,35 +2043,22 @@ TNode<Object> RegExpBuiltinsAssembler::MatchAllIterator(
var_matcher = RegExpCreate(context, native_context, maybe_regexp,
StringConstant("g"));
// d. Let global be true.
// c. Let global be true.
var_global = Int32Constant(1);
// e. Let fullUnicode be false.
// d. Let fullUnicode be false.
var_unicode = Int32Constant(0);
Label if_matcher_slow_regexp(this, Label::kDeferred);
BranchIfFastRegExp(context, var_matcher.value(), &create_iterator,
&if_matcher_slow_regexp);
BIND(&if_matcher_slow_regexp);
{
// c. If ? IsRegExp(matcher) is not true, throw a TypeError exception.
GotoIfNot(IsRegExp(context, var_matcher.value()), &throw_type_error);
#ifdef DEBUG
// Assert: ! Get(matcher, "lastIndex") is 0.
TNode<Object> last_index =
CAST(LoadLastIndex(context, var_matcher.value(), false));
CSA_ASSERT(this, WordEqual(SmiConstant(0), last_index));
#endif // DEBUG
// f. If ? Get(matcher, "lastIndex") is not 0, throw a TypeError
// exception.
TNode<Object> last_index =
CAST(LoadLastIndex(context, var_matcher.value(), false));
Branch(WordEqual(SmiConstant(0), last_index), &create_iterator,
&throw_type_error);
}
}
BIND(&throw_type_error);
{
ThrowTypeError(context, MessageTemplate::kIncompatibleMethodReceiver,
StringConstant(method_name), maybe_regexp);
Goto(&create_iterator);
}
// 4. Return ! CreateRegExpStringIterator(matcher, S, global, fullUnicode).
// CreateRegExpStringIterator ( R, S, global, fullUnicode )
BIND(&create_iterator);
{
TNode<Map> map = CAST(LoadContextElement(