-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://bugs.webkit.org/show_bug.cgi?id=264246 rdar://117989641 Reviewed by Michael Saboff. This patch makes CachedCall 2x faster. We integrate CallLinkInfo / PolymorphicCallNode's CodeBlock linking mechanism into CachedCall. 1. This patch unifies CallLinkInfo and PolymorphicCallNode's linking mechanism into CallLinkInfoBase. Now both class has CallLinkInfoBase and CodeBlock handles both via linkIncomingCall in the same way. 2. Extend this for CachedCall too. The key is that, previously, we are repeatedly checking CodeBlock's update for CachedCall. But now, it is notified by the CodeBlock itself. So we do not need to check this costly thing frequently. This is exactly the same mechanism to CallLinkInfo and PolymorphicCallNode. This improves CachedCall by 2x. cpp-to-js-cached-call 54.9806+-0.0144 ^ 21.1277+-0.0073 ^ definitely 2.6023x faster * JSTests/microbenchmarks/js-to-js-cached-call.js: Added. (test): (cachedCallFromJS): * Source/JavaScriptCore/CMakeLists.txt: * Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj: * Source/JavaScriptCore/Sources.txt: * Source/JavaScriptCore/bytecode/CallLinkInfo.cpp: (JSC::CallLinkInfo::~CallLinkInfo): (JSC::CallLinkInfo::unlinkImpl): (JSC::CallLinkInfo::unlink): Deleted. * Source/JavaScriptCore/bytecode/CallLinkInfo.h: (JSC::CallLinkInfo::CallLinkInfo): * Source/JavaScriptCore/bytecode/CallLinkInfoBase.cpp: Added. (JSC::CallLinkInfoBase::unlink): * Source/JavaScriptCore/bytecode/CallLinkInfoBase.h: Added. (JSC::CallLinkInfoBase::CallLinkInfoBase): (JSC::CallLinkInfoBase::~CallLinkInfoBase): (JSC::CallLinkInfoBase::callSiteType const): * Source/JavaScriptCore/bytecode/CallLinkStatus.cpp: (JSC::CallLinkStatus::computeFromCallLinkInfo): * Source/JavaScriptCore/bytecode/CodeBlock.cpp: (JSC::CodeBlock::linkIncomingCall): (JSC::CodeBlock::unlinkIncomingCalls): (JSC::CodeBlock::linkIncomingPolymorphicCall): Deleted. * Source/JavaScriptCore/bytecode/CodeBlock.h: * Source/JavaScriptCore/interpreter/CachedCall.h: (JSC::CachedCall::CachedCall): (JSC::CachedCall::~CachedCall): (JSC::CachedCall::unlinkImpl): (JSC::CachedCall::relink): * Source/JavaScriptCore/interpreter/Interpreter.cpp: (JSC::Interpreter::prepareForCachedCall): * Source/JavaScriptCore/interpreter/Interpreter.h: * Source/JavaScriptCore/interpreter/InterpreterInlines.h: (JSC::Interpreter::executeCachedCall): * Source/JavaScriptCore/jit/PolymorphicCallStubRoutine.cpp: (JSC::PolymorphicCallNode::unlinkImpl): (JSC::PolymorphicCallStubRoutine::PolymorphicCallStubRoutine): (JSC::CallLinkInfoBase::unlink): (JSC::PolymorphicCallNode::~PolymorphicCallNode): Deleted. (JSC::PolymorphicCallNode::unlink): Deleted. * Source/JavaScriptCore/jit/PolymorphicCallStubRoutine.h: (JSC::PolymorphicCallNode::PolymorphicCallNode): Deleted. (JSC::PolymorphicCallNode::hasCallLinkInfo): Deleted. Canonical link: https://commits.webkit.org/270347@main
- Loading branch information
1 parent
6dd6fa0
commit 52bceb7
Showing
17 changed files
with
202 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function test() { } | ||
noInline(test); | ||
|
||
function cachedCallFromJS(func, times) | ||
{ | ||
for (var i = 0; i < times; ++i) | ||
func(); | ||
} | ||
noInline(cachedCallFromJS); | ||
|
||
cachedCallFromJS(test, 4e6); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "CallLinkInfoBase.h" | ||
|
||
#include "CachedCall.h" | ||
#include "CallLinkInfo.h" | ||
#include "PolymorphicCallStubRoutine.h" | ||
|
||
namespace JSC { | ||
|
||
void CallLinkInfoBase::unlink(VM& vm) | ||
{ | ||
switch (callSiteType()) { | ||
case CallSiteType::CallLinkInfo: | ||
static_cast<CallLinkInfo*>(this)->unlinkImpl(vm); | ||
break; | ||
#if ENABLE(JIT) | ||
case CallSiteType::PolymorphicCallNode: | ||
static_cast<PolymorphicCallNode*>(this)->unlinkImpl(vm); | ||
break; | ||
#endif | ||
case CallSiteType::CachedCall: | ||
static_cast<CachedCall*>(this)->unlinkImpl(vm); | ||
break; | ||
} | ||
} | ||
|
||
} // namespace JSC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | ||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | ||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | ||
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <wtf/SentinelLinkedList.h> | ||
|
||
namespace JSC { | ||
|
||
class VM; | ||
|
||
class CallLinkInfoBase : public PackedRawSentinelNode<CallLinkInfoBase> { | ||
public: | ||
enum class CallSiteType : uint8_t { | ||
CallLinkInfo, | ||
#if ENABLE(JIT) | ||
PolymorphicCallNode, | ||
#endif | ||
CachedCall, | ||
}; | ||
|
||
explicit CallLinkInfoBase(CallSiteType callSiteType) | ||
: m_callSiteType(callSiteType) | ||
{ | ||
} | ||
|
||
~CallLinkInfoBase() | ||
{ | ||
if (isOnList()) | ||
remove(); | ||
} | ||
|
||
CallSiteType callSiteType() const { return m_callSiteType; } | ||
|
||
void unlink(VM&); | ||
|
||
private: | ||
CallSiteType m_callSiteType; | ||
}; | ||
|
||
} // namespace JSC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.