<!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>[198674] 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/198674">198674</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-03-25 10:37:48 -0700 (Fri, 25 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[JSC] implement String.prototype.padStart() and String.prototype.padEnd() proposal
https://bugs.webkit.org/show_bug.cgi?id=155795

Patch by Caitlin Potter &lt;caitp@igalia.com&gt; on 2016-03-25
Reviewed by Darin Adler.

Source/JavaScriptCore:

Implements ECMAScript proposal http://tc39.github.io/proposal-string-pad-start-end/
Currently at Stage 3.

* runtime/JSString.h:
* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
(JSC::repeatCharacter):
(JSC::repeatStringPattern):
(JSC::padString):
(JSC::stringProtoFuncPadEnd):
(JSC::stringProtoFuncPadStart):
* tests/es6.yaml:
* tests/es6/String.prototype_methods_String.prototype.padEnd.js: Added.
* tests/es6/String.prototype_methods_String.prototype.padStart.js: Added.

LayoutTests:

* js/Object-getOwnPropertyNames-expected.txt:
* js/script-tests/Object-getOwnPropertyNames.js:</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="#trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs">trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSStringh">trunk/Source/JavaScriptCore/runtime/JSString.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="#trunkSourceJavaScriptCoretestses6Stringprototype_methods_StringprototypepadEndjs">trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js</a></li>
<li><a href="#trunkSourceJavaScriptCoretestses6Stringprototype_methods_StringprototypepadStartjs">trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/LayoutTests/ChangeLog        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-03-25  Caitlin Potter  &lt;caitp@igalia.com&gt;
+
+        [JSC] implement String.prototype.padStart() and String.prototype.padEnd() proposal
+        https://bugs.webkit.org/show_bug.cgi?id=155795
+
+        Reviewed by Darin Adler.
+
+        * js/Object-getOwnPropertyNames-expected.txt:
+        * js/script-tests/Object-getOwnPropertyNames.js:
+
</ins><span class="cx"> 2016-03-25  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         [Fetch API] Add basic loading of resources
</span></span></pre></div>
<a id="trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -48,7 +48,7 @@
</span><span class="cx"> PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
</span><span class="cx"> PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']
</span><del>-PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'normalize', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']
</del><ins>+PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']
</ins><span class="cx"> PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Boolean.prototype) is ['constructor', 'toString', 'valueOf']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Number) is ['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_VALUE', 'MIN_SAFE_INTEGER', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'length', 'name', 'parseFloat', 'parseInt', 'prototype']
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">     &quot;Array&quot;: &quot;['from', 'isArray', 'length', 'name', 'of', 'prototype']&quot;,
</span><span class="cx">     &quot;Array.prototype&quot;: &quot;['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'forEach', 'includes', 'indexOf', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']&quot;,
</span><span class="cx">     &quot;String&quot;: &quot;['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']&quot;,
</span><del>-    &quot;String.prototype&quot;: &quot;['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'normalize', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']&quot;,
</del><ins>+    &quot;String.prototype&quot;: &quot;['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', 'valueOf']&quot;,
</ins><span class="cx">     &quot;Boolean&quot;: &quot;['length', 'name', 'prototype']&quot;,
</span><span class="cx">     &quot;Boolean.prototype&quot;: &quot;['constructor', 'toString', 'valueOf']&quot;,
</span><span class="cx">     &quot;Number&quot;: &quot;['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_VALUE', 'MIN_SAFE_INTEGER', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'length', 'name', 'parseFloat', 'parseInt', 'prototype']&quot;,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-03-25  Caitlin Potter  &lt;caitp@igalia.com&gt;
+
+        [JSC] implement String.prototype.padStart() and String.prototype.padEnd() proposal
+        https://bugs.webkit.org/show_bug.cgi?id=155795
+
+        Reviewed by Darin Adler.
+
+        Implements ECMAScript proposal http://tc39.github.io/proposal-string-pad-start-end/
+        Currently at Stage 3.
+
+        * runtime/JSString.h:
+        * runtime/StringPrototype.cpp:
+        (JSC::StringPrototype::finishCreation):
+        (JSC::repeatCharacter):
+        (JSC::repeatStringPattern):
+        (JSC::padString):
+        (JSC::stringProtoFuncPadEnd):
+        (JSC::stringProtoFuncPadStart):
+        * tests/es6.yaml:
+        * tests/es6/String.prototype_methods_String.prototype.padEnd.js: Added.
+        * tests/es6/String.prototype_methods_String.prototype.padStart.js: Added.
+
</ins><span class="cx"> 2016-03-24  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix Mac CMake build.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSStringh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSString.h (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSString.h        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/Source/JavaScriptCore/runtime/JSString.h        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -87,6 +87,8 @@
</span><span class="cx">     static const bool needsDestruction = true;
</span><span class="cx">     static void destroy(JSCell*);
</span><span class="cx"> 
</span><ins>+    static const unsigned MaxLength = std::numeric_limits&lt;int32_t&gt;::max();
+
</ins><span class="cx"> private:
</span><span class="cx">     JSString(VM&amp; vm, PassRefPtr&lt;StringImpl&gt; value)
</span><span class="cx">         : JSCell(vm, vm.stringStructure.get())
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeStringPrototypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -66,6 +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><ins>+EncodedJSValue JSC_HOST_CALL stringProtoFuncPadEnd(ExecState*);
+EncodedJSValue JSC_HOST_CALL stringProtoFuncPadStart(ExecState*);
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncRepeat(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncReplace(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncSlice(ExecState*);
</span><span class="lines">@@ -133,6 +135,8 @@
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;concat&quot;, stringProtoFuncConcat, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;indexOf&quot;, stringProtoFuncIndexOf, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;lastIndexOf&quot;, stringProtoFuncLastIndexOf, DontEnum, 1);
</span><ins>+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;padEnd&quot;, stringProtoFuncPadEnd, DontEnum, 1);
+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;padStart&quot;, stringProtoFuncPadStart, DontEnum, 1);
</ins><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;repeat&quot;, stringProtoFuncRepeat, DontEnum, 1);
</span><span class="cx">     JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(&quot;replace&quot;, stringProtoFuncReplace, DontEnum, 2, StringPrototypeReplaceIntrinsic);
</span><span class="cx">     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION(&quot;slice&quot;, stringProtoFuncSlice, DontEnum, 2);
</span><span class="lines">@@ -775,6 +779,39 @@
</span><span class="cx">     return jsString(exec, impl.release());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+template &lt;typename CharacterType&gt;
+static inline JSString* repeatCharacter(ExecState&amp; exec, CharacterType character, unsigned repeatCount)
+{
+    CharacterType* buffer = nullptr;
+    RefPtr&lt;StringImpl&gt; impl = StringImpl::tryCreateUninitialized(repeatCount, buffer);
+    if (!impl)
+        return throwOutOfMemoryError(&amp;exec), nullptr;
+
+    std::fill_n(buffer, repeatCount, character);
+
+    return jsString(&amp;exec, impl.release());
+}
+
+static inline bool repeatStringPattern(ExecState&amp; exec, unsigned maxLength, JSString* string, JSRopeString::RopeBuilder&amp; ropeBuilder)
+{
+    unsigned repeatCount = maxLength / string-&gt;length();
+    unsigned remainingCharacters = maxLength - repeatCount * string-&gt;length();
+    for (unsigned i = 0; i &lt; repeatCount; ++i) {
+        if (!ropeBuilder.append(string)) {
+            throwOutOfMemoryError(&amp;exec);
+            return false;
+        }
+    }
+    if (remainingCharacters) {
+        JSString* substr = jsSubstring(&amp;exec, string, 0, remainingCharacters);
+        if (!substr || !ropeBuilder.append(substr)) {
+            throwOutOfMemoryError(&amp;exec);
+            return false;
+        }
+    }
+    return true;
+}
+
</ins><span class="cx"> EncodedJSValue JSC_HOST_CALL stringProtoFuncRepeat(ExecState* exec)
</span><span class="cx"> {
</span><span class="cx">     JSValue thisValue = exec-&gt;thisValue();
</span><span class="lines">@@ -822,6 +859,79 @@
</span><span class="cx">     return JSValue::encode(ropeBuilder.release());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+enum class StringPaddingLocation { Start, End };
+
+static EncodedJSValue padString(ExecState&amp; exec, StringPaddingLocation paddingLocation)
+{
+    JSValue thisValue = exec.thisValue();
+    if (!thisValue.requireObjectCoercible(&amp;exec))
+        return JSValue::encode(jsUndefined());
+    JSString* thisString = thisValue.toString(&amp;exec);
+    if (exec.hadException())
+        return JSValue::encode(jsUndefined());
+
+    double maxLengthAsDouble = exec.argument(0).toLength(&amp;exec);
+    if (exec.hadException())
+        return JSValue::encode(jsUndefined());
+    ASSERT(maxLengthAsDouble &gt;= 0.0);
+    ASSERT(maxLengthAsDouble == std::trunc(maxLengthAsDouble));
+
+    if (maxLengthAsDouble &lt;= thisString-&gt;length())
+        return JSValue::encode(thisString);
+
+    if (maxLengthAsDouble &gt; JSString::MaxLength)
+        return JSValue::encode(throwOutOfMemoryError(&amp;exec));
+
+    unsigned maxLength = static_cast&lt;unsigned&gt;(maxLengthAsDouble);
+
+    JSValue fillString = exec.argument(1);
+    JSString* filler = nullptr;
+    if (!fillString.isUndefined()) {
+        filler = fillString.toString(&amp;exec);
+        if (!filler)
+            return JSValue::encode(jsUndefined());
+    }
+
+    unsigned fillLength = static_cast&lt;unsigned&gt;(maxLength) - thisString-&gt;length();
+
+    JSRopeString::RopeBuilder ropeBuilder(exec.vm());
+    if (paddingLocation == StringPaddingLocation::End) {
+        if (!ropeBuilder.append(thisString))
+            return JSValue::encode(throwOutOfMemoryError(&amp;exec));
+    }
+
+    if (!filler || filler-&gt;length() == 1) {
+        UChar character = filler ? filler-&gt;view(&amp;exec)[0] : ' ';
+        if (!(character &amp; ~0xff))
+            filler = repeatCharacter(exec, static_cast&lt;LChar&gt;(character), fillLength);
+        else
+            filler = repeatCharacter(exec, character, fillLength);
+        if (!filler || !ropeBuilder.append(filler))
+            return JSValue::encode(throwOutOfMemoryError(&amp;exec));
+        ASSERT(filler-&gt;length() == fillLength);
+    } else {
+        if (!repeatStringPattern(exec, fillLength, filler, ropeBuilder))
+            return JSValue::encode(throwOutOfMemoryError(&amp;exec));
+    }
+
+    if (paddingLocation == StringPaddingLocation::Start) {
+        if (!ropeBuilder.append(thisString))
+            return JSValue::encode(throwOutOfMemoryError(&amp;exec));
+    }
+    ASSERT(!exec.hadException());
+    return JSValue::encode(ropeBuilder.release());
+}
+
+EncodedJSValue JSC_HOST_CALL stringProtoFuncPadEnd(ExecState* exec)
+{
+    return padString(*exec, StringPaddingLocation::End);
+}
+
+EncodedJSValue JSC_HOST_CALL stringProtoFuncPadStart(ExecState* exec)
+{
+    return padString(*exec, StringPaddingLocation::Start);
+}
+
</ins><span class="cx"> ALWAYS_INLINE EncodedJSValue replace(
</span><span class="cx">     ExecState* exec, JSString* string, JSValue searchValue, JSValue replaceValue)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6Stringprototype_methods_StringprototypepadEndjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js (0 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padEnd.js        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -0,0 +1,107 @@
</span><ins>+function shouldBe(expected, actual, msg) {
+    if (msg === void 0)
+        msg = '';
+    else
+        msg = ' for ' + msg;
+    if (actual !== expected)
+        throw new Error('bad value' + msg + ': ' + actual + '. Expected ' + expected);
+}
+
+function shouldThrow(func, errorType) {
+    try {
+        func();
+        throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but did not throw.');
+    } catch (e) {
+        if (e instanceof errorType) return;
+        throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but threw ' + e);
+    }
+}
+
+(function TestMeta() {
+    shouldBe(1, String.prototype.padEnd.length);
+    shouldBe(&quot;function&quot;, typeof String.prototype.padEnd);
+    shouldBe(Object.getPrototypeOf(Function), Object.getPrototypeOf(String.prototype.padEnd));
+    shouldBe(&quot;padEnd&quot;, String.prototype.padEnd.name);
+
+    var descriptor = Object.getOwnPropertyDescriptor(String.prototype, &quot;padEnd&quot;);
+    shouldBe(undefined, descriptor.get);
+    shouldBe(undefined, descriptor.set);
+    shouldBe(true, descriptor.configurable);
+    shouldBe(false, descriptor.enumerable);
+    shouldBe(true, descriptor.writable);
+    shouldBe(String.prototype.padEnd, descriptor.value);
+
+    shouldThrow(() =&gt; new Function(`${String.prototype.padEnd}`), SyntaxError);
+})();
+
+(function TestRequireObjectCoercible() {
+    var padEnd = String.prototype.padEnd;
+    shouldThrow(() =&gt; padEnd.call(null, 4, &quot;test&quot;), TypeError);
+    shouldThrow(() =&gt; padEnd.call(undefined, 4, &quot;test&quot;), TypeError);
+    shouldBe(&quot;123   &quot;, padEnd.call({
+        __proto__: null,
+        valueOf() { return 123; }
+    }, 6, &quot; &quot;));
+
+    var proxy = new Proxy({}, {
+        get(t, name) {
+            if (name === Symbol.toPrimitive || name === &quot;toString&quot;) return;
+            if (name === &quot;valueOf&quot;) return () =&gt; 6.7;
+            throw new Error(&quot;unreachable code&quot;);
+        }
+    });
+    shouldBe(&quot;6.7   &quot;, padEnd.call(proxy, 6, &quot; &quot;));
+
+    proxy = new Proxy({}, {
+        get(t, name) {
+            if (name === Symbol.toPrimitive || name === &quot;valueOf&quot;) return;
+            if (name === &quot;toString&quot;) return () =&gt; 6.7;
+            throw new Error(&quot;unreachable code&quot;);
+        }
+    });
+    shouldBe(&quot;6.7   &quot;, padEnd.call(proxy, 6, &quot; &quot;));
+})();
+
+(function TestToLength() {
+    shouldThrow(() =&gt; &quot;123&quot;.padEnd(Symbol(&quot;16&quot;)), TypeError);
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd(-1));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd({ toString() { return -1; } }));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd(-0));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd({ toString() { return -0; } }));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd(+0));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd({ toString() { return +0; } }));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd(NaN));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padEnd({ toString() { return NaN; } }));
+})();
+
+(function TestFillerToString() {
+    shouldBe(&quot;.         &quot;, &quot;.&quot;.padEnd(10));
+    shouldBe(&quot;.         &quot;, &quot;.&quot;.padEnd(10, undefined));
+    shouldBe(&quot;.         &quot;, &quot;.&quot;.padEnd(10, { toString() { return &quot;&quot;; } }));
+    shouldBe(&quot;.nullnulln&quot;, &quot;.&quot;.padEnd(10, null));
+})();
+
+(function TestSingleCharacterFiller() {
+    shouldBe(&quot;.!!!!!!!!!&quot;, &quot;.&quot;.padEnd(10, &quot;!&quot;));
+    shouldBe(&quot;.!!!!!!!!!&quot;, &quot;.&quot;.padEnd(10, { toString() { return &quot;!&quot;; } }));
+    shouldBe(&quot;.!!!!!!!!!&quot;, &quot;.&quot;.padEnd(10, &quot;&quot; + &quot;!&quot; + &quot;&quot;));
+    shouldBe(&quot;.!!!!!!!!!&quot;, &quot;.&quot;.padEnd(10, { toString() { return &quot;&quot; + &quot;!&quot; + &quot;&quot;; } }));
+})();
+
+(function TestMemoryLimits() {
+    shouldThrow(() =&gt; &quot;.&quot;.padEnd(0x80000000, &quot;o&quot;), Error);
+    shouldThrow(() =&gt; &quot;.&quot;.padEnd({ valueOf() { return 0x80000000; } }, &quot;o&quot;), Error);
+    shouldThrow(() =&gt; &quot;.&quot;.padEnd(&quot;0x80000000&quot;, &quot;o&quot;), Error);
+})();
+
+(function TestFillerRepetition() {
+    for (var i = 2000; i &gt; 0; --i) {
+        var expected = &quot;123&quot; + &quot;xoxo&quot;.repeat(i / 4).slice(0, i - 3);
+        var actual = &quot;123&quot;.padEnd(i, &quot;xoxo&quot;);
+        shouldBe(expected, actual);
+        shouldBe(i &gt; &quot;123&quot;.length ? i : 3, actual.length);
+        actual = &quot;123&quot;.padEnd(i, &quot;xo&quot; + &quot;&quot; + &quot;xo&quot;);
+        shouldBe(expected, actual);
+        shouldBe(i &gt; &quot;123&quot;.length ? i : 3, actual.length);
+    }
+})();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6Stringprototype_methods_StringprototypepadStartjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js (0 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js                                (rev 0)
+++ trunk/Source/JavaScriptCore/tests/es6/String.prototype_methods_String.prototype.padStart.js        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -0,0 +1,107 @@
</span><ins>+function shouldBe(expected, actual, msg) {
+    if (msg === void 0)
+        msg = '';
+    else
+        msg = ' for ' + msg;
+    if (actual !== expected)
+        throw new Error('bad value' + msg + ': ' + actual + '. Expected ' + expected);
+}
+
+function shouldThrow(func, errorType) {
+    try {
+        func();
+        throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but did not throw.');
+    } catch (e) {
+        if (e instanceof errorType) return;
+        throw new Error('Expected ' + func + '() to throw ' + errorType.name + ', but threw ' + e);
+    }
+}
+
+(function TestMeta() {
+    shouldBe(1, String.prototype.padEnd.length);
+    shouldBe(&quot;function&quot;, typeof String.prototype.padStart);
+    shouldBe(Object.getPrototypeOf(Function), Object.getPrototypeOf(String.prototype.padStart));
+    shouldBe(&quot;padStart&quot;, String.prototype.padStart.name);
+
+    var descriptor = Object.getOwnPropertyDescriptor(String.prototype, &quot;padStart&quot;);
+    shouldBe(undefined, descriptor.get);
+    shouldBe(undefined, descriptor.set);
+    shouldBe(true, descriptor.configurable);
+    shouldBe(false, descriptor.enumerable);
+    shouldBe(true, descriptor.writable);
+    shouldBe(String.prototype.padStart, descriptor.value);
+
+    shouldThrow(() =&gt; new Function(`${String.prototype.padStart}`), SyntaxError);
+})();
+
+(function TestRequireObjectCoercible() {
+    var padStart = String.prototype.padStart;
+    shouldThrow(() =&gt; padStart.call(null, 4, &quot;test&quot;), TypeError);
+    shouldThrow(() =&gt; padStart.call(undefined, 4, &quot;test&quot;), TypeError);
+    shouldBe(&quot;   123&quot;, padStart.call({
+        __proto__: null,
+        valueOf() { return 123; }
+    }, 6, &quot; &quot;));
+
+    var proxy = new Proxy({}, {
+        get(t, name) {
+            if (name === Symbol.toPrimitive || name === &quot;toString&quot;) return;
+            if (name === &quot;valueOf&quot;) return () =&gt; 6.7;
+            throw new Error(&quot;unreachable code&quot;);
+        }
+    });
+    shouldBe(&quot;   6.7&quot;, padStart.call(proxy, 6, &quot; &quot;));
+
+    proxy = new Proxy({}, {
+        get(t, name) {
+            if (name === Symbol.toPrimitive || name === &quot;valueOf&quot;) return;
+            if (name === &quot;toString&quot;) return () =&gt; 6.7;
+            throw new Error(&quot;unreachable code&quot;);
+        }
+    });
+    shouldBe(&quot;   6.7&quot;, padStart.call(proxy, 6, &quot; &quot;));
+})();
+
+(function TestToLength() {
+    shouldThrow(() =&gt; &quot;123&quot;.padStart(Symbol(&quot;16&quot;)), TypeError);
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart(-1));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart({ toString() { return -1; } }));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart(-0));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart({ toString() { return -0; } }));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart(+0));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart({ toString() { return +0; } }));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart(NaN));
+    shouldBe(&quot;123&quot;, &quot;123&quot;.padStart({ toString() { return NaN; } }));
+})();
+
+(function TestFillerToString() {
+    shouldBe(&quot;         .&quot;, &quot;.&quot;.padStart(10));
+    shouldBe(&quot;         .&quot;, &quot;.&quot;.padStart(10, undefined));
+    shouldBe(&quot;         .&quot;, &quot;.&quot;.padStart(10, { toString() { return &quot;&quot;; } }));
+    shouldBe(&quot;nullnulln.&quot;, &quot;.&quot;.padStart(10, null));
+})();
+
+(function TestSingleCharacterFiller() {
+    shouldBe(&quot;!!!!!!!!!.&quot;, &quot;.&quot;.padStart(10, &quot;!&quot;));
+    shouldBe(&quot;!!!!!!!!!.&quot;, &quot;.&quot;.padStart(10, { toString() { return &quot;!&quot;; } }));
+    shouldBe(&quot;!!!!!!!!!.&quot;, &quot;.&quot;.padStart(10, &quot;&quot; + &quot;!&quot; + &quot;&quot;));
+    shouldBe(&quot;!!!!!!!!!.&quot;, &quot;.&quot;.padStart(10, { toString() { return &quot;&quot; + &quot;!&quot; + &quot;&quot;; } }));
+})();
+
+(function TestMemoryLimits() {
+    shouldThrow(() =&gt; &quot;.&quot;.padStart(0x80000000, &quot;o&quot;), Error);
+    shouldThrow(() =&gt; &quot;.&quot;.padStart({ valueOf() { return 0x80000000; } }, &quot;o&quot;), Error);
+    shouldThrow(() =&gt; &quot;.&quot;.padStart(&quot;0x80000000&quot;, &quot;o&quot;), Error);
+})();
+
+(function TestFillerRepetition() {
+    for (var i = 2000; i &gt; 0; --i) {
+        var expected = &quot;xoxo&quot;.repeat(i / 4).slice(0, i - 3) + &quot;123&quot;;
+        var actual = &quot;123&quot;.padStart(i, &quot;xoxo&quot;);
+        shouldBe(expected, actual);
+        shouldBe(i &gt; &quot;123&quot;.length ? i : 3, actual.length);
+        actual = &quot;123&quot;.padStart(i, &quot;xo&quot; + &quot;&quot; + &quot;xo&quot;);
+        shouldBe(expected, actual);
+        shouldBe(i &gt; &quot;123&quot;.length ? i : 3, actual.length);
+    }
+})();
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretestses6yaml"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tests/es6.yaml (198673 => 198674)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tests/es6.yaml        2016-03-25 17:24:33 UTC (rev 198673)
+++ trunk/Source/JavaScriptCore/tests/es6.yaml        2016-03-25 17:37:48 UTC (rev 198674)
</span><span class="lines">@@ -574,6 +574,10 @@
</span><span class="cx">   cmd: runES6 :normal
</span><span class="cx"> - path: es6/String.prototype_methods_String.prototype.normalize.js
</span><span class="cx">   cmd: runES6 :normal
</span><ins>+- path: es6/String.prototype_methods_String.prototype.padEnd.js
+  cmd: runES6 :normal
+- path: es6/String.prototype_methods_String.prototype.padStart.js
+  cmd: runES6 :normal
</ins><span class="cx"> - path: es6/String.prototype_methods_String.prototype.repeat.js
</span><span class="cx">   cmd: runES6 :normal
</span><span class="cx"> - path: es6/String.prototype_methods_String.prototype.startsWith.js
</span></span></pre>
</div>
</div>

</body>
</html>