Title: [141222] trunk/Source/_javascript_Core
- Revision
- 141222
- Author
- [email protected]
- Date
- 2013-01-29 21:43:47 -0800 (Tue, 29 Jan 2013)
Log Message
Be a little more conservative about emitting table-based switches
https://bugs.webkit.org/show_bug.cgi?id=108292
Reviewed by Filip Pizlo.
Profiling shows we're using op_switch in cases where it's a regression.
* bytecompiler/NodesCodegen.cpp:
(JSC):
(JSC::length):
(JSC::CaseBlockNode::tryTableSwitch):
(JSC::CaseBlockNode::emitBytecodeForBlock):
* parser/Nodes.h:
(CaseBlockNode):
Modified Paths
Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (141221 => 141222)
--- trunk/Source/_javascript_Core/ChangeLog 2013-01-30 05:37:21 UTC (rev 141221)
+++ trunk/Source/_javascript_Core/ChangeLog 2013-01-30 05:43:47 UTC (rev 141222)
@@ -1,3 +1,20 @@
+2013-01-29 Geoffrey Garen <[email protected]>
+
+ Be a little more conservative about emitting table-based switches
+ https://bugs.webkit.org/show_bug.cgi?id=108292
+
+ Reviewed by Filip Pizlo.
+
+ Profiling shows we're using op_switch in cases where it's a regression.
+
+ * bytecompiler/NodesCodegen.cpp:
+ (JSC):
+ (JSC::length):
+ (JSC::CaseBlockNode::tryTableSwitch):
+ (JSC::CaseBlockNode::emitBytecodeForBlock):
+ * parser/Nodes.h:
+ (CaseBlockNode):
+
2013-01-29 Sheriff Bot <[email protected]>
Unreviewed, rolling out r140983.
Modified: trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp (141221 => 141222)
--- trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2013-01-30 05:37:21 UTC (rev 141221)
+++ trunk/Source/_javascript_Core/bytecompiler/NodesCodegen.cpp 2013-01-30 05:43:47 UTC (rev 141222)
@@ -1851,9 +1851,22 @@
break;
}
}
-
-SwitchInfo::SwitchType CaseBlockNode::tryOptimizedSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num)
+
+static inline size_t length(ClauseListNode* list1, ClauseListNode* list2)
{
+ size_t length = 0;
+ for (ClauseListNode* node = list1; node; node = node->getNext())
+ ++length;
+ for (ClauseListNode* node = list2; node; node = node->getNext())
+ ++length;
+ return length;
+}
+
+SwitchInfo::SwitchType CaseBlockNode::tryTableSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num)
+{
+ if (length(m_list1, m_list2) < s_tableSwitchMinimum)
+ return SwitchInfo::SwitchNone;
+
SwitchKind typeForTable = SwitchUnset;
bool singleCharacterSwitch = true;
@@ -1888,7 +1901,7 @@
Vector<ExpressionNode*, 8> literalVector;
int32_t min_num = std::numeric_limits<int32_t>::max();
int32_t max_num = std::numeric_limits<int32_t>::min();
- SwitchInfo::SwitchType switchType = tryOptimizedSwitch(literalVector, min_num, max_num);
+ SwitchInfo::SwitchType switchType = tryTableSwitch(literalVector, min_num, max_num);
if (switchType != SwitchInfo::SwitchNone) {
// Prepare the various labels
Modified: trunk/Source/_javascript_Core/parser/Nodes.h (141221 => 141222)
--- trunk/Source/_javascript_Core/parser/Nodes.h 2013-01-30 05:37:21 UTC (rev 141221)
+++ trunk/Source/_javascript_Core/parser/Nodes.h 2013-01-30 05:43:47 UTC (rev 141222)
@@ -1509,7 +1509,8 @@
RegisterID* emitBytecodeForBlock(BytecodeGenerator&, RegisterID* input, RegisterID* destination);
private:
- SwitchInfo::SwitchType tryOptimizedSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num);
+ SwitchInfo::SwitchType tryTableSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num);
+ static const size_t s_tableSwitchMinimum = 10;
ClauseListNode* m_list1;
CaseClauseNode* m_defaultClause;
ClauseListNode* m_list2;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes