Ignore:
Timestamp:
Jan 21, 2009, 8:28:05 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-01-21 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Fix for https://bugs.webkit.org/show_bug.cgi?id=23469.

We need to check all numbers in integer switches, not just those
represented as integer JSImmediates.

  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute): (JSC::Interpreter::cti_op_switch_imm):

LayoutTests:

2009-01-21 Gavin Barraclough <[email protected]>

Reviewed by Oliver Hunt.

Add layout test for switch (-0).

  • fast/js/resources/switch-behaviour.js:
  • fast/js/switch-behaviour-expected.txt:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r40108 r40111  
    31443144        if (scrutinee.isInt32Fast())
    31453145            vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(scrutinee.getInt32Fast(), defaultOffset);
    3146         else
    3147             vPC += defaultOffset;
     3146        else {
     3147            int32_t value;
     3148            if (scrutinee.numberToInt32(value))
     3149                vPC += callFrame->codeBlock()->immediateSwitchJumpTable(tableIndex).offsetForValue(value, defaultOffset);
     3150            else
     3151                vPC += defaultOffset;
     3152        }
    31483153        NEXT_INSTRUCTION();
    31493154    }
     
    59695974    if (scrutinee.isInt32Fast())
    59705975        return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee.getInt32Fast());
    5971 
    5972     return codeBlock->immediateSwitchJumpTable(tableIndex).ctiDefault;
     5976    else {
     5977        int32_t value;
     5978        if (scrutinee.numberToInt32(value))
     5979            return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(value);
     5980        else
     5981            return codeBlock->immediateSwitchJumpTable(tableIndex).ctiDefault;
     5982    }
    59735983}
    59745984
Note: See TracChangeset for help on using the changeset viewer.