Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (224271 => 224272)
--- trunk/Source/_javascript_Core/ChangeLog 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-11-01 06:15:59 UTC (rev 224272)
@@ -1,3 +1,54 @@
+2017-10-31 JF Bastien <[email protected]>
+
+ WebAssembly: Wasm::IndexOrName has a raw pointer to Name
+ https://bugs.webkit.org/show_bug.cgi?id=176644
+
+ Reviewed by Michael Saboff.
+
+ IndexOrName now keeps a RefPtr to its original NameSection, which
+ holds the Name (or references nullptr if Index). Holding onto the
+ entire section seems like the better thing to do, since backtraces
+ probably contain multiple names from the same Module.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * interpreter/Interpreter.cpp:
+ (JSC::GetStackTraceFunctor::operator() const):
+ * interpreter/StackVisitor.h: Frame is no longer POD because of the
+ RefPtr.
+ * runtime/StackFrame.cpp:
+ (JSC::StackFrame::StackFrame):
+ * runtime/StackFrame.h: Drop the union, size is now 40 bytes.
+ (JSC::StackFrame::StackFrame): Deleted. Initialized in class instead.
+ (JSC::StackFrame::wasm): Deleted. Make it a ctor instead.
+ * wasm/WasmBBQPlanInlines.h:
+ (JSC::Wasm::BBQPlan::initializeCallees):
+ * wasm/WasmCallee.cpp:
+ (JSC::Wasm::Callee::Callee):
+ * wasm/WasmCallee.h:
+ (JSC::Wasm::Callee::create):
+ * wasm/WasmFormat.h: Move NameSection to its own header.
+ (JSC::Wasm::isValidNameType):
+ (JSC::Wasm::NameSection::get): Deleted.
+ * wasm/WasmIndexOrName.cpp:
+ (JSC::Wasm::IndexOrName::IndexOrName):
+ (JSC::Wasm::makeString):
+ * wasm/WasmIndexOrName.h:
+ (JSC::Wasm::IndexOrName::IndexOrName):
+ (JSC::Wasm::IndexOrName::isEmpty const):
+ (JSC::Wasm::IndexOrName::isIndex const):
+ * wasm/WasmModuleInformation.cpp:
+ (JSC::Wasm::ModuleInformation::ModuleInformation):
+ * wasm/WasmModuleInformation.h:
+ (JSC::Wasm::ModuleInformation::ModuleInformation): Deleted.
+ * wasm/WasmNameSection.h:
+ (JSC::Wasm::NameSection::get):
+ (JSC::Wasm::NameSection::create): Deleted.
+ * wasm/WasmNameSectionParser.cpp:
+ (JSC::Wasm::NameSectionParser::parse):
+ * wasm/WasmNameSectionParser.h:
+ * wasm/WasmOMGPlan.cpp:
+ (JSC::Wasm::OMGPlan::work):
+
2017-10-31 Tim Horton <[email protected]>
Clean up some drag and drop feature flags
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (224271 => 224272)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2017-11-01 06:15:59 UTC (rev 224272)
@@ -1488,6 +1488,7 @@
AD5C36EC1F75AD7C000BCAAF /* WasmToJS.h in Headers */ = {isa = PBXBuildFile; fileRef = ADD09AEE1F5F623F001313C2 /* WasmToJS.h */; settings = {ATTRIBUTES = (Private, ); }; };
AD5C36EF1F7A263A000BCAAF /* WasmMemoryMode.h in Headers */ = {isa = PBXBuildFile; fileRef = AD5C36EE1F7A2629000BCAAF /* WasmMemoryMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
AD7438C01E0457A400FD0C2A /* WasmSignature.h in Headers */ = {isa = PBXBuildFile; fileRef = AD7438BF1E04579200FD0C2A /* WasmSignature.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 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 /* JSWebAssemblyCodeBlock.h in Headers */ = {isa = PBXBuildFile; fileRef = AD9E852E1E8A0C6E008DE39E /* JSWebAssemblyCodeBlock.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -4238,6 +4239,7 @@
AD5C36F01F7A26BF000BCAAF /* WasmMemoryMode.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmMemoryMode.cpp; sourceTree = "<group>"; };
AD7438BE1E04579200FD0C2A /* WasmSignature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmSignature.cpp; sourceTree = "<group>"; };
AD7438BF1E04579200FD0C2A /* WasmSignature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmSignature.h; sourceTree = "<group>"; };
+ AD7B4B2D1FA3E28600C9DF79 /* WasmNameSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmNameSection.h; sourceTree = "<group>"; };
AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
AD8DD6CF1F67089F0004EB52 /* JSToWasm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = JSToWasm.h; path = js/JSToWasm.h; sourceTree = "<group>"; };
AD8DD6D01F6708A30004EB52 /* JSToWasm.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = JSToWasm.cpp; path = js/JSToWasm.cpp; sourceTree = "<group>"; };
@@ -6153,6 +6155,7 @@
53F40E961D5A7BEC0099A1B6 /* WasmModuleParser.cpp */,
53F40E941D5A7AEF0099A1B6 /* WasmModuleParser.h */,
AD5B416E1EBAFB65008EFA43 /* WasmName.h */,
+ AD7B4B2D1FA3E28600C9DF79 /* WasmNameSection.h */,
ADD8FA441EB3077100DF542F /* WasmNameSectionParser.cpp */,
ADD8FA431EB3077100DF542F /* WasmNameSectionParser.h */,
5311BD481EA581E500525281 /* WasmOMGPlan.cpp */,
@@ -8262,6 +8265,7 @@
0F96303C1D4192CD005609D9 /* DestructionMode.h in Headers */,
A77A423E17A0BBFD00A8DB81 /* DFGAbstractHeap.h in Headers */,
A704D90317A0BAA8006BA554 /* DFGAbstractInterpreter.h in Headers */,
+ AD7B4B2E1FA3E29800C9DF79 /* WasmNameSection.h in Headers */,
A704D90417A0BAA8006BA554 /* DFGAbstractInterpreterInlines.h in Headers */,
0F620177143FCD3F0068B77C /* DFGAbstractValue.h in Headers */,
0FD3E4021B618AAF00C80E1E /* DFGAdaptiveInferredPropertyValueWatchpoint.h in Headers */,
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -507,7 +507,7 @@
if (m_remainingCapacityForFrameCapture) {
if (visitor->isWasmFrame()) {
- m_results.append(StackFrame::wasm(visitor->wasmFunctionIndexOrName()));
+ m_results.append(StackFrame(visitor->wasmFunctionIndexOrName()));
} else if (!!visitor->codeBlock() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
m_results.append(
StackFrame(m_vm, m_owner, visitor->callee().asCell(), visitor->codeBlock(), visitor->bytecodeOffset()));
Modified: trunk/Source/_javascript_Core/interpreter/StackVisitor.h (224271 => 224272)
--- trunk/Source/_javascript_Core/interpreter/StackVisitor.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/interpreter/StackVisitor.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -121,9 +121,9 @@
size_t m_index;
size_t m_argumentCountIncludingThis;
unsigned m_bytecodeOffset;
- Wasm::IndexOrName m_wasmFunctionIndexOrName;
bool m_callerIsEntryFrame : 1;
bool m_isWasmFrame : 1;
+ Wasm::IndexOrName m_wasmFunctionIndexOrName;
friend class StackVisitor;
};
Modified: trunk/Source/_javascript_Core/runtime/StackFrame.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/runtime/StackFrame.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/runtime/StackFrame.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -35,7 +35,6 @@
StackFrame::StackFrame(VM& vm, JSCell* owner, JSCell* callee)
: m_callee(vm, owner, callee)
- , m_bytecodeOffset(UINT_MAX)
{
}
@@ -46,6 +45,12 @@
{
}
+StackFrame::StackFrame(Wasm::IndexOrName indexOrName)
+ : m_wasmFunctionIndexOrName(indexOrName)
+ , m_isWasmFrame(true)
+{
+}
+
intptr_t StackFrame::sourceID() const
{
if (!m_codeBlock)
Modified: trunk/Source/_javascript_Core/runtime/StackFrame.h (224271 => 224272)
--- trunk/Source/_javascript_Core/runtime/StackFrame.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/runtime/StackFrame.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -37,22 +37,10 @@
class StackFrame {
public:
- StackFrame()
- : m_bytecodeOffset(UINT_MAX)
- { }
-
StackFrame(VM&, JSCell* owner, JSCell* callee);
-
StackFrame(VM&, JSCell* owner, JSCell* callee, CodeBlock*, unsigned bytecodeOffset);
+ StackFrame(Wasm::IndexOrName);
- static StackFrame wasm(Wasm::IndexOrName indexOrName)
- {
- StackFrame result;
- result.m_isWasmFrame = true;
- result.m_wasmFunctionIndexOrName = indexOrName;
- return result;
- }
-
bool hasLineAndColumnInfo() const { return !!m_codeBlock; }
void computeLineAndColumn(unsigned& line, unsigned& column) const;
@@ -73,10 +61,8 @@
private:
WriteBarrier<JSCell> m_callee { };
WriteBarrier<CodeBlock> m_codeBlock { };
- union {
- unsigned m_bytecodeOffset;
- Wasm::IndexOrName m_wasmFunctionIndexOrName;
- };
+ Wasm::IndexOrName m_wasmFunctionIndexOrName;
+ unsigned m_bytecodeOffset { UINT_MAX };
bool m_isWasmFrame { false };
};
Modified: trunk/Source/_javascript_Core/wasm/WasmBBQPlanInlines.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmBBQPlanInlines.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmBBQPlanInlines.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -30,6 +30,7 @@
#include "CalleeBits.h"
#include "WasmBBQPlan.h"
#include "WasmCallee.h"
+#include "WasmNameSection.h"
namespace JSC { namespace Wasm {
@@ -47,7 +48,7 @@
InternalFunction* function = m_wasmInternalFunctions[internalFunctionIndex].get();
size_t functionIndexSpace = internalFunctionIndex + m_moduleInformation->importFunctionCount();
- Ref<Wasm::Callee> wasmEntrypointCallee = Wasm::Callee::create(WTFMove(function->entrypoint), functionIndexSpace, m_moduleInformation->nameSection.get(functionIndexSpace));
+ Ref<Wasm::Callee> wasmEntrypointCallee = Wasm::Callee::create(WTFMove(function->entrypoint), functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace));
MacroAssembler::repatchPointer(function->calleeMoveLocation, CalleeBits::boxWasm(wasmEntrypointCallee.ptr()));
callback(internalFunctionIndex, WTFMove(embedderEntrypointCallee), WTFMove(wasmEntrypointCallee));
Modified: trunk/Source/_javascript_Core/wasm/WasmCallee.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmCallee.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmCallee.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -38,9 +38,9 @@
registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end());
}
-Callee::Callee(Entrypoint&& entrypoint, size_t index, const Name* name)
+Callee::Callee(Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name)
: m_entrypoint(WTFMove(entrypoint))
- , m_indexOrName(index, name)
+ , m_indexOrName(index, WTFMove(name))
{
registerCode(m_entrypoint.compilation->codeRef().executableMemory()->start(), m_entrypoint.compilation->codeRef().executableMemory()->end());
}
Modified: trunk/Source/_javascript_Core/wasm/WasmCallee.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmCallee.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmCallee.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -44,9 +44,9 @@
return adoptRef(*callee);
}
- static Ref<Callee> create(Wasm::Entrypoint&& entrypoint, size_t index, const Name* name)
+ static Ref<Callee> create(Wasm::Entrypoint&& entrypoint, size_t index, std::pair<const Name*, RefPtr<NameSection>>&& name)
{
- Callee* callee = new Callee(WTFMove(entrypoint), index, name);
+ Callee* callee = new Callee(WTFMove(entrypoint), index, WTFMove(name));
return adoptRef(*callee);
}
@@ -57,7 +57,7 @@
private:
JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&);
- JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&, size_t, const Name*);
+ JS_EXPORT_PRIVATE Callee(Wasm::Entrypoint&&, size_t, std::pair<const Name*, RefPtr<NameSection>>&&);
Wasm::Entrypoint m_entrypoint;
IndexOrName m_indexOrName;
Modified: trunk/Source/_javascript_Core/wasm/WasmFormat.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmFormat.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmFormat.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -34,6 +34,7 @@
#include "RegisterAtOffsetList.h"
#include "WasmMemoryInformation.h"
#include "WasmName.h"
+#include "WasmNameSection.h"
#include "WasmOps.h"
#include "WasmPageCount.h"
#include "WasmSignature.h"
@@ -253,15 +254,6 @@
}
return false;
}
-
-struct NameSection {
- Name moduleName;
- Vector<Name> functionNames;
- const Name* get(size_t functionIndexSpace)
- {
- return functionIndexSpace < functionNames.size() ? &functionNames[functionIndexSpace] : nullptr;
- }
-};
struct UnlinkedWasmToWasmCall {
CodeLocationNearCall callLocation;
Modified: trunk/Source/_javascript_Core/wasm/WasmIndexOrName.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmIndexOrName.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmIndexOrName.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -28,17 +28,19 @@
namespace JSC { namespace Wasm {
-IndexOrName::IndexOrName(Index index, const Name* name)
+IndexOrName::IndexOrName(Index index, std::pair<const Name*, RefPtr<NameSection>>&& name)
{
- static_assert(sizeof(m_index) == sizeof(m_name), "bit-tagging depends on sizes being equal");
- static_assert(sizeof(m_index) == sizeof(*this), "bit-tagging depends on object being the size of the union's types");
+ static_assert(sizeof(m_indexName.index) == sizeof(m_indexName.name), "bit-tagging depends on sizes being equal");
- if ((index & allTags) || (bitwise_cast<Index>(name) & allTags))
+ if ((index & allTags) || (bitwise_cast<Index>(name.first) & allTags))
*this = IndexOrName();
- else if (name)
- m_name = name;
- else
- m_index = indexTag | index;
+ else {
+ if (name.first)
+ m_indexName.name = name.first;
+ else
+ m_indexName.index = indexTag | index;
+ m_nameSection = WTFMove(name.second);
+ }
}
String makeString(const IndexOrName& ion)
@@ -46,8 +48,8 @@
if (ion.isEmpty())
return String();
if (ion.isIndex())
- return String::number(ion.m_index & ~IndexOrName::indexTag);
- return String(ion.m_name->data(), ion.m_name->size());
+ return String::number(ion.m_indexName.index & ~IndexOrName::indexTag);
+ return String(ion.m_indexName.name->data(), ion.m_indexName.name->size());
};
} } // namespace JSC::Wasm
Modified: trunk/Source/_javascript_Core/wasm/WasmIndexOrName.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmIndexOrName.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmIndexOrName.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -26,20 +26,22 @@
#pragma once
#include "WasmName.h"
+#include "WasmNameSection.h"
+#include <wtf/RefPtr.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/WTFString.h>
namespace JSC { namespace Wasm {
+struct NameSection;
+
struct IndexOrName {
typedef size_t Index;
- IndexOrName()
- : m_index(emptyTag)
- { }
- IndexOrName(Index, const Name*);
- bool isEmpty() const { return bitwise_cast<Index>(*this) & emptyTag; }
- bool isIndex() const { return bitwise_cast<Index>(*this) & indexTag; }
+ IndexOrName() { m_indexName.index = emptyTag; }
+ IndexOrName(Index, std::pair<const Name*, RefPtr<NameSection>>&&);
+ bool isEmpty() const { return bitwise_cast<Index>(m_indexName) & emptyTag; }
+ bool isIndex() const { return bitwise_cast<Index>(m_indexName) & indexTag; }
bool isName() const { return !(isEmpty() || isName()); }
friend String makeString(const IndexOrName&);
@@ -46,9 +48,10 @@
private:
union {
- Index m_index;
- const Name* m_name;
- };
+ Index index;
+ const Name* name;
+ } m_indexName;
+ RefPtr<NameSection> m_nameSection;
// Use the top bits as tags. Neither pointers nor the function index space should use them.
static constexpr Index indexTag = 1ull << (CHAR_BIT * sizeof(Index) - 1);
Modified: trunk/Source/_javascript_Core/wasm/WasmModuleInformation.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmModuleInformation.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmModuleInformation.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -28,8 +28,15 @@
#if ENABLE(WEBASSEMBLY)
+#include "WasmNameSection.h"
+
namespace JSC { namespace Wasm {
+ModuleInformation::ModuleInformation(Vector<uint8_t>&& sourceBytes)
+ : source(WTFMove(sourceBytes))
+ , nameSection(new NameSection())
+{
+}
ModuleInformation::~ModuleInformation() { }
} } // namespace JSC::Wasm
Modified: trunk/Source/_javascript_Core/wasm/WasmModuleInformation.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmModuleInformation.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmModuleInformation.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -32,6 +32,14 @@
namespace JSC { namespace Wasm {
struct ModuleInformation : public ThreadSafeRefCounted<ModuleInformation> {
+ ModuleInformation() = delete;
+ ModuleInformation(const ModuleInformation&) = delete;
+ ModuleInformation(ModuleInformation&&) = delete;
+
+ ModuleInformation(Vector<uint8_t>&& sourceBytes);
+
+ JS_EXPORT_PRIVATE ~ModuleInformation();
+
size_t functionIndexSpaceSize() const { return importFunctionSignatureIndices.size() + internalFunctionSignatureIndices.size(); }
bool isImportedFunctionFromFunctionIndexSpace(size_t functionIndex) const
{
@@ -48,13 +56,6 @@
uint32_t importFunctionCount() const { return importFunctionSignatureIndices.size(); }
uint32_t internalFunctionCount() const { return internalFunctionSignatureIndices.size(); }
- ModuleInformation(Vector<uint8_t>&& sourceBytes)
- : source(WTFMove(sourceBytes))
- {
- }
-
- JS_EXPORT_PRIVATE ~ModuleInformation();
-
const Vector<uint8_t> source;
Vector<Import> imports;
@@ -74,7 +75,7 @@
Vector<Global> globals;
unsigned firstInternalGlobal { 0 };
Vector<CustomSection> customSections;
- NameSection nameSection;
+ RefPtr<NameSection> nameSection;
};
Modified: trunk/Source/_javascript_Core/wasm/WasmNameSection.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmNameSection.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmNameSection.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -28,21 +28,17 @@
#include "WasmName.h"
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/Vector.h>
+#include <utility>
namespace JSC { namespace Wasm {
-struct NameSection : ThreadSafeRefCounted<NameSection> {
- static Ref<NameSection> create()
+struct NameSection : public ThreadSafeRefCounted<NameSection> {
+ std::pair<const Name*, RefPtr<NameSection>> get(size_t functionIndexSpace)
{
- return adoptRef(*new NameSection());
+ return functionIndexSpace < functionNames.size() ? std::make_pair(&functionNames[functionIndexSpace], RefPtr<NameSection>(this)) : std::pair<const Name*, RefPtr<NameSection>>(nullptr, nullptr);
}
-
Name moduleName;
Vector<Name> functionNames;
- const Name* get(size_t functionIndexSpace)
- {
- return functionIndexSpace < functionNames.size() ? &functionNames[functionIndexSpace] : nullptr;
- }
};
} } // namespace JSC::Wasm
Modified: trunk/Source/_javascript_Core/wasm/WasmNameSectionParser.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmNameSectionParser.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmNameSectionParser.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -29,14 +29,15 @@
#if ENABLE(WEBASSEMBLY)
#include "IdentifierInlines.h"
+#include "WasmNameSection.h"
namespace JSC { namespace Wasm {
auto NameSectionParser::parse() -> Result
{
- NameSection nameSection;
- WASM_PARSER_FAIL_IF(!nameSection.functionNames.tryReserveCapacity(m_info.functionIndexSpaceSize()), "can't allocate enough memory for function names");
- nameSection.functionNames.resize(m_info.functionIndexSpaceSize());
+ RefPtr<NameSection> nameSection(adoptRef(*new NameSection()));
+ WASM_PARSER_FAIL_IF(!nameSection->functionNames.tryReserveCapacity(m_info.functionIndexSpaceSize()), "can't allocate enough memory for function names");
+ nameSection->functionNames.resize(m_info.functionIndexSpaceSize());
for (size_t payloadNumber = 0; m_offset < length(); ++payloadNumber) {
uint8_t nameType;
@@ -58,7 +59,7 @@
Name nameString;
WASM_PARSER_FAIL_IF(!parseVarUInt32(nameLen), "can't get module's name length for payload ", payloadNumber);
WASM_PARSER_FAIL_IF(!consumeUTF8String(nameString, nameLen), "can't get module's name of length ", nameLen, " for payload ", payloadNumber);
- nameSection.moduleName = WTFMove(nameString);
+ nameSection->moduleName = WTFMove(nameString);
break;
}
case NameType::Function: {
@@ -72,7 +73,7 @@
WASM_PARSER_FAIL_IF(m_info.functionIndexSpaceSize() <= index, "function ", function, " index ", index, " is larger than function index space ", m_info.functionIndexSpaceSize(), " for payload ", payloadNumber);
WASM_PARSER_FAIL_IF(!parseVarUInt32(nameLen), "can't get functions ", function, "'s name length for payload ", payloadNumber);
WASM_PARSER_FAIL_IF(!consumeUTF8String(nameString, nameLen), "can't get function ", function, "'s name of length ", nameLen, " for payload ", payloadNumber);
- nameSection.functionNames[index] = WTFMove(nameString);
+ nameSection->functionNames[index] = WTFMove(nameString);
}
break;
}
Modified: trunk/Source/_javascript_Core/wasm/WasmNameSectionParser.h (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmNameSectionParser.h 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmNameSectionParser.h 2017-11-01 06:15:59 UTC (rev 224272)
@@ -29,10 +29,11 @@
#include "WasmFormat.h"
#include "WasmParser.h"
+#include <wtf/RefPtr.h>
namespace JSC { namespace Wasm {
-class NameSectionParser : public Parser<NameSection> {
+class NameSectionParser : public Parser<RefPtr<NameSection>> {
public:
NameSectionParser(const uint8_t* sourceBuffer, size_t sourceLength, const ModuleInformation& info)
: Parser(sourceBuffer, sourceLength)
Modified: trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp (224271 => 224272)
--- trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp 2017-11-01 03:26:41 UTC (rev 224271)
+++ trunk/Source/_javascript_Core/wasm/WasmOMGPlan.cpp 2017-11-01 06:15:59 UTC (rev 224272)
@@ -38,6 +38,7 @@
#include "WasmInstance.h"
#include "WasmMachineThreads.h"
#include "WasmMemory.h"
+#include "WasmNameSection.h"
#include "WasmValidate.h"
#include "WasmWorklist.h"
#include <wtf/DataLog.h>
@@ -105,7 +106,7 @@
void* entrypoint;
{
ASSERT(m_codeBlock.ptr() == m_module->codeBlockFor(mode()));
- Ref<Callee> callee = Callee::create(WTFMove(omgEntrypoint), functionIndexSpace, m_moduleInformation->nameSection.get(functionIndexSpace));
+ Ref<Callee> callee = Callee::create(WTFMove(omgEntrypoint), functionIndexSpace, m_moduleInformation->nameSection->get(functionIndexSpace));
MacroAssembler::repatchPointer(parseAndCompileResult.value()->calleeMoveLocation, CalleeBits::boxWasm(callee.ptr()));
ASSERT(!m_codeBlock->m_optimizedCallees[m_functionIndex]);
entrypoint = callee->entrypoint();