Changeset 153237 in webkit for trunk/Source/JavaScriptCore/bytecompiler
- Timestamp:
- Jul 24, 2013, 9:03:23 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r153221 r153237 2241 2241 } 2242 2242 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, so2250 // the labels should not be "forward" references2251 ASSERT(!labels[i]->isForward());2252 jumpTable.add(keyForImmediateSwitch(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3));2253 }2254 }2255 2256 2243 static int32_t keyForCharacterSwitch(ExpressionNode* node, int32_t min, int32_t max) 2257 2244 { … … 2267 2254 } 2268 2255 2269 static void prepareJumpTableForCharacterSwitch(UnlinkedSimpleJumpTable& jumpTable, int32_t switchAddress, uint32_t clauseCount, RefPtr<Label>* labels, ExpressionNode** nodes, int32_t min, int32_t max) 2256 static 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)) 2270 2260 { 2271 2261 jumpTable.min = min; … … 2276 2266 // the labels should not be "forward" references 2277 2267 ASSERT(!labels[i]->isForward()); 2278 jumpTable.add(key ForCharacterSwitch(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3));2268 jumpTable.add(keyGetter(nodes[i], min, max), labels[i]->bind(switchAddress, switchAddress + 3)); 2279 2269 } 2280 2270 } … … 2297 2287 SwitchInfo switchInfo = m_switchContextStack.last(); 2298 2288 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(); 2301 2294 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3); 2302 2295 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 } 2308 2304 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: { 2313 2306 instructions()[switchInfo.bytecodeOffset + 1] = m_codeBlock->numberOfStringSwitchJumpTables(); 2314 2307 instructions()[switchInfo.bytecodeOffset + 2] = defaultLabel->bind(switchInfo.bytecodeOffset, switchInfo.bytecodeOffset + 3); … … 2316 2309 UnlinkedStringJumpTable& jumpTable = m_codeBlock->addStringSwitchJumpTable(); 2317 2310 prepareJumpTableForStringSwitch(jumpTable, switchInfo.bytecodeOffset, clauseCount, labels, nodes); 2311 break; 2312 } 2313 2314 default: 2315 RELEASE_ASSERT_NOT_REACHED(); 2316 break; 2318 2317 } 2319 2318 }
Note:
See TracChangeset
for help on using the changeset viewer.