[JSC] Implement Object.assign in C++
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jun 2017 19:37:21 +0000 (19:37 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Jun 2017 19:37:21 +0000 (19:37 +0000)
commit3aa87c161d7fdbd95e5e43997d12c581c761e3b1
tree0fbc3aec1f7ea9aeed46118b6afed3ec53c63f3f
parentdeeedee7344ada1c2b0539c66bf9cab039e38f3a
[JSC] Implement Object.assign in C++
https://bugs.webkit.org/show_bug.cgi?id=173414

Reviewed by Saam Barati.

JSTests:

* stress/object-assign-string-first.js: Added.
(shouldBe):
(source.get Symbol):
(source.get 1):
(source.get cocoa):

Source/JavaScriptCore:

Implementing Object.assign in JS is not so good compared to C++ version because,

1. JS version allocates JS array for object own keys. And we allocate JSString / Symbol for each key.
But basically, they can be handled as UniquedStringImpl in C++. Allocating these cells are wasteful.

2. While implementing builtins in JS offers some good type speculation chances, Object.assign is inherently super polymorphic.
So JS's type profile doesn't help well.

3. We have a chance to introduce various fast path for Object.assign in C++.

This patch moves implementation from JS to C++. It achieves the above (1) and (2). (3) is filed in [1].

We can see 1.65x improvement in SixSpeed object-assign.es6.

                            baseline                  patched

object-assign.es6      643.3253+-8.0521     ^    389.1075+-8.8840        ^ definitely 1.6533x faster

[1]: https://bugs.webkit.org/show_bug.cgi?id=173416

* builtins/ObjectConstructor.js:
(entries):
(assign): Deleted.
* runtime/JSCJSValueInlines.h:
(JSC::JSValue::putInline):
* runtime/JSCell.h:
* runtime/JSCellInlines.h:
(JSC::JSCell::putInline):
* runtime/JSObject.cpp:
(JSC::JSObject::put):
* runtime/JSObject.h:
* runtime/JSObjectInlines.h:
(JSC::JSObject::putInlineForJSObject):
(JSC::JSObject::putInline): Deleted.
* runtime/ObjectConstructor.cpp:
(JSC::objectConstructorAssign):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218348 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/stress/object-assign-string-first.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/builtins/ObjectConstructor.js
Source/JavaScriptCore/runtime/JSCJSValueInlines.h
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSCellInlines.h
Source/JavaScriptCore/runtime/JSObject.cpp
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/JSObjectInlines.h
Source/JavaScriptCore/runtime/ObjectConstructor.cpp