Changeset 141222 in webkit


Ignore:
Timestamp:
Jan 29, 2013 9:43:47 PM (11 years ago)
Author:
ggaren@apple.com
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):

Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r141202 r141222  
     12013-01-29  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Be a little more conservative about emitting table-based switches
     4        https://bugs.webkit.org/show_bug.cgi?id=108292
     5
     6        Reviewed by Filip Pizlo.
     7
     8        Profiling shows we're using op_switch in cases where it's a regression.
     9
     10        * bytecompiler/NodesCodegen.cpp:
     11        (JSC):
     12        (JSC::length):
     13        (JSC::CaseBlockNode::tryTableSwitch):
     14        (JSC::CaseBlockNode::emitBytecodeForBlock):
     15        * parser/Nodes.h:
     16        (CaseBlockNode):
     17
    1182013-01-29  Sheriff Bot  <webkit.review.bot@gmail.com>
    219
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r140594 r141222  
    18521852    }
    18531853}
    1854    
    1855 SwitchInfo::SwitchType CaseBlockNode::tryOptimizedSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num)
    1856 {
     1854
     1855static inline size_t length(ClauseListNode* list1, ClauseListNode* list2)
     1856{
     1857    size_t length = 0;
     1858    for (ClauseListNode* node = list1; node; node = node->getNext())
     1859        ++length;
     1860    for (ClauseListNode* node = list2; node; node = node->getNext())
     1861        ++length;
     1862    return length;
     1863}
     1864
     1865SwitchInfo::SwitchType CaseBlockNode::tryTableSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num)
     1866{
     1867    if (length(m_list1, m_list2) < s_tableSwitchMinimum)
     1868        return SwitchInfo::SwitchNone;
     1869
    18571870    SwitchKind typeForTable = SwitchUnset;
    18581871    bool singleCharacterSwitch = true;
     
    18891902    int32_t min_num = std::numeric_limits<int32_t>::max();
    18901903    int32_t max_num = std::numeric_limits<int32_t>::min();
    1891     SwitchInfo::SwitchType switchType = tryOptimizedSwitch(literalVector, min_num, max_num);
     1904    SwitchInfo::SwitchType switchType = tryTableSwitch(literalVector, min_num, max_num);
    18921905
    18931906    if (switchType != SwitchInfo::SwitchNone) {
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r140947 r141222  
    15101510
    15111511    private:
    1512         SwitchInfo::SwitchType tryOptimizedSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num);
     1512        SwitchInfo::SwitchType tryTableSwitch(Vector<ExpressionNode*, 8>& literalVector, int32_t& min_num, int32_t& max_num);
     1513        static const size_t s_tableSwitchMinimum = 10;
    15131514        ClauseListNode* m_list1;
    15141515        CaseClauseNode* m_defaultClause;
Note: See TracChangeset for help on using the changeset viewer.