WebKit Bugzilla
Attachment 349134 Details for
Bug 189401
: [WebAssembly] Optimize JS to Wasm call by using pointer of Signature as SignatureIndex
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-189401-20180907191129.patch (text/plain), 24.14 KB, created by
Yusuke Suzuki
on 2018-09-07 03:11:30 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Yusuke Suzuki
Created:
2018-09-07 03:11:30 PDT
Size:
24.14 KB
patch
obsolete
>Subversion Revision: 235778 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index 99460871fe6907d271a4d0086f2354a858998bbd..8de5a980860d035fdc30cdceed0e7270191febf3 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,57 @@ >+2018-09-07 Yusuke Suzuki <yusukesuzuki@slowstart.org> >+ >+ [WebAssembly] Optimize JS to Wasm call by using pointer of Signature as SignatureIndex >+ https://bugs.webkit.org/show_bug.cgi?id=189401 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ SignatureInformation is a global repository for Signature to make Signature atomic. >+ It takes Ref<Signature>&& and generates SignatureIndex. And we get const Signature& >+ by using this SignatureIndex. However, converting SignatureIndex to const Signature& >+ always looks up a hash table. This is costly since JS to Wasm calls always use >+ Signature& to check types of arguments. >+ >+ Instead of using this hash table, this patch uses a pointer of Signature as SignatureIndex. >+ This allows us to convert SignatureIndex to Signature by just casting it. It significantly >+ optimizes JS to wasm calls from 600ms to 400ms. We also optimize SignatureInformation::singleton >+ by making an accessor function inlined. >+ >+ In the future, we can remove SignatureIndex by directly handling Ref<Signature>: adding >+ deref() of Signature which unregisters itself from SignatureInformation carefully. >+ >+ * wasm/WasmB3IRGenerator.cpp: >+ (JSC::Wasm::B3IRGenerator::addCallIndirect): >+ * wasm/WasmBBQPlan.cpp: >+ * wasm/WasmFormat.h: >+ (JSC::Wasm::WasmToWasmImportableFunction::offsetOfSignatureIndex): >+ * wasm/WasmFunctionParser.h: >+ * wasm/WasmModule.h: >+ * wasm/WasmOMGPlan.cpp: >+ * wasm/WasmSectionParser.cpp: >+ (JSC::Wasm::SectionParser::parseType): >+ * wasm/WasmSignature.cpp: >+ (JSC::Wasm::SignatureInformation::adopt): >+ (JSC::Wasm::SignatureInformation::tryCleanup): >+ (JSC::Wasm::SignatureInformation::singleton): Deleted. >+ (JSC::Wasm::SignatureInformation::get): Deleted. >+ * wasm/WasmSignature.h: >+ (JSC::Wasm::Signature::index const): >+ (JSC::Wasm::SignatureHash::SignatureHash): >+ (JSC::Wasm::SignatureHash::hash): >+ (JSC::Wasm::SignatureHash::isHashTableDeletedValue const): >+ (JSC::Wasm::SignatureHash::empty): Deleted. >+ (JSC::Wasm::SignatureHash::deleted): Deleted. >+ * wasm/WasmSignatureInlines.h: Added. >+ (JSC::Wasm::SignatureInformation::singleton): >+ (JSC::Wasm::SignatureInformation::get): >+ * wasm/js/JSToWasm.cpp: >+ * wasm/js/JSWebAssemblyModule.h: >+ * wasm/js/WasmToJS.cpp: >+ (JSC::Wasm::wasmToJS): >+ * wasm/js/WebAssemblyFunction.cpp: >+ * wasm/js/WebAssemblyModuleRecord.cpp: >+ * wasm/js/WebAssemblyWrapperFunction.cpp: >+ > 2018-09-06 Yusuke Suzuki <yusukesuzuki@slowstart.org> > > [WebAssembly] Optimize JS to Wasm call by removing Vector allocation >diff --git a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp b/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp >index 3e7ce60ad74b0020474a86993da76e7180dc6f24..e0bc1599320c0e276da65803fad2e4d3298bc05f 100644 >--- a/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp >+++ b/Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp >@@ -59,6 +59,7 @@ > #include "WasmMemory.h" > #include "WasmOMGPlan.h" > #include "WasmOpcodeOrigin.h" >+#include "WasmSignatureInlines.h" > #include "WasmThunks.h" > #include <limits> > #include <wtf/Optional.h> >@@ -1229,13 +1230,13 @@ auto B3IRGenerator::addCallIndirect(const Signature& signature, Vector<Expressio > > // Check that the WasmToWasmImportableFunction is initialized. We trap if it isn't. An "invalid" SignatureIndex indicates it's not initialized. > // FIXME: when we have trap handlers, we can just let the call fail because Signature::invalidIndex is 0. https://bugs.webkit.org/show_bug.cgi?id=177210 >- static_assert(sizeof(WasmToWasmImportableFunction::signatureIndex) == sizeof(uint32_t), "Load codegen assumes i32"); >- ExpressionType calleeSignatureIndex = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin(), callableFunction, safeCast<int32_t>(OBJECT_OFFSETOF(WasmToWasmImportableFunction, signatureIndex))); >+ static_assert(sizeof(WasmToWasmImportableFunction::signatureIndex) == sizeof(uint64_t), "Load codegen assumes i64"); >+ ExpressionType calleeSignatureIndex = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int64, origin(), callableFunction, safeCast<int32_t>(WasmToWasmImportableFunction::offsetOfSignatureIndex())); > { > CheckValue* check = m_currentBlock->appendNew<CheckValue>(m_proc, Check, origin(), > m_currentBlock->appendNew<Value>(m_proc, Equal, origin(), > calleeSignatureIndex, >- m_currentBlock->appendNew<Const32Value>(m_proc, origin(), Signature::invalidIndex))); >+ m_currentBlock->appendNew<Const64Value>(m_proc, origin(), Signature::invalidIndex))); > > check->setGenerator([=] (CCallHelpers& jit, const B3::StackmapGenerationParams&) { > this->emitExceptionCheck(jit, ExceptionType::NullTableEntry); >@@ -1244,7 +1245,7 @@ auto B3IRGenerator::addCallIndirect(const Signature& signature, Vector<Expressio > > // Check the signature matches the value we expect. > { >- ExpressionType expectedSignatureIndex = m_currentBlock->appendNew<Const32Value>(m_proc, origin(), SignatureInformation::get(signature)); >+ ExpressionType expectedSignatureIndex = m_currentBlock->appendNew<Const64Value>(m_proc, origin(), SignatureInformation::get(signature)); > CheckValue* check = m_currentBlock->appendNew<CheckValue>(m_proc, Check, origin(), > m_currentBlock->appendNew<Value>(m_proc, NotEqual, origin(), calleeSignatureIndex, expectedSignatureIndex)); > >diff --git a/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp b/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp >index 43c8f562afa1c3633a7e6c61f40922ec0be97213..22a65c3110cfc8cdb94cd105fb6d7c3e53e770a8 100644 >--- a/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp >+++ b/Source/JavaScriptCore/wasm/WasmBBQPlan.cpp >@@ -36,6 +36,7 @@ > #include "WasmFaultSignalHandler.h" > #include "WasmMemory.h" > #include "WasmModuleParser.h" >+#include "WasmSignatureInlines.h" > #include "WasmTierUpCount.h" > #include "WasmValidate.h" > #include <wtf/DataLog.h> >diff --git a/Source/JavaScriptCore/wasm/WasmFormat.h b/Source/JavaScriptCore/wasm/WasmFormat.h >index e43f4ed936167ff2938d837a0ce088d43d20a4e6..4632394db2ce3c258fedd76ea013eba5d175b733 100644 >--- a/Source/JavaScriptCore/wasm/WasmFormat.h >+++ b/Source/JavaScriptCore/wasm/WasmFormat.h >@@ -276,6 +276,7 @@ struct InternalFunction { > // meant as fast lookup tables for these opcodes and do not own code. > struct WasmToWasmImportableFunction { > using LoadLocation = MacroAssemblerCodePtr<WasmEntryPtrTag>*; >+ static ptrdiff_t offsetOfSignatureIndex() { return OBJECT_OFFSETOF(WasmToWasmImportableFunction, signatureIndex); } > static ptrdiff_t offsetOfEntrypointLoadLocation() { return OBJECT_OFFSETOF(WasmToWasmImportableFunction, entrypointLoadLocation); } > > // FIXME: Pack signature index and code pointer into one 64-bit value. See <https://bugs.webkit.org/show_bug.cgi?id=165511>. >diff --git a/Source/JavaScriptCore/wasm/WasmFunctionParser.h b/Source/JavaScriptCore/wasm/WasmFunctionParser.h >index 8735ce8e6accb38e84c84b7b8e11d53379ab8dbe..088e728ce4cc54ce3c606b40f255a609d57b3b91 100644 >--- a/Source/JavaScriptCore/wasm/WasmFunctionParser.h >+++ b/Source/JavaScriptCore/wasm/WasmFunctionParser.h >@@ -28,6 +28,7 @@ > #if ENABLE(WEBASSEMBLY) > > #include "WasmParser.h" >+#include "WasmSignatureInlines.h" > #include <wtf/DataLog.h> > > namespace JSC { namespace Wasm { >diff --git a/Source/JavaScriptCore/wasm/WasmModule.h b/Source/JavaScriptCore/wasm/WasmModule.h >index fa36a69b803915d61c396fc1b3f9bc764200e632..652ddd37db8e5788d05875d2c2dfc7fadc9e7365 100644 >--- a/Source/JavaScriptCore/wasm/WasmModule.h >+++ b/Source/JavaScriptCore/wasm/WasmModule.h >@@ -41,7 +41,7 @@ struct Context; > struct ModuleInformation; > class Plan; > >-using SignatureIndex = uint32_t; >+using SignatureIndex = uint64_t; > > class Module : public ThreadSafeRefCounted<Module> { > public: >diff --git a/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp b/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp >index 9e0c4a5666e44e0eacc2312abbb765453b879f48..e31b471b79252dcece67f6fafdf06b71483327a7 100644 >--- a/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp >+++ b/Source/JavaScriptCore/wasm/WasmOMGPlan.cpp >@@ -39,6 +39,7 @@ > #include "WasmMachineThreads.h" > #include "WasmMemory.h" > #include "WasmNameSection.h" >+#include "WasmSignatureInlines.h" > #include "WasmValidate.h" > #include "WasmWorklist.h" > #include <wtf/DataLog.h> >diff --git a/Source/JavaScriptCore/wasm/WasmSectionParser.cpp b/Source/JavaScriptCore/wasm/WasmSectionParser.cpp >index 9a9bacb67ded2504535d8c2de5c5ed833def1602..ae8725d079cc3c9c88200470dc0bff7be7644fcb 100644 >--- a/Source/JavaScriptCore/wasm/WasmSectionParser.cpp >+++ b/Source/JavaScriptCore/wasm/WasmSectionParser.cpp >@@ -34,6 +34,7 @@ > #include "WasmNameSectionParser.h" > #include "WasmOps.h" > #include "WasmSections.h" >+#include "WasmSignatureInlines.h" > > namespace JSC { namespace Wasm { > >@@ -75,8 +76,7 @@ auto SectionParser::parseType() -> PartialResult > returnType = Type::Void; > signature->returnType() = returnType; > >- std::pair<SignatureIndex, Ref<Signature>> result = SignatureInformation::adopt(WTFMove(signature)); >- m_info->usedSignatures.uncheckedAppend(WTFMove(result.second)); >+ m_info->usedSignatures.uncheckedAppend(SignatureInformation::adopt(WTFMove(signature))); > } > return { }; > } >diff --git a/Source/JavaScriptCore/wasm/WasmSignature.cpp b/Source/JavaScriptCore/wasm/WasmSignature.cpp >index 6a42d517195ea4fb61d92b10c8cc377367c2eb9d..29ce21375213c31455aa33a295e8f86e4d9b4e9a 100644 >--- a/Source/JavaScriptCore/wasm/WasmSignature.cpp >+++ b/Source/JavaScriptCore/wasm/WasmSignature.cpp >@@ -41,6 +41,9 @@ static const bool verbose = false; > } > } > >+SignatureInformation* SignatureInformation::theOne { nullptr }; >+std::once_flag SignatureInformation::signatureInformationFlag; >+ > String Signature::toString() const > { > String result(makeString(returnType())); >@@ -83,60 +86,22 @@ SignatureInformation::SignatureInformation() > { > } > >-SignatureInformation& SignatureInformation::singleton() >-{ >- static SignatureInformation* theOne; >- static std::once_flag signatureInformationFlag; >- std::call_once(signatureInformationFlag, [] () { >- theOne = new SignatureInformation; >- }); >- >- return *theOne; >-} >- >-std::pair<SignatureIndex, Ref<Signature>> SignatureInformation::adopt(Ref<Signature>&& signature) >+Ref<Signature> SignatureInformation::adopt(Ref<Signature>&& signature) > { > SignatureInformation& info = singleton(); > LockHolder lock(info.m_lock); > >- SignatureIndex nextValue = info.m_nextIndex; >- auto addResult = info.m_signatureMap.add(SignatureHash { signature.ptr() }, nextValue); >+ SignatureIndex nextValue = signature->index(); >+ auto addResult = info.m_signatureSet.add(SignatureHash { signature.copyRef() }); > if (addResult.isNewEntry) { >- ++info.m_nextIndex; >- RELEASE_ASSERT(info.m_nextIndex > nextValue); // crash on overflow. >- ASSERT(nextValue == addResult.iterator->value); > if (WasmSignatureInternal::verbose) >- dataLogLn("Adopt new signature ", signature.get(), " with index ", addResult.iterator->value, " hash: ", signature->hash()); >- >- auto addResult = info.m_indexMap.add(nextValue, signature.copyRef()); >- RELEASE_ASSERT(addResult.isNewEntry); >- ASSERT(info.m_indexMap.size() == info.m_signatureMap.size()); >- return std::make_pair(nextValue, WTFMove(signature)); >+ dataLogLn("Adopt new signature ", signature.get(), " with index ", nextValue, " hash: ", signature->hash()); >+ return WTFMove(signature); > } >+ nextValue = addResult.iterator->key->index(); > if (WasmSignatureInternal::verbose) >- dataLogLn("Existing signature ", signature.get(), " with index ", addResult.iterator->value, " hash: ", signature->hash()); >- ASSERT(addResult.iterator->value != Signature::invalidIndex); >- ASSERT(info.m_indexMap.contains(addResult.iterator->value)); >- return std::make_pair(addResult.iterator->value, Ref<Signature>(*info.m_indexMap.get(addResult.iterator->value))); >-} >- >-const Signature& SignatureInformation::get(SignatureIndex index) >-{ >- ASSERT(index != Signature::invalidIndex); >- SignatureInformation& info = singleton(); >- LockHolder lock(info.m_lock); >- >- return *info.m_indexMap.get(index); >-} >- >-SignatureIndex SignatureInformation::get(const Signature& signature) >-{ >- SignatureInformation& info = singleton(); >- LockHolder lock(info.m_lock); >- >- auto result = info.m_signatureMap.get(SignatureHash { &signature }); >- ASSERT(result != Signature::invalidIndex); >- return result; >+ dataLogLn("Existing signature ", signature.get(), " with index ", nextValue, " hash: ", signature->hash()); >+ return Ref<Signature>(*addResult.iterator->key); > } > > void SignatureInformation::tryCleanup() >@@ -144,24 +109,10 @@ void SignatureInformation::tryCleanup() > SignatureInformation& info = singleton(); > LockHolder lock(info.m_lock); > >- Vector<std::pair<SignatureIndex, Signature*>> toRemove; >- for (const auto& pair : info.m_indexMap) { >- const Ref<Signature>& signature = pair.value; >- if (signature->refCount() == 1) { >- // We're the only owner. >- toRemove.append(std::make_pair(pair.key, signature.ptr())); >- } >- } >- for (const auto& pair : toRemove) { >- bool removed = info.m_signatureMap.remove(SignatureHash { pair.second }); >- ASSERT_UNUSED(removed, removed); >- removed = info.m_indexMap.remove(pair.first); >- ASSERT_UNUSED(removed, removed); >- } >- if (info.m_signatureMap.isEmpty()) { >- ASSERT(info.m_indexMap.isEmpty()); >- info.m_nextIndex = Signature::firstValidIndex; >- } >+ info.m_signatureSet.removeIf([&] (auto& hash) { >+ const auto& signature = hash.key; >+ return signature->refCount() == 1; >+ }); > } > > } } // namespace JSC::Wasm >diff --git a/Source/JavaScriptCore/wasm/WasmSignature.h b/Source/JavaScriptCore/wasm/WasmSignature.h >index 9f49ccb14568d201f1f8adceefb0c1331eb77f0b..6db28c3f19422e4c68a3280c165c7138c67235fd 100644 >--- a/Source/JavaScriptCore/wasm/WasmSignature.h >+++ b/Source/JavaScriptCore/wasm/WasmSignature.h >@@ -33,6 +33,7 @@ > #include <cstring> > #include <wtf/CheckedArithmetic.h> > #include <wtf/HashMap.h> >+#include <wtf/HashSet.h> > #include <wtf/HashTraits.h> > #include <wtf/StdLibExtras.h> > #include <wtf/ThreadSafeRefCounted.h> >@@ -47,7 +48,7 @@ namespace JSC { > namespace Wasm { > > using SignatureArgCount = uint32_t; >-using SignatureIndex = uint32_t; >+using SignatureIndex = uint64_t; > > class Signature : public ThreadSafeRefCounted<Signature> { > WTF_MAKE_FAST_ALLOCATED; >@@ -81,6 +82,7 @@ class Signature : public ThreadSafeRefCounted<Signature> { > return *storage(returnCount() + i); > } > Type argument(SignatureArgCount i) const { return const_cast<Signature*>(this)->argument(i); } >+ SignatureIndex index() const { return bitwise_cast<SignatureIndex>(this); } > > WTF::String toString() const; > void dump(WTF::PrintStream& out) const; >@@ -111,28 +113,21 @@ class Signature : public ThreadSafeRefCounted<Signature> { > }; > > struct SignatureHash { >- const Signature* key; >- static const Signature* empty() { return nullptr; } >- static const Signature* deleted() { return reinterpret_cast<const Signature*>(1); } >- SignatureHash() >- : key(empty()) >+ RefPtr<Signature> key { nullptr }; >+ SignatureHash() = default; >+ explicit SignatureHash(Ref<Signature>&& key) >+ : key(WTFMove(key)) > { > } >- explicit SignatureHash(const Signature* key) >- : key(key) >- { >- ASSERT(key != empty()); >- ASSERT(key != deleted()); >- } > explicit SignatureHash(WTF::HashTableDeletedValueType) >- : key(deleted()) >+ : key(WTF::HashTableDeletedValue) > { > } > bool operator==(const SignatureHash& rhs) const { return equal(*this, rhs); } > static bool equal(const SignatureHash& lhs, const SignatureHash& rhs) { return lhs.key == rhs.key || (lhs.key && rhs.key && *lhs.key == *rhs.key); } >- static unsigned hash(const SignatureHash& signature) { return signature.key->hash(); } >+ static unsigned hash(const SignatureHash& signature) { return signature.key ? signature.key->hash() : 0; } > static const bool safeToCompareToEmptyOrDeleted = false; >- bool isHashTableDeletedValue() const { return key == deleted(); } >+ bool isHashTableDeletedValue() const { return key.isHashTableDeletedValue(); } > }; > > } } // namespace JSC::Wasm >@@ -165,16 +160,17 @@ class SignatureInformation { > public: > static SignatureInformation& singleton(); > >- static std::pair<SignatureIndex, Ref<Signature>> WARN_UNUSED_RETURN adopt(Ref<Signature>&&); >+ static Ref<Signature> WARN_UNUSED_RETURN adopt(Ref<Signature>&&); > static const Signature& WARN_UNUSED_RETURN get(SignatureIndex); > static SignatureIndex WARN_UNUSED_RETURN get(const Signature&); > static void tryCleanup(); > > private: >- HashMap<Wasm::SignatureHash, Wasm::SignatureIndex> m_signatureMap; >- HashMap<Wasm::SignatureIndex, Ref<Signature>> m_indexMap; >- SignatureIndex m_nextIndex { Signature::firstValidIndex }; >+ HashSet<Wasm::SignatureHash> m_signatureSet; > Lock m_lock; >+ >+ JS_EXPORT_PRIVATE static SignatureInformation* theOne; >+ JS_EXPORT_PRIVATE static std::once_flag signatureInformationFlag; > }; > > } } // namespace JSC::Wasm >diff --git a/Source/JavaScriptCore/wasm/WasmSignatureInlines.h b/Source/JavaScriptCore/wasm/WasmSignatureInlines.h >new file mode 100644 >index 0000000000000000000000000000000000000000..51a5014056b0d9d25d22fc64e462fa6c51c48744 >--- /dev/null >+++ b/Source/JavaScriptCore/wasm/WasmSignatureInlines.h >@@ -0,0 +1,61 @@ >+/* >+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved. >+ * Copyright (C) 2018 Yusuke Suzuki <yusukesuzuki@slowstart.org>. >+ * >+ * 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 "WasmSignature.h" >+ >+#if ENABLE(WEBASSEMBLY) >+ >+namespace JSC { namespace Wasm { >+ >+inline SignatureInformation& SignatureInformation::singleton() >+{ >+ std::call_once(signatureInformationFlag, [] () { >+ theOne = new SignatureInformation; >+ }); >+ return *theOne; >+} >+ >+inline const Signature& SignatureInformation::get(SignatureIndex index) >+{ >+ ASSERT(index != Signature::invalidIndex); >+ return *bitwise_cast<const Signature*>(index); >+} >+ >+inline SignatureIndex SignatureInformation::get(const Signature& signature) >+{ >+ if (!ASSERT_DISABLED) { >+ SignatureInformation& info = singleton(); >+ auto locker = holdLock(info.m_lock); >+ ASSERT_UNUSED(info, info.m_signatureSet.contains(SignatureHash { &signature })); >+ } >+ return bitwise_cast<SignatureIndex>(&signature); >+} >+ >+} } // namespace JSC::Wasm >+ >+#endif // ENABLE(WEBASSEMBLY) >diff --git a/Source/JavaScriptCore/wasm/js/JSToWasm.cpp b/Source/JavaScriptCore/wasm/js/JSToWasm.cpp >index fcb9b0c618ae69e1511a7fa4cf3bf0652d6b312d..364f7c74bc19fc55bf2ad69bad490eceeee919da 100644 >--- a/Source/JavaScriptCore/wasm/js/JSToWasm.cpp >+++ b/Source/JavaScriptCore/wasm/js/JSToWasm.cpp >@@ -31,6 +31,7 @@ > #include "CCallHelpers.h" > #include "JSWebAssemblyInstance.h" > #include "WasmCallingConvention.h" >+#include "WasmSignatureInlines.h" > > namespace JSC { namespace Wasm { > >diff --git a/Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h b/Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h >index d393006919d27ad17469fe2695db8438423d082e..72a3063a4b37c570cf940d76b59d1c0ccbc05e48 100644 >--- a/Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h >+++ b/Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h >@@ -43,7 +43,7 @@ namespace Wasm { > class Module; > struct ModuleInformation; > class Plan; >-using SignatureIndex = uint32_t; >+using SignatureIndex = uint64_t; > } > > class SymbolTable; >diff --git a/Source/JavaScriptCore/wasm/js/WasmToJS.cpp b/Source/JavaScriptCore/wasm/js/WasmToJS.cpp >index 1270c79b1c4310cc5fc63029ae83bfb18c5e03c6..ee00fc88e0caf2544d9d79ecc93f4e1232538b32 100644 >--- a/Source/JavaScriptCore/wasm/js/WasmToJS.cpp >+++ b/Source/JavaScriptCore/wasm/js/WasmToJS.cpp >@@ -41,6 +41,7 @@ > #include "WasmContext.h" > #include "WasmExceptionType.h" > #include "WasmInstance.h" >+#include "WasmSignatureInlines.h" > > namespace JSC { namespace Wasm { > >@@ -301,7 +302,8 @@ Expected<MacroAssemblerCodeRef<WasmEntryPtrTag>, BindingFailure> wasmToJS(VM* vm > jit.move(CCallHelpers::TrustedImm32(0), GPRInfo::argumentGPR3); > > static_assert(GPRInfo::numberOfArgumentRegisters >= 4, "We rely on this with the call below."); >- jit.setupArguments<decltype(callFunc)>(GPRInfo::argumentGPR1, CCallHelpers::TrustedImm32(signatureIndex), CCallHelpers::TrustedImmPtr(buffer)); >+ static_assert(sizeof(SignatureIndex) == sizeof(uint64_t), "Following code assumes SignatureIndex is 64bit."); >+ jit.setupArguments<decltype(callFunc)>(GPRInfo::argumentGPR1, CCallHelpers::TrustedImm64(signatureIndex), CCallHelpers::TrustedImmPtr(buffer)); > auto call = jit.call(OperationPtrTag); > auto noException = jit.emitExceptionCheck(*vm, AssemblyHelpers::InvertedExceptionCheck); > >diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp >index 02b4c24c42bccf12f823ab079753b05e5a3aa54a..5db924f8ecfb03a7e0ba6f5d084822b34711bac7 100644 >--- a/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp >+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.cpp >@@ -42,6 +42,7 @@ > #include "WasmContext.h" > #include "WasmFormat.h" > #include "WasmMemory.h" >+#include "WasmSignatureInlines.h" > #include <wtf/FastTLS.h> > #include <wtf/SystemTracing.h> > >diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp >index d74417cb1a4c1ca3b2f38efa2077a538b165ea12..e8ca58cbf60ac46ab230ee3df04a5f4a3028f2f2 100644 >--- a/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp >+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp >@@ -37,7 +37,7 @@ > #include "JSWebAssemblyLinkError.h" > #include "JSWebAssemblyModule.h" > #include "ProtoCallFrame.h" >-#include "WasmSignature.h" >+#include "WasmSignatureInlines.h" > #include "WebAssemblyFunction.h" > #include <limits> > >diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.cpp >index 36f378306be727c029531db492a8d00927291a6e..444efbf8b4a7a35f40f01ceb4c79ec843eb1646f 100644 >--- a/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.cpp >+++ b/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.cpp >@@ -32,6 +32,7 @@ > #include "FunctionPrototype.h" > #include "JSCInlines.h" > #include "JSWebAssemblyInstance.h" >+#include "WasmSignatureInlines.h" > > namespace JSC { >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 189401
:
349131
|
349134
|
349136
|
349137
|
349138
|
349139
|
349140
|
349143