Consider removing double load for accessing the instructions from LLInt
authoryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2018 06:51:54 +0000 (06:51 +0000)
committeryusukesuzuki@slowstart.org <yusukesuzuki@slowstart.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Nov 2018 06:51:54 +0000 (06:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190932

Reviewed by Mark Lam.

Changing InstructionStream to RefCountedArray like structure involves so much changes
including BytecodeGraph, PreciseJumpTargets etc. Instead, CodeBlock simply hold a raw
pointer to the InstructionStream's data. Since InstructionStream is not changed
anymore, this pointer is valid while CodeBlock is live.

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
* bytecode/CodeBlock.h:
* bytecode/InstructionStream.h:
(JSC::InstructionStream::rawPointer const):
* llint/LowLevelInterpreter.asm:
* llint/LowLevelInterpreter32_64.asm:
* llint/LowLevelInterpreter64.asm:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238367 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/bytecode/CodeBlock.cpp
Source/JavaScriptCore/bytecode/CodeBlock.h
Source/JavaScriptCore/bytecode/InstructionStream.h
Source/JavaScriptCore/llint/LowLevelInterpreter.asm
Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
Source/JavaScriptCore/llint/LowLevelInterpreter64.asm

index 990db29..f7023ab 100644 (file)
@@ -1,3 +1,24 @@
+2018-11-12  Yusuke Suzuki  <yusukesuzuki@slowstart.org>
+
+        Consider removing double load for accessing the instructions from LLInt
+        https://bugs.webkit.org/show_bug.cgi?id=190932
+
+        Reviewed by Mark Lam.
+
+        Changing InstructionStream to RefCountedArray like structure involves so much changes
+        including BytecodeGraph, PreciseJumpTargets etc. Instead, CodeBlock simply hold a raw
+        pointer to the InstructionStream's data. Since InstructionStream is not changed
+        anymore, this pointer is valid while CodeBlock is live.
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::CodeBlock):
+        * bytecode/CodeBlock.h:
+        * bytecode/InstructionStream.h:
+        (JSC::InstructionStream::rawPointer const):
+        * llint/LowLevelInterpreter.asm:
+        * llint/LowLevelInterpreter32_64.asm:
+        * llint/LowLevelInterpreter64.asm:
+
 2018-11-18  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         REGRESSION(r238039) WebCore::JSDOMGlobalObject::createStructure is using JSC::Structure::create without including StructureInlines.h
index 05a9092..d4ea5dd 100644 (file)
@@ -303,8 +303,9 @@ CodeBlock::CodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, CodeBlock
     , m_unlinkedCode(*other.vm(), this, other.m_unlinkedCode.get())
     , m_ownerExecutable(*other.vm(), this, other.m_ownerExecutable.get())
     , m_poisonedVM(other.m_poisonedVM)
-    , m_instructionCount(other.m_instructionCount)
     , m_instructions(other.m_instructions)
+    , m_instructionsRawPointer(other.m_instructionsRawPointer)
+    , m_instructionCount(other.m_instructionCount)
     , m_thisRegister(other.m_thisRegister)
     , m_scopeRegister(other.m_scopeRegister)
     , m_hash(other.m_hash)
@@ -369,6 +370,7 @@ CodeBlock::CodeBlock(VM* vm, Structure* structure, ScriptExecutable* ownerExecut
     , m_ownerExecutable(*vm, this, ownerExecutable)
     , m_poisonedVM(vm)
     , m_instructions(&unlinkedCodeBlock->instructions())
+    , m_instructionsRawPointer(m_instructions->rawPointer())
     , m_thisRegister(unlinkedCodeBlock->thisRegister())
     , m_scopeRegister(unlinkedCodeBlock->scopeRegister())
     , m_source(WTFMove(sourceProvider))
index 3c5b567..29a605b 100644 (file)
@@ -949,8 +949,9 @@ private:
     WriteBarrier<ExecutableToCodeBlockEdge> m_ownerEdge;
     Poisoned<CodeBlockPoison, VM*> m_poisonedVM;
 
-    unsigned m_instructionCount { 0 };
     const InstructionStream* m_instructions;
+    const void* m_instructionsRawPointer { nullptr };
+    unsigned m_instructionCount { 0 };
     VirtualRegister m_thisRegister;
     VirtualRegister m_scopeRegister;
     mutable CodeBlockHash m_hash;
index 4b34386..44b4be7 100644 (file)
@@ -162,6 +162,11 @@ public:
         return m_instructions.size();
     }
 
+    const void* rawPointer() const
+    {
+        return m_instructions.data();
+    }
+
 protected:
     explicit InstructionStream(InstructionBuffer&&);
 
index 416f3ba..2f9ae88 100644 (file)
@@ -1127,17 +1127,11 @@ macro prologue(codeBlockGetter, codeBlockSetter, osrSlowPath, traceSlowPath)
 
     # Set up the PC.
     if JSVALUE64
-        # FIXME: cleanup double load
-        # https://bugs.webkit.org/show_bug.cgi?id=190932
-        loadp CodeBlock::m_instructions[t1], PB
-        loadp [PB], PB
+        loadp CodeBlock::m_instructionsRawPointer[t1], PB
         unpoison(_g_CodeBlockPoison, PB, t3)
         move 0, PC
     else
-        # FIXME: cleanup double load
-        # https://bugs.webkit.org/show_bug.cgi?id=190932
-        loadp CodeBlock::m_instructions[t1], PC
-        loadp [PC], PC
+        loadp CodeBlock::m_instructionsRawPointer[t1], PC
     end
 
     # Get new sp in t0 and check stack height.
index 81e203b..e75b668 100644 (file)
@@ -678,10 +678,7 @@ macro functionArityCheck(doneLabel, slowPath)
 .continue:
     # Reload CodeBlock and PC, since the slow_path clobbered it.
     loadp CodeBlock[cfr], t1
-    # FIXME: cleanup double load
-    # https://bugs.webkit.org/show_bug.cgi?id=190932
-    loadp CodeBlock::m_instructions[t1], PC
-    loadp [PC], PC
+    loadp CodeBlock::m_instructionsRawPointer[t1], PC
     jmp doneLabel
 end
 
@@ -1818,7 +1815,7 @@ llintOpWithJump(op_switch_imm, OpSwitchImm, macro (size, get, jump, dispatch)
     loadConstantOrVariable(size, t2, t1, t0)
     loadp CodeBlock[cfr], t2
     loadp CodeBlock::m_rareData[t2], t2
-    muli sizeof SimpleJumpTable, t3   # FIXME: would be nice to peephole this!
+    muli sizeof SimpleJumpTable, t3
     loadp CodeBlock::RareData::m_switchJumpTables + VectorBufferOffset[t2], t2
     addp t3, t2
     bineq t1, Int32Tag, .opSwitchImmNotInt
index 56ded71..86ddd92 100644 (file)
@@ -80,10 +80,7 @@ end
 macro dispatchAfterCall(size, op, dispatch)
     loadi ArgumentCount + TagOffset[cfr], PC
     loadp CodeBlock[cfr], PB
-    # FIXME: cleanup double load
-    # https://bugs.webkit.org/show_bug.cgi?id=190932
-    loadp CodeBlock::m_instructions[PB], PB
-    loadp [PB], PB
+    loadp CodeBlock::m_instructionsRawPointer[PB], PB
     unpoison(_g_CodeBlockPoison, PB, t1)
     get(size, op, dst, t1)
     storeq r0, [cfr, t1, 8]
@@ -632,10 +629,7 @@ macro functionArityCheck(doneLabel, slowPath)
 .continue:
     # Reload CodeBlock and reset PC, since the slow_path clobbered them.
     loadp CodeBlock[cfr], t1
-    # FIXME: cleanup double load
-    # https://bugs.webkit.org/show_bug.cgi?id=190932
-    loadp CodeBlock::m_instructions[t1], PB
-    loadp [PB], PB
+    loadp CodeBlock::m_instructionsRawPointer[t1], PB
     unpoison(_g_CodeBlockPoison, PB, t2)
     move 0, PC
     jmp doneLabel
@@ -1913,7 +1907,7 @@ llintOpWithJump(op_switch_imm, OpSwitchImm, macro (size, get, jump, dispatch)
     loadConstantOrVariable(size, t2, t1)
     loadp CodeBlock[cfr], t2
     loadp CodeBlock::m_rareData[t2], t2
-    muli sizeof SimpleJumpTable, t3    # FIXME: would be nice to peephole this!
+    muli sizeof SimpleJumpTable, t3
     loadp CodeBlock::RareData::m_switchJumpTables + VectorBufferOffset[t2], t2
     addp t3, t2
     bqb t1, tagTypeNumber, .opSwitchImmNotInt
@@ -2056,10 +2050,7 @@ commonOp(llint_op_catch, macro() end, macro (size)
     restoreStackPointerAfterCall()
 
     loadp CodeBlock[cfr], PB
-    # FIXME: cleanup double load
-    # https://bugs.webkit.org/show_bug.cgi?id=190932
-    loadp CodeBlock::m_instructions[PB], PB
-    loadp [PB], PB
+    loadp CodeBlock::m_instructionsRawPointer[PB], PB
     unpoison(_g_CodeBlockPoison, PB, t2)
     loadp VM::targetInterpreterPCForThrow[t3], PC
     subp PB, PC