Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (230095 => 230096)
--- trunk/Source/_javascript_Core/ChangeLog 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/ChangeLog 2018-03-30 05:04:44 UTC (rev 230096)
@@ -1,3 +1,65 @@
+2018-03-29 Mark Lam <mark....@apple.com>
+
+ Use MacroAssemblerCodePtr in Wasm code for code pointers instead of void*.
+ https://bugs.webkit.org/show_bug.cgi?id=184163
+ <rdar://problem/39020397>
+
+ Reviewed by JF Bastien.
+
+ With the use of MacroAssemblerCodePtr, we now get poisoning for Wasm code pointers.
+
+ Also renamed some structs, methods, and variable names to be more accurate.
+ Previously, there is some confusion between a code pointer and the address of a
+ code pointer (sometimes referred to in the code as a "LoadLocation"). We now name
+ the LoadLocation variables appropriately to distinguish them from code pointers.
+
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::B3IRGenerator::addCall):
+ (JSC::Wasm::B3IRGenerator::addCallIndirect):
+ * wasm/WasmBinding.cpp:
+ (JSC::Wasm::wasmToWasm):
+ * wasm/WasmCodeBlock.cpp:
+ (JSC::Wasm::CodeBlock::CodeBlock):
+ * wasm/WasmCodeBlock.h:
+ (JSC::Wasm::CodeBlock::entrypointLoadLocationFromFunctionIndexSpace):
+ (JSC::Wasm::CodeBlock::wasmEntrypointLoadLocationFromFunctionIndexSpace): Deleted.
+ * wasm/WasmFormat.h:
+ (JSC::Wasm::WasmToWasmImportableFunction::WasmToWasmImportableFunction):
+ (JSC::Wasm::WasmToWasmImportableFunction::offsetOfEntrypointLoadLocation):
+ (JSC::Wasm::CallableFunction::CallableFunction): Deleted.
+ (JSC::Wasm::CallableFunction::offsetOfWasmEntrypointLoadLocation): Deleted.
+ * wasm/WasmInstance.h:
+ (JSC::Wasm::Instance::offsetOfWasmEntrypointLoadLocation):
+ (JSC::Wasm::Instance::offsetOfWasmToEmbedderStub):
+ (JSC::Wasm::Instance::offsetOfWasmEntrypoint): Deleted.
+ (JSC::Wasm::Instance::offsetOfWasmToEmbedderStubExecutableAddress): Deleted.
+ * wasm/WasmOMGPlan.cpp:
+ (JSC::Wasm::OMGPlan::work):
+ * wasm/WasmTable.cpp:
+ (JSC::Wasm::Table::Table):
+ (JSC::Wasm::Table::grow):
+ (JSC::Wasm::Table::clearFunction):
+ (JSC::Wasm::Table::setFunction):
+ * wasm/WasmTable.h:
+ (JSC::Wasm::Table::offsetOfFunctions):
+ * wasm/js/JSWebAssemblyCodeBlock.h:
+ * wasm/js/JSWebAssemblyInstance.cpp:
+ (JSC::JSWebAssemblyInstance::finalizeCreation):
+ (JSC::JSWebAssemblyInstance::create):
+ * wasm/js/JSWebAssemblyTable.cpp:
+ (JSC::JSWebAssemblyTable::setFunction):
+ * wasm/js/WebAssemblyFunction.cpp:
+ (JSC::WebAssemblyFunction::create):
+ (JSC::WebAssemblyFunction::WebAssemblyFunction):
+ * wasm/js/WebAssemblyFunction.h:
+ * wasm/js/WebAssemblyModuleRecord.cpp:
+ (JSC::WebAssemblyModuleRecord::link):
+ (JSC::WebAssemblyModuleRecord::evaluate):
+ * wasm/js/WebAssemblyWrapperFunction.cpp:
+ (JSC::WebAssemblyWrapperFunction::WebAssemblyWrapperFunction):
+ (JSC::WebAssemblyWrapperFunction::create):
+ * wasm/js/WebAssemblyWrapperFunction.h:
+
2018-03-29 Yusuke Suzuki <utatane....@gmail.com>
Remove WTF_EXPORTDATA and JS_EXPORTDATA
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -48,6 +48,7 @@
#include "B3WasmAddressValue.h"
#include "B3WasmBoundsCheckValue.h"
#include "JSCInlines.h"
+#include "JSCPoison.h"
#include "ScratchRegisterAllocator.h"
#include "VirtualRegister.h"
#include "WasmCallingConvention.h"
@@ -1130,7 +1131,10 @@
// implement the IC to be over Context*.
// https://bugs.webkit.org/show_bug.cgi?id=170375
Value* jumpDestination = isEmbedderBlock->appendNew<MemoryValue>(m_proc,
- Load, pointerType(), origin(), instanceValue(), safeCast<int32_t>(Instance::offsetOfWasmToEmbedderStubExecutableAddress(functionIndex)));
+ Load, pointerType(), origin(), instanceValue(), safeCast<int32_t>(Instance::offsetOfWasmToEmbedderStub(functionIndex)));
+ if (Options::usePoisoning())
+ jumpDestination = isEmbedderBlock->appendNew<Value>(m_proc, BitXor, origin(), jumpDestination, isEmbedderBlock->appendNew<Const64Value>(m_proc, origin(), g_JITCodePoison));
+
Value* embedderCallResult = wasmCallingConvention().setupCall(m_proc, isEmbedderBlock, origin(), args, toB3Type(returnType),
[&] (PatchpointValue* patchpoint) {
patchpoint->effects.writesPinned = true;
@@ -1227,13 +1231,13 @@
{
// Compute the offset in the table index space we are looking for.
ExpressionType offset = m_currentBlock->appendNew<Value>(m_proc, Mul, origin(),
- calleeIndex, constant(pointerType(), sizeof(CallableFunction)));
+ calleeIndex, constant(pointerType(), sizeof(WasmToWasmImportableFunction)));
callableFunction = m_currentBlock->appendNew<Value>(m_proc, Add, origin(), callableFunctionBuffer, offset);
- // Check that the CallableFunction is initialized. We trap if it isn't. An "invalid" SignatureIndex indicates it's not initialized.
+ // 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(CallableFunction::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(CallableFunction, signatureIndex)));
+ 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)));
{
CheckValue* check = m_currentBlock->appendNew<CheckValue>(m_proc, Check, origin(),
m_currentBlock->appendNew<Value>(m_proc, Equal, origin(),
@@ -1308,7 +1312,9 @@
ExpressionType calleeCode = m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(),
m_currentBlock->appendNew<MemoryValue>(m_proc, Load, pointerType(), origin(), callableFunction,
- safeCast<int32_t>(OBJECT_OFFSETOF(CallableFunction, code))));
+ safeCast<int32_t>(WasmToWasmImportableFunction::offsetOfEntrypointLoadLocation())));
+ if (Options::usePoisoning())
+ calleeCode = m_currentBlock->appendNew<Value>(m_proc, BitXor, origin(), calleeCode, m_currentBlock->appendNew<Const64Value>(m_proc, origin(), g_JITCodePoison));
Type returnType = signature.returnType();
result = wasmCallingConvention().setupCall(m_proc, m_currentBlock, origin(), args, toB3Type(returnType),
Modified: trunk/Source/_javascript_Core/wasm/WasmBinding.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmBinding.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmBinding.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -56,7 +56,7 @@
// Get the callee's Wasm::Instance and set it as WasmContext's instance. The caller will take care of restoring its own Instance.
jit.loadPtr(JIT::Address(sizeRegAsScratch, Instance::offsetOfTargetInstance(importIndex)), baseMemory); // Instance*.
// While we're accessing that cacheline, also get the wasm entrypoint so we can tail call to it below.
- jit.loadPtr(JIT::Address(sizeRegAsScratch, Instance::offsetOfWasmEntrypoint(importIndex)), scratch); // Wasm::WasmEntrypointLoadLocation.
+ jit.loadPtr(JIT::Address(sizeRegAsScratch, Instance::offsetOfWasmEntrypointLoadLocation(importIndex)), scratch);
jit.storeWasmContextInstance(baseMemory);
jit.loadPtr(JIT::Address(sizeRegAsScratch, Instance::offsetOfCachedStackLimit()), sizeRegAsScratch);
@@ -76,6 +76,8 @@
// Tail call into the callee WebAssembly function.
jit.loadPtr(scratch, scratch);
+ if (Options::usePoisoning())
+ jit.xorPtr(JIT::TrustedImmPtr(g_JITCodePoison), scratch);
jit.jump(scratch, NoPtrTag);
LinkBuffer patchBuffer(jit, GLOBAL_THUNK_ID, JITCompilationCanFail);
Modified: trunk/Source/_javascript_Core/wasm/WasmCodeBlock.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmCodeBlock.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmCodeBlock.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -1,6 +1,5 @@
-
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -67,7 +66,7 @@
ASSERT_UNUSED(result, result.isNewEntry);
}
m_callees[calleeIndex] = WTFMove(wasmEntrypointCallee);
- m_wasmIndirectCallEntryPoints[calleeIndex] = m_callees[calleeIndex]->entrypoint().executableAddress();
+ m_wasmIndirectCallEntryPoints[calleeIndex] = m_callees[calleeIndex]->entrypoint();
});
m_wasmToWasmExitStubs = m_plan->takeWasmToWasmExitStubs();
Modified: trunk/Source/_javascript_Core/wasm/WasmCodeBlock.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmCodeBlock.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmCodeBlock.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -46,7 +46,6 @@
class OMGPlan;
struct ModuleInformation;
struct UnlinkedWasmToWasmCall;
-typedef void** WasmEntrypointLoadLocation;
enum class MemoryMode : uint8_t;
class CodeBlock : public ThreadSafeRefCounted<CodeBlock> {
@@ -97,7 +96,7 @@
return *m_callees[calleeIndex].get();
}
- WasmEntrypointLoadLocation wasmEntrypointLoadLocationFromFunctionIndexSpace(unsigned functionIndexSpace)
+ MacroAssemblerCodePtr* entrypointLoadLocationFromFunctionIndexSpace(unsigned functionIndexSpace)
{
RELEASE_ASSERT(functionIndexSpace >= functionImportCount());
unsigned calleeIndex = functionIndexSpace - functionImportCount();
@@ -124,7 +123,7 @@
Vector<RefPtr<Callee>> m_callees;
Vector<RefPtr<Callee>> m_optimizedCallees;
HashMap<uint32_t, RefPtr<Callee>, typename DefaultHash<uint32_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<uint32_t>> m_embedderCallees;
- Vector<void*> m_wasmIndirectCallEntryPoints;
+ Vector<MacroAssemblerCodePtr> m_wasmIndirectCallEntryPoints;
Vector<TierUpCount> m_tierUpCounts;
Vector<Vector<UnlinkedWasmToWasmCall>> m_wasmToWasmCallsites;
Vector<MacroAssemblerCodeRef> m_wasmToWasmExitStubs;
Modified: trunk/Source/_javascript_Core/wasm/WasmFormat.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmFormat.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmFormat.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -270,28 +270,27 @@
Entrypoint entrypoint;
};
-using WasmEntrypointLoadLocation = void**;
-
// WebAssembly direct calls and call_indirect use indices into "function index space". This space starts
-// with all imports, and then all internal functions. CallableFunction and FunctionIndexSpace are only
+// with all imports, and then all internal functions. WasmToWasmImportableFunction and FunctionIndexSpace are only
// meant as fast lookup tables for these opcodes and do not own code.
-struct CallableFunction {
+struct WasmToWasmImportableFunction {
+ using LoadLocation = MacroAssemblerCodePtr*;
#if !COMPILER_SUPPORTS(NSDMI_FOR_AGGREGATES)
- CallableFunction() = default;
- CallableFunction(SignatureIndex signatureIndex, WasmEntrypointLoadLocation code = nullptr)
+ WasmToWasmImportableFunction() = default;
+ WasmToWasmImportableFunction(SignatureIndex signatureIndex, LoadLocation entrypointLoadLocation)
: signatureIndex { signatureIndex }
- , code { code }
+ , entrypointLoadLocation { entrypointLoadLocation }
{
}
#endif
- static ptrdiff_t offsetOfWasmEntrypointLoadLocation() { return OBJECT_OFFSETOF(CallableFunction, code); }
+ 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>.
SignatureIndex signatureIndex { Signature::invalidIndex };
- WasmEntrypointLoadLocation code { nullptr };
+ LoadLocation entrypointLoadLocation;
};
-using FunctionIndexSpace = Vector<CallableFunction>;
+using FunctionIndexSpace = Vector<WasmToWasmImportableFunction>;
} } // namespace JSC::Wasm
Modified: trunk/Source/_javascript_Core/wasm/WasmInstance.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmInstance.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmInstance.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -118,8 +118,8 @@
struct ImportFunctionInfo {
// Target instance and entrypoint are only set for wasm->wasm calls, and are otherwise nullptr. The embedder-specific logic occurs through import function.
Instance* targetInstance { nullptr };
- Wasm::WasmEntrypointLoadLocation wasmEntrypoint { nullptr };
- void* wasmToEmbedderStubExecutableAddress { nullptr };
+ WasmToWasmImportableFunction::LoadLocation wasmEntrypointLoadLocation { nullptr };
+ MacroAssemblerCodePtr wasmToEmbedderStub;
void* importFunction { nullptr }; // In a JS embedding, this is a PoisonedBarrier<JSObject>.
};
unsigned numImportFunctions() const { return m_numImportFunctions; }
@@ -129,8 +129,8 @@
return &bitwise_cast<ImportFunctionInfo*>(bitwise_cast<char*>(this) + offsetOfTail())[importFunctionNum];
}
static size_t offsetOfTargetInstance(size_t importFunctionNum) { return offsetOfTail() + importFunctionNum * sizeof(ImportFunctionInfo) + OBJECT_OFFSETOF(ImportFunctionInfo, targetInstance); }
- static size_t offsetOfWasmEntrypoint(size_t importFunctionNum) { return offsetOfTail() + importFunctionNum * sizeof(ImportFunctionInfo) + OBJECT_OFFSETOF(ImportFunctionInfo, wasmEntrypoint); }
- static size_t offsetOfWasmToEmbedderStubExecutableAddress(size_t importFunctionNum) { return offsetOfTail() + importFunctionNum * sizeof(ImportFunctionInfo) + OBJECT_OFFSETOF(ImportFunctionInfo, wasmToEmbedderStubExecutableAddress); }
+ static size_t offsetOfWasmEntrypointLoadLocation(size_t importFunctionNum) { return offsetOfTail() + importFunctionNum * sizeof(ImportFunctionInfo) + OBJECT_OFFSETOF(ImportFunctionInfo, wasmEntrypointLoadLocation); }
+ static size_t offsetOfWasmToEmbedderStub(size_t importFunctionNum) { return offsetOfTail() + importFunctionNum * sizeof(ImportFunctionInfo) + OBJECT_OFFSETOF(ImportFunctionInfo, wasmToEmbedderStub); }
static size_t offsetOfImportFunction(size_t importFunctionNum) { return offsetOfTail() + importFunctionNum * sizeof(ImportFunctionInfo) + OBJECT_OFFSETOF(ImportFunctionInfo, importFunction); }
template<typename T> T* importFunction(unsigned importFunctionNum) { return reinterpret_cast<T*>(&importFunctionInfo(importFunctionNum)->importFunction); }
Modified: trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -136,7 +136,7 @@
resetInstructionCacheOnAllThreads();
WTF::storeStoreFence(); // This probably isn't necessary but it's good to be paranoid.
- m_codeBlock->m_wasmIndirectCallEntryPoints[m_functionIndex] = entrypoint.executableAddress();
+ m_codeBlock->m_wasmIndirectCallEntryPoints[m_functionIndex] = entrypoint;
{
LockHolder holder(m_codeBlock->m_lock);
Modified: trunk/Source/_javascript_Core/wasm/WasmTable.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmTable.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmTable.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -66,12 +66,12 @@
// FIXME: It might be worth trying to pre-allocate maximum here. The spec recommends doing so.
// But for now, we're not doing that.
- m_functions = MallocPtr<Wasm::CallableFunction>::malloc((sizeof(Wasm::CallableFunction) * Checked<size_t>(allocatedLength(m_length))).unsafeGet());
+ m_importableFunctions = MallocPtr<WasmToWasmImportableFunction>::malloc((sizeof(WasmToWasmImportableFunction) * Checked<size_t>(allocatedLength(m_length))).unsafeGet());
// FIXME this over-allocates and could be smarter about not committing all of that memory https://bugs.webkit.org/show_bug.cgi?id=181425
m_instances = MallocPtr<Instance*>::malloc((sizeof(Instance*) * Checked<size_t>(allocatedLength(m_length))).unsafeGet());
for (uint32_t i = 0; i < allocatedLength(m_length); ++i) {
- new (&m_functions.get()[i]) CallableFunction();
- ASSERT(m_functions.get()[i].signatureIndex == Wasm::Signature::invalidIndex); // We rely on this in compiled code.
+ new (&m_importableFunctions.get()[i]) WasmToWasmImportableFunction();
+ ASSERT(m_importableFunctions.get()[i].signatureIndex == Wasm::Signature::invalidIndex); // We rely on this in compiled code.
m_instances.get()[i] = nullptr;
}
}
@@ -108,7 +108,7 @@
return true;
};
- if (!checkedGrow(m_functions))
+ if (!checkedGrow(m_importableFunctions))
return std::nullopt;
if (!checkedGrow(m_instances))
return std::nullopt;
@@ -121,15 +121,15 @@
void Table::clearFunction(uint32_t index)
{
RELEASE_ASSERT(index < length());
- m_functions.get()[index & m_mask] = Wasm::CallableFunction();
- ASSERT(m_functions.get()[index & m_mask].signatureIndex == Wasm::Signature::invalidIndex); // We rely on this in compiled code.
+ m_importableFunctions.get()[index & m_mask] = WasmToWasmImportableFunction();
+ ASSERT(m_importableFunctions.get()[index & m_mask].signatureIndex == Wasm::Signature::invalidIndex); // We rely on this in compiled code.
m_instances.get()[index & m_mask] = nullptr;
}
-void Table::setFunction(uint32_t index, CallableFunction function, Instance* instance)
+void Table::setFunction(uint32_t index, WasmToWasmImportableFunction function, Instance* instance)
{
RELEASE_ASSERT(index < length());
- m_functions.get()[index & m_mask] = function;
+ m_importableFunctions.get()[index & m_mask] = function;
m_instances.get()[index & m_mask] = instance;
}
Modified: trunk/Source/_javascript_Core/wasm/WasmTable.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/WasmTable.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/WasmTable.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -48,9 +48,9 @@
uint32_t length() const { return m_length; }
std::optional<uint32_t> grow(uint32_t delta) WARN_UNUSED_RETURN;
void clearFunction(uint32_t);
- void setFunction(uint32_t, CallableFunction, Instance*);
+ void setFunction(uint32_t, WasmToWasmImportableFunction, Instance*);
- static ptrdiff_t offsetOfFunctions() { return OBJECT_OFFSETOF(Table, m_functions); }
+ static ptrdiff_t offsetOfFunctions() { return OBJECT_OFFSETOF(Table, m_importableFunctions); }
static ptrdiff_t offsetOfInstances() { return OBJECT_OFFSETOF(Table, m_instances); }
static ptrdiff_t offsetOfLength() { return OBJECT_OFFSETOF(Table, m_length); }
static ptrdiff_t offsetOfMask() { return OBJECT_OFFSETOF(Table, m_mask); }
@@ -64,7 +64,7 @@
void setLength(uint32_t);
- MallocPtr<CallableFunction> m_functions;
+ MallocPtr<WasmToWasmImportableFunction> m_importableFunctions;
// call_indirect needs to do an Instance check to potentially context switch when calling a function to another instance. We can hold raw pointers to Instance here because the embedder ensures that Table keeps all the instances alive. We couldn't hold a Ref here because it would cause cycles.
MallocPtr<Instance*> m_instances;
uint32_t m_length;
Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyCodeBlock.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -68,7 +68,7 @@
Wasm::CodeBlock& codeBlock() { return m_codeBlock.get(); }
- void* wasmToEmbedderStubExecutableAddress(size_t importFunctionNum) { return m_wasmToJSExitStubs[importFunctionNum].code().executableAddress(); }
+ MacroAssemblerCodePtr wasmToEmbedderStub(size_t importFunctionNum) { return m_wasmToJSExitStubs[importFunctionNum].code(); }
void finishCreation(VM&);
Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyInstance.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -123,7 +123,7 @@
for (unsigned importFunctionNum = 0; importFunctionNum < instance().numImportFunctions(); ++importFunctionNum) {
auto* info = instance().importFunctionInfo(importFunctionNum);
- info->wasmToEmbedderStubExecutableAddress = m_codeBlock->wasmToEmbedderStubExecutableAddress(importFunctionNum);
+ info->wasmToEmbedderStub = m_codeBlock->wasmToEmbedderStub(importFunctionNum);
}
auto* moduleRecord = jsCast<WebAssemblyModuleRecord*>(m_moduleNamespaceObject->moduleRecord());
@@ -203,7 +203,7 @@
return exception(createJSWebAssemblyLinkError(exec, vm, importFailMessage(import, "import function", "must be callable")));
Wasm::Instance* calleeInstance = nullptr;
- Wasm::WasmEntrypointLoadLocation wasmEntrypoint = nullptr;
+ WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation = nullptr;
JSObject* function = jsCast<JSObject*>(value);
// ii. If v is an Exported Function Exotic Object:
@@ -215,7 +215,7 @@
if (wasmFunction) {
importedSignatureIndex = wasmFunction->signatureIndex();
calleeInstance = &wasmFunction->instance()->instance();
- wasmEntrypoint = wasmFunction->wasmEntrypointLoadLocation();
+ entrypointLoadLocation = wasmFunction->entrypointLoadLocation();
}
else {
importedSignatureIndex = wasmWrapperFunction->signatureIndex();
@@ -235,7 +235,7 @@
ASSERT(numImportFunctions == import.kindIndex);
auto* info = jsInstance->instance().importFunctionInfo(numImportFunctions);
info->targetInstance = calleeInstance;
- info->wasmEntrypoint = wasmEntrypoint;
+ info->wasmEntrypointLoadLocation = entrypointLoadLocation;
jsInstance->instance().importFunction<PoisonedBarrier<JSObject>>(numImportFunctions)->set(vm, jsInstance, function);
++numImportFunctions;
// v. Append closure to imports.
Modified: trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyTable.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyTable.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/JSWebAssemblyTable.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -126,13 +126,13 @@
void JSWebAssemblyTable::setFunction(VM& vm, uint32_t index, WebAssemblyFunction* function)
{
- m_table->setFunction(index, function->callableFunction(), &function->instance()->instance());
+ m_table->setFunction(index, function->importableFunction(), &function->instance()->instance());
m_jsFunctions.get()[index & m_table->mask()].set(vm, this, function);
}
void JSWebAssemblyTable::setFunction(VM& vm, uint32_t index, WebAssemblyWrapperFunction* function)
{
- m_table->setFunction(index, function->callableFunction(), &function->instance()->instance());
+ m_table->setFunction(index, function->importableFunction(), &function->instance()->instance());
m_jsFunctions.get()[index & m_table->mask()].set(vm, this, function);
}
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -176,11 +176,11 @@
return EncodedJSValue();
}
-WebAssemblyFunction* WebAssemblyFunction::create(VM& vm, JSGlobalObject* globalObject, unsigned length, const String& name, JSWebAssemblyInstance* instance, Wasm::Callee& jsEntrypoint, Wasm::WasmEntrypointLoadLocation wasmEntrypoint, Wasm::SignatureIndex signatureIndex)
+WebAssemblyFunction* WebAssemblyFunction::create(VM& vm, JSGlobalObject* globalObject, unsigned length, const String& name, JSWebAssemblyInstance* instance, Wasm::Callee& jsEntrypoint, Wasm::WasmToWasmImportableFunction::LoadLocation wasmToWasmEntrypointLoadLocation, Wasm::SignatureIndex signatureIndex)
{
NativeExecutable* executable = vm.getHostFunction(callWebAssemblyFunction, NoIntrinsic, callHostFunctionAsConstructor, nullptr, name);
Structure* structure = globalObject->webAssemblyFunctionStructure();
- WebAssemblyFunction* function = new (NotNull, allocateCell<WebAssemblyFunction>(vm.heap)) WebAssemblyFunction(vm, globalObject, structure, jsEntrypoint, wasmEntrypoint, signatureIndex);
+ WebAssemblyFunction* function = new (NotNull, allocateCell<WebAssemblyFunction>(vm.heap)) WebAssemblyFunction(vm, globalObject, structure, jsEntrypoint, wasmToWasmEntrypointLoadLocation, signatureIndex);
function->finishCreation(vm, executable, length, name, instance);
ASSERT_WITH_MESSAGE(!function->isLargeAllocation(), "WebAssemblyFunction should be allocated not in large allocation since it is JSCallee.");
return function;
@@ -192,10 +192,10 @@
return Structure::create(vm, globalObject, prototype, TypeInfo(JSFunctionType, StructureFlags), info());
}
-WebAssemblyFunction::WebAssemblyFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure, Wasm::Callee& jsEntrypoint, Wasm::WasmEntrypointLoadLocation wasmEntrypoint, Wasm::SignatureIndex signatureIndex)
+WebAssemblyFunction::WebAssemblyFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure, Wasm::Callee& jsEntrypoint, Wasm::WasmToWasmImportableFunction::LoadLocation wasmToWasmEntrypointLoadLocation, Wasm::SignatureIndex signatureIndex)
: Base { vm, globalObject, structure }
, m_jsEntrypoint { jsEntrypoint.entrypoint() }
- , m_wasmFunction { signatureIndex, wasmEntrypoint }
+ , m_importableFunction { signatureIndex, wasmToWasmEntrypointLoadLocation }
{ }
} // namespace JSC
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyFunction.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -37,6 +37,7 @@
class JSGlobalObject;
struct ProtoCallFrame;
class WebAssemblyInstance;
+using Wasm::WasmToWasmImportableFunction;
namespace B3 {
class Compilation;
@@ -56,25 +57,25 @@
DECLARE_EXPORT_INFO;
- JS_EXPORT_PRIVATE static WebAssemblyFunction* create(VM&, JSGlobalObject*, unsigned, const String&, JSWebAssemblyInstance*, Wasm::Callee& jsEntrypoint, Wasm::WasmEntrypointLoadLocation, Wasm::SignatureIndex);
+ JS_EXPORT_PRIVATE static WebAssemblyFunction* create(VM&, JSGlobalObject*, unsigned, const String&, JSWebAssemblyInstance*, Wasm::Callee& jsEntrypoint, WasmToWasmImportableFunction::LoadLocation, Wasm::SignatureIndex);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
- Wasm::SignatureIndex signatureIndex() const { return m_wasmFunction.signatureIndex; }
- Wasm::WasmEntrypointLoadLocation wasmEntrypointLoadLocation() const { return m_wasmFunction.code; }
- Wasm::CallableFunction callableFunction() const { return m_wasmFunction; }
+ Wasm::SignatureIndex signatureIndex() const { return m_importableFunction.signatureIndex; }
+ WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation() const { return m_importableFunction.entrypointLoadLocation; }
+ WasmToWasmImportableFunction importableFunction() const { return m_importableFunction; }
MacroAssemblerCodePtr jsEntrypoint() { return m_jsEntrypoint; }
- static ptrdiff_t offsetOfWasmEntrypointLoadLocation() { return OBJECT_OFFSETOF(WebAssemblyFunction, m_wasmFunction) + Wasm::CallableFunction::offsetOfWasmEntrypointLoadLocation(); }
+ static ptrdiff_t offsetOfEntrypointLoadLocation() { return OBJECT_OFFSETOF(WebAssemblyFunction, m_importableFunction) + WasmToWasmImportableFunction::offsetOfEntrypointLoadLocation(); }
private:
- WebAssemblyFunction(VM&, JSGlobalObject*, Structure*, Wasm::Callee& jsEntrypoint, Wasm::WasmEntrypointLoadLocation, Wasm::SignatureIndex);
+ WebAssemblyFunction(VM&, JSGlobalObject*, Structure*, Wasm::Callee& jsEntrypoint, WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation, Wasm::SignatureIndex);
- // It's safe to just hold the raw CallableFunction/jsEntrypoint because we have a reference
+ // It's safe to just hold the raw WasmToWasmImportableFunction/jsEntrypoint because we have a reference
// to our Instance, which points to the Module that exported us, which
// ensures that the actual Signature/code doesn't get deallocated.
MacroAssemblerCodePtr m_jsEntrypoint;
- Wasm::CallableFunction m_wasmFunction;
+ WasmToWasmImportableFunction m_importableFunction;
};
} // namespace JSC
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -123,10 +123,10 @@
// b. Append func to funcs.
// c. Return func.
Wasm::Callee& embedderEntrypointCallee = codeBlock->embedderEntrypointCalleeFromFunctionIndexSpace(exp.kindIndex);
- Wasm::WasmEntrypointLoadLocation wasmEntrypointLoadLocation = codeBlock->wasmEntrypointLoadLocationFromFunctionIndexSpace(exp.kindIndex);
+ Wasm::WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation = codeBlock->entrypointLoadLocationFromFunctionIndexSpace(exp.kindIndex);
Wasm::SignatureIndex signatureIndex = module->signatureIndexFromFunctionIndexSpace(exp.kindIndex);
const Wasm::Signature& signature = Wasm::SignatureInformation::get(signatureIndex);
- WebAssemblyFunction* function = WebAssemblyFunction::create(vm, globalObject, signature.argumentCount(), String::fromUTF8(exp.field), instance, embedderEntrypointCallee, wasmEntrypointLoadLocation, signatureIndex);
+ WebAssemblyFunction* function = WebAssemblyFunction::create(vm, globalObject, signature.argumentCount(), String::fromUTF8(exp.field), instance, embedderEntrypointCallee, entrypointLoadLocation, signatureIndex);
exportedValue = function;
}
break;
@@ -195,8 +195,8 @@
m_startFunction.set(vm, this, startFunction);
} else {
Wasm::Callee& embedderEntrypointCallee = codeBlock->embedderEntrypointCalleeFromFunctionIndexSpace(startFunctionIndexSpace);
- Wasm::WasmEntrypointLoadLocation wasmEntrypointLoadLocation = codeBlock->wasmEntrypointLoadLocationFromFunctionIndexSpace(startFunctionIndexSpace);
- WebAssemblyFunction* function = WebAssemblyFunction::create(vm, globalObject, signature.argumentCount(), "start", instance, embedderEntrypointCallee, wasmEntrypointLoadLocation, signatureIndex);
+ Wasm::WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation = codeBlock->entrypointLoadLocationFromFunctionIndexSpace(startFunctionIndexSpace);
+ WebAssemblyFunction* function = WebAssemblyFunction::create(vm, globalObject, signature.argumentCount(), "start", instance, embedderEntrypointCallee, entrypointLoadLocation, signatureIndex);
m_startFunction.set(vm, this, function);
}
}
@@ -313,7 +313,7 @@
}
Wasm::Callee& embedderEntrypointCallee = codeBlock->embedderEntrypointCalleeFromFunctionIndexSpace(functionIndex);
- Wasm::WasmEntrypointLoadLocation wasmEntrypointLoadLocation = codeBlock->wasmEntrypointLoadLocationFromFunctionIndexSpace(functionIndex);
+ Wasm::WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation = codeBlock->entrypointLoadLocationFromFunctionIndexSpace(functionIndex);
const Wasm::Signature& signature = Wasm::SignatureInformation::get(signatureIndex);
// FIXME: Say we export local function "foo" at function index 0.
// What if we also set it to the table an Element w/ index 0.
@@ -320,7 +320,7 @@
// Does (new Instance(...)).exports.foo === table.get(0)?
// https://bugs.webkit.org/show_bug.cgi?id=165825
WebAssemblyFunction* function = WebAssemblyFunction::create(
- vm, m_instance->globalObject(), signature.argumentCount(), String(), m_instance.get(), embedderEntrypointCallee, wasmEntrypointLoadLocation, signatureIndex);
+ vm, m_instance->globalObject(), signature.argumentCount(), String(), m_instance.get(), embedderEntrypointCallee, entrypointLoadLocation, signatureIndex);
table->setFunction(vm, tableIndex, function);
++tableIndex;
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.cpp (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.cpp 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.cpp 2018-03-30 05:04:44 UTC (rev 230096)
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2018 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -53,9 +53,9 @@
return JSValue::encode(call(exec, function, callType, callData, jsUndefined(), ArgList(exec)));
}
-WebAssemblyWrapperFunction::WebAssemblyWrapperFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure, Wasm::CallableFunction wasmFunction)
+WebAssemblyWrapperFunction::WebAssemblyWrapperFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure, Wasm::WasmToWasmImportableFunction importableFunction)
: Base(vm, globalObject, structure)
- , m_wasmFunction(wasmFunction)
+ , m_importableFunction(importableFunction)
{ }
WebAssemblyWrapperFunction* WebAssemblyWrapperFunction::create(VM& vm, JSGlobalObject* globalObject, JSObject* function, unsigned importIndex, JSWebAssemblyInstance* instance, Wasm::SignatureIndex signatureIndex)
@@ -63,7 +63,7 @@
ASSERT_WITH_MESSAGE(!function->inherits<WebAssemblyWrapperFunction>(vm), "We should never double wrap a wrapper function.");
String name = "";
NativeExecutable* executable = vm.getHostFunction(callWebAssemblyWrapperFunction, NoIntrinsic, callHostFunctionAsConstructor, nullptr, name);
- WebAssemblyWrapperFunction* result = new (NotNull, allocateCell<WebAssemblyWrapperFunction>(vm.heap)) WebAssemblyWrapperFunction(vm, globalObject, globalObject->webAssemblyWrapperFunctionStructure(), Wasm::CallableFunction { signatureIndex, &instance->instance().importFunctionInfo(importIndex)->wasmToEmbedderStubExecutableAddress } );
+ WebAssemblyWrapperFunction* result = new (NotNull, allocateCell<WebAssemblyWrapperFunction>(vm.heap)) WebAssemblyWrapperFunction(vm, globalObject, globalObject->webAssemblyWrapperFunctionStructure(), Wasm::WasmToWasmImportableFunction { signatureIndex, &instance->instance().importFunctionInfo(importIndex)->wasmToEmbedderStub } );
const Wasm::Signature& signature = Wasm::SignatureInformation::get(signatureIndex);
result->finishCreation(vm, executable, signature.argumentCount(), name, function, instance);
return result;
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.h (230095 => 230096)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.h 2018-03-30 04:45:21 UTC (rev 230095)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyWrapperFunction.h 2018-03-30 05:04:44 UTC (rev 230096)
@@ -32,6 +32,8 @@
namespace JSC {
+using Wasm::WasmToWasmImportableFunction;
+
class WebAssemblyWrapperFunction final : public WebAssemblyFunctionBase {
public:
using Base = WebAssemblyFunctionBase;
@@ -49,9 +51,9 @@
static WebAssemblyWrapperFunction* create(VM&, JSGlobalObject*, JSObject*, unsigned importIndex, JSWebAssemblyInstance*, Wasm::SignatureIndex);
static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
- Wasm::SignatureIndex signatureIndex() const { return m_wasmFunction.signatureIndex; }
- Wasm::WasmEntrypointLoadLocation wasmEntrypointLoadLocation() const { return m_wasmFunction.code; }
- Wasm::CallableFunction callableFunction() const { return m_wasmFunction; }
+ Wasm::SignatureIndex signatureIndex() const { return m_importableFunction.signatureIndex; }
+ WasmToWasmImportableFunction::LoadLocation entrypointLoadLocation() const { return m_importableFunction.entrypointLoadLocation; }
+ WasmToWasmImportableFunction importableFunction() const { return m_importableFunction; }
JSObject* function() { return m_function.get(); }
protected:
@@ -60,13 +62,13 @@
void finishCreation(VM&, NativeExecutable*, unsigned length, const String& name, JSObject*, JSWebAssemblyInstance*);
private:
- WebAssemblyWrapperFunction(VM&, JSGlobalObject*, Structure*, Wasm::CallableFunction);
+ WebAssemblyWrapperFunction(VM&, JSGlobalObject*, Structure*, WasmToWasmImportableFunction);
PoisonedWriteBarrier<WebAssemblyWrapperFunctionPoison, JSObject> m_function;
- // It's safe to just hold the raw CallableFunction because we have a reference
+ // It's safe to just hold the raw WasmToWasmImportableFunction because we have a reference
// to our Instance, which points to the CodeBlock, which points to the Module
// that exported us, which ensures that the actual Signature/code doesn't get deallocated.
- Wasm::CallableFunction m_wasmFunction;
+ WasmToWasmImportableFunction m_importableFunction;
};
} // namespace JSC