Skip to content
Permalink
Browse files
WebAssembly: topEntryFrame on Wasm::Instance
https://bugs.webkit.org/show_bug.cgi?id=178690

Reviewed by Saam Barati.

topEntryFrame is usually on VM, but for a no-VM WebAssembly we
need to hold topEntryFrame elsewhere, and generated code cannot
hard-code where topEntryFrame live. Do this at creation time of
Wasm::Instance, and then generated code will just load from
wherever Wasm::Instance was told topEntryFrame is. In a JavaScript
embedding this is still from VM, so all of the unwinding machinery
stays the same.

* dfg/DFGOSREntry.cpp:
(JSC::DFG::prepareOSREntry):
* dfg/DFGOSRExit.cpp:
(JSC::DFG::restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer):
(JSC::DFG::copyCalleeSavesToVMEntryFrameCalleeSavesBuffer):
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::compileStub):
* interpreter/Interpreter.cpp:
(JSC::UnwindFunctor::copyCalleeSavesToEntryFrameCalleeSavesBuffer const):
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::restoreCalleeSavesFromEntryFrameCalleeSavesBuffer):
(JSC::AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBufferImpl):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBuffer):
The default parameter was never non-defaulted from any of the
callers. The new version calls the impl directly because it
doesn't have VM and doesn't hard-code the address of
topEntryFrame.
* jit/RegisterSet.cpp:
(JSC::RegisterSet::vmCalleeSaveRegisterOffsets): This was weird on
VM because it's not really VM-specific.
* jit/RegisterSet.h:
* runtime/VM.cpp:
(JSC::VM::getAllCalleeSaveRegisterOffsets): Deleted.
* runtime/VM.h:
(JSC::VM::getCTIStub):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::B3IRGenerator::addCall):
(JSC::Wasm::B3IRGenerator::addCallIndirect):
* wasm/WasmInstance.cpp:
(JSC::Wasm::Instance::Instance):
* wasm/WasmInstance.h: topEntryFramePointer will eventually live
here for real. Right now it's mirrored in JSWebAssemblyInstance
because that's the acting Context.
(JSC::Wasm::Instance::create):
(JSC::Wasm::Instance::offsetOfTopEntryFramePointer):
* wasm/WasmThunks.cpp:
(JSC::Wasm::throwExceptionFromWasmThunkGenerator):
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::JSWebAssemblyInstance):
* wasm/js/JSWebAssemblyInstance.h: Mirror Wasm::Instance temporarily.
(JSC::JSWebAssemblyInstance::offsetOfCallee):
(JSC::JSWebAssemblyInstance::offsetOfTopEntryFramePointer):
(JSC::JSWebAssemblyInstance::offsetOfVM): Deleted.
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyPrototype.cpp:
(JSC::instantiate):


Canonical link: https://commits.webkit.org/194862@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
jfbastien committed Oct 24, 2017
1 parent 0452764 commit f1507e18024fd34a7495c0c9f04e19a7782e71c7
Showing 19 changed files with 118 additions and 40 deletions.
@@ -1,3 +1,68 @@
2017-10-23 JF Bastien <jfbastien@apple.com>

WebAssembly: topEntryFrame on Wasm::Instance
https://bugs.webkit.org/show_bug.cgi?id=178690

Reviewed by Saam Barati.

topEntryFrame is usually on VM, but for a no-VM WebAssembly we
need to hold topEntryFrame elsewhere, and generated code cannot
hard-code where topEntryFrame live. Do this at creation time of
Wasm::Instance, and then generated code will just load from
wherever Wasm::Instance was told topEntryFrame is. In a JavaScript
embedding this is still from VM, so all of the unwinding machinery
stays the same.

* dfg/DFGOSREntry.cpp:
(JSC::DFG::prepareOSREntry):
* dfg/DFGOSRExit.cpp:
(JSC::DFG::restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer):
(JSC::DFG::copyCalleeSavesToVMEntryFrameCalleeSavesBuffer):
* ftl/FTLOSRExitCompiler.cpp:
(JSC::FTL::compileStub):
* interpreter/Interpreter.cpp:
(JSC::UnwindFunctor::copyCalleeSavesToEntryFrameCalleeSavesBuffer const):
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::restoreCalleeSavesFromEntryFrameCalleeSavesBuffer):
(JSC::AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBufferImpl):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBuffer):
The default parameter was never non-defaulted from any of the
callers. The new version calls the impl directly because it
doesn't have VM and doesn't hard-code the address of
topEntryFrame.
* jit/RegisterSet.cpp:
(JSC::RegisterSet::vmCalleeSaveRegisterOffsets): This was weird on
VM because it's not really VM-specific.
* jit/RegisterSet.h:
* runtime/VM.cpp:
(JSC::VM::getAllCalleeSaveRegisterOffsets): Deleted.
* runtime/VM.h:
(JSC::VM::getCTIStub):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::B3IRGenerator::addCall):
(JSC::Wasm::B3IRGenerator::addCallIndirect):
* wasm/WasmInstance.cpp:
(JSC::Wasm::Instance::Instance):
* wasm/WasmInstance.h: topEntryFramePointer will eventually live
here for real. Right now it's mirrored in JSWebAssemblyInstance
because that's the acting Context.
(JSC::Wasm::Instance::create):
(JSC::Wasm::Instance::offsetOfTopEntryFramePointer):
* wasm/WasmThunks.cpp:
(JSC::Wasm::throwExceptionFromWasmThunkGenerator):
* wasm/js/JSWebAssemblyInstance.cpp:
(JSC::JSWebAssemblyInstance::JSWebAssemblyInstance):
* wasm/js/JSWebAssemblyInstance.h: Mirror Wasm::Instance temporarily.
(JSC::JSWebAssemblyInstance::offsetOfCallee):
(JSC::JSWebAssemblyInstance::offsetOfTopEntryFramePointer):
(JSC::JSWebAssemblyInstance::offsetOfVM): Deleted.
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::constructJSWebAssemblyInstance):
* wasm/js/WebAssemblyPrototype.cpp:
(JSC::instantiate):

2017-10-23 Joseph Pecoraro <pecoraro@apple.com>

Web Inspector: Please support HAR Export for network traffic
@@ -313,7 +313,7 @@ void* prepareOSREntry(ExecState* exec, CodeBlock* codeBlock, unsigned bytecodeIn
// 6) Copy our callee saves to buffer.
#if NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
RegisterAtOffsetList* registerSaveLocations = codeBlock->calleeSaveRegisters();
RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet dontSaveRegisters = RegisterSet(RegisterSet::stackRegisters(), RegisterSet::allFPRs());

unsigned registerCount = registerSaveLocations->size();
@@ -122,7 +122,7 @@ static void restoreCalleeSavesFromVMEntryFrameCalleeSavesBuffer(Context& context
{
VM& vm = *context.arg<VM*>();

RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet dontRestoreRegisters = RegisterSet::stackRegisters();
unsigned registerCount = allCalleeSaves->size();

@@ -151,7 +151,7 @@ static void copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(Context& context)
VMEntryRecord* entryRecord = vmEntryRecord(vm.topEntryFrame);
void* calleeSaveBuffer = entryRecord->calleeSaveRegistersBuffer;

RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet dontCopyRegisters = RegisterSet::stackRegisters();
unsigned registerCount = allCalleeSaves->size();

@@ -409,7 +409,7 @@ static void compileStub(

RegisterSet allFTLCalleeSaves = RegisterSet::ftlCalleeSaveRegisters();
RegisterAtOffsetList* baselineCalleeSaves = baselineCodeBlock->calleeSaveRegisters();
RegisterAtOffsetList* vmCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* vmCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet vmCalleeSavesToSkip = RegisterSet::stackRegisters();
if (exit.isExceptionHandler()) {
jit.loadPtr(&vm->topEntryFrame, GPRInfo::regT1);
@@ -671,7 +671,7 @@ class UnwindFunctor {
if (!currentCalleeSaves)
return;

RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet dontCopyRegisters = RegisterSet::stackRegisters();
intptr_t* frame = reinterpret_cast<intptr_t*>(m_callFrame->registers());

@@ -585,7 +585,7 @@ void AssemblyHelpers::emitRandomThunk(VM& vm, GPRReg scratch0, GPRReg scratch1,
void AssemblyHelpers::restoreCalleeSavesFromEntryFrameCalleeSavesBuffer(EntryFrame*& topEntryFrame)
{
#if NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet dontRestoreRegisters = RegisterSet::stackRegisters();
unsigned registerCount = allCalleeSaves->size();

@@ -880,7 +880,7 @@ void AssemblyHelpers::copyCalleeSavesToEntryFrameCalleeSavesBufferImpl(GPRReg ca
#if NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
addPtr(TrustedImm32(EntryFrame::calleeSaveRegistersBufferOffset()), calleeSavesBuffer);

RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterSet dontCopyRegisters = RegisterSet::stackRegisters();
unsigned registerCount = allCalleeSaves->size();

@@ -367,15 +367,24 @@ class AssemblyHelpers : public MacroAssembler {
#endif
}

void copyCalleeSavesToEntryFrameCalleeSavesBuffer(EntryFrame*& topEntryFrame, const TempRegisterSet& usedRegisters = { RegisterSet::stubUnavailableRegisters() })
void copyCalleeSavesToEntryFrameCalleeSavesBuffer(EntryFrame*& topEntryFrame)
{
#if NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
const TempRegisterSet& usedRegisters = { RegisterSet::stubUnavailableRegisters() };
GPRReg temp1 = usedRegisters.getFreeGPR(0);
loadPtr(&topEntryFrame, temp1);
copyCalleeSavesToEntryFrameCalleeSavesBufferImpl(temp1);
#else
UNUSED_PARAM(topEntryFrame);
UNUSED_PARAM(usedRegisters);
#endif
}

void copyCalleeSavesToEntryFrameCalleeSavesBuffer(GPRReg topEntryFrame)
{
#if NUMBER_OF_CALLEE_SAVES_REGISTERS > 0
copyCalleeSavesToEntryFrameCalleeSavesBufferImpl(topEntryFrame);
#else
UNUSED_PARAM(topEntryFrame);
#endif
}

@@ -395,7 +404,7 @@ class AssemblyHelpers : public MacroAssembler {
loadPtr(&topEntryFrame, temp1);
addPtr(TrustedImm32(EntryFrame::calleeSaveRegistersBufferOffset()), temp1);

RegisterAtOffsetList* allCalleeSaves = VM::getAllCalleeSaveRegisterOffsets();
RegisterAtOffsetList* allCalleeSaves = RegisterSet::vmCalleeSaveRegisterOffsets();
RegisterAtOffsetList* currentCalleeSaves = codeBlock()->calleeSaveRegisters();
RegisterSet dontCopyRegisters = RegisterSet::stackRegisters();
unsigned registerCount = allCalleeSaves->size();
@@ -29,8 +29,9 @@
#if ENABLE(JIT)

#include "GPRInfo.h"
#include "MacroAssembler.h"
#include "JSCInlines.h"
#include "MacroAssembler.h"
#include "RegisterAtOffsetList.h"
#include <wtf/CommaPrinter.h>

namespace JSC {
@@ -201,6 +202,16 @@ RegisterSet RegisterSet::vmCalleeSaveRegisters()
return result;
}

RegisterAtOffsetList* RegisterSet::vmCalleeSaveRegisterOffsets()
{
static RegisterAtOffsetList* result;
static std::once_flag calleeSavesFlag;
std::call_once(calleeSavesFlag, [] () {
result = new RegisterAtOffsetList(vmCalleeSaveRegisters(), RegisterAtOffsetList::ZeroBased);
});
return result;
}

RegisterSet RegisterSet::llintBaselineCalleeSaveRegisters()
{
RegisterSet result;
@@ -36,6 +36,7 @@
namespace JSC {

typedef Bitmap<MacroAssembler::numGPRs + MacroAssembler::numFPRs + 1> RegisterBitmap;
class RegisterAtOffsetList;

class RegisterSet {
public:
@@ -51,6 +52,7 @@ class RegisterSet {
static RegisterSet specialRegisters(); // The union of stack, reserved hardware, and runtime registers.
JS_EXPORT_PRIVATE static RegisterSet calleeSaveRegisters();
static RegisterSet vmCalleeSaveRegisters(); // Callee save registers that might be saved and used by any tier.
static RegisterAtOffsetList* vmCalleeSaveRegisterOffsets();
static RegisterSet llintBaselineCalleeSaveRegisters(); // Registers saved and used by the LLInt.
static RegisterSet dfgCalleeSaveRegisters(); // Registers saved and used by the DFG JIT.
static RegisterSet ftlCalleeSaveRegisters(); // Registers that might be saved and used by the FTL JIT.
@@ -996,20 +996,6 @@ void VM::verifyExceptionCheckNeedIsSatisfied(unsigned recursionDepth, ExceptionE
}
#endif

#if ENABLE(JIT)
RegisterAtOffsetList* VM::getAllCalleeSaveRegisterOffsets()
{
static RegisterAtOffsetList* result;

static std::once_flag calleeSavesFlag;
std::call_once(calleeSavesFlag, [] () {
result = new RegisterAtOffsetList(RegisterSet::vmCalleeSaveRegisters(), RegisterAtOffsetList::ZeroBased);
});

return result;
}
#endif // ENABLE(JIT)

#if USE(CF)
void VM::registerRunLoopTimer(JSRunLoopTimer* timer)
{
@@ -478,8 +478,6 @@ class VM : public ThreadSafeRefCounted<VM>, public DoublyLinkedListNode<VM> {
{
return jitStubs->ctiStub(this, generator);
}

static RegisterAtOffsetList* getAllCalleeSaveRegisterOffsets();

#endif // ENABLE(JIT)
std::unique_ptr<CommonSlowPaths::ArityCheckData> arityCheckData;
@@ -406,7 +406,7 @@ B3IRGenerator::B3IRGenerator(const ModuleInformation& info, Procedure& procedure
// 1. Emit less code.
// 2. Try to speed things up by skipping stack checks.
minimumParentCheckSize,
// This allows us to elide stack checks in the Wasm -> JS call IC stub. Since these will
// This allows us to elide stack checks in the Wasm -> Embedder call IC stub. Since these will
// spill all arguments to the stack, we ensure that a stack check here covers the
// stack that such a stub would use.
(Checked<uint32_t>(m_maxNumJSCallArguments) * sizeof(Register) + jscCallingConvention().headerSizeInBytes()).unsafeGet()
@@ -1109,7 +1109,7 @@ auto B3IRGenerator::addCall(uint32_t functionIndex, const Signature& signature,
isWasmBlock->appendNewControlValue(m_proc, Jump, origin(), continuation);

// 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
// for calls out to the embedder. This shouldn't be that hard to do. We could probably
// implement the IC to be over Context*.
// https://bugs.webkit.org/show_bug.cgi?id=170375
Value* jumpDestination = isEmbedderBlock->appendNew<MemoryValue>(m_proc,
@@ -1169,8 +1169,8 @@ auto B3IRGenerator::addCallIndirect(const Signature& signature, Vector<Expressio

m_makesCalls = true;
// Note: call indirect can call either WebAssemblyFunction or WebAssemblyWrapperFunction. Because
// WebAssemblyWrapperFunction is like calling into JS, we conservatively assume all call indirects
// can be to JS for our stack check calculation.
// WebAssemblyWrapperFunction is like calling into the embedder, we conservatively assume all call indirects
// can be to the embedder for our stack check calculation.
m_maxNumJSCallArguments = std::max(m_maxNumJSCallArguments, static_cast<uint32_t>(args.size()));

ExpressionType callableFunctionBuffer;
@@ -40,9 +40,10 @@ size_t globalMemoryByteSize(Module& module)
}
}

Instance::Instance(Ref<Module>&& module)
Instance::Instance(Ref<Module>&& module, EntryFrame** topEntryFramePointer)
: m_module(WTFMove(module))
, m_globals(MallocPtr<uint64_t>::malloc(globalMemoryByteSize(m_module.get())))
, m_topEntryFramePointer(topEntryFramePointer)
{
}

@@ -40,9 +40,9 @@ namespace JSC { namespace Wasm {

class Instance : public ThreadSafeRefCounted<Instance> {
public:
static Ref<Instance> create(Ref<Module>&& module)
static Ref<Instance> create(Ref<Module>&& module, EntryFrame** topEntryFramePointer)
{
return adoptRef(*new Instance(WTFMove(module)));
return adoptRef(*new Instance(WTFMove(module), topEntryFramePointer));
}

void finalizeCreation(Ref<CodeBlock>&& codeBlock)
@@ -65,20 +65,23 @@ class Instance : public ThreadSafeRefCounted<Instance> {
double loadF64Global(unsigned i) const { return bitwise_cast<double>(loadI64Global(i)); }
void setGlobal(unsigned i, int64_t bits) { m_globals.get()[i] = bits; }

static ptrdiff_t offsetOfTopEntryFramePointer() { return OBJECT_OFFSETOF(Instance, m_topEntryFramePointer); }

static ptrdiff_t offsetOfCachedStackLimit() { return OBJECT_OFFSETOF(Instance, m_cachedStackLimit); }
void* cachedStackLimit() const { return m_cachedStackLimit; }
void setCachedStackLimit(void* limit) { m_cachedStackLimit = limit; }

friend class JSC::JSWebAssemblyInstance; // FIXME remove this once refactored https://webkit.org/b/177472.

private:
Instance(Ref<Module>&&);
Instance(Ref<Module>&&, EntryFrame**);

Ref<Module> m_module;
RefPtr<CodeBlock> m_codeBlock;
RefPtr<Memory> m_memory;
RefPtr<Table> m_table;
MallocPtr<uint64_t> m_globals;
EntryFrame** m_topEntryFramePointer { nullptr };
void* m_cachedStackLimit { bitwise_cast<void*>(std::numeric_limits<uintptr_t>::max()) };
};

@@ -47,8 +47,9 @@ MacroAssemblerCodeRef throwExceptionFromWasmThunkGenerator(const AbstractLocker&
// The thing that jumps here must move ExceptionType into the argumentGPR1 before jumping here.
// We're allowed to use temp registers here. We are not allowed to use callee saves.
jit.loadWasmContextInstance(GPRInfo::argumentGPR2);
jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR2, JSWebAssemblyInstance::offsetOfVM()), GPRInfo::argumentGPR0);
jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer(GPRInfo::argumentGPR0);
jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR2, JSWebAssemblyInstance::offsetOfTopEntryFramePointer()), GPRInfo::argumentGPR0);
jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR0), GPRInfo::argumentGPR0);
jit.copyCalleeSavesToEntryFrameCalleeSavesBuffer(GPRInfo::argumentGPR0);
jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
CCallHelpers::Call call = jit.call();
jit.jump(GPRInfo::returnValueGPR);
@@ -56,6 +56,7 @@ JSWebAssemblyInstance::JSWebAssemblyInstance(VM& vm, Structure* structure, unsig
, m_wasmModule(m_instance->module())
, m_wasmTable(m_instance->m_table.get())
, m_globals(m_instance->m_globals.get())
, m_topEntryFramePointer(m_instance->m_topEntryFramePointer)
, m_numImportFunctions(numImportFunctions)
{
for (unsigned i = 0; i < m_numImportFunctions; ++i)
@@ -92,12 +92,12 @@ class JSWebAssemblyInstance : public JSDestructibleObject {
Wasm::CodeBlock& wasmCodeBlock() const { return *m_instance->codeBlock(); }
static ptrdiff_t offsetOfWasmTable() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_wasmTable); }
static ptrdiff_t offsetOfCallee() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_callee); }
static ptrdiff_t offsetOfVM() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_vm); }
static ptrdiff_t offsetOfGlobals() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_globals); }
static ptrdiff_t offsetOfCodeBlock() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_codeBlock); }
static ptrdiff_t offsetOfWasmCodeBlock() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_wasmCodeBlock); }
static ptrdiff_t offsetOfCachedStackLimit() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_cachedStackLimit); }
static ptrdiff_t offsetOfWasmMemory() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_wasmMemory); }
static ptrdiff_t offsetOfTopEntryFramePointer() { return OBJECT_OFFSETOF(JSWebAssemblyInstance, m_topEntryFramePointer); }
void* cachedStackLimit() const { RELEASE_ASSERT(m_instance->cachedStackLimit() == m_cachedStackLimit); return m_cachedStackLimit; }
void setCachedStackLimit(void* limit) { m_instance->setCachedStackLimit(limit); m_cachedStackLimit = limit; }
Wasm::Memory* wasmMemory() { return m_wasmMemory; }
@@ -134,6 +134,7 @@ class JSWebAssemblyInstance : public JSDestructibleObject {
Wasm::Memory* m_wasmMemory { nullptr };
Wasm::Table* m_wasmTable { nullptr };
uint64_t* m_globals { nullptr };
EntryFrame** m_topEntryFramePointer { nullptr };

unsigned m_numImportFunctions;
};
@@ -77,7 +77,7 @@ static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyInstance(ExecState* ex
Structure* instanceStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), exec->lexicalGlobalObject()->WebAssemblyInstanceStructure());
RETURN_IF_EXCEPTION(scope, { });

JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, exec, module, importObject, instanceStructure, Wasm::Instance::create(Ref<Wasm::Module>(module->module())));
JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, exec, module, importObject, instanceStructure, Wasm::Instance::create(Ref<Wasm::Module>(module->module()), &vm.topEntryFrame));
RETURN_IF_EXCEPTION(scope, { });

instance->finalizeCreation(vm, exec, module->module().compileSync(&vm.wasmContext, instance->memoryMode(), &Wasm::createJSToWasmWrapper, &Wasm::wasmToJSException));
@@ -137,7 +137,7 @@ static void instantiate(VM& vm, ExecState* exec, JSPromiseDeferred* promise, JSW
{
auto scope = DECLARE_CATCH_SCOPE(vm);
// In order to avoid potentially recompiling a module. We first gather all the import/memory information prior to compiling code.
JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, exec, module, importObject, exec->lexicalGlobalObject()->WebAssemblyInstanceStructure(), Wasm::Instance::create(Ref<Wasm::Module>(module->module())));
JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, exec, module, importObject, exec->lexicalGlobalObject()->WebAssemblyInstanceStructure(), Wasm::Instance::create(Ref<Wasm::Module>(module->module()), &vm.topEntryFrame));
RETURN_IF_EXCEPTION(scope, reject(exec, scope, promise));

Vector<Strong<JSCell>> dependencies;

0 comments on commit f1507e1

Please sign in to comment.