Changeset 286992 in webkit
- Timestamp:
- Dec 13, 2021, 3:56:13 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
wasm/WasmInstance.cpp (modified) (2 diffs)
-
wasm/WasmInstance.h (modified) (2 diffs)
-
wasm/WasmModuleInformation.h (modified) (1 diff)
-
wasm/WasmTag.cpp (modified) (1 diff)
-
wasm/WasmTag.h (modified) (3 diffs)
-
wasm/js/WebAssemblyModuleRecord.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r286969 r286992 1 2021-12-13 Yusuke Suzuki <ysuzuki@apple.com> 2 3 [JSC] Use FixedVector for wasm exception in Wasm::Instance 4 https://bugs.webkit.org/show_bug.cgi?id=234224 5 6 Reviewed by Saam Barati. 7 8 Since we know # of exception tags when instantiating Wasm::Instance, 9 we can use FixedVector instead of Vector. This is the same to Table, 10 Functions etc. 11 12 We also remove Wasm::Tag::m_id. Since we do not copy Wasm::Tag and 13 we always allocate Wasm::Tag from heap, we can just use pointer 14 comparison. Then, we do not need to have this m_id. 15 16 * wasm/WasmInstance.cpp: 17 (JSC::Wasm::Instance::Instance): 18 (JSC::Wasm::Instance::setTag): 19 (JSC::Wasm::Instance::addTag): Deleted. 20 * wasm/WasmInstance.h: 21 * wasm/WasmModuleInformation.h: 22 (JSC::Wasm::ModuleInformation::internalExceptionCount const): 23 * wasm/WasmTag.cpp: 24 * wasm/WasmTag.h: 25 (JSC::Wasm::Tag::create): Deleted. 26 (JSC::Wasm::Tag::parameterCount const): Deleted. 27 (JSC::Wasm::Tag::parameter const): Deleted. 28 (JSC::Wasm::Tag::operator== const): Deleted. 29 (JSC::Wasm::Tag::operator!= const): Deleted. 30 (JSC::Wasm::Tag::signature const): Deleted. 31 (JSC::Wasm::Tag::Tag): Deleted. 32 * wasm/js/WebAssemblyModuleRecord.cpp: 33 (JSC::WebAssemblyModuleRecord::initializeImportsAndExports): 34 1 35 2021-12-13 waddlesplash <waddlesplash@gmail.com> 2 36 -
trunk/Source/JavaScriptCore/wasm/WasmInstance.cpp
r283852 r286992 59 59 , m_passiveElements(m_module->moduleInformation().elementCount()) 60 60 , m_passiveDataSegments(m_module->moduleInformation().dataSegmentsCount()) 61 , m_tags(m_module->moduleInformation().exceptionIndexSpaceSize()) 61 62 { 62 63 for (unsigned i = 0; i < m_numImportFunctions; ++i) … … 301 302 } 302 303 303 void Instance::addTag(const Tag& tag) 304 { 305 m_tags.append(Ref { tag }); 306 } 307 308 void Instance::addTag(Ref<Tag>&& tag) 309 { 310 m_tags.append(WTFMove(tag)); 304 void Instance::setTag(unsigned index, Ref<const Tag>&& tag) 305 { 306 m_tags[index] = WTFMove(tag); 311 307 } 312 308 -
trunk/Source/JavaScriptCore/wasm/WasmInstance.h
r286703 r286992 210 210 } 211 211 212 void addTag(const Tag&);213 void addTag(Ref<Tag>&&);214 212 const Tag& tag(unsigned i) const { return *m_tags[i]; } 213 void setTag(unsigned, Ref<const Tag>&&); 215 214 216 215 private: … … 240 239 BitVector m_passiveElements; 241 240 BitVector m_passiveDataSegments; 242 Vector<RefPtr<const Tag>> m_tags;241 FixedVector<RefPtr<const Tag>> m_tags; 243 242 }; 244 243 -
trunk/Source/JavaScriptCore/wasm/WasmModuleInformation.h
r283852 r286992 75 75 uint32_t internalFunctionCount() const { return internalFunctionSignatureIndices.size(); } 76 76 uint32_t importExceptionCount() const { return importExceptionSignatureIndices.size(); } 77 uint32_t internalExceptionCount() const { return internalExceptionSignatureIndices.size(); } 77 78 78 79 // Currently, our wasm implementation allows only one memory and table. -
trunk/Source/JavaScriptCore/wasm/WasmTag.cpp
r283852 r286992 32 32 namespace Wasm { 33 33 34 std::atomic<uint32_t> Tag::s_id = 0;35 36 34 } } // namespace JSC::Wasm 37 35 -
trunk/Source/JavaScriptCore/wasm/WasmTag.h
r283852 r286992 32 32 namespace JSC { namespace Wasm { 33 33 34 class Tag : public ThreadSafeRefCounted<Tag> {34 class Tag final : public ThreadSafeRefCounted<Tag> { 35 35 WTF_MAKE_FAST_ALLOCATED; 36 36 WTF_MAKE_NONCOPYABLE(Tag); … … 41 41 Type parameter(SignatureArgCount i) const { return m_signature->argument(i); } 42 42 43 bool operator==(const Tag& other) const { return m_id == other.m_id; } 44 bool operator!=(const Tag& other) const { return m_id != other.m_id; } 43 // Since (1) we do not copy Wasm::Tag and (2) we always allocate Wasm::Tag from heap, we can use 44 // pointer comparison for identity check. 45 bool operator==(const Tag& other) const { return this == &other; } 46 bool operator!=(const Tag& other) const { return this != &other; } 45 47 46 48 const Signature& signature() const { return m_signature.get(); } … … 48 50 private: 49 51 Tag(const Signature& signature) 50 : m_id(++s_id) 51 , m_signature(Ref { signature }) 52 : m_signature(Ref { signature }) 52 53 { 53 54 } 54 55 55 static std::atomic<uint32_t> s_id;56 uint32_t m_id;57 56 Ref<const Signature> m_signature; 58 57 }; -
trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp
r286703 r286992 406 406 return exception(createJSWebAssemblyLinkError(globalObject, vm, importFailMessage(import, "imported Tag", "signature doesn't match the imported WebAssembly Tag's signature"))); 407 407 408 m_instance->instance(). addTag(tag->tag());408 m_instance->instance().setTag(import.kindIndex, tag->tag()); 409 409 break; 410 410 } … … 479 479 Wasm::CodeBlock* codeBlock = m_instance->instance().codeBlock(); 480 480 481 for (Wasm::SignatureIndex signatureIndex : moduleInformation.internalExceptionSignatureIndices) 482 m_instance->instance().addTag(Wasm::Tag::create(Wasm::SignatureInformation::get(signatureIndex))); 481 for (unsigned index = 0; index < moduleInformation.internalExceptionSignatureIndices.size(); ++index) { 482 Wasm::SignatureIndex signatureIndex = moduleInformation.internalExceptionSignatureIndices[index]; 483 m_instance->instance().setTag(moduleInformation.importExceptionCount() + index, Wasm::Tag::create(Wasm::SignatureInformation::get(signatureIndex))); 484 } 483 485 484 486 unsigned functionImportCount = codeBlock->functionImportCount();
Note:
See TracChangeset
for help on using the changeset viewer.