Ignore:
Timestamp:
May 5, 2015, 1:42:44 PM (10 years ago)
Author:
[email protected]
Message:

FTL SwitchString slow case creates duplicate switch cases
https://bugs.webkit.org/show_bug.cgi?id=144634

Reviewed by Geoffrey Garen.

The problem of duplicate switches is sufficiently annoying that I fixed the issue and also
added mostly-debug-only asserts to catch such issues earlier.

  • bytecode/CallVariant.cpp:

(JSC::variantListWithVariant): Assertion to prevent similar bugs.

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::switchStringRecurse): Assertion to prevent similar bugs.
(JSC::FTL::LowerDFGToLLVM::switchStringSlow): This is the bug.

  • jit/BinarySwitch.cpp:

(JSC::BinarySwitch::BinarySwitch): Assertion to prevent similar bugs.

  • jit/Repatch.cpp:

(JSC::linkPolymorphicCall): Assertion to prevent similar bugs.

  • tests/stress/ftl-switch-string-slow-duplicate-cases.js: Added. This tests the FTL SwitchString bug. It was previously crashing every time.

(foo):
(cat):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/bytecode/CallVariant.cpp

    r179478 r183825  
    2828
    2929#include "JSCInlines.h"
     30#include <wtf/ListDump.h>
    3031
    3132namespace JSC {
     
    6970    if (!!variantToAdd)
    7071        result.append(variantToAdd);
     72   
     73    if (!ASSERT_DISABLED) {
     74        for (unsigned i = 0; i < result.size(); ++i) {
     75            for (unsigned j = i + 1; j < result.size(); ++j) {
     76                if (result[i] != result[j])
     77                    continue;
     78               
     79                dataLog("variantListWithVariant(", listDump(list), ", ", variantToAdd, ") failed: got duplicates in result: ", listDump(result), "\n");
     80                RELEASE_ASSERT_NOT_REACHED();
     81            }
     82        }
     83    }
     84   
    7185    return result;
    7286}
Note: See TracChangeset for help on using the changeset viewer.