Ignore:
Timestamp:
Apr 6, 2016, 8:17:58 PM (9 years ago)
Author:
[email protected]
Message:

String.prototype.match() should be calling internal function RegExpCreate.
https://bugs.webkit.org/show_bug.cgi?id=156318

Reviewed by Filip Pizlo.

RegExpCreate is not the same as the RegExp constructor. The current implementation
invokes new @RegExp which calls the constructor. This results in failures in
es6/Proxy_internal_get_calls_String.prototype.match.js, and
es6/Proxy_internal_get_calls_String.prototype.search.js due to observable side
effects.

This patch fixes this by factoring out the part of the RegExp constructor that
makes the RegExpCreate function, and changing String's match and search to call
RegExpCreate instead in accordance with the ES6 spec.

  • builtins/StringPrototype.js:

(match):
(search):

  • runtime/CommonIdentifiers.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/RegExpConstructor.cpp:

(JSC::toFlags):
(JSC::regExpCreate):
(JSC::constructRegExp):
(JSC::esSpecRegExpCreate):
(JSC::constructWithRegExpConstructor):

  • runtime/RegExpConstructor.h:

(JSC::isRegExp):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/builtins/StringPrototype.js

    r198838 r199144  
    22 * Copyright (C) 2015 Andy VanWagoner <[email protected]>.
    33 * Copyright (C) 2016 Yusuke Suzuki <[email protected]>
     4 * Copyright (C) 2016 Apple Inc. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    4243
    4344    let thisString = @toString(this);
    44     let createdRegExp = new @RegExp(regexp, @undefined);
     45    let createdRegExp = @regExpCreate(regexp, @undefined);
    4546    return createdRegExp[@symbolMatch](thisString);
    4647}
     
    6364
    6465    var thisString = @toString(this);
    65     var createdRegExp = new @RegExp(regexp, @undefined);
     66    var createdRegExp = @regExpCreate(regexp, @undefined);
    6667    return createdRegExp[@symbolSearch](thisString);
    6768}
Note: See TracChangeset for help on using the changeset viewer.