Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (214543 => 214544)
--- trunk/Source/_javascript_Core/ChangeLog 2017-03-29 17:22:48 UTC (rev 214543)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-03-29 17:27:23 UTC (rev 214544)
@@ -1,3 +1,22 @@
+2017-03-29 Keith Miller <keith_mil...@apple.com>
+
+ WebAssembly: pack OpcodeOrigin to fit in a pointer
+ https://bugs.webkit.org/show_bug.cgi?id=170244
+
+ Reviewed by Michael Saboff.
+
+ This patch makes it so we don't have to have allocate the OpcodeOrigin and can just
+ pack all the data into the pointer B3::Origin already has.
+
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::parseAndCompile):
+ * wasm/WasmOpcodeOrigin.cpp:
+ (JSC::Wasm::OpcodeOrigin::dump):
+ * wasm/WasmOpcodeOrigin.h:
+ (JSC::Wasm::OpcodeOrigin::OpcodeOrigin):
+ (JSC::Wasm::OpcodeOrigin::opcode):
+ (JSC::Wasm::OpcodeOrigin::location):
+
2017-03-29 JF Bastien <jfbast...@apple.com>
WebAssembly: NFC s/goto/lambda/g
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (214543 => 214544)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2017-03-29 17:22:48 UTC (rev 214543)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2017-03-29 17:27:23 UTC (rev 214544)
@@ -235,7 +235,6 @@
BasicBlock* m_currentBlock;
Vector<Variable*> m_locals;
Vector<UnlinkedWasmToWasmCall>& m_unlinkedWasmToWasmCalls; // List each call site and the function index whose address it should be patched with.
- Vector<std::unique_ptr<OpcodeOrigin>> m_origins;
GPRReg m_memoryBaseGPR;
GPRReg m_memorySizeGPR;
GPRReg m_wasmContextGPR;
@@ -1272,10 +1271,7 @@
auto B3IRGenerator::origin() -> Origin
{
- if (m_origins.isEmpty() || m_origins.last()->location != m_parser->currentOpcodeStartingOffset())
- m_origins.append(std::make_unique<OpcodeOrigin>(m_parser->currentOpcode(), m_parser->currentOpcodeStartingOffset()));
-
- return Origin(m_origins.last().get());
+ return bitwise_cast<Origin>(OpcodeOrigin(m_parser->currentOpcode(), m_parser->currentOpcodeStartingOffset()));
}
Expected<std::unique_ptr<WasmInternalFunction>, String> parseAndCompile(VM& vm, CompilationContext& compilationContext, const uint8_t* functionStart, size_t functionLength, const Signature* signature, Vector<UnlinkedWasmToWasmCall>& unlinkedWasmToWasmCalls, const ModuleInformation& info, const Vector<SignatureIndex>& moduleSignatureIndicesToUniquedSignatureIndices, MemoryMode mode, unsigned optLevel)
@@ -1289,7 +1285,7 @@
procedure.setOriginPrinter([] (PrintStream& out, Origin origin) {
if (origin.data())
- out.print("Wasm: ", *bitwise_cast<OpcodeOrigin*>(origin.data()));
+ out.print("Wasm: ", bitwise_cast<OpcodeOrigin>(origin));
});
B3IRGenerator context(vm, info, procedure, result.get(), unlinkedWasmToWasmCalls, mode);
Modified: trunk/Source/_javascript_Core/wasm/WasmOpcodeOrigin.cpp (214543 => 214544)
--- trunk/Source/_javascript_Core/wasm/WasmOpcodeOrigin.cpp 2017-03-29 17:22:48 UTC (rev 214543)
+++ trunk/Source/_javascript_Core/wasm/WasmOpcodeOrigin.cpp 2017-03-29 17:27:23 UTC (rev 214544)
@@ -32,7 +32,7 @@
void OpcodeOrigin::dump(PrintStream& out) const
{
- out.print("{opcode: ", makeString(opcode), ", location: ", location, "}");
+ out.print("{opcode: ", makeString(opcode()), ", location: ", location(), "}");
}
} } // namespace JSC::Wasm
Modified: trunk/Source/_javascript_Core/wasm/WasmOpcodeOrigin.h (214543 => 214544)
--- trunk/Source/_javascript_Core/wasm/WasmOpcodeOrigin.h 2017-03-29 17:22:48 UTC (rev 214543)
+++ trunk/Source/_javascript_Core/wasm/WasmOpcodeOrigin.h 2017-03-29 17:27:23 UTC (rev 214544)
@@ -28,22 +28,28 @@
#include "B3Origin.h"
#include "WasmFormat.h"
+#include <wtf/ForbidHeapAllocation.h>
+
namespace JSC { namespace Wasm {
class OpcodeOrigin {
- WTF_MAKE_FAST_ALLOCATED;
- WTF_MAKE_NONCOPYABLE(OpcodeOrigin);
+ WTF_FORBID_HEAP_ALLOCATION;
public:
- OpcodeOrigin(OpType op, size_t offset)
- : opcode(op)
- , location(offset)
+ OpcodeOrigin() = default;
+ OpcodeOrigin(OpType opcode, size_t offset)
{
+ ASSERT(static_cast<uint32_t>(offset) == offset);
+ packedData = (static_cast<uint64_t>(opcode) << 32) | offset;
}
void dump(PrintStream&) const;
- const OpType opcode;
- const size_t location;
+ OpType opcode() const { return static_cast<OpType>(packedData >> 32); }
+ size_t location() const { return static_cast<uint32_t>(packedData); }
+
+private:
+ static_assert(sizeof(void*) == sizeof(uint64_t), "this packing doesn't work if this isn't the case");
+ uint64_t packedData { 0 };
};
} } // namespace JSC::Wasm