Enable named offsets into JSC bytecodes
authorkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Aug 2017 20:13:54 +0000 (20:13 +0000)
committerkeith_miller@apple.com <keith_miller@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 15 Aug 2017 20:13:54 +0000 (20:13 +0000)
commit2752945007e0d9fddda390658bb4c9d2921eebd2
treeaf8a75f2d297bd789561594465a324df2da1aa33
parenta897f00413c50c345787b22bd0b705f52784bab8
Enable named offsets into JSC bytecodes
https://bugs.webkit.org/show_bug.cgi?id=175561

Reviewed by Mark Lam.

This patch adds the ability to add named offsets into JSC's
bytecodes.  In the bytecode json file, instead of listing a
length, you can now list a set of names and their types. Each
opcode with an offsets property will have a struct named after the
opcode by in our C++ naming style. For example,
op_overrides_has_instance would become OpOverridesHasInstance. The
struct has the same memory layout as the instruction list has but
comes with handy named accessors.

As a first cut I converted the various instanceof bytecodes to use
named offsets.

As an example op_overrides_has_instance produces the following struct:

struct OpOverridesHasInstance {
public:
    Opcode& opcode() { return *reinterpret_cast<Opcode*>(&m_opcode); }
    const Opcode& opcode() const { return *reinterpret_cast<const Opcode*>(&m_opcode); }
    int& dst() { return *reinterpret_cast<int*>(&m_dst); }
    const int& dst() const { return *reinterpret_cast<const int*>(&m_dst); }
    int& constructor() { return *reinterpret_cast<int*>(&m_constructor); }
    const int& constructor() const { return *reinterpret_cast<const int*>(&m_constructor); }
    int& hasInstanceValue() { return *reinterpret_cast<int*>(&m_hasInstanceValue); }
    const int& hasInstanceValue() const { return *reinterpret_cast<const int*>(&m_hasInstanceValue); }

private:
    friend class LLIntOffsetsExtractor;
    std::aligned_storage<sizeof(Opcode), sizeof(Instruction)>::type m_opcode;
    std::aligned_storage<sizeof(int), sizeof(Instruction)>::type m_dst;
    std::aligned_storage<sizeof(int), sizeof(Instruction)>::type m_constructor;
    std::aligned_storage<sizeof(int), sizeof(Instruction)>::type m_hasInstanceValue;
};

* CMakeLists.txt:
* DerivedSources.make:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/BytecodeList.json:
* dfg/DFGByteCodeParser.cpp:
(JSC::DFG::ByteCodeParser::parseBlock):
* generate-bytecode-files:
* jit/JITOpcodes.cpp:
(JSC::JIT::emit_op_overrides_has_instance):
(JSC::JIT::emit_op_instanceof):
(JSC::JIT::emitSlow_op_instanceof):
(JSC::JIT::emitSlow_op_instanceof_custom):
* jit/JITOpcodes32_64.cpp:
(JSC::JIT::emit_op_overrides_has_instance):
(JSC::JIT::emit_op_instanceof):
(JSC::JIT::emitSlow_op_instanceof):
(JSC::JIT::emitSlow_op_instanceof_custom):
* llint/LLIntOffsetsExtractor.cpp:
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
13 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/BytecodeList.json
Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
Source/JavaScriptCore/generate-bytecode-files
Source/JavaScriptCore/jit/JITOpcodes.cpp
Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
Source/JavaScriptCore/llint/LLIntOffsetsExtractor.cpp
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
Source/JavaScriptCore/llint/LowLevelInterpreter64.asm