<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[198554] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/198554">198554</a></dd>
<dt>Author</dt> <dd>msaboff@apple.com</dd>
<dt>Date</dt> <dd>2016-03-22 14:42:06 -0700 (Tue, 22 Mar 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[ES6] Implement RegExp.prototype[@@match]
https://bugs.webkit.org/show_bug.cgi?id=155711
Reviewed by Filip Pizlo.
Source/JavaScriptCore:
Implemented ES6 spec for String.prototype.match and RegExp.prototype[@@match].
Implemented both as builtins, with String.prototype.match calling
RegExp.prototype[@@match].
For performance reasons, RegExp.prototype[@@match] has a C++ fast path when
RegExp.prototype.exec has not been overridden. This fast path,
RegExpObject::matchGlobal, was taken from the prior StringPrototype::match.
It only handles global matches.
Added new test, stress/regexp-match.js.
Updated various tests for changes exception string and now passing ES6 behavior.
* CMakeLists.txt:
* DerivedSources.make:
* JavaScriptCore.xcodeproj/project.pbxproj:
Added builtins/RegExpPrototype.js and eliminated RegExpPrototype.lut.h.
* builtins/RegExpPrototype.js: Added.
(match.advanceStringIndexUnicode): Helper.
(match): Implements RegExp.prototype[@@match].
* builtins/StringPrototype.js:
(match): Implements String.prototype.match.
* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
(JSC::BytecodeIntrinsicRegistry::lookup):
* bytecode/BytecodeIntrinsicRegistry.h:
* runtime/CommonIdentifiers.h:
Added Symbol.match and builtins @match and @exec.
* runtime/RegExpObject.cpp:
* runtime/RegExpObject.h:
* runtime/RegExpObjectInlines.h:
(JSC::RegExpObject::matchGlobal): Added.
(JSC::RegExpObject::advanceStringUnicode): Added helper.
* runtime/RegExpPrototype.cpp:
* runtime/RegExpPrototype.h:
(JSC::RegExpPrototype::RegExpPrototype):
(JSC::RegExpPrototype::finishCreation):
(JSC::RegExpPrototype::visitChildren):
(JSC::regExpProtoFuncMatchPrivate):
(JSC::RegExpPrototype::getOwnPropertySlot): Deleted.
(JSC::RegExpPrototype::create):
Restructured to create properties explicitly due to having two names for native regExpProtoFuncExec.
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
Made match a builtin.
Removed unused declaration of stringProtoFuncSearch() since it was made a builtin.
* tests/es6.yaml:
* tests/stress/regexp-match.js: Added.
(shouldBe):
(shouldThrow):
(errorKey.toString):
(primitive.of.primitives.shouldThrow):
(testRegExpMatch):
(testMatch):
(testBoth):
(alwaysUnmatch):
LayoutTests:
Updated tests for exception string changes and added Symbol.match.
* js/Object-getOwnPropertyNames-expected.txt:
* js/dom/string-prototype-properties-expected.txt:
* js/script-tests/Object-getOwnPropertyNames.js:
* sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt">trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsdomstringprototypepropertiesexpectedtxt">trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs">trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js</a></li>
<li><a href="#trunkLayoutTestssputnikConformance15_Native_Objects155_String1554155410_StringprototypematchS155410_A1_T3expectedtxt">trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreDerivedSourcesmake">trunk/Source/JavaScriptCore/DerivedSources.make</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsStringPrototypejs">trunk/Source/JavaScriptCore/builtins/StringPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeBytecodeIntrinsicRegistrycpp">trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeBytecodeIntrinsicRegistryh">trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpObjectcpp">trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpObjecth">trunk/Source/JavaScriptCore/runtime/RegExpObject.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpObjectInlinesh">trunk/Source/JavaScriptCore/runtime/RegExpObjectInlines.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpPrototypecpp">trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeRegExpPrototypeh">trunk/Source/JavaScriptCore/runtime/RegExpPrototype.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeStringPrototypecpp">trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6yaml">trunk/Source/JavaScriptCore/tests/es6.yaml</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCorebuiltinsRegExpPrototypejs">trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestsstressregexpmatchjs">trunk/Source/JavaScriptCore/tests/stress/regexp-match.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/LayoutTests/ChangeLog        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2016-03-22 Michael Saboff <msaboff@apple.com>
+
+ [ES6] Implement RegExp.prototype[@@match]
+ https://bugs.webkit.org/show_bug.cgi?id=155711
+
+ Reviewed by Filip Pizlo.
+
+ Updated tests for exception string changes and added Symbol.match.
+
+ * js/Object-getOwnPropertyNames-expected.txt:
+ * js/dom/string-prototype-properties-expected.txt:
+ * js/script-tests/Object-getOwnPropertyNames.js:
+ * sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt:
+
</ins><span class="cx"> 2016-03-22 Daniel Bates <dabates@apple.com>
</span><span class="cx">
</span><span class="cx"> CSP: Should only execute <script> or apply <style> if its hash appears in all policies
</span></span></pre></div>
<a id="trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> PASS getSortedOwnPropertyNames(Error.prototype) is ['constructor', 'message', 'name', 'toString']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Math) is ['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']
</span><span class="cx"> PASS getSortedOwnPropertyNames(JSON) is ['parse', 'stringify']
</span><del>-PASS getSortedOwnPropertyNames(Symbol) is ['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'search', 'species', 'toPrimitive', 'toStringTag', 'unscopables']
</del><ins>+PASS getSortedOwnPropertyNames(Symbol) is ['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'match', 'name', 'prototype', 'search', 'species', 'toPrimitive', 'toStringTag', 'unscopables']
</ins><span class="cx"> PASS getSortedOwnPropertyNames(Symbol.prototype) is ['constructor', 'toString', 'valueOf']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Map) is ['length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Map.prototype) is ['clear', 'constructor', 'delete', 'entries', 'forEach', 'get', 'has', 'keys', 'set', 'size', 'values']
</span></span></pre></div>
<a id="trunkLayoutTestsjsdomstringprototypepropertiesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/LayoutTests/js/dom/string-prototype-properties-expected.txt        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -10,7 +10,7 @@
</span><span class="cx"> PASS String.prototype.concat.call(undefined, 'five') threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.indexOf.call(undefined, '2') threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.lastIndexOf.call(undefined, '2') threw exception TypeError: Type error.
</span><del>-PASS String.prototype.match.call(undefined, /2+/) threw exception TypeError: Type error.
</del><ins>+PASS String.prototype.match.call(undefined, /2+/) threw exception TypeError: String.prototype.match requires that |this| not be undefined.
</ins><span class="cx"> PASS String.prototype.replace.call(undefined, /2+/, '-') threw exception TypeError: Type error.
</span><span class="cx"> PASS String.prototype.search.call(undefined, '4') threw exception TypeError: String.prototype.search requires that |this| not be undefined.
</span><span class="cx"> PASS String.prototype.slice.call(undefined, 1, 3) threw exception TypeError: Type error.
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx"> "Error.prototype": "['constructor', 'message', 'name', 'toString']",
</span><span class="cx"> "Math": "['E','LN10','LN2','LOG10E','LOG2E','PI','SQRT1_2','SQRT2','abs','acos','acosh','asin','asinh','atan','atan2','atanh','cbrt','ceil','clz32','cos','cosh','exp','expm1','floor','fround','hypot','imul','log','log10','log1p','log2','max','min','pow','random','round','sign','sin','sinh','sqrt','tan','tanh','trunc']",
</span><span class="cx"> "JSON": "['parse', 'stringify']",
</span><del>- "Symbol": "['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'name', 'prototype', 'search', 'species', 'toPrimitive', 'toStringTag', 'unscopables']",
</del><ins>+ "Symbol": "['for', 'hasInstance', 'iterator', 'keyFor', 'length', 'match', 'name', 'prototype', 'search', 'species', 'toPrimitive', 'toStringTag', 'unscopables']",
</ins><span class="cx"> "Symbol.prototype": "['constructor', 'toString', 'valueOf']",
</span><span class="cx"> "Map": "['length', 'name', 'prototype']",
</span><span class="cx"> "Map.prototype": "['clear', 'constructor', 'delete', 'entries', 'forEach', 'get', 'has', 'keys', 'set', 'size', 'values']",
</span></span></pre></div>
<a id="trunkLayoutTestssputnikConformance15_Native_Objects155_String1554155410_StringprototypematchS155410_A1_T3expectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.10_String.prototype.match/S15.5.4.10_A1_T3-expected.txt        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> S15.5.4.10_A1_T3
</span><span class="cx">
</span><del>-FAIL TypeError: Type error
</del><ins>+FAIL TypeError: String.prototype.match requires that |this| not be undefined
</ins><span class="cx">
</span><span class="cx"> TEST COMPLETE
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -1219,6 +1219,7 @@
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/PromiseOperations.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/PromisePrototype.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/ReflectObject.js
</span><ins>+ ${JAVASCRIPTCORE_DIR}/builtins/RegExpPrototype.js
</ins><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/SetPrototype.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/StringConstructor.js
</span><span class="cx"> ${JAVASCRIPTCORE_DIR}/builtins/StringIteratorPrototype.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -1,3 +1,73 @@
</span><ins>+2016-03-22 Michael Saboff <msaboff@apple.com>
+
+ [ES6] Implement RegExp.prototype[@@match]
+ https://bugs.webkit.org/show_bug.cgi?id=155711
+
+ Reviewed by Filip Pizlo.
+
+ Implemented ES6 spec for String.prototype.match and RegExp.prototype[@@match].
+ Implemented both as builtins, with String.prototype.match calling
+ RegExp.prototype[@@match].
+
+ For performance reasons, RegExp.prototype[@@match] has a C++ fast path when
+ RegExp.prototype.exec has not been overridden. This fast path,
+ RegExpObject::matchGlobal, was taken from the prior StringPrototype::match.
+ It only handles global matches.
+
+ Added new test, stress/regexp-match.js.
+
+ Updated various tests for changes exception string and now passing ES6 behavior.
+
+ * CMakeLists.txt:
+ * DerivedSources.make:
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ Added builtins/RegExpPrototype.js and eliminated RegExpPrototype.lut.h.
+
+ * builtins/RegExpPrototype.js: Added.
+ (match.advanceStringIndexUnicode): Helper.
+ (match): Implements RegExp.prototype[@@match].
+ * builtins/StringPrototype.js:
+ (match): Implements String.prototype.match.
+
+ * bytecode/BytecodeIntrinsicRegistry.cpp:
+ (JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
+ (JSC::BytecodeIntrinsicRegistry::lookup):
+ * bytecode/BytecodeIntrinsicRegistry.h:
+ * runtime/CommonIdentifiers.h:
+ Added Symbol.match and builtins @match and @exec.
+
+ * runtime/RegExpObject.cpp:
+ * runtime/RegExpObject.h:
+ * runtime/RegExpObjectInlines.h:
+ (JSC::RegExpObject::matchGlobal): Added.
+ (JSC::RegExpObject::advanceStringUnicode): Added helper.
+
+ * runtime/RegExpPrototype.cpp:
+ * runtime/RegExpPrototype.h:
+ (JSC::RegExpPrototype::RegExpPrototype):
+ (JSC::RegExpPrototype::finishCreation):
+ (JSC::RegExpPrototype::visitChildren):
+ (JSC::regExpProtoFuncMatchPrivate):
+ (JSC::RegExpPrototype::getOwnPropertySlot): Deleted.
+ (JSC::RegExpPrototype::create):
+ Restructured to create properties explicitly due to having two names for native regExpProtoFuncExec.
+
+ * runtime/StringPrototype.cpp:
+ (JSC::StringPrototype::finishCreation):
+ Made match a builtin.
+ Removed unused declaration of stringProtoFuncSearch() since it was made a builtin.
+
+ * tests/es6.yaml:
+ * tests/stress/regexp-match.js: Added.
+ (shouldBe):
+ (shouldThrow):
+ (errorKey.toString):
+ (primitive.of.primitives.shouldThrow):
+ (testRegExpMatch):
+ (testMatch):
+ (testBoth):
+ (alwaysUnmatch):
+
</ins><span class="cx"> 2016-03-22 Caitlin Potter <caitp@igalia.com>
</span><span class="cx">
</span><span class="cx"> [JSC] allow duplicate property names returned from Proxy ownKeys() trap
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreDerivedSourcesmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/DerivedSources.make (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/DerivedSources.make        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/DerivedSources.make        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -99,6 +99,7 @@
</span><span class="cx"> $(JavaScriptCore)/builtins/PromiseOperations.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/PromisePrototype.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/ReflectObject.js \
</span><ins>+ $(JavaScriptCore)/builtins/RegExpPrototype.js \
</ins><span class="cx"> $(JavaScriptCore)/builtins/SetPrototype.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/StringConstructor.js \
</span><span class="cx"> $(JavaScriptCore)/builtins/StringIteratorPrototype.js \
</span><span class="lines">@@ -147,7 +148,6 @@
</span><span class="cx"> ObjectConstructor.lut.h \
</span><span class="cx"> ReflectObject.lut.h \
</span><span class="cx"> RegExpConstructor.lut.h \
</span><del>- RegExpPrototype.lut.h \
</del><span class="cx"> SetPrototype.lut.h \
</span><span class="cx"> StringConstructor.lut.h \
</span><span class="cx"> StringIteratorPrototype.lut.h \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -1464,7 +1464,6 @@
</span><span class="cx">                 996B73211BDA08EF00331B84 /* NumberPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730D1BD9FA2C00331B84 /* NumberPrototype.lut.h */; };
</span><span class="cx">                 996B73221BDA08EF00331B84 /* ObjectConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730E1BD9FA2C00331B84 /* ObjectConstructor.lut.h */; };
</span><span class="cx">                 996B73231BDA08EF00331B84 /* ReflectObject.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */; };
</span><del>-                996B73241BDA08EF00331B84 /* RegExpPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73101BD9FA2C00331B84 /* RegExpPrototype.lut.h */; };
</del><span class="cx">                 996B73251BDA08EF00331B84 /* StringConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */; };
</span><span class="cx">                 996B73261BDA08EF00331B84 /* StringIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73121BD9FA2C00331B84 /* StringIteratorPrototype.lut.h */; };
</span><span class="cx">                 996B73271BDA08EF00331B84 /* SymbolConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = 996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */; };
</span><span class="lines">@@ -3355,6 +3354,7 @@
</span><span class="cx">                 6540C79F1B82D9CE000F6B79 /* RegisterAtOffset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegisterAtOffset.h; sourceTree = "<group>"; };
</span><span class="cx">                 6546F51F1A32A59C006F07D5 /* NullGetterFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = NullGetterFunction.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
</span><span class="cx">                 6546F5201A32A59C006F07D5 /* NullGetterFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullGetterFunction.h; sourceTree = "<group>"; };
</span><ins>+                654788421C937D2C000781A0 /* RegExpPrototype.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = RegExpPrototype.js; sourceTree = "<group>"; };
</ins><span class="cx">                 65525FC31A6DD3B3007B5495 /* NullSetterFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NullSetterFunction.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 65525FC41A6DD3B3007B5495 /* NullSetterFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NullSetterFunction.h; sourceTree = "<group>"; };
</span><span class="cx">                 6553A32F17A1F1EE008CF6F3 /* CommonSlowPathsExceptions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CommonSlowPathsExceptions.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -3669,7 +3669,6 @@
</span><span class="cx">                 996B730D1BD9FA2C00331B84 /* NumberPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NumberPrototype.lut.h; sourceTree = "<group>"; };
</span><span class="cx">                 996B730E1BD9FA2C00331B84 /* ObjectConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectConstructor.lut.h; sourceTree = "<group>"; };
</span><span class="cx">                 996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReflectObject.lut.h; sourceTree = "<group>"; };
</span><del>-                996B73101BD9FA2C00331B84 /* RegExpPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RegExpPrototype.lut.h; sourceTree = "<group>"; };
</del><span class="cx">                 996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConstructor.lut.h; sourceTree = "<group>"; };
</span><span class="cx">                 996B73121BD9FA2C00331B84 /* StringIteratorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringIteratorPrototype.lut.h; sourceTree = "<group>"; };
</span><span class="cx">                 996B73131BD9FA2C00331B84 /* SymbolConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolConstructor.lut.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -5370,7 +5369,6 @@
</span><span class="cx">                                 996B730F1BD9FA2C00331B84 /* ReflectObject.lut.h */,
</span><span class="cx">                                 BCD202D50E170708002C7E82 /* RegExpConstructor.lut.h */,
</span><span class="cx">                                 A718F61A11754A21002465A7 /* RegExpJitTables.h */,
</span><del>-                                996B73101BD9FA2C00331B84 /* RegExpPrototype.lut.h */,
</del><span class="cx">                                 7035587F1C418458004BD7BF /* SetPrototype.lut.h */,
</span><span class="cx">                                 996B73111BD9FA2C00331B84 /* StringConstructor.lut.h */,
</span><span class="cx">                                 996B73121BD9FA2C00331B84 /* StringIteratorPrototype.lut.h */,
</span><span class="lines">@@ -6843,6 +6841,7 @@
</span><span class="cx">                                 7CFBAC1C18B535E500D00750 /* PromisePrototype.js */,
</span><span class="cx">                                 7CF9BC5E1B65D9B1009DB1EF /* PromiseConstructor.js */,
</span><span class="cx">                                 7CF9BC5F1B65D9B1009DB1EF /* ReflectObject.js */,
</span><ins>+                                654788421C937D2C000781A0 /* RegExpPrototype.js */,
</ins><span class="cx">                                 7035587D1C418419004BD7BF /* SetPrototype.js */,
</span><span class="cx">                                 7CF9BC601B65D9B1009DB1EF /* StringConstructor.js */,
</span><span class="cx">                                 7CF9BC611B65D9B1009DB1EF /* StringIteratorPrototype.js */,
</span><span class="lines">@@ -7897,7 +7896,6 @@
</span><span class="cx">                                 A1712B4111C7B235007A5315 /* RegExpKey.h in Headers */,
</span><span class="cx">                                 BC18C45B0E16F5CD00B34460 /* RegExpObject.h in Headers */,
</span><span class="cx">                                 BCD202C40E1706A7002C7E82 /* RegExpPrototype.h in Headers */,
</span><del>-                                996B73241BDA08EF00331B84 /* RegExpPrototype.lut.h in Headers */,
</del><span class="cx">                                 BC18C45D0E16F5CD00B34460 /* Register.h in Headers */,
</span><span class="cx">                                 969A072B0ED1CE6900F1F681 /* RegisterID.h in Headers */,
</span><span class="cx">                                 623A37EC1B87A7C000754209 /* RegisterMap.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsRegExpPrototypejs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js (0 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js         (rev 0)
+++ trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -0,0 +1,89 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function match(str)
+{
+ "use strict";
+
+ function advanceStringIndexUnicode(string, stringLength, index)
+ {
+ if (index + 1 >= stringLength)
+ return index + 1;
+
+ let first = string.@charCodeAt(index);
+ if (first < 0xD800 || first > 0xDBFF)
+ return index + 1;
+
+ let second = string.@charCodeAt(index + 1);
+ if (second < 0xDC00 || second > 0xDFFF)
+ return index + 1;
+
+ return index + 2;
+ }
+
+ if (!(this instanceof @Object))
+ throw new @TypeError("RegExp.prototype.@@match requires that |this| be an Object");
+
+ let regexp = @Object(this);
+ let stringArg = @toString(str);
+
+ if (!regexp.global)
+ return regexp.exec(stringArg);
+
+ regexp.lastIndex = 0;
+
+ let resultList = [];
+
+ if (regexp.exec !== @RegExp.prototype.@exec && typeof(regexp.exec) === "function") {
+ // Match using the overridden exec.
+ let unicode = regexp.unicode;
+ let stringLength = str.length;
+
+ while (true) {
+ let result = regexp.exec(stringArg);
+
+ if (result === null) {
+ if (resultList.length === 0)
+ return null;
+ return resultList;
+ } else if (!@isObject(result))
+ throw new @TypeError("RegExp.prototype.@@match call to RegExp.exec didn't return null or an object");
+
+ let resultString = @toString(result[0]);
+
+ if (!resultString.length) {
+ if (unicode)
+ regexp.lastIndex = advanceStringIndexUnicode(stringArg, stringLength, regexp.lastIndex);
+ else
+ regexp.lastIndex++;
+ }
+
+ resultList.@push(resultString);
+ }
+ }
+
+ return regexp.@match(stringArg);
+}
+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsStringPrototypejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/builtins/StringPrototype.js (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/StringPrototype.js        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/builtins/StringPrototype.js        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -26,6 +26,27 @@
</span><span class="cx">
</span><span class="cx"> // @conditional=ENABLE(INTL)
</span><span class="cx">
</span><ins>+function match(regexp)
+{
+ "use strict";
+
+ if (this == null) {
+ if (this === null)
+ throw new @TypeError("String.prototype.match requires that |this| not be null");
+ throw new @TypeError("String.prototype.match requires that |this| not be undefined");
+ }
+
+ if (regexp != null) {
+ var matcher = regexp[@symbolMatch];
+ if (matcher !== @undefined)
+ return matcher.@call(regexp, this);
+ }
+
+ let thisString = @toString(this);
+ let createdRegExp = new @RegExp(regexp, @undefined);
+ return createdRegExp[@symbolMatch](thisString);
+}
+
</ins><span class="cx"> function search(regexp)
</span><span class="cx"> {
</span><span class="cx"> "use strict";
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeBytecodeIntrinsicRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx"> m_promiseStateFulfilled.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Fulfilled)));
</span><span class="cx"> m_promiseStateRejected.set(m_vm, jsNumber(static_cast<unsigned>(JSPromise::Status::Rejected)));
</span><span class="cx"> m_symbolIterator.set(m_vm, Symbol::create(m_vm, static_cast<SymbolImpl&>(*m_vm.propertyNames->iteratorSymbol.impl())));
</span><ins>+ m_symbolMatch.set(m_vm, Symbol::create(m_vm, static_cast<SymbolImpl&>(*m_vm.propertyNames->matchSymbol.impl())));
</ins><span class="cx"> m_symbolSearch.set(m_vm, Symbol::create(m_vm, static_cast<SymbolImpl&>(*m_vm.propertyNames->searchSymbol.impl())));
</span><span class="cx"> m_symbolSpecies.set(m_vm, Symbol::create(m_vm, static_cast<SymbolImpl&>(*m_vm.propertyNames->speciesSymbol.impl())));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeBytecodeIntrinsicRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -53,6 +53,7 @@
</span><span class="cx"> macro(promiseStateFulfilled) \
</span><span class="cx"> macro(promiseStateRejected) \
</span><span class="cx"> macro(symbolIterator) \
</span><ins>+ macro(symbolMatch) \
</ins><span class="cx"> macro(symbolSearch) \
</span><span class="cx"> macro(symbolSpecies)
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -274,13 +274,13 @@
</span><span class="cx">
</span><span class="cx"> #define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL_NOT_IMPLEMENTED_YET(macro)\
</span><span class="cx"> macro(isConcatSpreadable) \
</span><del>- macro(match) \
</del><span class="cx"> macro(replace) \
</span><del>- macro(split) \
</del><ins>+ macro(split)
</ins><span class="cx">
</span><span class="cx"> #define JSC_COMMON_PRIVATE_IDENTIFIERS_EACH_WELL_KNOWN_SYMBOL(macro) \
</span><span class="cx"> macro(hasInstance) \
</span><span class="cx"> macro(iterator) \
</span><ins>+ macro(match) \
</ins><span class="cx"> macro(search) \
</span><span class="cx"> macro(species) \
</span><span class="cx"> macro(toPrimitive) \
</span><span class="lines">@@ -352,6 +352,7 @@
</span><span class="cx"> macro(Uint32Array) \
</span><span class="cx"> macro(Float32Array) \
</span><span class="cx"> macro(Float64Array) \
</span><ins>+ macro(exec) \
</ins><span class="cx"> macro(generator) \
</span><span class="cx"> macro(generatorNext) \
</span><span class="cx"> macro(generatorState) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/RegExpObject.cpp        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -169,4 +169,65 @@
</span><span class="cx"> return matchInline(exec, globalObject, string);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+JSValue RegExpObject::matchGlobal(ExecState* exec, JSGlobalObject* globalObject, JSString* string)
+{
+ RegExp* regExp = this->regExp();
+
+ ASSERT(regExp->global());
+
+ VM* vm = &globalObject->vm();
+
+ setLastIndex(exec, 0);
+ if (exec->hadException())
+ return jsUndefined();
+
+ String s = string->value(exec);
+ RegExpConstructor* regExpConstructor = globalObject->regExpConstructor();
+ MatchResult result = regExpConstructor->performMatch(*vm, regExp, string, s, 0);
+
+ // return array of matches
+ MarkedArgumentBuffer list;
+ // We defend ourselves from crazy.
+ const size_t maximumReasonableMatchSize = 1000000000;
+
+ if (regExp->unicode()) {
+ while (result) {
+ if (list.size() > maximumReasonableMatchSize) {
+ throwOutOfMemoryError(exec);
+ return jsUndefined();
+ }
+
+ size_t end = result.end;
+ size_t length = end - result.start;
+ list.append(jsSubstring(exec, s, result.start, length));
+ if (!length)
+ end = advanceStringUnicode(s, length, end);
+ result = regExpConstructor->performMatch(*vm, regExp, string, s, end);
+ }
+ } else {
+ while (result) {
+ if (list.size() > maximumReasonableMatchSize) {
+ throwOutOfMemoryError(exec);
+ return jsUndefined();
+ }
+
+ size_t end = result.end;
+ size_t length = end - result.start;
+ list.append(jsSubstring(exec, s, result.start, length));
+ if (!length)
+ ++end;
+ result = regExpConstructor->performMatch(*vm, regExp, string, s, end);
+ }
+ }
+
+ if (list.isEmpty()) {
+ // if there are no matches at all, it's important to return
+ // Null instead of an empty array, because this matches
+ // other browsers and because Null is a false value.
+ return jsNull();
+ }
+
+ return constructArray(exec, static_cast<ArrayAllocationProfile*>(0), list);
+}
+
</ins><span class="cx"> } // namespace JSC
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpObjecth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpObject.h (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpObject.h        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/RegExpObject.h        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -70,6 +70,8 @@
</span><span class="cx"> bool testInline(ExecState* exec, JSGlobalObject* globalObject, JSString* string) { return !!matchInline(exec, globalObject, string); }
</span><span class="cx"> JSValue exec(ExecState*, JSGlobalObject*, JSString*);
</span><span class="cx"> JSValue execInline(ExecState*, JSGlobalObject*, JSString*);
</span><ins>+ MatchResult match(ExecState*, JSGlobalObject*, JSString*);
+ JSValue matchGlobal(ExecState*, JSGlobalObject*, JSString*);
</ins><span class="cx">
</span><span class="cx"> static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
</span><span class="cx"> static bool put(JSCell*, ExecState*, PropertyName, JSValue, PutPropertySlot&);
</span><span class="lines">@@ -102,9 +104,9 @@
</span><span class="cx"> JS_EXPORT_PRIVATE static void getPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
</span><span class="cx"> JS_EXPORT_PRIVATE static void getGenericPropertyNames(JSObject*, ExecState*, PropertyNameArray&, EnumerationMode);
</span><span class="cx"> JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
</span><ins>+ unsigned advanceStringUnicode(String, unsigned, unsigned);
</ins><span class="cx">
</span><span class="cx"> private:
</span><del>- MatchResult match(ExecState*, JSGlobalObject*, JSString*);
</del><span class="cx"> MatchResult matchInline(ExecState*, JSGlobalObject*, JSString*);
</span><span class="cx">
</span><span class="cx"> WriteBarrier<RegExp> m_regExp;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpObjectInlinesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpObjectInlines.h (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpObjectInlines.h        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/RegExpObjectInlines.h        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -108,6 +108,22 @@
</span><span class="cx"> return result;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+unsigned RegExpObject::advanceStringUnicode(String s, unsigned length, unsigned currentIndex)
+{
+ if (currentIndex + 1 >= length)
+ return currentIndex + 1;
+
+ UChar first = s[currentIndex];
+ if (first < 0xD800 || first > 0xDBFF)
+ return currentIndex + 1;
+
+ UChar second = s[currentIndex];
+ if (second < 0xDC00 || second > 0xDFFF)
+ return currentIndex + 1;
+
+ return currentIndex + 2;
+}
+
</ins><span class="cx"> } // namespace JSC
</span><span class="cx">
</span><span class="cx"> #endif // RegExpObjectInlines_h
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -22,8 +22,10 @@
</span><span class="cx"> #include "RegExpPrototype.h"
</span><span class="cx">
</span><span class="cx"> #include "ArrayPrototype.h"
</span><ins>+#include "BuiltinNames.h"
</ins><span class="cx"> #include "Error.h"
</span><span class="cx"> #include "JSArray.h"
</span><ins>+#include "JSCBuiltins.h"
</ins><span class="cx"> #include "JSCJSValue.h"
</span><span class="cx"> #include "JSFunction.h"
</span><span class="cx"> #include "JSObject.h"
</span><span class="lines">@@ -36,12 +38,14 @@
</span><span class="cx"> #include "RegExp.h"
</span><span class="cx"> #include "RegExpCache.h"
</span><span class="cx"> #include "RegExpConstructor.h"
</span><ins>+#include "RegExpMatchesArray.h"
</ins><span class="cx"> #include "StringRecursionChecker.h"
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoFuncTest(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoFuncExec(ExecState*);
</span><ins>+static EncodedJSValue JSC_HOST_CALL regExpProtoFuncMatchPrivate(ExecState*);
</ins><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoFuncToString(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoFuncSearch(ExecState*);
</span><span class="lines">@@ -53,30 +57,8 @@
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoGetterSource(ExecState*);
</span><span class="cx"> static EncodedJSValue JSC_HOST_CALL regExpProtoGetterFlags(ExecState*);
</span><span class="cx">
</span><del>-}
</del><ins>+const ClassInfo RegExpPrototype::s_info = { "Object", &Base::s_info, 0, CREATE_METHOD_TABLE(RegExpPrototype) };
</ins><span class="cx">
</span><del>-#include "RegExpPrototype.lut.h"
-
-namespace JSC {
-
-const ClassInfo RegExpPrototype::s_info = { "Object", &Base::s_info, &regExpPrototypeTable, CREATE_METHOD_TABLE(RegExpPrototype) };
-
-/* Source for RegExpPrototype.lut.h
-@begin regExpPrototypeTable
- compile regExpProtoFuncCompile DontEnum|Function 2
- exec regExpProtoFuncExec DontEnum|Function 1
- test regExpProtoFuncTest DontEnum|Function 1
- toString regExpProtoFuncToString DontEnum|Function 0
- global regExpProtoGetterGlobal DontEnum|Accessor
- ignoreCase regExpProtoGetterIgnoreCase DontEnum|Accessor
- multiline regExpProtoGetterMultiline DontEnum|Accessor
- sticky regExpProtoGetterSticky DontEnum|Accessor
- unicode regExpProtoGetterUnicode DontEnum|Accessor
- source regExpProtoGetterSource DontEnum|Accessor
- flags regExpProtoGetterFlags DontEnum|Accessor
-@end
-*/
-
</del><span class="cx"> RegExpPrototype::RegExpPrototype(VM& vm, Structure* structure)
</span><span class="cx"> : JSNonFinalObject(vm, structure)
</span><span class="cx"> {
</span><span class="lines">@@ -86,16 +68,27 @@
</span><span class="cx"> {
</span><span class="cx"> Base::finishCreation(vm);
</span><span class="cx"> ASSERT(inherits(info()));
</span><del>- JSC_NATIVE_FUNCTION(vm.propertyNames->searchSymbol, regExpProtoFuncSearch, DontEnum, 1);
</del><ins>+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->compile, regExpProtoFuncCompile, DontEnum, 2);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->test, regExpProtoFuncTest, DontEnum, 1);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->toString, regExpProtoFuncToString, DontEnum, 0);
+ JSC_NATIVE_GETTER(vm.propertyNames->global, regExpProtoGetterGlobal, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->ignoreCase, regExpProtoGetterIgnoreCase, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->multiline, regExpProtoGetterMultiline, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->sticky, regExpProtoGetterSticky, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->unicode, regExpProtoGetterUnicode, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->source, regExpProtoGetterSource, DontEnum | Accessor);
+ JSC_NATIVE_GETTER(vm.propertyNames->flags, regExpProtoGetterFlags, DontEnum | Accessor);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().matchPrivateName(), regExpProtoFuncMatchPrivate, DontEnum | DontDelete | ReadOnly, 1);
+ JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->matchSymbol, regExpPrototypeMatchCodeGenerator, DontEnum);
+ JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->searchSymbol, regExpProtoFuncSearch, DontEnum, 1);
</ins><span class="cx">
</span><ins>+ JSFunction* execFunction = JSFunction::create(vm, globalObject, 1, vm.propertyNames->exec.string(), regExpProtoFuncExec, RegExpExecIntrinsic);
+ putDirectWithoutTransition(vm, vm.propertyNames->execPrivateName, execFunction, DontEnum | DontDelete | ReadOnly);
+ putDirectWithoutTransition(vm, vm.propertyNames->exec, execFunction, DontEnum);
+
</ins><span class="cx"> m_emptyRegExp.set(vm, this, RegExp::create(vm, "", NoFlags));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool RegExpPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot &slot)
-{
- return getStaticFunctionSlot<Base>(exec, regExpPrototypeTable, jsCast<RegExpPrototype*>(object), propertyName, slot);
-}
-
</del><span class="cx"> void RegExpPrototype::visitChildren(JSCell* cell, SlotVisitor& visitor)
</span><span class="cx"> {
</span><span class="cx"> RegExpPrototype* thisObject = jsCast<RegExpPrototype*>(cell);
</span><span class="lines">@@ -129,6 +122,17 @@
</span><span class="cx"> return JSValue::encode(asRegExpObject(thisValue)->exec(exec, exec->lexicalGlobalObject(), string));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+EncodedJSValue JSC_HOST_CALL regExpProtoFuncMatchPrivate(ExecState* exec)
+{
+ JSValue thisValue = exec->thisValue();
+ if (!thisValue.inherits(RegExpObject::info()))
+ return throwVMTypeError(exec);
+ JSString* string = exec->argument(0).toStringOrNull(exec);
+ if (!string)
+ return JSValue::encode(jsUndefined());
+ return JSValue::encode(asRegExpObject(thisValue)->matchGlobal(exec, exec->lexicalGlobalObject(), string));
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL regExpProtoFuncCompile(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx"> JSValue thisValue = exec->thisValue();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeRegExpPrototypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/RegExpPrototype.h (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/RegExpPrototype.h        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/RegExpPrototype.h        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -29,7 +29,7 @@
</span><span class="cx"> class RegExpPrototype : public JSNonFinalObject {
</span><span class="cx"> public:
</span><span class="cx"> typedef JSNonFinalObject Base;
</span><del>- static const unsigned StructureFlags = Base::StructureFlags | OverridesGetOwnPropertySlot;
</del><ins>+ static const unsigned StructureFlags = Base::StructureFlags;
</ins><span class="cx">
</span><span class="cx"> static RegExpPrototype* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
</span><span class="cx"> {
</span><span class="lines">@@ -54,7 +54,6 @@
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> void finishCreation(VM&, JSGlobalObject*);
</span><del>- static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
</del><span class="cx">
</span><span class="cx"> WriteBarrier<RegExp> m_emptyRegExp;
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeStringPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -66,10 +66,8 @@
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncConcat(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncIndexOf(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncLastIndexOf(ExecState*);
</span><del>-EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState*);
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncRepeat(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*);
</span><del>-EncodedJSValue JSC_HOST_CALL stringProtoFuncSearch(ExecState*);
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncSplit(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncSubstr(ExecState*);
</span><span class="lines">@@ -111,6 +109,7 @@
</span><span class="cx">
</span><span class="cx"> /* Source for StringConstructor.lut.h
</span><span class="cx"> @begin stringPrototypeTable
</span><ins>+ match JSBuiltin DontEnum|Function 1
</ins><span class="cx"> search JSBuiltin DontEnum|Function 1
</span><span class="cx"> @end
</span><span class="cx"> */
</span><span class="lines">@@ -134,7 +133,6 @@
</span><span class="cx"> JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("concat", stringProtoFuncConcat, DontEnum, 1);
</span><span class="cx"> JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("indexOf", stringProtoFuncIndexOf, DontEnum, 1);
</span><span class="cx"> JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("lastIndexOf", stringProtoFuncLastIndexOf, DontEnum, 1);
</span><del>- JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("match", stringProtoFuncMatch, DontEnum, 1);
</del><span class="cx"> JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("repeat", stringProtoFuncRepeat, DontEnum, 1);
</span><span class="cx"> JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION("replace", stringProtoFuncReplace, DontEnum, 2, StringPrototypeReplaceIntrinsic);
</span><span class="cx"> JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("slice", stringProtoFuncSlice, DontEnum, 2);
</span><span class="lines">@@ -1030,107 +1028,6 @@
</span><span class="cx"> return JSValue::encode(jsNumber(result));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-EncodedJSValue JSC_HOST_CALL stringProtoFuncMatch(ExecState* exec)
-{
- JSValue thisValue = exec->thisValue();
- if (!checkObjectCoercible(thisValue))
- return throwVMTypeError(exec);
- JSString* string = thisValue.toString(exec);
- String s = string->value(exec);
- JSGlobalObject* globalObject = exec->lexicalGlobalObject();
- VM* vm = &globalObject->vm();
-
- JSValue a0 = exec->argument(0);
-
- RegExp* regExp;
- unsigned startOffset = 0;
- bool global = false;
- bool sticky = false;
- RegExpObject* regExpObject = nullptr;
- if (a0.inherits(RegExpObject::info())) {
- regExpObject = asRegExpObject(a0);
- regExp = regExpObject->regExp();
- if ((global = regExp->global())) {
- // ES6 21.2.5.6 step 6.b.
- regExpObject->setLastIndex(exec, 0);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
- }
- sticky = regExp->sticky();
- if (!global && sticky) {
- JSValue jsLastIndex = regExpObject->getLastIndex();
- unsigned lastIndex;
- if (LIKELY(jsLastIndex.isUInt32())) {
- lastIndex = jsLastIndex.asUInt32();
- if (lastIndex > s.length()) {
- regExpObject->setLastIndex(exec, 0);
- return JSValue::encode(jsUndefined());
- }
- } else {
- double doubleLastIndex = jsLastIndex.toInteger(exec);
- if (doubleLastIndex < 0 || doubleLastIndex > s.length()) {
- regExpObject->setLastIndex(exec, 0);
- return JSValue::encode(jsUndefined());
- }
- lastIndex = static_cast<unsigned>(doubleLastIndex);
- }
-
- startOffset = lastIndex;
- }
- } else {
- /*
- * ECMA 15.5.4.12 String.prototype.search (regexp)
- * If regexp is not an object whose [[Class]] property is "RegExp", it is
- * replaced with the result of the expression new RegExp(regexp).
- * Per ECMA 15.10.4.1, if a0 is undefined substitute the empty string.
- */
- String patternString = emptyString();
- if (!a0.isUndefined()) {
- patternString = a0.toString(exec)->value(exec);
- if (exec->hadException())
- return JSValue::encode(jsUndefined());
- }
- regExp = RegExp::create(exec->vm(), patternString, NoFlags);
- if (!regExp->isValid())
- return throwVMError(exec, createSyntaxError(exec, regExp->errorMessage()));
- }
- RegExpConstructor* regExpConstructor = globalObject->regExpConstructor();
- MatchResult result = regExpConstructor->performMatch(*vm, regExp, string, s, startOffset);
- // case without 'g' flag is handled like RegExp.prototype.exec
- if (!global) {
- if (sticky)
- regExpObject->setLastIndex(exec, result ? result.end : 0);
-
- return JSValue::encode(result ? createRegExpMatchesArray(exec, globalObject, string, regExp, result.start) : jsNull());
- }
-
- // return array of matches
- MarkedArgumentBuffer list;
- while (result) {
- // We defend ourselves from crazy.
- const size_t maximumReasonableMatchSize = 1000000000;
- if (list.size() > maximumReasonableMatchSize) {
- throwOutOfMemoryError(exec);
- return JSValue::encode(jsUndefined());
- }
-
- size_t end = result.end;
- size_t length = end - result.start;
- list.append(jsSubstring(exec, s, result.start, length));
- if (!length)
- ++end;
- result = regExpConstructor->performMatch(*vm, regExp, string, s, end);
- }
- if (list.isEmpty()) {
- // if there are no matches at all, it's important to return
- // Null instead of an empty array, because this matches
- // other browsers and because Null is a false value.
- return JSValue::encode(jsNull());
- }
-
- return JSValue::encode(constructArray(exec, static_cast<ArrayAllocationProfile*>(0), list));
-}
-
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx"> JSValue thisValue = exec->thisValue();
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (198553 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-03-22 21:31:16 UTC (rev 198553)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -1007,7 +1007,7 @@
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_RegExp_constructor.js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_String.prototype.match.js
</span><del>- cmd: runES6 :fail
</del><ins>+ cmd: runES6 :normal
</ins><span class="cx"> - path: es6/Proxy_internal_get_calls_String.prototype.replace.js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/Proxy_internal_get_calls_String.prototype.search.js
</span><span class="lines">@@ -1083,7 +1083,7 @@
</span><span class="cx"> - path: es6/Reflect_Reflect.set.js
</span><span class="cx"> cmd: runES6 :normal
</span><span class="cx"> - path: es6/RegExp.prototype_properties_RegExp.prototype[Symbol.match].js
</span><del>- cmd: runES6 :fail
</del><ins>+ cmd: runES6 :normal
</ins><span class="cx"> - path: es6/RegExp.prototype_properties_RegExp.prototype[Symbol.replace].js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/RegExp.prototype_properties_RegExp.prototype[Symbol.search].js
</span><span class="lines">@@ -1193,7 +1193,7 @@
</span><span class="cx"> - path: es6/well-known_symbols_Symbol.isConcatSpreadable.js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/well-known_symbols_Symbol.match.js
</span><del>- cmd: runES6 :fail
</del><ins>+ cmd: runES6 :normal
</ins><span class="cx"> - path: es6/well-known_symbols_Symbol.replace.js
</span><span class="cx"> cmd: runES6 :fail
</span><span class="cx"> - path: es6/well-known_symbols_Symbol.search.js
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestsstressregexpmatchjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/stress/regexp-match.js (0 => 198554)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/stress/regexp-match.js         (rev 0)
+++ trunk/Source/JavaScriptCore/tests/stress/regexp-match.js        2016-03-22 21:42:06 UTC (rev 198554)
</span><span class="lines">@@ -0,0 +1,102 @@
</span><ins>+
+function shouldBe(actual, expected) {
+ if (actual !== expected && !(actual !== null && typeof(expected) === "string" && actual.toString() == expected))
+ throw new Error('expected: ' + expected + ', bad value: ' + actual);
+}
+
+function shouldThrow(func, expected) {
+ var error = null;
+ try {
+ func();
+ } catch (e) {
+ error = e;
+ }
+ if (!error)
+ throw new Error('not thrown');
+ shouldBe(String(error), expected);
+}
+
+var errorKey = {
+ toString() {
+ throw new Error('out');
+ }
+};
+var string = 'Cocoa, Cappuccino, Rize, Matcha, Kilimanjaro';
+
+shouldThrow(function () {
+ String.prototype.match.call(null, /Cocoa/);
+}, "TypeError: String.prototype.match requires that |this| not be null");
+
+shouldThrow(function () {
+ String.prototype.match.call(undefined, /Cocoa/);
+}, "TypeError: String.prototype.match requires that |this| not be undefined");
+
+shouldThrow(function () {
+ string.match(errorKey);
+}, "Error: out");
+
+shouldBe('Cocoa'.match(/Cocoa/), "Cocoa");
+
+shouldBe(string.match(/Rize/), "Rize");
+shouldBe(string.match('Rize'), "Rize");
+shouldBe(string.match(/Matcha/), "Matcha");
+shouldBe(string.match('Matcha'), "Matcha");
+
+shouldBe(' undefined'.match(), "");
+shouldBe(' undefined'.match('undefined'), "undefined");
+
+shouldBe((/Cocoa/)[Symbol.match]('Cocoa'), "Cocoa");
+
+var primitives = [
+ '',
+ 'string',
+ 42,
+ Symbol('Cocoa'),
+];
+
+for (var primitive of primitives) {
+ shouldThrow(function () {
+ RegExp.prototype[Symbol.match].call(primitive)
+ }, 'TypeError: RegExp.prototype.@@match requires that |this| be an Object');
+}
+
+shouldThrow(function () {
+ /Cocoa/[Symbol.match](errorKey);
+}, "Error: out");
+
+
+function testRegExpMatch(regexp, string, result, lastIndex) {
+ shouldBe(regexp[Symbol.match](string), result);
+ shouldBe(regexp.lastIndex, lastIndex);
+}
+
+function testMatch(regexp, string, result, lastIndex) {
+ shouldBe(string.match(regexp), result);
+ shouldBe(regexp.lastIndex, lastIndex);
+}
+
+function testBoth(regexp, string, result, lastIndex) {
+ testMatch(regexp, string, result, lastIndex);
+ testRegExpMatch(regexp, string, result, lastIndex);
+}
+
+var cocoa = /Cocoa/;
+cocoa.lastIndex = 20;
+testBoth(cocoa, 'Cocoa', "Cocoa", 20);
+testBoth(cocoa, ' Cocoa', "Cocoa", 20);
+testBoth(cocoa, ' ', null, 20);
+
+var multibyte = /ココア/;
+multibyte.lastIndex = 20;
+testBoth(multibyte, 'ココア', 'ココア', 20);
+testBoth(multibyte, ' Cocoa', null, 20);
+testBoth(multibyte, 'カプチーノ', null, 20);
+
+function alwaysUnmatch(string) {
+ return null;
+}
+
+var regexp = new RegExp('ココア');
+regexp[Symbol.match] = alwaysUnmatch;
+shouldBe(regexp[Symbol.match], alwaysUnmatch);
+testBoth(regexp, 'ココア', null, 0);
</ins></span></pre>
</div>
</div>
</body>
</html>