[webkit-changes] [WebKit/WebKit] 11aee4: [JSC] Use cloning for Object.assign with empty object

Yusuke Suzuki noreply at github.com
Mon Jan 8 16:35:15 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 11aee4671a9e0291cec87cf0ebeb615d3f6ac51c
      https://github.com/WebKit/WebKit/commit/11aee4671a9e0291cec87cf0ebeb615d3f6ac51c
  Author: Yusuke Suzuki <ysuzuki at apple.com>
  Date:   2024-01-08 (Mon, 08 Jan 2024)

  Changed paths:
    A JSTests/stress/object-assign-clone.js
    M Source/JavaScriptCore/dfg/DFGOperations.cpp
    M Source/JavaScriptCore/runtime/JSObject.h
    M Source/JavaScriptCore/runtime/JSObjectInlines.h
    M Source/JavaScriptCore/runtime/ObjectConstructor.cpp
    M Source/JavaScriptCore/runtime/ObjectConstructorInlines.h
    M Source/JavaScriptCore/runtime/Structure.cpp
    M Source/JavaScriptCore/runtime/Structure.h
    M Source/JavaScriptCore/runtime/StructureInlines.h

  Log Message:
  -----------
  [JSC] Use cloning for Object.assign with empty object
https://bugs.webkit.org/show_bug.cgi?id=267239
rdar://120667395

Reviewed by Justin Michaud.

This patch implements fast cloning path for `Object.assign({}, source)` case.
When conditions are met, we clone Butterfly in source, set it to the empty target object,
and use the source's Structure for target. This completely avoids iterating all object properties.

* JSTests/stress/object-assign-clone.js: Added.
(shouldBe):
(shouldBeArray):
(shouldBe.Reflect.getOwnPropertyDescriptor):
(shouldBe.set get let):
* Source/JavaScriptCore/dfg/DFGOperations.cpp:
(JSC::DFG::JSC_DEFINE_JIT_OPERATION):
* Source/JavaScriptCore/runtime/JSObject.h:
* Source/JavaScriptCore/runtime/JSObjectInlines.h:
(JSC::JSObject::fastForEachPropertyWithSideEffectFreeFunctor): Deleted.
* Source/JavaScriptCore/runtime/ObjectConstructor.cpp:
(JSC::JSC_DEFINE_HOST_FUNCTION):
(JSC::toPropertyDescriptor):
(JSC::defineProperties):
* Source/JavaScriptCore/runtime/ObjectConstructorInlines.h:
(JSC::objectCloneFast):
(JSC::objectAssignFast):
* Source/JavaScriptCore/runtime/Structure.cpp:
(JSC::Structure::Structure):
(JSC::Structure::nonPropertyTransitionSlow):
* Source/JavaScriptCore/runtime/Structure.h:
(JSC::Structure::seenProperties const):
(JSC::Structure::bitFieldFlagsCantBeChangedWithoutTransition):
(JSC::Structure::transitionPropertyAttributes const):
(JSC::Structure::setTransitionPropertyAttributes):
* Source/JavaScriptCore/runtime/StructureInlines.h:
(JSC::Structure::add):
(JSC::Structure::attributeChange):
(JSC::Structure::addOrReplacePropertyWithoutTransition):

Canonical link: https://commits.webkit.org/272794@main




More information about the webkit-changes mailing list