Ignore:
Timestamp:
Jul 24, 2013, 9:03:23 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: There should only be one table of SimpleJumpTables
https://bugs.webkit.org/show_bug.cgi?id=117856

Reviewed by Geoffrey Garen.

Having multiple tables of SimpleJumpTables just means we have to duplicate a
ton of code. This patch deduplicates all of it.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::dumpBytecode):
(JSC):
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::shrinkToFit):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::numberOfSwitchJumpTables):
(JSC::CodeBlock::addSwitchJumpTable):
(JSC::CodeBlock::switchJumpTable):
(JSC::CodeBlock::clearSwitchJumpTables):
(RareData):

  • bytecode/PreciseJumpTargets.cpp:

(JSC):
(JSC::computePreciseJumpTargets):

  • bytecode/UnlinkedCodeBlock.h:

(JSC::UnlinkedCodeBlock::shrinkToFit):
(JSC::UnlinkedCodeBlock::numberOfSwitchJumpTables):
(JSC::UnlinkedCodeBlock::addSwitchJumpTable):
(JSC::UnlinkedCodeBlock::switchJumpTable):
(RareData):

  • bytecompiler/BytecodeGenerator.cpp:

(JSC):
(JSC::prepareJumpTableForSwitch):
(JSC::BytecodeGenerator::endSwitch):

  • dfg/DFGByteCodeParser.cpp:

(InlineStackEntry):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::link):

  • dfg/DFGJITCompiler.h:

(JITCompiler):

  • dfg/DFGOperations.cpp:
  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::emitSwitchIntJump):
(DFG):
(JSC::DFG::SpeculativeJIT::emitSwitchImm):
(JSC::DFG::SpeculativeJIT::emitSwitchCharStringJump):

  • dfg/DFGSpeculativeJIT.h:

(SpeculativeJIT):

  • ftl/FTLLink.cpp:

(JSC::FTL::link):

  • jit/JITOpcodes.cpp:

(JSC::JIT::emit_op_switch_imm):
(JSC::JIT::emit_op_switch_char):

  • jit/JITOpcodes32_64.cpp:

(JSC::JIT::emit_op_switch_imm):
(JSC::JIT::emit_op_switch_char):

  • jit/JITStubs.cpp:

(JSC::DEFINE_STUB_FUNCTION):

  • llint/LLIntSlowPaths.cpp:

(JSC::LLInt::LLINT_SLOW_PATH_DECL):

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp

    r153221 r153237  
    22412241}
    22422242
    2243 static void prepareJumpTableForImmediateSwitch(UnlinkedSimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max)
    2244 {
    2245     jumpTable.min = min;
    2246     jumpTable.branchOffsets.resize(max - min + 1);
    2247     jumpTable.branchOffsets.fill(0);
    2248     for (uint32_t i = 0; i < clauseCount; ++i) {
    2249         // We're emitting this after the clause labels should have been fixed, so
    2250         // the labels should not be "forward" references
    2251         ASSERT(!labels[i]->isForward());
    2252         jumpTable.add(keyForImmediateSwitch(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3));
    2253     }
    2254 }
    2255 
    22562243static int32_t keyForCharacterSwitch(ExpressionNode* node, int32_t min, int32_t max)
    22572244{
     
    22672254}
    22682255
    2269 static void prepareJumpTableForCharacterSwitch(UnlinkedSimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max)
     2256static void prepareJumpTableForSwitch(
     2257    UnlinkedSimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount,
     2258    RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max,
     2259    int32_t (*keyGetter)(ExpressionNode*, int32_t min, int32_t max))
    22702260{
    22712261    jumpTable.min = min;
     
    22762266        // the labels should not be "forward" references
    22772267        ASSERT(!labels[i]->isForward());
    2278         jumpTable.add(keyForCharacterSwitch(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3));
     2268        jumpTable.add(keyGetter(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3));
    22792269    }
    22802270}
     
    22972287    SwitchInfo switchInfo = m_switchContextStack.last();
    22982288    m_switchContextStack.removeLast();
    2299     if (switchInfo.switchType == SwitchInfo::SwitchImmediate) {
    2300         instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfImmediateSwitchJumpTables();
     2289   
     2290    switch (switchInfo.switchType) {
     2291    case SwitchInfo::SwitchImmediate:
     2292    case SwitchInfo::SwitchCharacter: {
     2293        instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfSwitchJumpTables();
    23012294        instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3);
    23022295
    2303         UnlinkedSimpleJumpTable& jumpTable = m_codeBlock->addImmediateSwitchJumpTable();
    2304         prepareJumpTableForImmediateSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes, min, max);
    2305     } else if (switchInfo.switchType == SwitchInfo::SwitchCharacter) {
    2306         instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfCharacterSwitchJumpTables();
    2307         instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3);
     2296        UnlinkedSimpleJumpTable& jumpTable = m_codeBlock->addSwitchJumpTable();
     2297        prepareJumpTableForSwitch(
     2298            jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes, min, max,
     2299            switchInfo.switchType == SwitchInfo::SwitchImmediate
     2300                ? keyForImmediateSwitch
     2301                : keyForCharacterSwitch);
     2302        break;
     2303    }
    23082304       
    2309         UnlinkedSimpleJumpTable& jumpTable = m_codeBlock->addCharacterSwitchJumpTable();
    2310         prepareJumpTableForCharacterSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes, min, max);
    2311     } else {
    2312         ASSERT(switchInfo.switchType == SwitchInfo::SwitchString);
     2305    case SwitchInfo::SwitchString: {
    23132306        instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfStringSwitchJumpTables();
    23142307        instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3);
     
    23162309        UnlinkedStringJumpTable& jumpTable = m_codeBlock->addStringSwitchJumpTable();
    23172310        prepareJumpTableForStringSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes);
     2311        break;
     2312    }
     2313       
     2314    default:
     2315        RELEASE_ASSERT_NOT_REACHED();
     2316        break;
    23182317    }
    23192318}
Note: See TracChangeset for help on using the changeset viewer.