<!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>[183199] 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/183199">183199</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-23 11:44:16 -0700 (Thu, 23 Apr 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Implement `Object.assign`
https://bugs.webkit.org/show_bug.cgi?id=143980
Patch by Jordan Harband <ljharb@gmail.com> on 2015-04-23
Reviewed by Filip Pizlo.
Source/JavaScriptCore:
per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
* builtins/ObjectConstructor.js: Added.
(assign):
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/ObjectConstructor.cpp:
* runtime/ObjectConstructor.h:
LayoutTests:
* js/Object-assign-expected.txt: Added.
* js/Object-assign.html: Added.
* js/Object-getOwnPropertyNames-expected.txt:
* js/script-tests/Object-assign.js: Added.
* 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="#trunkSourceJavaScriptCoreCMakeListstxt">trunk/Source/JavaScriptCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeCommonIdentifiersh">trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp">trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeObjectConstructorcpp">trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreruntimeObjectConstructorh">trunk/Source/JavaScriptCore/runtime/ObjectConstructor.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsjsObjectassignexpectedtxt">trunk/LayoutTests/js/Object-assign-expected.txt</a></li>
<li><a href="#trunkLayoutTestsjsObjectassignhtml">trunk/LayoutTests/js/Object-assign.html</a></li>
<li><a href="#trunkLayoutTestsjsscripttestsObjectassignjs">trunk/LayoutTests/js/script-tests/Object-assign.js</a></li>
<li><a href="#trunkSourceJavaScriptCorebuiltinsObjectConstructorjs">trunk/Source/JavaScriptCore/builtins/ObjectConstructor.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/LayoutTests/ChangeLog        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-04-23 Jordan Harband <ljharb@gmail.com>
+
+ Implement `Object.assign`
+ https://bugs.webkit.org/show_bug.cgi?id=143980
+
+ Reviewed by Filip Pizlo.
+
+ * js/Object-assign-expected.txt: Added.
+ * js/Object-assign.html: Added.
+ * js/Object-getOwnPropertyNames-expected.txt:
+ * js/script-tests/Object-assign.js: Added.
+ * js/script-tests/Object-getOwnPropertyNames.js:
+
</ins><span class="cx"> 2015-04-23 Chris Dumez <cdumez@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, temporarily skip http/tests/websocket/tests/hybi/stop-on-resume-in-error-handler.html on Windows.
</span></span></pre></div>
<a id="trunkLayoutTestsjsObjectassignexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/Object-assign-expected.txt (0 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-assign-expected.txt         (rev 0)
+++ trunk/LayoutTests/js/Object-assign-expected.txt        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+Test to ensure correct behavior of Object.assign
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Object.assign.length is 2
+PASS Object.assign.name is 'assign'
+check TypeError on null/undefined
+PASS Object.assign() threw exception TypeError: can't convert undefined to object.
+PASS Object.assign(undefined) threw exception TypeError: can't convert undefined to object.
+PASS Object.assign(null) threw exception TypeError: can't convert null to object.
+PASS var target = {}, ret = Object.assign(target); target === ret is true
+multiple sources are copied
+PASS var target = {}, ret = Object.assign(target, {a: 1}); target === ret is true
+PASS var target = {}; Object.assign(target, {a: 1}); target.a === 1 is true
+PASS var target = {}; Object.assign(target, {a: 1}, {b: 2}); target.b === 2 is true
+PASS var target = {}; Object.assign(target, {a: 1}, {a: 2}); target.a === 2 is true
+only enumerable properties are copied
+PASS var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: false }); Object.assign(target, {a: 2}, source); target.a === 2 is true
+PASS var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: false }); Object.assign(target, source); 'a' in target && target.a === 1 is false
+PASS var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: false }); Object.assign(target, source, {a: 2}); target.a === 2 is true
+PASS var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: true }); Object.assign(target, source, {a: 2}); target.a === 2 is true
+PASS var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: true }); Object.assign(target, {a: 2}, source); target.a === 1 is true
+only own properties are copied
+PASS var target = {}, C = function C() {}; C.prototype.a = 1; Object.assign(target, {a: 2}, new C()); target.a === 2 is true
+Symbols are copied
+PASS var target = {}, source = {}, sym = Symbol('sym'); source[sym] = sym; Object.assign(target, source); target[sym] === sym is true
+PASS var target = {}, source1 = {}, source2 = {}, sym = Symbol('sym'); source1[sym] = 1; source2[sym] = 2; Object.assign(target, source1, source2); target[sym] === 2 is true
+non-enumerable Symbols are not copied
+PASS var target = {}, source = {}, sym = Symbol('sym'); Object.defineProperty(source, sym, { value: 1, enumerable: false }); Object.assign(target, source); target[sym] is undefined.
+only own Symbols are copied
+PASS var target = {}, source1 = {}, sym = Symbol('sym'), C = function C() {}; C.prototype[sym] = 1; source1[sym] = 2; Object.assign(target, source1, new C()); target[sym] === 2 is true
+primitives as sources
+PASS var target = {}; Object.assign(target, true); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, false); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, NaN); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, Infinity); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, -Infinity); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, 0); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, -0); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, Symbol('sym')); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, ''); Object.getOwnPropertyNames(target).length === 0 is true
+PASS var target = {}; Object.assign(target, 'abc'); Object.getOwnPropertyNames(target).length === 'abc'.length is true
+primitives as target
+PASS var target = Object.assign(true, { a: 1 }); isBoxedPrimitive(target, Boolean, true) && target.a === 1 is true
+PASS var target = Object.assign(false, { a: 1 }); isBoxedPrimitive(target, Boolean, false) && target.a === 1 is true
+PASS var target = Object.assign(NaN, { a: 1 }); isBoxedPrimitive(target, Number, NaN) && target.a === 1 is true
+PASS var target = Object.assign(Infinity, { a: 1 }); isBoxedPrimitive(target, Number, Infinity) && target.a === 1 is true
+PASS var target = Object.assign(-Infinity, { a: 1 }); isBoxedPrimitive(target, Number, -Infinity) && target.a === 1 is true
+PASS var target = Object.assign(0, { a: 1 }); isBoxedPrimitive(target, Number, 0) && target.a === 1 is true
+PASS var target = Object.assign(-0, { a: 1 }); isBoxedPrimitive(target, Number, -0) && target.a === 1 is true
+PASS var sym = Symbol('sym'); var target = Object.assign(sym, { a: 1 }); isBoxedPrimitive(target, Symbol, sym) && target.a === 1 is true
+PASS var target = Object.assign('', { a: 1 }); isBoxedPrimitive(target, String, '') && target.a === 1 is true
+PASS var target = Object.assign('abc', { a: 1 }); isBoxedPrimitive(target, String, 'abc') && target.a === 1 is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsjsObjectassignhtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/Object-assign.html (0 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-assign.html         (rev 0)
+++ trunk/LayoutTests/js/Object-assign.html        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -0,0 +1,10 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/Object-assign.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
</ins></span></pre></div>
<a id="trunkLayoutTestsjsObjectgetOwnPropertyNamesexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> PASS getSortedOwnPropertyNames(decodeURIComponent) is ['length', 'name']
</span><span class="cx"> PASS getSortedOwnPropertyNames(encodeURI) is ['length', 'name']
</span><span class="cx"> PASS getSortedOwnPropertyNames(encodeURIComponent) is ['length', 'name']
</span><del>-PASS getSortedOwnPropertyNames(Object) is ['create', 'defineProperties', 'defineProperty', 'freeze', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'preventExtensions', 'prototype', 'seal']
</del><ins>+PASS getSortedOwnPropertyNames(Object) is ['assign', 'create', 'defineProperties', 'defineProperty', 'freeze', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'preventExtensions', 'prototype', 'seal']
</ins><span class="cx"> PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Function) is ['length', 'name', 'prototype']
</span><span class="cx"> PASS getSortedOwnPropertyNames(Function.prototype) is ['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']
</span></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsObjectassignjs"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/js/script-tests/Object-assign.js (0 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-assign.js         (rev 0)
+++ trunk/LayoutTests/js/script-tests/Object-assign.js        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -0,0 +1,73 @@
</span><ins>+description("Test to ensure correct behavior of Object.assign");
+
+shouldBe("Object.assign.length", "2");
+shouldBe("Object.assign.name", "'assign'");
+
+debug("check TypeError on null/undefined");
+shouldThrow("Object.assign()");
+shouldThrow("Object.assign(undefined)");
+shouldThrow("Object.assign(null)");
+
+shouldBeTrue("var target = {}, ret = Object.assign(target); target === ret");
+
+debug("multiple sources are copied");
+shouldBeTrue("var target = {}, ret = Object.assign(target, {a: 1}); target === ret");
+shouldBeTrue("var target = {}; Object.assign(target, {a: 1}); target.a === 1");
+shouldBeTrue("var target = {}; Object.assign(target, {a: 1}, {b: 2}); target.b === 2");
+shouldBeTrue("var target = {}; Object.assign(target, {a: 1}, {a: 2}); target.a === 2");
+
+debug("only enumerable properties are copied");
+shouldBeTrue("var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: false }); Object.assign(target, {a: 2}, source); target.a === 2");
+shouldBeFalse("var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: false }); Object.assign(target, source); 'a' in target && target.a === 1");
+shouldBeTrue("var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: false }); Object.assign(target, source, {a: 2}); target.a === 2");
+shouldBeTrue("var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: true }); Object.assign(target, source, {a: 2}); target.a === 2");
+shouldBeTrue("var target = {}, source = {}; Object.defineProperty(source, 'a', { value: 1, enumerable: true }); Object.assign(target, {a: 2}, source); target.a === 1");
+
+debug("only own properties are copied");
+shouldBeTrue("var target = {}, C = function C() {}; C.prototype.a = 1; Object.assign(target, {a: 2}, new C()); target.a === 2");
+
+debug("Symbols are copied");
+shouldBeTrue("var target = {}, source = {}, sym = Symbol('sym'); source[sym] = sym; Object.assign(target, source); target[sym] === sym");
+shouldBeTrue("var target = {}, source1 = {}, source2 = {}, sym = Symbol('sym'); source1[sym] = 1; source2[sym] = 2; Object.assign(target, source1, source2); target[sym] === 2");
+
+debug("non-enumerable Symbols are not copied");
+shouldBeUndefined("var target = {}, source = {}, sym = Symbol('sym'); Object.defineProperty(source, sym, { value: 1, enumerable: false }); Object.assign(target, source); target[sym]");
+
+debug("only own Symbols are copied");
+shouldBeTrue("var target = {}, source1 = {}, sym = Symbol('sym'), C = function C() {}; C.prototype[sym] = 1; source1[sym] = 2; Object.assign(target, source1, new C()); target[sym] === 2");
+
+debug("primitives as sources");
+shouldBeTrue("var target = {}; Object.assign(target, true); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, false); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, NaN); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, Infinity); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, -Infinity); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, 0); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, -0); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, Symbol('sym')); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, ''); Object.getOwnPropertyNames(target).length === 0");
+shouldBeTrue("var target = {}; Object.assign(target, 'abc'); Object.getOwnPropertyNames(target).length === 'abc'.length");
+
+debug("primitives as target");
+var is = function (a, b) {
+ if (a !== a && b !== b) {
+ return true;
+ } else if (a === 0) {
+ return a / 1 === b / 1;
+ } else {
+ return a === b;
+ }
+};
+var isBoxedPrimitive = function isBoxedPrimitive(object, Wrapper, primitive) {
+ return object instanceof Wrapper && is(Wrapper.prototype.valueOf.call(object), primitive);
+};
+shouldBeTrue("var target = Object.assign(true, { a: 1 }); isBoxedPrimitive(target, Boolean, true) && target.a === 1");
+shouldBeTrue("var target = Object.assign(false, { a: 1 }); isBoxedPrimitive(target, Boolean, false) && target.a === 1");
+shouldBeTrue("var target = Object.assign(NaN, { a: 1 }); isBoxedPrimitive(target, Number, NaN) && target.a === 1");
+shouldBeTrue("var target = Object.assign(Infinity, { a: 1 }); isBoxedPrimitive(target, Number, Infinity) && target.a === 1");
+shouldBeTrue("var target = Object.assign(-Infinity, { a: 1 }); isBoxedPrimitive(target, Number, -Infinity) && target.a === 1");
+shouldBeTrue("var target = Object.assign(0, { a: 1 }); isBoxedPrimitive(target, Number, 0) && target.a === 1");
+shouldBeTrue("var target = Object.assign(-0, { a: 1 }); isBoxedPrimitive(target, Number, -0) && target.a === 1");
+shouldBeTrue("var sym = Symbol('sym'); var target = Object.assign(sym, { a: 1 }); isBoxedPrimitive(target, Symbol, sym) && target.a === 1");
+shouldBeTrue("var target = Object.assign('', { a: 1 }); isBoxedPrimitive(target, String, '') && target.a === 1");
+shouldBeTrue("var target = Object.assign('abc', { a: 1 }); isBoxedPrimitive(target, String, 'abc') && target.a === 1");
</ins></span></pre></div>
<a id="trunkLayoutTestsjsscripttestsObjectgetOwnPropertyNamesjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx"> "encodeURI": "['length', 'name']",
</span><span class="cx"> "encodeURIComponent": "['length', 'name']",
</span><span class="cx"> // Built-in ECMA objects
</span><del>- "Object": "['create', 'defineProperties', 'defineProperty', 'freeze', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'preventExtensions', 'prototype', 'seal']",
</del><ins>+ "Object": "['assign', 'create', 'defineProperties', 'defineProperty', 'freeze', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'preventExtensions', 'prototype', 'seal']",
</ins><span class="cx"> "Object.prototype": "['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']",
</span><span class="cx"> "Function": "['length', 'name', 'prototype']",
</span><span class="cx"> "Function.prototype": "['apply', 'bind', 'call', 'constructor', 'length', 'name', 'toString']",
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/CMakeLists.txt (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/CMakeLists.txt        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/Source/JavaScriptCore/CMakeLists.txt        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -1229,3 +1229,4 @@
</span><span class="cx"> if (ENABLE_FTL_JIT)
</span><span class="cx"> add_dependencies(JavaScriptCore llvmForJSC)
</span><span class="cx"> endif ()
</span><ins>+
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/Source/JavaScriptCore/ChangeLog        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2015-04-23 Jordan Harband <ljharb@gmail.com>
+
+ Implement `Object.assign`
+ https://bugs.webkit.org/show_bug.cgi?id=143980
+
+ Reviewed by Filip Pizlo.
+
+ per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
+
+ * builtins/ObjectConstructor.js: Added.
+ (assign):
+ * runtime/CommonIdentifiers.h:
+ * runtime/JSGlobalObject.cpp:
+ (JSC::JSGlobalObject::init):
+ * runtime/ObjectConstructor.cpp:
+ * runtime/ObjectConstructor.h:
+
</ins><span class="cx"> 2015-04-22 Filip Pizlo <fpizlo@apple.com>
</span><span class="cx">
</span><span class="cx"> Unreviewed, fix debug build.
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebuiltinsObjectConstructorjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/builtins/ObjectConstructor.js (0 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/builtins/ObjectConstructor.js         (rev 0)
+++ trunk/Source/JavaScriptCore/builtins/ObjectConstructor.js        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -0,0 +1,58 @@
</span><ins>+/*
+ * Copyright (C) 2015 Jordan Harband. 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 assign(target/*[*/, /*...*/sources/*] */) {
+ "use strict";
+
+ if (target == null)
+ throw new @TypeError("can't convert " + target + " to object");
+
+ var objTarget = @Object(target);
+ var s, nextSource, from, i, keys, nextKey, desc;
+ for (s = 1; s < arguments.length; ++s) {
+ nextSource = arguments[s];
+ if (nextSource != null) {
+ from = @Object(nextSource);
+ // TODO: replace @objectKeys + @objectGetOwnPropertySymbols with single @OwnPropertyKeys c++ operation
+ keys = @objectKeys(from);
+ for (i = 0; i < keys.length; ++i) {
+ nextKey = keys[i];
+ desc = @objectGetOwnPropertyDescriptor(from, nextKey);
+ if (typeof desc !== "undefined" && desc.enumerable) {
+ objTarget[nextKey] = from[nextKey];
+ }
+ }
+ keys = @objectGetOwnPropertySymbols(from);
+ for (i = 0; i < keys.length; ++i) {
+ nextKey = keys[i];
+ desc = @objectGetOwnPropertyDescriptor(from, nextKey);
+ if (typeof desc !== "undefined" && desc.enumerable) {
+ objTarget[nextKey] = from[nextKey];
+ }
+ }
+ }
+ }
+ return objTarget;
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeCommonIdentifiersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/Source/JavaScriptCore/runtime/CommonIdentifiers.h        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -264,6 +264,9 @@
</span><span class="cx"> macro(deferred) \
</span><span class="cx"> macro(countdownHolder) \
</span><span class="cx"> macro(Object) \
</span><ins>+ macro(objectKeys) \
+ macro(objectGetOwnPropertyDescriptor) \
+ macro(objectGetOwnPropertySymbols) \
</ins><span class="cx"> macro(Number) \
</span><span class="cx"> macro(Array) \
</span><span class="cx"> macro(abs) \
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeJSGlobalObjectcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -428,12 +428,19 @@
</span><span class="cx"> JSFunction* privateFuncFloor = JSFunction::create(vm, this, 0, String(), globalPrivateFuncFloor);
</span><span class="cx"> JSFunction* privateFuncIsFinite = JSFunction::create(vm, this, 0, String(), globalFuncIsFinite);
</span><span class="cx">
</span><ins>+ JSFunction* privateFuncObjectKeys = JSFunction::create(vm, this, 0, String(), objectConstructorKeys);
+ JSFunction* privateFuncObjectGetOwnPropertyDescriptor = JSFunction::create(vm, this, 0, String(), objectConstructorGetOwnPropertyDescriptor);
+ JSFunction* privateFuncObjectGetOwnPropertySymbols = JSFunction::create(vm, this, 0, String(), objectConstructorGetOwnPropertySymbols);
+
</ins><span class="cx"> GlobalPropertyInfo staticGlobals[] = {
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->NaN, jsNaN(), DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->Infinity, jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->undefinedKeyword, jsUndefined(), DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->undefinedPrivateName, jsUndefined(), DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->ObjectPrivateName, objectConstructor, DontEnum | DontDelete | ReadOnly),
</span><ins>+ GlobalPropertyInfo(vm.propertyNames->objectKeysPrivateName, privateFuncObjectKeys, DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->objectGetOwnPropertyDescriptorPrivateName, privateFuncObjectGetOwnPropertyDescriptor, DontEnum | DontDelete | ReadOnly),
+ GlobalPropertyInfo(vm.propertyNames->objectGetOwnPropertySymbolsPrivateName, privateFuncObjectGetOwnPropertySymbols, DontEnum | DontDelete | ReadOnly),
</ins><span class="cx"> GlobalPropertyInfo(vm.propertyNames->TypeErrorPrivateName, m_typeErrorConstructor.get(), DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->BuiltinLogPrivateName, builtinLog, DontEnum | DontDelete | ReadOnly),
</span><span class="cx"> GlobalPropertyInfo(vm.propertyNames->ArrayPrivateName, arrayConstructor, DontEnum | DontDelete | ReadOnly),
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeObjectConstructorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -39,10 +39,7 @@
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorGetPrototypeOf(ExecState*);
</span><del>-EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*);
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyNames(ExecState*);
</span><del>-EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertySymbols(ExecState*);
-EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState*);
</del><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperty(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorDefineProperties(ExecState*);
</span><span class="cx"> EncodedJSValue JSC_HOST_CALL objectConstructorCreate(ExecState*);
</span><span class="lines">@@ -80,6 +77,7 @@
</span><span class="cx"> isFrozen objectConstructorIsFrozen DontEnum|Function 1
</span><span class="cx"> isExtensible objectConstructorIsExtensible DontEnum|Function 1
</span><span class="cx"> is objectConstructorIs DontEnum|Function 2
</span><ins>+ assign objectConstructorAssign DontEnum|Function 2
</ins><span class="cx"> @end
</span><span class="cx"> */
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreruntimeObjectConstructorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/runtime/ObjectConstructor.h (183198 => 183199)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/runtime/ObjectConstructor.h        2015-04-23 18:41:10 UTC (rev 183198)
+++ trunk/Source/JavaScriptCore/runtime/ObjectConstructor.h        2015-04-23 18:44:16 UTC (rev 183199)
</span><span class="lines">@@ -27,6 +27,10 @@
</span><span class="cx">
</span><span class="cx"> namespace JSC {
</span><span class="cx">
</span><ins>+EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertyDescriptor(ExecState*);
+EncodedJSValue JSC_HOST_CALL objectConstructorGetOwnPropertySymbols(ExecState*);
+EncodedJSValue JSC_HOST_CALL objectConstructorKeys(ExecState*);
+
</ins><span class="cx"> class ObjectPrototype;
</span><span class="cx">
</span><span class="cx"> class ObjectConstructor : public InternalFunction {
</span></span></pre>
</div>
</div>
</body>
</html>