[JSC] Object.assign for final objects should be faster
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 03:38:10 +0000 (03:38 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 May 2018 03:38:10 +0000 (03:38 +0000)
commit98e4e3eebb8ab15c4429959b3dd9deb40e6d8066
treeff91e5a6f73ec44ccc45ef93f5d27b8061f4e500
parent839e4d862154e6dbab9e26e09aad2768cf984a79
[JSC] Object.assign for final objects should be faster
https://bugs.webkit.org/show_bug.cgi?id=185348

Reviewed by Saam Barati.

JSTests:

* stress/object-assign-fast-path.js: Added.
(shouldBe):
(checkProperty):

Source/JavaScriptCore:

Object.assign is so heavily used to clone an object. For example, speedometer react-redux can be significantly
improved if Object.assign becomes fast. It is worth adding a complex fast path to accelerate the major use cases.

If enumerating properties of source objects and putting properties to target object are non observable,
we can avoid hash table looking up of source object properties. We can enumerate object property entries,
and put them to target object. This patch adds this fast path to Object.assign implementation.

When enumerating properties, we need to ensure that the given |source| object does not include "__proto__"
property since we cannot perform fast [[Put]] for the |target| object. We add a new flag
"HasUnderscoreProtoPropertyExcludingOriginalProto" to Structure to track this state.

This improves object-assign.es6 by 1.85x.

                                baseline                  patched

    object-assign.es6      368.6132+-8.3508     ^    198.8775+-4.9042        ^ definitely 1.8535x faster

And Speedometer2.0 React-Redux-TodoMVC's total time is improved from 490ms to 431ms.

* runtime/JSObject.h:
* runtime/JSObjectInlines.h:
(JSC::JSObject::canPerformFastPutInlineExcludingProto):
(JSC::JSObject::canPerformFastPutInline):
* runtime/ObjectConstructor.cpp:
(JSC::objectConstructorAssign):
* runtime/Structure.cpp:
(JSC::Structure::Structure):
* runtime/Structure.h:
* runtime/StructureInlines.h:
(JSC::Structure::forEachProperty):
(JSC::Structure::add):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231687 268f45cc-cd09-0410-ab3c-d52691b4dbfc
JSTests/ChangeLog
JSTests/stress/object-assign-fast-path.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/JSObject.h
Source/JavaScriptCore/runtime/JSObjectInlines.h
Source/JavaScriptCore/runtime/ObjectConstructor.cpp
Source/JavaScriptCore/runtime/Structure.cpp
Source/JavaScriptCore/runtime/Structure.h
Source/JavaScriptCore/runtime/StructureInlines.h