Changeset 198447 in webkit


Ignore:
Timestamp:
Mar 18, 2016, 4:14:34 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

ES6 spec requires that RegExpPrototype not be a RegExp object.
https://bugs.webkit.org/show_bug.cgi?id=155654

Reviewed by Filip Pizlo.

Source/JavaScriptCore:

The ES6 spec states that RegExp.prototype should not be an instance of RegExp:
https://tc39.github.io/ecma262/#sec-properties-of-the-regexp-prototype-object

"The RegExp prototype object is an ordinary object. It is not a RegExp instance
and does not have a RegExpMatcher internal slot or any of the other internal
slots of RegExp instance objects."

This patch changes RegExpPrototype to conform to the above specifications.

  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/RegExpConstructor.cpp:

(JSC::RegExpConstructor::RegExpConstructor):
(JSC::RegExpConstructor::finishCreation):

  • runtime/RegExpPrototype.cpp:

(JSC::RegExpPrototype::RegExpPrototype):
(JSC::RegExpPrototype::finishCreation):
(JSC::RegExpPrototype::getOwnPropertySlot):
(JSC::RegExpPrototype::visitChildren):
(JSC::regExpProtoFuncTest):

  • runtime/RegExpPrototype.h:

(JSC::RegExpPrototype::create):
(JSC::RegExpPrototype::createStructure):
(JSC::RegExpPrototype::emptyRegExp):

  • tests/es6.yaml:
  • This patch makes the es6/miscellaneous_built-in_prototypes_are_not_instances.js test now pass. However, the kangax version of this test still fails because it also checks Error objects (which will be fixed in a subsequent patch).
  • tests/mozilla/ecma_2/shell.js:

(stringify):
(test):
(getFailedCases):
(err):

  • tests/stress/static-getter-in-names.js:

(shouldBe):

LayoutTests:

Rebase all the test results.

  • fast/regex/script-tests/toString.js:
  • fast/regex/toString-expected.txt:
  • ietestcenter/Javascript/15.10.6-expected.txt:
  • ietestcenter/Javascript/15.10.7.1-1-expected.txt:
  • ietestcenter/Javascript/15.10.7.2-1-expected.txt:
  • ietestcenter/Javascript/15.10.7.3-1-expected.txt:
  • ietestcenter/Javascript/15.10.7.4-1-expected.txt:
  • ietestcenter/Javascript/15.10.7.5-1-expected.txt:
  • ietestcenter/Javascript/TestCases/15.10.6.js:

(ES5Harness.registerTest.test):

  • ietestcenter/Javascript/TestCases/15.10.7.1-1.js:

(ES5Harness.registerTest.test):

  • ietestcenter/Javascript/TestCases/15.10.7.2-1.js:

(ES5Harness.registerTest.test):

  • ietestcenter/Javascript/TestCases/15.10.7.3-1.js:

(ES5Harness.registerTest.test):

  • ietestcenter/Javascript/TestCases/15.10.7.4-1.js:

(ES5Harness.registerTest.test):

  • ietestcenter/Javascript/TestCases/15.10.7.5-1.js:

(ES5Harness.registerTest.test):

  • js/Object-getOwnPropertyNames-expected.txt:
  • js/kde/RegExp-expected.txt:
  • js/kde/script-tests/RegExp.js:
  • js/script-tests/Object-getOwnPropertyNames.js:
  • sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/S15.10.6_A2-expected.txt:
Location:
trunk
Files:
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r198439 r198447  
     12016-03-18  Mark Lam  <mark.lam@apple.com>
     2
     3        ES6 spec requires that RegExpPrototype not be a RegExp object.
     4        https://bugs.webkit.org/show_bug.cgi?id=155654
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Rebase all the test results.
     9
     10        * fast/regex/script-tests/toString.js:
     11        * fast/regex/toString-expected.txt:
     12        * ietestcenter/Javascript/15.10.6-expected.txt:
     13        * ietestcenter/Javascript/15.10.7.1-1-expected.txt:
     14        * ietestcenter/Javascript/15.10.7.2-1-expected.txt:
     15        * ietestcenter/Javascript/15.10.7.3-1-expected.txt:
     16        * ietestcenter/Javascript/15.10.7.4-1-expected.txt:
     17        * ietestcenter/Javascript/15.10.7.5-1-expected.txt:
     18        * ietestcenter/Javascript/TestCases/15.10.6.js:
     19        (ES5Harness.registerTest.test):
     20        * ietestcenter/Javascript/TestCases/15.10.7.1-1.js:
     21        (ES5Harness.registerTest.test):
     22        * ietestcenter/Javascript/TestCases/15.10.7.2-1.js:
     23        (ES5Harness.registerTest.test):
     24        * ietestcenter/Javascript/TestCases/15.10.7.3-1.js:
     25        (ES5Harness.registerTest.test):
     26        * ietestcenter/Javascript/TestCases/15.10.7.4-1.js:
     27        (ES5Harness.registerTest.test):
     28        * ietestcenter/Javascript/TestCases/15.10.7.5-1.js:
     29        (ES5Harness.registerTest.test):
     30        * js/Object-getOwnPropertyNames-expected.txt:
     31        * js/kde/RegExp-expected.txt:
     32        * js/kde/script-tests/RegExp.js:
     33        * js/script-tests/Object-getOwnPropertyNames.js:
     34        * sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/S15.10.6_A2-expected.txt:
     35
    1362016-03-18  Brent Fulgham  <bfulgham@apple.com>
    237
  • trunk/LayoutTests/fast/regex/script-tests/toString.js

    r109275 r198447  
    2020shouldBe("RegExp('/').source", '"\\\\/"');
    2121shouldBe("RegExp('').source", '"(?:)"');
    22 shouldBe("RegExp.prototype.source", '"(?:)"');
     22shouldThrow("RegExp.prototype.source", '"TypeError: Type error"');
    2323
    2424shouldBe("RegExp('/').toString()", '"/\\\\//"');
    2525shouldBe("RegExp('').toString()", '"/(?:)/"');
    26 shouldBe("RegExp.prototype.toString()", '"/(?:)/"');
     26shouldThrow("RegExp.prototype.toString()", '"TypeError: Type error"');
    2727
    2828// These strings are equivalent, since the '\' is identity escaping the '/' at the string level.
  • trunk/LayoutTests/fast/regex/toString-expected.txt

    r109275 r198447  
    66PASS RegExp('/').source is "\\/"
    77PASS RegExp('').source is "(?:)"
    8 PASS RegExp.prototype.source is "(?:)"
     8PASS RegExp.prototype.source threw exception TypeError: Type error.
    99PASS RegExp('/').toString() is "/\\//"
    1010PASS RegExp('').toString() is "/(?:)/"
    11 PASS RegExp.prototype.toString() is "/(?:)/"
     11PASS RegExp.prototype.toString() threw exception TypeError: Type error.
    1212PASS testForwardSlash("^/$", "/"); is true
    1313PASS testForwardSlash("^/$", "/"); is true
  • trunk/LayoutTests/ietestcenter/Javascript/15.10.6-expected.txt

    r62864 r198447  
    1 15.10.6 (TestCases/chapter15/15.10/15.10.6/15.10.6.js) RegExp.prototype is itself a RegExp
     115.10.6 (TestCases/chapter15/15.10/15.10.6/15.10.6.js) RegExp.prototype is not a RegExp
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/ietestcenter/Javascript/15.10.7.1-1-expected.txt

    r62864 r198447  
    1 15.10.7.1-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js) RegExp.prototype.source is of type String
     115.10.7.1-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js) RegExp.prototype.source should throw because RegExp.prototype is not a RegExp
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/ietestcenter/Javascript/15.10.7.2-1-expected.txt

    r62864 r198447  
    1 15.10.7.2-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.2/15.10.7.2-1.js) RegExp.prototype.global is of type Boolean
     115.10.7.2-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.2/15.10.7.2-1.js) RegExp.prototype.global should throw because RegExp.prototype is not a RegExp
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/ietestcenter/Javascript/15.10.7.3-1-expected.txt

    r62864 r198447  
    1 15.10.7.3-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.3/15.10.7.3-1.js) RegExp.prototype.ignoreCase is of type Boolean
     115.10.7.3-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.3/15.10.7.3-1.js) RegExp.prototype.ignoreCase should throw because RegExp.prototype is not a RegExp
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/ietestcenter/Javascript/15.10.7.4-1-expected.txt

    r62864 r198447  
    1 15.10.7.4-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.4/15.10.7.4-1.js) RegExp.prototype.multiline is of type Boolean
     115.10.7.4-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.4/15.10.7.4-1.js) RegExp.prototype.multiline should throw because RegExp.prototype is not a RegExp
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/ietestcenter/Javascript/15.10.7.5-1-expected.txt

    r62864 r198447  
    1 15.10.7.5-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.5/15.10.7.5-1.js) RegExp.prototype.lastIndex is of type Number
     115.10.7.5-1 (TestCases/chapter15/15.10/15.10.7/15.10.7.5/15.10.7.5-1.js) RegExp.prototype.lastIndex is undefined because RegExp.prototype is not a RegExp
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
  • trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.6.js

    r62810 r198447  
    2525path: "TestCases/chapter15/15.10/15.10.6/15.10.6.js",
    2626
    27 description: "RegExp.prototype is itself a RegExp",
     27description: "RegExp.prototype is not a RegExp",
    2828
    2929test: function testcase() {
    3030  var s = Object.prototype.toString.call(RegExp.prototype);
    31   if (s === '[object RegExp]') {
     31  if (s === '[object Object]') {
    3232    return true;
    3333  }
  • trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.1-1.js

    r62810 r198447  
    2525path: "TestCases/chapter15/15.10/15.10.7/15.10.7.1/15.10.7.1-1.js",
    2626
    27 description: "RegExp.prototype.source is of type String",
     27description: "RegExp.prototype.source should throw because RegExp.prototype is not a RegExp",
    2828
    2929test: function testcase() {
    30   if((typeof(RegExp.prototype.source)) === 'string')
    31     return true;
     30    try {
     31        RegExp.prototype.source;
     32        return false;
     33    } catch (e) {
     34        return true;
     35    }
    3236 }
    3337});
  • trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.2-1.js

    r62810 r198447  
    2525path: "TestCases/chapter15/15.10/15.10.7/15.10.7.2/15.10.7.2-1.js",
    2626
    27 description: "RegExp.prototype.global is of type Boolean",
     27description: "RegExp.prototype.global should throw because RegExp.prototype is not a RegExp",
    2828
    2929test: function testcase() {
    30   if((typeof(RegExp.prototype.global)) === 'boolean')
    31     return true;
     30    try {
     31        RegExp.prototype.global;
     32        return false;
     33    } catch (e) {
     34        return true;
     35    }
    3236 }
    3337});
  • trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.3-1.js

    r62810 r198447  
    2525path: "TestCases/chapter15/15.10/15.10.7/15.10.7.3/15.10.7.3-1.js",
    2626
    27 description: "RegExp.prototype.ignoreCase is of type Boolean",
     27description: "RegExp.prototype.ignoreCase should throw because RegExp.prototype is not a RegExp",
    2828
    2929test: function testcase() {
    30   if((typeof(RegExp.prototype.ignoreCase)) === 'boolean')
    31     return true;
     30    try {
     31        RegExp.prototype.ignoreCase;
     32        return false;
     33    } catch (e) {
     34        return true;
     35    }
    3236 }
    3337});
  • trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.4-1.js

    r62810 r198447  
    2525path: "TestCases/chapter15/15.10/15.10.7/15.10.7.4/15.10.7.4-1.js",
    2626
    27 description: "RegExp.prototype.multiline is of type Boolean",
     27description: "RegExp.prototype.multiline should throw because RegExp.prototype is not a RegExp",
    2828
    2929test: function testcase() {
    30   if((typeof(RegExp.prototype.multiline)) === 'boolean')
    31     return true;
     30    try {
     31        RegExp.prototype.multiline;
     32        return false;
     33    } catch (e) {
     34        return true;
     35    }
    3236 }
    3337});
  • trunk/LayoutTests/ietestcenter/Javascript/TestCases/15.10.7.5-1.js

    r62810 r198447  
    2525path: "TestCases/chapter15/15.10/15.10.7/15.10.7.5/15.10.7.5-1.js",
    2626
    27 description: "RegExp.prototype.lastIndex is of type Number",
     27description: "RegExp.prototype.lastIndex is undefined because RegExp.prototype is not a RegExp",
    2828
    2929test: function testcase() {
    30   if((typeof(RegExp.prototype.lastIndex)) === 'number')
     30  if((typeof(RegExp.prototype.lastIndex)) === 'undefined')
    3131    return true;
    3232 }
  • trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt

    r197869 r198447  
    5757PASS getSortedOwnPropertyNames(Date.prototype) is ['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf']
    5858PASS getSortedOwnPropertyNames(RegExp) is ['$&', "$'", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext']
    59 PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'sticky', 'test', 'toString', 'unicode']
     59PASS getSortedOwnPropertyNames(RegExp.prototype) is ['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'multiline', 'source', 'sticky', 'test', 'toString', 'unicode']
    6060PASS getSortedOwnPropertyNames(Error) is ['length', 'name', 'prototype']
    6161PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString']
  • trunk/LayoutTests/js/kde/RegExp-expected.txt

    r109275 r198447  
    9191PASS /\u0061/.source is '\\u0061'
    9292PASS 'abc'.match(/\u0062/).toString() is 'b'
    93 PASS Object.prototype.toString.apply(RegExp.prototype) is '[object RegExp]'
    94 PASS typeof RegExp.prototype.toString() is 'string'
     93PASS Object.prototype.toString.apply(RegExp.prototype) is '[object Object]'
     94PASS RegExp.prototype.toString() threw exception TypeError: Type error.
    9595PASS new RegExp().toString() is '/(?:)/'
    9696PASS (new RegExp('(?:)')).source is '(?:)'
  • trunk/LayoutTests/js/kde/script-tests/RegExp.js

    r109275 r198447  
    144144
    145145shouldBe("Object.prototype.toString.apply(RegExp.prototype)",
    146          "'[object RegExp]'");
     146         "'[object Object]'");
    147147
    148148// not sure what this should return. most importantly
    149149// it doesn't throw an exception
    150 shouldBe("typeof RegExp.prototype.toString()", "'string'");
     150shouldThrow("RegExp.prototype.toString()", "'TypeError: Type error'");
    151151
    152152// Empty regular expressions have string representation /(?:)/
  • trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js

    r197869 r198447  
    6666    "Date.prototype": "['constructor', 'getDate', 'getDay', 'getFullYear', 'getHours', 'getMilliseconds', 'getMinutes', 'getMonth', 'getSeconds', 'getTime', 'getTimezoneOffset', 'getUTCDate', 'getUTCDay', 'getUTCFullYear', 'getUTCHours', 'getUTCMilliseconds', 'getUTCMinutes', 'getUTCMonth', 'getUTCSeconds', 'getYear', 'setDate', 'setFullYear', 'setHours', 'setMilliseconds', 'setMinutes', 'setMonth', 'setSeconds', 'setTime', 'setUTCDate', 'setUTCFullYear', 'setUTCHours', 'setUTCMilliseconds', 'setUTCMinutes', 'setUTCMonth', 'setUTCSeconds', 'setYear', 'toDateString', 'toGMTString', 'toISOString', 'toJSON', 'toLocaleDateString', 'toLocaleString', 'toLocaleTimeString', 'toString', 'toTimeString', 'toUTCString', 'valueOf']",
    6767    "RegExp": "['$&', \"$'\", '$*', '$+', '$1', '$2', '$3', '$4', '$5', '$6', '$7', '$8', '$9', '$_', '$`', 'input', 'lastMatch', 'lastParen', 'leftContext', 'length', 'multiline', 'name', 'prototype', 'rightContext']",
    68     "RegExp.prototype": "['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'lastIndex', 'multiline', 'source', 'sticky', 'test', 'toString', 'unicode']",
     68    "RegExp.prototype": "['compile', 'constructor', 'exec', 'flags', 'global', 'ignoreCase', 'multiline', 'source', 'sticky', 'test', 'toString', 'unicode']",
    6969    "Error": "['length', 'name', 'prototype']",
    7070    "Error.prototype": "['constructor', 'message', 'name', 'toString']",
  • trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.10_RegExp/15.10.6/S15.10.6_A2-expected.txt

    r62864 r198447  
    11S15.10.6_A2
    22
    3 FAIL SputnikError: #1: RegExp.prototype.toString = Object.prototype.toString; RegExp.prototype.toString() === "[object " + "Object" + "]". Actual: [object RegExp]
     3PASS
    44
    55TEST COMPLETE
  • trunk/Source/JavaScriptCore/ChangeLog

    r198435 r198447  
     12016-03-18  Mark Lam  <mark.lam@apple.com>
     2
     3        ES6 spec requires that RegExpPrototype not be a RegExp object.
     4        https://bugs.webkit.org/show_bug.cgi?id=155654
     5
     6        Reviewed by Filip Pizlo.
     7
     8        The ES6 spec states that RegExp.prototype should not be an instance of RegExp:
     9        https://tc39.github.io/ecma262/#sec-properties-of-the-regexp-prototype-object
     10
     11        "The RegExp prototype object is an ordinary object. It is not a RegExp instance
     12        and does not have a [[RegExpMatcher]] internal slot or any of the other internal
     13        slots of RegExp instance objects."
     14
     15        This patch changes RegExpPrototype to conform to the above specifications.
     16
     17        * runtime/JSGlobalObject.cpp:
     18        (JSC::JSGlobalObject::init):
     19        * runtime/RegExpConstructor.cpp:
     20        (JSC::RegExpConstructor::RegExpConstructor):
     21        (JSC::RegExpConstructor::finishCreation):
     22        * runtime/RegExpPrototype.cpp:
     23        (JSC::RegExpPrototype::RegExpPrototype):
     24        (JSC::RegExpPrototype::finishCreation):
     25        (JSC::RegExpPrototype::getOwnPropertySlot):
     26        (JSC::RegExpPrototype::visitChildren):
     27        (JSC::regExpProtoFuncTest):
     28        * runtime/RegExpPrototype.h:
     29        (JSC::RegExpPrototype::create):
     30        (JSC::RegExpPrototype::createStructure):
     31        (JSC::RegExpPrototype::emptyRegExp):
     32
     33        * tests/es6.yaml:
     34        - This patch makes the es6/miscellaneous_built-in_prototypes_are_not_instances.js
     35          test now pass.  However, the kangax version of this test still fails because
     36          it also checks Error objects (which will be fixed in a subsequent patch).
     37
     38        * tests/mozilla/ecma_2/shell.js:
     39        (stringify):
     40        (test):
     41        (getFailedCases):
     42        (err):
     43        * tests/stress/static-getter-in-names.js:
     44        (shouldBe):
     45
    1462016-03-18  Keith Miller  <keith_miller@apple.com>
    247
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r198348 r198447  
    362362        m_arrayStructureForIndexingShapeDuringAllocation[i] = m_originalArrayStructureForIndexingShape[i];
    363363
    364     RegExp* emptyRegex = RegExp::create(vm, "", NoFlags);
    365    
    366     m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get()), emptyRegex));
     364    m_regExpPrototype.set(vm, this, RegExpPrototype::create(vm, this, RegExpPrototype::createStructure(vm, this, m_objectPrototype.get())));
    367365    m_regExpStructure.set(vm, this, RegExpObject::createStructure(vm, this, m_regExpPrototype.get()));
    368366    m_regExpMatchesArrayStructure.set(vm, this, createRegExpMatchesArrayStructure(vm, this));
  • trunk/Source/JavaScriptCore/runtime/RegExpConstructor.cpp

    r198023 r198447  
    8787RegExpConstructor::RegExpConstructor(VM& vm, Structure* structure, RegExpPrototype* regExpPrototype)
    8888    : InternalFunction(vm, structure)
    89     , m_cachedResult(vm, this, regExpPrototype->regExp())
     89    , m_cachedResult(vm, this, regExpPrototype->emptyRegExp())
    9090    , m_multiline(false)
    9191{
     
    9494void RegExpConstructor::finishCreation(VM& vm, RegExpPrototype* regExpPrototype, GetterSetter* speciesSymbol)
    9595{
    96     Base::finishCreation(vm, regExpPrototype->classInfo()->className);
     96    Base::finishCreation(vm, ASCIILiteral("RegExp"));
    9797    ASSERT(inherits(info()));
    9898
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp

    r197999 r198447  
    6060namespace JSC {
    6161
    62 const ClassInfo RegExpPrototype::s_info = { "RegExp", &RegExpObject::s_info, &regExpPrototypeTable, CREATE_METHOD_TABLE(RegExpPrototype) };
     62const ClassInfo RegExpPrototype::s_info = { "Object", &Base::s_info, &regExpPrototypeTable, CREATE_METHOD_TABLE(RegExpPrototype) };
    6363
    6464/* Source for RegExpPrototype.lut.h
     
    7878*/
    7979
    80 RegExpPrototype::RegExpPrototype(VM& vm, Structure* structure, RegExp* regExp)
    81     : RegExpObject(vm, structure, regExp)
     80RegExpPrototype::RegExpPrototype(VM& vm, Structure* structure)
     81    : JSNonFinalObject(vm, structure)
    8282{
    8383}
     
    8888    ASSERT(inherits(info()));
    8989    JSC_NATIVE_FUNCTION(vm.propertyNames->searchSymbol, regExpProtoFuncSearch, DontEnum, 1);
     90
     91    m_emptyRegExp.set(vm, this, RegExp::create(vm, "", NoFlags));
    9092}
    9193
     
    9395{
    9496    return getStaticFunctionSlot<Base>(exec, regExpPrototypeTable, jsCast<RegExpPrototype*>(object), propertyName, slot);
     97}
     98
     99void RegExpPrototype::visitChildren(JSCell* cell, SlotVisitor& visitor)
     100{
     101    RegExpPrototype* thisObject = jsCast<RegExpPrototype*>(cell);
     102    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
     103    Base::visitChildren(thisObject, visitor);
     104   
     105    visitor.append(&thisObject->m_emptyRegExp);
    95106}
    96107
  • trunk/Source/JavaScriptCore/runtime/RegExpPrototype.h

    r196498 r198447  
    11/*
    22 *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
    3  *  Copyright (C) 2003, 2007, 2008 Apple Inc. All Rights Reserved.
     3 *  Copyright (C) 2003, 2007-2008, 2016 Apple Inc. All Rights Reserved.
    44 *
    55 *  This library is free software; you can redistribute it and/or
     
    2222#define RegExpPrototype_h
    2323
    24 #include "RegExpObject.h"
    2524#include "JSObject.h"
     25#include "RegExp.h"
    2626
    2727namespace JSC {
    2828
    29 class RegExpPrototype : public RegExpObject {
     29class RegExpPrototype : public JSNonFinalObject {
    3030public:
    31     typedef RegExpObject Base;
     31    typedef JSNonFinalObject Base;
    3232    static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot;
    3333
    34     static RegExpPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
     34    static RegExpPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
    3535    {
    36         RegExpPrototype* prototype = new (NotNull, allocateCell<RegExpPrototype>(vm.heap)) RegExpPrototype(vm, structure, regExp);
     36        RegExpPrototype* prototype = new (NotNull, allocateCell<RegExpPrototype>(vm.heap)) RegExpPrototype(vm, structure);
    3737        prototype->finishCreation(vm, globalObject);
    3838        return prototype;
     
    4646    }
    4747
     48    JS_EXPORT_PRIVATE static void visitChildren(JSCell*, SlotVisitor&);
     49
     50    RegExp* emptyRegExp() const { return m_emptyRegExp.get(); }
     51
    4852protected:
    49     RegExpPrototype(VM&, Structure*, RegExp*);
     53    RegExpPrototype(VM&, Structure*);
    5054
    5155private:
    5256    void finishCreation(VM&, JSGlobalObject*);
    5357    static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
     58
     59    WriteBarrier<RegExp> m_emptyRegExp;
    5460};
    5561
  • trunk/Source/JavaScriptCore/tests/es6.yaml

    r198360 r198447  
    868868  cmd: runES6 :normal
    869869- path: es6/miscellaneous_built-in_prototypes_are_not_instances.js
    870   cmd: runES6 :fail
     870  cmd: runES6 :normal
    871871- path: es6/miscellaneous_function_length_is_configurable.js
    872872  cmd: runES6 :normal
  • trunk/Source/JavaScriptCore/tests/mozilla/ecma_2/shell.js

    r53061 r198447  
    4242var PASSED = " PASSED!"
    4343var FAILED = " FAILED! expected: ";
     44
     45function stringify(x) {
     46    let str;
     47    try {
     48        str = "" + x;
     49    } catch (e) {
     50        str = Object.prototype.toString.call(x);
     51    }
     52    return str;
     53}
    4454
    4555function test() {
     
    4959                            testcases[tc].actual,
    5060                            testcases[tc].description +" = "+
    51                             testcases[tc].actual );
     61                            stringify(testcases[tc].actual));
    5262
    5363        testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";
     
    168178  for ( var i = 0; i < testcases.length; i++ ) {
    169179     if ( ! testcases[i].passed ) {
    170         print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect );
     180        print( testcases[i].description +" = " +stringify(testcases[i].actual) +" expected: "+ stringify(testcases[i].expect));
    171181     }
    172182  }
     
    178188    writeTestCaseResult( testcases[tc].expect,
    179189                         testcases[tc].actual,
    180                          testcases[tc].description +" = "+ testcases[tc].actual +
     190                         testcases[tc].description +" = "+ stringify(testcases[tc].actual) +
    181191                         ": " + testcases[tc].reason );
    182192    stopTest();
     
    195205  for ( var     i =     0; i < testcases.length; i++ ) {
    196206         if     ( !     testcases[i].passed     ) {
    197                 writeLineToLog( testcases[i].description        +" = " +testcases[i].actual     +
    198                     " expected: "+      testcases[i].expect     );
     207                writeLineToLog( testcases[i].description        +" = " + stringify(testcases[i].actual) +
     208                    " expected: "+      stringify(testcases[i].expect));
    199209         }
    200210  }
  • trunk/Source/JavaScriptCore/tests/stress/static-getter-in-names.js

    r197869 r198447  
    44}
    55
    6 shouldBe(JSON.stringify(Object.getOwnPropertyNames(RegExp.prototype).sort()), '["compile","constructor","exec","flags","global","ignoreCase","lastIndex","multiline","source","sticky","test","toString","unicode"]');
     6shouldBe(JSON.stringify(Object.getOwnPropertyNames(RegExp.prototype).sort()), '["compile","constructor","exec","flags","global","ignoreCase","multiline","source","sticky","test","toString","unicode"]');
    77shouldBe(JSON.stringify(Object.getOwnPropertyNames(/Cocoa/).sort()), '["lastIndex"]');
Note: See TracChangeset for help on using the changeset viewer.