Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3b5ee5168e4f033bd863dc2a3e89160179a62aff
      
https://github.com/WebKit/WebKit/commit/3b5ee5168e4f033bd863dc2a3e89160179a62aff
  Author: Menlodorian <[email protected]>
  Date:   2026-03-24 (Tue, 24 Mar 2026)

  Changed paths:
    M Source/JavaScriptCore/API/APICallbackFunction.h
    M Source/JavaScriptCore/API/JSCallbackObjectFunctions.h
    M Source/JavaScriptCore/interpreter/CallFrame.h
    M Source/JavaScriptCore/tools/Integrity.cpp
    M Source/JavaScriptCore/tools/Integrity.h

  Log Message:
  -----------
  Fix some JSC API implementation functions to avoid unnecessarily copying 
CallFrame arguments.
https://bugs.webkit.org/show_bug.cgi?id=310647
rdar://173257607

Reviewed by Marcus Plutowski.

This is a minor optimization on 64-bit platforms where JSValueRef is basically 
a JSValue.
The pre-existing code iterates the CallFrame arguments and copies them into a 
JSvalueRef
Vector before passing the vector's backing store to a target function as 
out-going arguments.

On 64-bit, a JSValueRef is a JSValue (see toJS() implementation in APICast.h).  
So, we can
avoid this iteration and vector construction by simply having CallFrame return 
its arguments
in a std::span<JSValue> for this use case.

On 32-bit, we still need to go thru the conversion from JSValue to JSValueRef 
because the
2 are not equivalent.

>From a GC perspective, it's safe to use a Vector here because the original 
>source of the
JSValues (i.e. the CallFrame arguments from the caller) are still on the stack, 
and are
therefore protected from the GC.

No new tests because there is just an optimization.  There is no externally 
observable
behavior change.

* Source/JavaScriptCore/API/APICallbackFunction.h:
(JSC::APICallbackFunction::callImpl):
(JSC::APICallbackFunction::constructImpl):
* Source/JavaScriptCore/API/JSCallbackObjectFunctions.h:
(JSC::JSCallbackObject<Parent>::constructImpl):
(JSC::JSCallbackObject<Parent>::callImpl):
* Source/JavaScriptCore/interpreter/CallFrame.h:
(JSC::CallFrame::argumentsSpan):
* Source/JavaScriptCore/tools/Integrity.cpp:
(JSC::Integrity::audit):
* Source/JavaScriptCore/tools/Integrity.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to