Ignore:
Timestamp:
Feb 26, 2009, 7:32:17 PM (16 years ago)
Author:
[email protected]
Message:

JavaScriptCore:

2009-02-26 Gavin Barraclough <[email protected]>

Reviewed by Geoff Garen.

Fix bug #23614. Switches on double precision values were incorrectly
truncating the scrutinee value. E.g.:

switch (1.1) { case 1: print("FAIL"); }

Was resulting in FAIL.

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

LayoutTests:

2009-02-26 Gavin Barraclough <[email protected]>

Rubber stamped by Geoff Garen.

Layout test for bug #23614.

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

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r41232 r41277  
    20262026        return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee.getInt32Fast()).addressForSwitch();
    20272027    else {
    2028         int32_t value;
    2029         if (scrutinee.numberToInt32(value))
    2030             return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(value).addressForSwitch();
     2028        double value;
     2029        int32_t intValue;
     2030        if (scrutinee.getNumber(value) && ((intValue = static_cast<int32_t>(value)) == value))
     2031            return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(intValue).addressForSwitch();
    20312032        else
    20322033            return codeBlock->immediateSwitchJumpTable(tableIndex).ctiDefault.addressForSwitch();
Note: See TracChangeset for help on using the changeset viewer.