Title: [222873] trunk/Source/_javascript_Core
Revision
222873
Author
[email protected]
Date
2017-10-04 13:20:43 -0700 (Wed, 04 Oct 2017)

Log Message

WebAssembly: address no VM / JS follow-ups
https://bugs.webkit.org/show_bug.cgi?id=177887

Reviewed by Saam Barati.

All minor fixes, no functional changes.

* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::B3IRGenerator::restoreWebAssemblyGlobalState):
(JSC::Wasm::B3IRGenerator::addCurrentMemory):
(JSC::Wasm::B3IRGenerator::addCall):
(JSC::Wasm::B3IRGenerator::addCallIndirect):
* wasm/WasmContext.cpp:
(JSC::Wasm::Context::store):
* wasm/WasmMemoryMode.h:
* wasm/WasmTable.h:
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::JSWebAssemblyInstance):
* wasm/js/JSWebAssemblyTable.cpp:
(JSC::JSWebAssemblyTable::JSWebAssemblyTable):
(JSC::JSWebAssemblyTable::grow):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (222872 => 222873)


--- trunk/Source/_javascript_Core/ChangeLog	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-10-04 20:20:43 UTC (rev 222873)
@@ -1,3 +1,28 @@
+2017-10-04  JF Bastien  <[email protected]>
+
+        WebAssembly: address no VM / JS follow-ups
+        https://bugs.webkit.org/show_bug.cgi?id=177887
+
+        Reviewed by Saam Barati.
+
+        All minor fixes, no functional changes.
+
+        * wasm/WasmB3IRGenerator.cpp:
+        (JSC::Wasm::B3IRGenerator::B3IRGenerator):
+        (JSC::Wasm::B3IRGenerator::restoreWebAssemblyGlobalState):
+        (JSC::Wasm::B3IRGenerator::addCurrentMemory):
+        (JSC::Wasm::B3IRGenerator::addCall):
+        (JSC::Wasm::B3IRGenerator::addCallIndirect):
+        * wasm/WasmContext.cpp:
+        (JSC::Wasm::Context::store):
+        * wasm/WasmMemoryMode.h:
+        * wasm/WasmTable.h:
+        * wasm/js/JSWebAssemblyInstance.cpp:
+        (JSC::JSWebAssemblyInstance::JSWebAssemblyInstance):
+        * wasm/js/JSWebAssemblyTable.cpp:
+        (JSC::JSWebAssemblyTable::JSWebAssemblyTable):
+        (JSC::JSWebAssemblyTable::grow):
+
 2017-10-04  Mark Lam  <[email protected]>
 
         Add support for using Probe DFG OSR Exit behind a runtime flag.

Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (222872 => 222873)


--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp	2017-10-04 20:20:43 UTC (rev 222873)
@@ -369,7 +369,10 @@
         case MemoryMode::BoundsChecking:
             break;
         case MemoryMode::Signaling:
-        // Most memory accesses in signaling mode don't do an explicit exception check because they can rely on fault handling to detect out-of-bounds accesses. FaultSignalHandler nonetheless needs the thunk to exist so that it can jump to that thunk.
+            // Most memory accesses in signaling mode don't do an explicit
+            // exception check because they can rely on fault handling to detect
+            // out-of-bounds accesses. FaultSignalHandler nonetheless needs the
+            // thunk to exist so that it can jump to that thunk.
             if (UNLIKELY(!Thunks::singleton().stub(throwExceptionFromWasmThunkGenerator)))
                 CRASH();
             break;
@@ -473,8 +476,8 @@
             const auto& sizeRegs = pinnedRegs->sizeRegisters;
             ASSERT(sizeRegs.size() >= 1);
             ASSERT(!sizeRegs[0].sizeOffset); // The following code assumes we start at 0, and calculates subsequent size registers relative to 0.
-            jit.loadPtr(CCallHelpers::Address(baseMemory, Wasm::Memory::offsetOfSize()), sizeRegs[0].sizeRegister);
-            jit.loadPtr(CCallHelpers::Address(baseMemory, Wasm::Memory::offsetOfMemory()), baseMemory);
+            jit.loadPtr(CCallHelpers::Address(baseMemory, Memory::offsetOfSize()), sizeRegs[0].sizeRegister);
+            jit.loadPtr(CCallHelpers::Address(baseMemory, Memory::offsetOfMemory()), baseMemory);
             for (unsigned i = 1; i < sizeRegs.size(); ++i)
                 jit.add64(CCallHelpers::TrustedImm32(-sizeRegs[i].sizeOffset), sizeRegs[0].sizeRegister, sizeRegs[i].sizeRegister);
         });
@@ -583,8 +586,8 @@
 {
     Value* memoryObject = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(), instanceValue(), safeCast<int32_t>(JSWebAssemblyInstance::offsetOfWasmMemory()));
 
-    static_assert(sizeof(decltype(static_cast<Wasm::Memory*>(nullptr)->size())) == sizeof(uint64_t), "codegen relies on this size");
-    Value* size = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int64, origin(), memoryObject, safeCast<int32_t>(Wasm::Memory::offsetOfSize()));
+    static_assert(sizeof(decltype(static_cast<Memory*>(nullptr)->size())) == sizeof(uint64_t), "codegen relies on this size");
+    Value* size = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int64, origin(), memoryObject, safeCast<int32_t>(Memory::offsetOfSize()));
     
     constexpr uint32_t shiftValue = 16;
     static_assert(PageCount::pageSize == 1ull << shiftValue, "This must hold for the code below to be correct.");
@@ -1107,7 +1110,7 @@
 
         // FIXME: Let's remove this indirection by creating a PIC friendly IC
         // for calls out to JS. This shouldn't be that hard to do. We could probably
-        // implement the IC to be over Wasm::Context*.
+        // implement the IC to be over Context*.
         // https://bugs.webkit.org/show_bug.cgi?id=170375
         Value* codeBlock = isEmbedderBlock->appendNew<MemoryValue>(m_proc,
             Load, pointerType(), origin(), instanceValue(), safeCast<int32_t>(JSWebAssemblyInstance::offsetOfWasmCodeBlock()));
@@ -1179,11 +1182,11 @@
         ExpressionType table = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(),
             instanceValue(), safeCast<int32_t>(JSWebAssemblyInstance::offsetOfWasmTable()));
         callableFunctionBuffer = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(),
-            table, safeCast<int32_t>(Wasm::Table::offsetOfFunctions()));
+            table, safeCast<int32_t>(Table::offsetOfFunctions()));
         instancesBuffer = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(),
-            table, safeCast<int32_t>(Wasm::Table::offsetOfInstances()));
+            table, safeCast<int32_t>(Table::offsetOfInstances()));
         callableFunctionBufferSize = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, Int32, origin(),
-            table, safeCast<int32_t>(Wasm::Table::offsetOfSize()));
+            table, safeCast<int32_t>(Table::offsetOfSize()));
     }
 
     // Check the index we are looking for is valid.
@@ -1232,7 +1235,7 @@
     {
         Value* offset = m_currentBlock->appendNew<Value>(m_proc, Mul, origin(),
             m_currentBlock->appendNew<Value>(m_proc, ZExt32, origin(), calleeIndex),
-            constant(pointerType(), sizeof(Wasm::Instance*)));
+            constant(pointerType(), sizeof(Instance*)));
         Value* newContextInstance = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(),
             m_currentBlock->appendNew<Value>(m_proc, Add, origin(), instancesBuffer, offset));
 
@@ -1263,13 +1266,13 @@
             jit.loadPtr(CCallHelpers::Address(oldContextInstance, JSWebAssemblyInstance::offsetOfCachedStackLimit()), baseMemory);
             jit.storePtr(baseMemory, CCallHelpers::Address(newContextInstance, JSWebAssemblyInstance::offsetOfCachedStackLimit()));
             jit.storeWasmContextInstance(newContextInstance);
-            jit.loadPtr(CCallHelpers::Address(newContextInstance, JSWebAssemblyInstance::offsetOfWasmMemory()), baseMemory); // Wasm::Memory*.
+            jit.loadPtr(CCallHelpers::Address(newContextInstance, JSWebAssemblyInstance::offsetOfWasmMemory()), baseMemory); // Memory*.
             ASSERT(sizeRegs.size() == 1);
             ASSERT(sizeRegs[0].sizeRegister != baseMemory);
             ASSERT(sizeRegs[0].sizeRegister != newContextInstance);
             ASSERT(!sizeRegs[0].sizeOffset);
-            jit.loadPtr(CCallHelpers::Address(baseMemory, Wasm::Memory::offsetOfSize()), sizeRegs[0].sizeRegister); // Memory size.
-            jit.loadPtr(CCallHelpers::Address(baseMemory, Wasm::Memory::offsetOfMemory()), baseMemory); // Wasm::Memory::void*.
+            jit.loadPtr(CCallHelpers::Address(baseMemory, Memory::offsetOfSize()), sizeRegs[0].sizeRegister); // Memory size.
+            jit.loadPtr(CCallHelpers::Address(baseMemory, Memory::offsetOfMemory()), baseMemory); // Memory::void*.
         });
         doContextSwitch->appendNewControlValue(m_proc, Jump, origin(), continuation);
 

Modified: trunk/Source/_javascript_Core/wasm/WasmContext.cpp (222872 => 222873)


--- trunk/Source/_javascript_Core/wasm/WasmContext.cpp	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/wasm/WasmContext.cpp	2017-10-04 20:20:43 UTC (rev 222873)
@@ -54,13 +54,13 @@
     return instance;
 }
 
-void Context::store(JSWebAssemblyInstance* i, void* softStackLimit)
+void Context::store(JSWebAssemblyInstance* inst, void* softStackLimit)
 {
 #if ENABLE(FAST_TLS_JIT)
     if (useFastTLS())
-        _pthread_setspecific_direct(WTF_WASM_CONTEXT_KEY, bitwise_cast<void*>(i));
+        _pthread_setspecific_direct(WTF_WASM_CONTEXT_KEY, bitwise_cast<void*>(inst));
 #endif
-    instance = i;
+    instance = inst;
     if (instance)
         instance->setCachedStackLimit(softStackLimit);
 }

Modified: trunk/Source/_javascript_Core/wasm/WasmMemoryMode.h (222872 => 222873)


--- trunk/Source/_javascript_Core/wasm/WasmMemoryMode.h	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/wasm/WasmMemoryMode.h	2017-10-04 20:20:43 UTC (rev 222873)
@@ -29,10 +29,8 @@
 
 #include "JSExportMacros.h"
 
-namespace JSC {
+namespace JSC { namespace Wasm {
 
-namespace Wasm {
-
 // FIXME: We should support other modes. see: https://bugs.webkit.org/show_bug.cgi?id=162693
 enum class MemoryMode : uint8_t {
     BoundsChecking,

Modified: trunk/Source/_javascript_Core/wasm/WasmTable.h (222872 => 222873)


--- trunk/Source/_javascript_Core/wasm/WasmTable.h	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/wasm/WasmTable.h	2017-10-04 20:20:43 UTC (rev 222873)
@@ -42,9 +42,6 @@
 
 class Table : public ThreadSafeRefCounted<Table> {
 public:
-    enum class CreateFail {
-        InvalidSize,
-    };
     static RefPtr<Table> create(uint32_t initial, std::optional<uint32_t> maximum);
 
     JS_EXPORT_PRIVATE ~Table();

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp (222872 => 222873)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp	2017-10-04 20:20:43 UTC (rev 222873)
@@ -59,7 +59,7 @@
     , m_numImportFunctions(numImportFunctions)
 {
     for (unsigned i = 0; i < m_numImportFunctions; ++i)
-        new (importFunctionInfo(i)) ImportFunctionInfo();
+        default_construct_at(importFunctionInfo(i));
 }
 
 void JSWebAssemblyInstance::finishCreation(VM& vm, JSWebAssemblyModule* module, JSModuleNamespaceObject* moduleNamespaceObject)

Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyTable.cpp (222872 => 222873)


--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyTable.cpp	2017-10-04 20:12:15 UTC (rev 222872)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyTable.cpp	2017-10-04 20:20:43 UTC (rev 222873)
@@ -62,7 +62,7 @@
     // But for now, we're not doing that.
     m_jsFunctions = MallocPtr<WriteBarrier<JSObject>>::malloc(sizeof(WriteBarrier<JSObject>) * static_cast<size_t>(size()));
     for (uint32_t i = 0; i < size(); ++i)
-        new (&m_jsFunctions.get()[i]) WriteBarrier<JSObject>();
+        default_construct_at(&m_jsFunctions.get()[i]);
 }
 
 void JSWebAssemblyTable::finishCreation(VM& vm)
@@ -102,7 +102,7 @@
     m_jsFunctions.realloc(sizeof(WriteBarrier<JSObject>) * newSize);
 
     for (size_t i = oldSize; i < newSize; ++i)
-        new (&m_jsFunctions.get()[i]) WriteBarrier<JSObject>();
+        default_construct_at(&m_jsFunctions.get()[i]);
 
     return true;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to