[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,
- 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.
- 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.
- 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):
(JSC::JSObject::put):
- runtime/JSObject.h:
- runtime/JSObjectInlines.h:
(JSC::JSObject::putInlineForJSObject):
(JSC::JSObject::putInline): Deleted.
- runtime/ObjectConstructor.cpp:
(JSC::objectConstructorAssign):