Clean up RegExp comments and test262 status

This patch fixes a bunch of out-of-date TODOs, un-skips some tests
and refers to appropriate bug numbers and current specification
status where appropriate.

R=adamk

Review-Url: https://codereview.chromium.org/2319203002
Cr-Commit-Position: refs/heads/master@{#39260}
This commit is contained in:
littledan 2016-09-07 12:39:47 -07:00 committed by Commit bot
parent 9048298d4c
commit 46edbd164d
2 changed files with 10 additions and 33 deletions

View File

@ -204,9 +204,6 @@ function RegExpSubclassExecJS(string) {
} }
// matchIndices is either null or the RegExpLastMatchInfo array. // matchIndices is either null or the RegExpLastMatchInfo array.
// TODO(littledan): Whether a RegExp is sticky is compiled into the RegExp
// itself, but ES2015 allows monkey-patching this property to differ from
// the internal flags. If it differs, recompile a different RegExp?
var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo); var matchIndices = %_RegExpExec(this, string, i, RegExpLastMatchInfo);
if (IS_NULL(matchIndices)) { if (IS_NULL(matchIndices)) {
@ -387,10 +384,9 @@ function AtSurrogatePair(subject, index) {
} }
// Legacy implementation of RegExp.prototype[Symbol.split] which // Fast path implementation of RegExp.prototype[Symbol.split] which
// doesn't properly call the underlying exec, @@species methods // doesn't properly call the underlying exec, @@species methods
function RegExpSplit(string, limit) { function RegExpSplit(string, limit) {
// TODO(yangguo): allow non-regexp receivers.
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
throw %make_type_error(kIncompatibleMethodReceiver, throw %make_type_error(kIncompatibleMethodReceiver,
"RegExp.prototype.@@split", this); "RegExp.prototype.@@split", this);
@ -473,11 +469,8 @@ function RegExpSubclassSplit(string, limit) {
var constructor = SpeciesConstructor(this, GlobalRegExp); var constructor = SpeciesConstructor(this, GlobalRegExp);
var flags = TO_STRING(this.flags); var flags = TO_STRING(this.flags);
// TODO(adamk): this fast path is wrong with respect to this.global // TODO(adamk): this fast path is wrong as we doesn't ensure that 'exec'
// and this.sticky, but hopefully the spec will remove those gets // is actually a data property on RegExp.prototype.
// and thus make the assumption of 'exec' having no side-effects
// more correct. Also, we doesn't ensure that 'exec' is actually
// a data property on RegExp.prototype.
var exec; var exec;
if (IS_REGEXP(this) && constructor === GlobalRegExp) { if (IS_REGEXP(this) && constructor === GlobalRegExp) {
exec = this.exec; exec = this.exec;
@ -869,12 +862,8 @@ function RegExpSubclassReplace(string, replace) {
this.lastIndex = 0; this.lastIndex = 0;
} }
// TODO(adamk): this fast path is wrong with respect to this.global // TODO(adamk): this fast path is wrong as we doesn't ensure that 'exec'
// and this.sticky, but hopefully the spec will remove those gets // is actually a data property on RegExp.prototype.
// and thus make the assumption of 'exec' having no side-effects
// more correct. Also, we doesn't ensure that 'exec' is actually
// a data property on RegExp.prototype, nor does the fast path
// correctly handle lastIndex setting.
var exec; var exec;
if (IS_REGEXP(this)) { if (IS_REGEXP(this)) {
exec = this.exec; exec = this.exec;
@ -1035,7 +1024,6 @@ function RegExpGetFlags() {
// ES6 21.2.5.4. // ES6 21.2.5.4.
function RegExpGetGlobal() { function RegExpGetGlobal() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// TODO(littledan): Remove this RegExp compat workaround
if (this === GlobalRegExpPrototype) { if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeOldFlagGetter); %IncrementUseCounter(kRegExpPrototypeOldFlagGetter);
return UNDEFINED; return UNDEFINED;
@ -1050,7 +1038,6 @@ function RegExpGetGlobal() {
// ES6 21.2.5.5. // ES6 21.2.5.5.
function RegExpGetIgnoreCase() { function RegExpGetIgnoreCase() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// TODO(littledan): Remove this RegExp compat workaround
if (this === GlobalRegExpPrototype) { if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeOldFlagGetter); %IncrementUseCounter(kRegExpPrototypeOldFlagGetter);
return UNDEFINED; return UNDEFINED;
@ -1064,7 +1051,6 @@ function RegExpGetIgnoreCase() {
// ES6 21.2.5.7. // ES6 21.2.5.7.
function RegExpGetMultiline() { function RegExpGetMultiline() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// TODO(littledan): Remove this RegExp compat workaround
if (this === GlobalRegExpPrototype) { if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeOldFlagGetter); %IncrementUseCounter(kRegExpPrototypeOldFlagGetter);
return UNDEFINED; return UNDEFINED;
@ -1078,7 +1064,6 @@ function RegExpGetMultiline() {
// ES6 21.2.5.10. // ES6 21.2.5.10.
function RegExpGetSource() { function RegExpGetSource() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// TODO(littledan): Remove this RegExp compat workaround
if (this === GlobalRegExpPrototype) { if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeSourceGetter); %IncrementUseCounter(kRegExpPrototypeSourceGetter);
return "(?:)"; return "(?:)";
@ -1092,8 +1077,6 @@ function RegExpGetSource() {
// ES6 21.2.5.12. // ES6 21.2.5.12.
function RegExpGetSticky() { function RegExpGetSticky() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// Compat fix: RegExp.prototype.sticky == undefined; UseCounter tracks it
// TODO(littledan): Remove this workaround or standardize it
if (this === GlobalRegExpPrototype) { if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeStickyGetter); %IncrementUseCounter(kRegExpPrototypeStickyGetter);
return UNDEFINED; return UNDEFINED;
@ -1108,7 +1091,6 @@ function RegExpGetSticky() {
// ES6 21.2.5.15. // ES6 21.2.5.15.
function RegExpGetUnicode() { function RegExpGetUnicode() {
if (!IS_REGEXP(this)) { if (!IS_REGEXP(this)) {
// TODO(littledan): Remove this RegExp compat workaround
if (this === GlobalRegExpPrototype) { if (this === GlobalRegExpPrototype) {
%IncrementUseCounter(kRegExpPrototypeUnicodeGetter); %IncrementUseCounter(kRegExpPrototypeUnicodeGetter);
return UNDEFINED; return UNDEFINED;
@ -1171,6 +1153,9 @@ var RegExpSetInput = function(string) {
// InstallGetterSetter had a bug which ignored the passed attributes and // InstallGetterSetter had a bug which ignored the passed attributes and
// simply installed as DONT_ENUM instead. We might want to change back // simply installed as DONT_ENUM instead. We might want to change back
// to the intended attributes at some point. // to the intended attributes at some point.
// On the other hand, installing attributes as DONT_ENUM matches the draft
// specification at
// https://github.com/claudepache/es-regexp-legacy-static-properties
%OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22); %OptimizeObjectForAddingMultipleProperties(GlobalRegExp, 22);
utils.InstallGetterSetter(GlobalRegExp, 'input', RegExpGetInput, RegExpSetInput, utils.InstallGetterSetter(GlobalRegExp, 'input', RegExpGetInput, RegExpSetInput,

View File

@ -100,15 +100,11 @@
'language/asi/S7.9_A5.7_T1': [PASS, FAIL_OK], 'language/asi/S7.9_A5.7_T1': [PASS, FAIL_OK],
###### BEGIN REGEXP SUBCLASSING SECTION ###### ###### BEGIN REGEXP SUBCLASSING SECTION ######
# Times out # https://bugs.chromium.org/p/v8/issues/detail?id=5361
'built-ins/RegExp/prototype/Symbol.match/coerce-global': [SKIP],
# Sticky support busted
'built-ins/RegExp/prototype/Symbol.replace/y-init-lastindex': [FAIL], 'built-ins/RegExp/prototype/Symbol.replace/y-init-lastindex': [FAIL],
'built-ins/RegExp/prototype/Symbol.replace/y-set-lastindex': [FAIL], 'built-ins/RegExp/prototype/Symbol.replace/y-set-lastindex': [FAIL],
# https://code.google.com/p/v8/issues/detail?id=4504 # https://bugs.chromium.org/p/v8/issues/detail?id=5360
# https://bugs.chromium.org/p/chromium/issues/detail?id=624318
'built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err': [PASS, FAIL], 'built-ins/RegExp/prototype/Symbol.match/builtin-failure-set-lastindex-err': [PASS, FAIL],
'built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err': [PASS, FAIL], 'built-ins/RegExp/prototype/Symbol.match/builtin-failure-y-set-lastindex-err': [PASS, FAIL],
'built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err': [SKIP], 'built-ins/RegExp/prototype/Symbol.match/builtin-success-g-set-lastindex-err': [SKIP],
@ -123,10 +119,6 @@
'built-ins/RegExp/prototype/exec/y-fail-lastindex-no-write': [PASS, FAIL], 'built-ins/RegExp/prototype/exec/y-fail-lastindex-no-write': [PASS, FAIL],
'built-ins/RegExp/prototype/test/y-fail-lastindex-no-write': [PASS, FAIL], 'built-ins/RegExp/prototype/test/y-fail-lastindex-no-write': [PASS, FAIL],
# SKIP rather than FAIL, as the test checks for an exception which
# happens to be thrown for some other reason.
'built-ins/RegExp/prototype/Symbol.split/str-result-get-length-err': [SKIP],
# https://bugs.chromium.org/p/v8/issues/detail?id=5123 # https://bugs.chromium.org/p/v8/issues/detail?id=5123
'built-ins/RegExp/prototype/Symbol.replace/coerce-global': [FAIL], 'built-ins/RegExp/prototype/Symbol.replace/coerce-global': [FAIL],
'built-ins/RegExp/prototype/Symbol.replace/coerce-unicode': [FAIL], 'built-ins/RegExp/prototype/Symbol.replace/coerce-unicode': [FAIL],