Title: [287582] trunk/Source/_javascript_Core
Revision
287582
Author
ysuz...@apple.com
Date
2022-01-04 13:25:43 -0800 (Tue, 04 Jan 2022)

Log Message

[JSC] Remove JSWebAssemblyCalleeGroup cell
https://bugs.webkit.org/show_bug.cgi?id=234780

Reviewed by Saam Barati.

This cell is not observable to users. And this cell just holds Wasm-to-JS stubs,
but it is the same to all memory modes. Thus, we should just generate it in VM-linked
Wasm::Module (it means, we should have it in JSWebAssemblyModule), and we do not need
to have / allocate JSWebAssemblyCalleeGroup cell.

* _javascript_Core.xcodeproj/project.pbxproj:
* Sources.txt:
* heap/Heap.cpp:
(JSC::Heap::Heap):
(JSC::Heap::finalizeUnconditionalFinalizers):
(JSC::Heap::deleteAllCodeBlocks):
* heap/Heap.h:
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:
* wasm/WasmBinding.h:
* wasm/js/JSWebAssemblyCalleeGroup.cpp: Removed.
* wasm/js/JSWebAssemblyCalleeGroup.h: Removed.
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::visitChildrenImpl):
(JSC::JSWebAssemblyInstance::finalizeCreation):
* wasm/js/JSWebAssemblyInstance.h:
* wasm/js/JSWebAssemblyModule.cpp:
(JSC::JSWebAssemblyModule::createStub):
(JSC::JSWebAssemblyModule::visitChildrenImpl):
(JSC::JSWebAssemblyModule::clearJSCallICs):
(JSC::JSWebAssemblyModule::finalizeUnconditionally):
(JSC::JSWebAssemblyModule::generateWasmToJSStubs):
(JSC::JSWebAssemblyModule::calleeGroup): Deleted.
(JSC::JSWebAssemblyModule::setCalleeGroup): Deleted.
* wasm/js/JSWebAssemblyModule.h:
* wasm/js/WebAssemblyModuleConstructor.cpp:
* wasm/js/WebAssemblyWrapperFunction.h:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (287581 => 287582)


--- trunk/Source/_javascript_Core/ChangeLog	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/ChangeLog	2022-01-04 21:25:43 UTC (rev 287582)
@@ -1,5 +1,46 @@
 2022-01-04  Yusuke Suzuki  <ysuz...@apple.com>
 
+        [JSC] Remove JSWebAssemblyCalleeGroup cell
+        https://bugs.webkit.org/show_bug.cgi?id=234780
+
+        Reviewed by Saam Barati.
+
+        This cell is not observable to users. And this cell just holds Wasm-to-JS stubs,
+        but it is the same to all memory modes. Thus, we should just generate it in VM-linked
+        Wasm::Module (it means, we should have it in JSWebAssemblyModule), and we do not need
+        to have / allocate JSWebAssemblyCalleeGroup cell.
+
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * Sources.txt:
+        * heap/Heap.cpp:
+        (JSC::Heap::Heap):
+        (JSC::Heap::finalizeUnconditionalFinalizers):
+        (JSC::Heap::deleteAllCodeBlocks):
+        * heap/Heap.h:
+        * runtime/VM.cpp:
+        (JSC::VM::VM):
+        * runtime/VM.h:
+        * wasm/WasmBinding.h:
+        * wasm/js/JSWebAssemblyCalleeGroup.cpp: Removed.
+        * wasm/js/JSWebAssemblyCalleeGroup.h: Removed.
+        * wasm/js/JSWebAssemblyInstance.cpp:
+        (JSC::JSWebAssemblyInstance::visitChildrenImpl):
+        (JSC::JSWebAssemblyInstance::finalizeCreation):
+        * wasm/js/JSWebAssemblyInstance.h:
+        * wasm/js/JSWebAssemblyModule.cpp:
+        (JSC::JSWebAssemblyModule::createStub):
+        (JSC::JSWebAssemblyModule::visitChildrenImpl):
+        (JSC::JSWebAssemblyModule::clearJSCallICs):
+        (JSC::JSWebAssemblyModule::finalizeUnconditionally):
+        (JSC::JSWebAssemblyModule::generateWasmToJSStubs):
+        (JSC::JSWebAssemblyModule::calleeGroup): Deleted.
+        (JSC::JSWebAssemblyModule::setCalleeGroup): Deleted.
+        * wasm/js/JSWebAssemblyModule.h:
+        * wasm/js/WebAssemblyModuleConstructor.cpp:
+        * wasm/js/WebAssemblyWrapperFunction.h:
+
+2022-01-04  Yusuke Suzuki  <ysuz...@apple.com>
+
         WebAssembly i32.atomic.wait timeout value incorrectly interpreted by factor 1000
         https://bugs.webkit.org/show_bug.cgi?id=234833
 

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (287581 => 287582)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2022-01-04 21:25:43 UTC (rev 287582)
@@ -1654,7 +1654,6 @@
 		AD7B4B2E1FA3E29800C9DF79 /* WasmNameSection.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7B4B2D1FA3E28600C9DF79 /* WasmNameSection.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		AD8FF3981EB5BDB20087FF82 /* WasmIndexOrName.h in Headers */ = {isa = PBXBuildFile; fileRef = AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */; settings = {ATTRIBUTES = (Private, ); }; };
-		AD9E852F1E8A0C7C008DE39E /* JSWebAssemblyCalleeGroup.h in Headers */ = {isa = PBXBuildFile; fileRef = AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCalleeGroup.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		ADD8FA461EB3079700DF542F /* WasmNameSectionParser.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */; };
 		ADE802991E08F1DE0058DE78 /* JSWebAssemblyLinkError.h in Headers */ = {isa = PBXBuildFile; fileRef = ADE802941E08F1C90058DE78 /* JSWebAssemblyLinkError.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		ADE8029A1E08F1DE0058DE78 /* WebAssemblyLinkErrorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = ADE802951E08F1C90058DE78 /* WebAssemblyLinkErrorConstructor.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3970,7 +3969,6 @@
 		5373B4D422ADB31400803572 /* WeakObjectRefConstructor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WeakObjectRefConstructor.cpp; sourceTree = "<group>"; };
 		5381B9361E60E9660090F794 /* WasmFaultSignalHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFaultSignalHandler.cpp; sourceTree = "<group>"; };
 		5381B9381E60E97D0090F794 /* WasmFaultSignalHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmFaultSignalHandler.h; sourceTree = "<group>"; };
-		5383AA2F1E65E8A100A532FC /* JSWebAssemblyCalleeGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyCalleeGroup.cpp; path = js/JSWebAssemblyCalleeGroup.cpp; sourceTree = "<group>"; };
 		538F15DD268FBBB300D601C4 /* UnifiedSource148.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource148.cpp; path = "DerivedSources/_javascript_Core/unified-sources/UnifiedSource148.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
 		538F15DE268FBBB300D601C4 /* UnifiedSource151.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource151.cpp; path = "DerivedSources/_javascript_Core/unified-sources/UnifiedSource151.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
 		538F15DF268FBBB300D601C4 /* UnifiedSource152.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource152.cpp; path = "DerivedSources/_javascript_Core/unified-sources/UnifiedSource152.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -4960,7 +4958,6 @@
 		AD8DD6D01F6708A30004EB52 /* JSToWasm.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JSToWasm.cpp; path = js/JSToWasm.cpp; sourceTree = "<group>"; };
 		AD8FF3951EB5BD850087FF82 /* WasmIndexOrName.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmIndexOrName.h; sourceTree = "<group>"; };
 		AD8FF3961EB5BD850087FF82 /* WasmIndexOrName.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmIndexOrName.cpp; sourceTree = "<group>"; };
-		AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCalleeGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyCalleeGroup.h; path = js/JSWebAssemblyCalleeGroup.h; sourceTree = "<group>"; };
 		ADB6F67C1E15D7500082F384 /* WasmPageCount.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPageCount.cpp; sourceTree = "<group>"; };
 		ADD09AEE1F5F623F001313C2 /* WasmToJS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WasmToJS.h; path = js/WasmToJS.h; sourceTree = "<group>"; };
 		ADD09AEF1F5F623F001313C2 /* WasmToJS.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = WasmToJS.cpp; path = js/WasmToJS.cpp; sourceTree = "<group>"; };
@@ -9266,8 +9263,6 @@
 				527CE35322555FDD00C6F382 /* JSToWasmICCallee.h */,
 				ADD09AF21F624829001313C2 /* JSWebAssembly.cpp */,
 				ADD09AF31F62482E001313C2 /* JSWebAssembly.h */,
-				5383AA2F1E65E8A100A532FC /* JSWebAssemblyCalleeGroup.cpp */,
-				AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCalleeGroup.h */,
 				AD2FCBA61DB58DA400B3E736 /* JSWebAssemblyCompileError.cpp */,
 				AD2FCBA71DB58DA400B3E736 /* JSWebAssemblyCompileError.h */,
 				14D01BDC26DEEF3700CAE0D0 /* JSWebAssemblyException.cpp */,
@@ -10670,7 +10665,6 @@
 				709FB8681AE335C60039D069 /* JSWeakSet.h in Headers */,
 				7A9774A8206B82E4008D03D0 /* JSWeakValue.h in Headers */,
 				AD5C36EB1F75AD73000BCAAF /* JSWebAssembly.h in Headers */,
-				AD9E852F1E8A0C7C008DE39E /* JSWebAssemblyCalleeGroup.h in Headers */,
 				AD2FCBE31DB58DAD00B3E736 /* JSWebAssemblyCompileError.h in Headers */,
 				14D01BED26DEEF3800CAE0D0 /* JSWebAssemblyException.h in Headers */,
 				E3BF3C4D2390D1E8008BC752 /* JSWebAssemblyGlobal.h in Headers */,

Modified: trunk/Source/_javascript_Core/Sources.txt (287581 => 287582)


--- trunk/Source/_javascript_Core/Sources.txt	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/Sources.txt	2022-01-04 21:25:43 UTC (rev 287582)
@@ -1113,7 +1113,6 @@
 wasm/js/JSToWasm.h
 wasm/js/JSToWasmICCallee.cpp
 wasm/js/JSWebAssembly.cpp
-wasm/js/JSWebAssemblyCalleeGroup.cpp
 wasm/js/JSWebAssemblyCompileError.cpp
 wasm/js/JSWebAssemblyException.cpp
 wasm/js/JSWebAssemblyGlobal.cpp

Modified: trunk/Source/_javascript_Core/heap/Heap.cpp (287581 => 287582)


--- trunk/Source/_javascript_Core/heap/Heap.cpp	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/heap/Heap.cpp	2022-01-04 21:25:43 UTC (rev 287582)
@@ -55,7 +55,6 @@
 #include "JSWeakMap.h"
 #include "JSWeakObjectRef.h"
 #include "JSWeakSet.h"
-#include "JSWebAssemblyCalleeGroup.h"
 #include "MachineStackMarker.h"
 #include "MarkStackMergingConstraint.h"
 #include "MarkedJSValueRefArray.h"
@@ -335,7 +334,6 @@
     , intlSegmenterHeapCellType(IsoHeapCellType::Args<IntlSegmenter>())
     , intlSegmentsHeapCellType(IsoHeapCellType::Args<IntlSegments>())
 #if ENABLE(WEBASSEMBLY)
-    , webAssemblyCalleeGroupHeapCellType(IsoHeapCellType::Args<JSWebAssemblyCalleeGroup>())
     , webAssemblyExceptionHeapCellType(IsoHeapCellType::Args<JSWebAssemblyException>())
     , webAssemblyFunctionHeapCellType(IsoHeapCellType::Args<WebAssemblyFunction>())
     , webAssemblyGlobalHeapCellType(IsoHeapCellType::Args<JSWebAssemblyGlobal>())
@@ -714,8 +712,8 @@
         finalizeMarkedUnconditionalFinalizers<JSFinalizationRegistry>(*m_finalizationRegistrySpace);
 
 #if ENABLE(WEBASSEMBLY)
-    if (m_webAssemblyCalleeGroupSpace)
-        finalizeMarkedUnconditionalFinalizers<JSWebAssemblyCalleeGroup>(*m_webAssemblyCalleeGroupSpace);
+    if (m_webAssemblyModuleSpace)
+        finalizeMarkedUnconditionalFinalizers<JSWebAssemblyModule>(*m_webAssemblyModuleSpace);
 #endif
 }
 
@@ -1036,10 +1034,10 @@
         // points into a CodeBlock that could be dead. The IC will still succeed because
         // it uses a callee check, but then it will call into dead code.
         HeapIterationScope heapIterationScope(*this);
-        if (m_webAssemblyCalleeGroupSpace) {
-            m_webAssemblyCalleeGroupSpace->forEachLiveCell([&] (HeapCell* cell, HeapCell::Kind kind) {
+        if (m_webAssemblyModuleSpace) {
+            m_webAssemblyModuleSpace->forEachLiveCell([&] (HeapCell* cell, HeapCell::Kind kind) {
                 ASSERT_UNUSED(kind, kind == HeapCell::JSCell);
-                static_cast<JSWebAssemblyCalleeGroup*>(cell)->clearJSCallICs(vm);
+                static_cast<JSWebAssemblyModule*>(cell)->clearJSCallICs(vm);
             });
         }
     }
@@ -3274,7 +3272,6 @@
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(intlSegmentsSpace, intlSegmentsHeapCellType, IntlSegments)
 #if ENABLE(WEBASSEMBLY)
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(jsToWasmICCalleeSpace, cellHeapCellType, JSToWasmICCallee)
-DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyCalleeGroupSpace, webAssemblyCalleeGroupHeapCellType, JSWebAssemblyCalleeGroup) // Hash:0x9ad995cd
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyExceptionSpace, webAssemblyExceptionHeapCellType, JSWebAssemblyException)
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyFunctionSpace, webAssemblyFunctionHeapCellType, WebAssemblyFunction) // Hash:0x8b7c32db
 DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER_SLOW(webAssemblyGlobalSpace, webAssemblyGlobalHeapCellType, JSWebAssemblyGlobal)

Modified: trunk/Source/_javascript_Core/heap/Heap.h (287581 => 287582)


--- trunk/Source/_javascript_Core/heap/Heap.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/heap/Heap.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -785,7 +785,6 @@
     IsoHeapCellType intlSegmenterHeapCellType;
     IsoHeapCellType intlSegmentsHeapCellType;
 #if ENABLE(WEBASSEMBLY)
-    IsoHeapCellType webAssemblyCalleeGroupHeapCellType;
     IsoHeapCellType webAssemblyExceptionHeapCellType;
     IsoHeapCellType webAssemblyFunctionHeapCellType;
     IsoHeapCellType webAssemblyGlobalHeapCellType;
@@ -967,7 +966,6 @@
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlSegmentsSpace)
 #if ENABLE(WEBASSEMBLY)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(jsToWasmICCalleeSpace)
-    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyCalleeGroupSpace)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyExceptionSpace)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyFunctionSpace)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyGlobalSpace)

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (287581 => 287582)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2022-01-04 21:25:43 UTC (rev 287582)
@@ -77,7 +77,6 @@
 #include "JSSet.h"
 #include "JSSourceCode.h"
 #include "JSTemplateObjectDescriptor.h"
-#include "JSWebAssemblyCalleeGroup.h"
 #include "LLIntData.h"
 #include "LLIntExceptions.h"
 #include "MarkedBlockInlines.h"
@@ -270,9 +269,6 @@
     evalExecutableStructure.set(*this, EvalExecutable::createStructure(*this, nullptr, jsNull()));
     programExecutableStructure.set(*this, ProgramExecutable::createStructure(*this, nullptr, jsNull()));
     functionExecutableStructure.set(*this, FunctionExecutable::createStructure(*this, nullptr, jsNull()));
-#if ENABLE(WEBASSEMBLY)
-    webAssemblyCalleeGroupStructure.set(*this, JSWebAssemblyCalleeGroup::createStructure(*this, nullptr, jsNull()));
-#endif
     moduleProgramExecutableStructure.set(*this, ModuleProgramExecutable::createStructure(*this, nullptr, jsNull()));
     regExpStructure.set(*this, RegExp::createStructure(*this, nullptr, jsNull()));
     symbolStructure.set(*this, Symbol::createStructure(*this, nullptr, jsNull()));

Modified: trunk/Source/_javascript_Core/runtime/VM.h (287581 => 287582)


--- trunk/Source/_javascript_Core/runtime/VM.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/runtime/VM.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -476,7 +476,6 @@
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(intlSegmentsSpace)
 #if ENABLE(WEBASSEMBLY)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(jsToWasmICCalleeSpace)
-    DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyCalleeGroupSpace)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyExceptionSpace)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyFunctionSpace)
     DYNAMIC_ISO_SUBSPACE_DEFINE_MEMBER(webAssemblyGlobalSpace)

Modified: trunk/Source/_javascript_Core/wasm/WasmBinding.h (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/WasmBinding.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/WasmBinding.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -28,6 +28,7 @@
 #if ENABLE(WEBASSEMBLY)
 
 #include "JITCompilation.h"
+#include "WasmBinding.h"
 #include "WasmFormat.h"
 #include <wtf/Expected.h>
 

Deleted: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCalleeGroup.cpp (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCalleeGroup.cpp	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCalleeGroup.cpp	2022-01-04 21:25:43 UTC (rev 287582)
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2017-2021 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 "JSWebAssemblyCalleeGroup.h"
-
-#if ENABLE(WEBASSEMBLY)
-
-#include "JSCJSValueInlines.h"
-#include "JSCellInlines.h"
-#include "WasmModuleInformation.h"
-#include "WasmToJS.h"
-
-namespace JSC {
-
-const ClassInfo JSWebAssemblyCalleeGroup::s_info = { "WebAssemblyCalleeGroup", nullptr, nullptr, nullptr, CREATE_METHOD_TABLE(JSWebAssemblyCalleeGroup) };
-
-JSWebAssemblyCalleeGroup* JSWebAssemblyCalleeGroup::create(VM& vm, Ref<Wasm::CalleeGroup> calleeGroup, const Wasm::ModuleInformation& moduleInformation)
-{
-    auto* result = new (NotNull, allocateCell<JSWebAssemblyCalleeGroup>(vm)) JSWebAssemblyCalleeGroup(vm, WTFMove(calleeGroup), moduleInformation);
-    result->finishCreation(vm);
-    return result;
-}
-
-JSWebAssemblyCalleeGroup::JSWebAssemblyCalleeGroup(VM& vm, Ref<Wasm::CalleeGroup>&& calleeGroup, const Wasm::ModuleInformation& moduleInformation)
-    : Base(vm, vm.webAssemblyCalleeGroupStructure.get())
-    , m_calleeGroup(WTFMove(calleeGroup))
-    , m_wasmToJSExitStubs(m_calleeGroup->functionImportCount())
-{
-    // FIXME: We should not need to do this synchronously.
-    // https://bugs.webkit.org/show_bug.cgi?id=170567
-    for (unsigned importIndex = 0; importIndex < m_calleeGroup->functionImportCount(); ++importIndex) {
-        Wasm::SignatureIndex signatureIndex = moduleInformation.importFunctionSignatureIndices.at(importIndex);
-        auto binding = Wasm::wasmToJS(vm, m_callLinkInfos, signatureIndex, importIndex);
-        if (UNLIKELY(!binding)) {
-            switch (binding.error()) {
-            case Wasm::BindingFailure::OutOfMemory:
-                m_errorMessage = "Out of executable memory"_s;
-                return;
-            }
-            RELEASE_ASSERT_NOT_REACHED();
-        }
-        m_wasmToJSExitStubs[importIndex] = binding.value();
-    }
-}
-
-void JSWebAssemblyCalleeGroup::finishCreation(VM& vm)
-{
-    Base::finishCreation(vm);
-}
-
-void JSWebAssemblyCalleeGroup::destroy(JSCell* cell)
-{
-    static_cast<JSWebAssemblyCalleeGroup*>(cell)->JSWebAssemblyCalleeGroup::~JSWebAssemblyCalleeGroup();
-}
-
-void JSWebAssemblyCalleeGroup::clearJSCallICs(VM& vm)
-{
-    for (auto iter = m_callLinkInfos.begin(); !!iter; ++iter)
-        (*iter)->unlink(vm);
-}
-
-template<typename Visitor>
-void JSWebAssemblyCalleeGroup::visitChildrenImpl(JSCell* cell, Visitor& visitor)
-{
-    JSWebAssemblyCalleeGroup* thisObject = jsCast<JSWebAssemblyCalleeGroup*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-
-    Base::visitChildren(thisObject, visitor);
-}
-
-DEFINE_VISIT_CHILDREN(JSWebAssemblyCalleeGroup);
-
-void JSWebAssemblyCalleeGroup::finalizeUnconditionally(VM& vm)
-{
-    for (auto iter = m_callLinkInfos.begin(); !!iter; ++iter)
-        (*iter)->visitWeak(vm);
-}
-
-} // namespace JSC
-
-#endif // ENABLE(WEBASSEMBLY)

Deleted: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCalleeGroup.h (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCalleeGroup.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCalleeGroup.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2017-2021 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
-
-#if ENABLE(WEBASSEMBLY)
-
-#include "CallLinkInfo.h"
-#include "DeferredWorkTimer.h"
-#include "JSCast.h"
-#include "Structure.h"
-#include "WasmCallee.h"
-#include "WasmFormat.h"
-#include "WasmModule.h"
-#include <wtf/Bag.h>
-#include <wtf/Ref.h>
-#include <wtf/Vector.h>
-
-namespace JSC {
-
-class JSWebAssemblyMemory;
-
-namespace Wasm {
-class Plan;
-}
-
-class JSWebAssemblyCalleeGroup final : public JSCell {
-public:
-    typedef JSCell Base;
-    static constexpr unsigned StructureFlags = Base::StructureFlags | StructureIsImmortal;
-
-    static JSWebAssemblyCalleeGroup* create(VM&, Ref<Wasm::CalleeGroup>, const Wasm::ModuleInformation&);
-    static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-    {
-        return Structure::create(vm, globalObject, prototype, TypeInfo(CellType, StructureFlags), info());
-    }
-
-    template<typename CellType, SubspaceAccess mode>
-    static IsoSubspace* subspaceFor(VM& vm)
-    {
-        return vm.webAssemblyCalleeGroupSpace<mode>();
-    }
-
-    Wasm::CalleeGroup& calleeGroup() { return m_calleeGroup.get(); }
-    
-    MacroAssemblerCodePtr<WasmEntryPtrTag> wasmToEmbedderStub(size_t importFunctionNum) { return m_wasmToJSExitStubs[importFunctionNum].code(); }
-
-    void finishCreation(VM&);
-
-    void clearJSCallICs(VM&);
-
-    bool runnable() const { return !m_errorMessage; }
-
-    String errorMessage()
-    {
-        ASSERT(!runnable());
-        return m_errorMessage;
-    }
-
-    void finalizeUnconditionally(VM&);
-
-private:
-    JSWebAssemblyCalleeGroup(VM&, Ref<Wasm::CalleeGroup>&&, const Wasm::ModuleInformation&);
-    DECLARE_EXPORT_INFO;
-    static constexpr bool needsDestruction = true;
-    static void destroy(JSCell*);
-    DECLARE_VISIT_CHILDREN;
-
-    Ref<Wasm::CalleeGroup> m_calleeGroup;
-    FixedVector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToJSExitStubs;
-    Bag<OptimizingCallLinkInfo> m_callLinkInfos;
-    String m_errorMessage;
-};
-
-} // namespace JSC
-
-#endif // ENABLE(WEBASSEMBLY)

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp	2022-01-04 21:25:43 UTC (rev 287582)
@@ -81,7 +81,6 @@
 
     Base::visitChildren(thisObject, visitor);
     visitor.append(thisObject->m_module);
-    visitor.append(thisObject->m_calleeGroup);
     visitor.append(thisObject->m_moduleRecord);
     visitor.append(thisObject->m_memory);
     for (auto& table : thisObject->m_tables)
@@ -117,23 +116,6 @@
     }
 
     RELEASE_ASSERT(wasmCalleeGroup->isSafeToRun(memoryMode()));
-    JSWebAssemblyCalleeGroup* jsCalleeGroup = m_module->calleeGroup(memoryMode());
-    if (jsCalleeGroup) {
-        // A CalleeGroup might have already been compiled. If so, it means
-        // that the CalleeGroup we are trying to compile must be the same
-        // because we will never compile a CalleeGroup again once it's
-        // runnable.
-        ASSERT(&jsCalleeGroup->calleeGroup() == wasmCalleeGroup.ptr());
-        m_calleeGroup.set(vm, this, jsCalleeGroup);
-    } else {
-        jsCalleeGroup = JSWebAssemblyCalleeGroup::create(vm, WTFMove(wasmCalleeGroup), module()->module().moduleInformation());
-        if (UNLIKELY(!jsCalleeGroup->runnable())) {
-            throwException(globalObject, scope, createJSWebAssemblyLinkError(globalObject, vm, jsCalleeGroup->errorMessage()));
-            return;
-        }
-        m_calleeGroup.set(vm, this, jsCalleeGroup);
-        m_module->setCalleeGroup(vm, memoryMode(), jsCalleeGroup);
-    }
 
     // In the module loader case, we will initialize all memory modes with the initial LLInt compilation
     // results, so that later when memory imports become available, the appropriate CalleeGroup can be used.
@@ -148,19 +130,13 @@
             if (i == static_cast<uint8_t>(initialMode))
                 continue;
             Wasm::MemoryMode memoryMode = static_cast<Wasm::MemoryMode>(i);
-            RefPtr<Wasm::CalleeGroup> calleeGroup = module()->module().calleeGroupFor(memoryMode);
-            jsCalleeGroup = JSWebAssemblyCalleeGroup::create(vm, calleeGroup.releaseNonNull(), module()->module().moduleInformation());
-            if (UNLIKELY(!jsCalleeGroup->runnable())) {
-                throwException(globalObject, scope, createJSWebAssemblyLinkError(globalObject, vm, jsCalleeGroup->errorMessage()));
-                return;
-            }
-            m_module->setCalleeGroup(vm, memoryMode, jsCalleeGroup);
+            module()->module().calleeGroupFor(memoryMode); // Materialize Wasm::CalleeGroup.
         }
     }
 
     for (unsigned importFunctionNum = 0; importFunctionNum < instance().numImportFunctions(); ++importFunctionNum) {
         auto* info = instance().importFunctionInfo(importFunctionNum);
-        info->wasmToEmbedderStub = m_calleeGroup->wasmToEmbedderStub(importFunctionNum);
+        info->wasmToEmbedderStub = m_module->wasmToEmbedderStub(importFunctionNum);
     }
 
     m_moduleRecord->prepareLink(vm, this);

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.h (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -28,7 +28,6 @@
 #if ENABLE(WEBASSEMBLY)
 
 #include "JSDestructibleObject.h"
-#include "JSWebAssemblyCalleeGroup.h"
 #include "JSWebAssemblyGlobal.h"
 #include "JSWebAssemblyMemory.h"
 #include "JSWebAssemblyTable.h"
@@ -114,7 +113,6 @@
 
     WriteBarrier<JSGlobalObject> m_globalObject;
     WriteBarrier<JSWebAssemblyModule> m_module;
-    WriteBarrier<JSWebAssemblyCalleeGroup> m_calleeGroup;
     WriteBarrier<WebAssemblyModuleRecord> m_moduleRecord;
     WriteBarrier<JSWebAssemblyMemory> m_memory;
     FixedVector<WriteBarrier<JSWebAssemblyTable>> m_tables;

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyModule.cpp (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyModule.cpp	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyModule.cpp	2022-01-04 21:25:43 UTC (rev 287582)
@@ -29,11 +29,11 @@
 #if ENABLE(WEBASSEMBLY)
 
 #include "JSCInlines.h"
-#include "JSWebAssemblyCalleeGroup.h"
 #include "JSWebAssemblyCompileError.h"
 #include "WasmFormat.h"
 #include "WasmModule.h"
 #include "WasmModuleInformation.h"
+#include "WasmToJS.h"
 #include <wtf/StdLibExtras.h>
 
 namespace JSC {
@@ -52,6 +52,16 @@
 
     auto* module = new (NotNull, allocateCell<JSWebAssemblyModule>(vm)) JSWebAssemblyModule(vm, structure, result.value().releaseNonNull());
     module->finishCreation(vm);
+
+    auto error = module->generateWasmToJSStubs(vm);
+    if (UNLIKELY(!error)) {
+        switch (error.error()) {
+        case Wasm::BindingFailure::OutOfMemory:
+            throwException(globalObject, scope, createJSWebAssemblyLinkError(globalObject, vm, "Out of executable memory"_s));
+            return nullptr;
+        }
+        ASSERT_NOT_REACHED();
+    }
     return module;
 }
 
@@ -109,21 +119,11 @@
     return m_module->signatureIndexFromFunctionIndexSpace(functionIndexSpace);
 }
 
-JSWebAssemblyCalleeGroup* JSWebAssemblyModule::calleeGroup(Wasm::MemoryMode mode)
-{
-    return m_calleeGroups[static_cast<size_t>(mode)].get();
-}
-
 Wasm::Module& JSWebAssemblyModule::module()
 {
     return m_module.get();
 }
 
-void JSWebAssemblyModule::setCalleeGroup(VM& vm, Wasm::MemoryMode mode, JSWebAssemblyCalleeGroup* calleeGroup)
-{
-    m_calleeGroups[static_cast<size_t>(mode)].set(vm, this, calleeGroup);
-}
-
 template<typename Visitor>
 void JSWebAssemblyModule::visitChildrenImpl(JSCell* cell, Visitor& visitor)
 {
@@ -132,12 +132,41 @@
 
     Base::visitChildren(thisObject, visitor);
     visitor.append(thisObject->m_exportSymbolTable);
-    for (unsigned i = 0; i < Wasm::NumberOfMemoryModes; ++i)
-        visitor.append(thisObject->m_calleeGroups[i]);
 }
 
 DEFINE_VISIT_CHILDREN(JSWebAssemblyModule);
 
+void JSWebAssemblyModule::clearJSCallICs(VM& vm)
+{
+    for (auto iter = m_callLinkInfos.begin(); !!iter; ++iter)
+        (*iter)->unlink(vm);
+}
+
+void JSWebAssemblyModule::finalizeUnconditionally(VM& vm)
+{
+    for (auto iter = m_callLinkInfos.begin(); !!iter; ++iter)
+        (*iter)->visitWeak(vm);
+}
+
+Expected<void, Wasm::BindingFailure> JSWebAssemblyModule::generateWasmToJSStubs(VM& vm)
+{
+    const Wasm::ModuleInformation& moduleInformation = m_module->moduleInformation();
+    if (moduleInformation.importFunctionCount()) {
+        Bag<OptimizingCallLinkInfo> callLinkInfos;
+        FixedVector<MacroAssemblerCodeRef<WasmEntryPtrTag>> stubs(moduleInformation.importFunctionCount());
+        for (unsigned importIndex = 0; importIndex < moduleInformation.importFunctionCount(); ++importIndex) {
+            Wasm::SignatureIndex signatureIndex = moduleInformation.importFunctionSignatureIndices.at(importIndex);
+            auto binding = Wasm::wasmToJS(vm, callLinkInfos, signatureIndex, importIndex);
+            if (UNLIKELY(!binding))
+                return makeUnexpected(binding.error());
+            stubs[importIndex] = binding.value();
+        }
+        m_wasmToJSExitStubs = WTFMove(stubs);
+        m_callLinkInfos = WTFMove(callLinkInfos);
+    }
+    return { };
+}
+
 } // namespace JSC
 
 #endif // ENABLE(WEBASSEMBLY)

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyModule.h (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyModule.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyModule.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -43,10 +43,10 @@
 class Module;
 struct ModuleInformation;
 class Plan;
+enum class BindingFailure;
 }
 
 class SymbolTable;
-class JSWebAssemblyCalleeGroup;
 class JSWebAssemblyMemory;
 
 class JSWebAssemblyModule final : public JSNonFinalObject {
@@ -70,14 +70,15 @@
     SymbolTable* exportSymbolTable() const;
     Wasm::SignatureIndex signatureIndexFromFunctionIndexSpace(unsigned functionIndexSpace) const;
 
-    JSWebAssemblyCalleeGroup* calleeGroup(Wasm::MemoryMode);
-    void setCalleeGroup(VM&, Wasm::MemoryMode, JSWebAssemblyCalleeGroup*);
+    Expected<void, Wasm::BindingFailure> generateWasmToJSStubs(VM&);
+    MacroAssemblerCodePtr<WasmEntryPtrTag> wasmToEmbedderStub(size_t importFunctionNum) { return m_wasmToJSExitStubs[importFunctionNum].code(); }
 
+    void clearJSCallICs(VM&);
+    void finalizeUnconditionally(VM&);
+
     JS_EXPORT_PRIVATE Wasm::Module& module();
 
 private:
-    friend class JSWebAssemblyCalleeGroup;
-
     JSWebAssemblyModule(VM&, Structure*, Ref<Wasm::Module>&&);
     void finishCreation(VM&);
     DECLARE_VISIT_CHILDREN;
@@ -84,7 +85,8 @@
 
     Ref<Wasm::Module> m_module;
     WriteBarrier<SymbolTable> m_exportSymbolTable;
-    WriteBarrier<JSWebAssemblyCalleeGroup> m_calleeGroups[Wasm::NumberOfMemoryModes];
+    FixedVector<MacroAssemblerCodeRef<WasmEntryPtrTag>> m_wasmToJSExitStubs;
+    Bag<OptimizingCallLinkInfo> m_callLinkInfos;
 };
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleConstructor.cpp (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleConstructor.cpp	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleConstructor.cpp	2022-01-04 21:25:43 UTC (rev 287582)
@@ -37,6 +37,7 @@
 #include "JSWebAssemblyHelpers.h"
 #include "JSWebAssemblyModule.h"
 #include "ObjectConstructor.h"
+#include "WasmModule.h"
 #include "WasmModuleInformation.h"
 #include "WebAssemblyModulePrototype.h"
 #include <wtf/StdLibExtras.h>

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.h (287581 => 287582)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.h	2022-01-04 20:59:30 UTC (rev 287581)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.h	2022-01-04 21:25:43 UTC (rev 287582)
@@ -27,7 +27,6 @@
 
 #if ENABLE(WEBASSEMBLY)
 
-#include "JSWebAssemblyCalleeGroup.h"
 #include "WebAssemblyFunctionBase.h"
 
 namespace JSC {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to