Changeset 174455 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Oct 8, 2014, 9:18:03 AM (11 years ago)
Author:
Brent Fulgham
Message:

[Win] Resolve some static analysis warnings in JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=137508

Reviewed by Geoffrey Garen.

  • API/tests/testapi.c:

(assertEqualsAsCharactersPtr): MSVC insists on using %Iu as its format specifier
for size_t. Make the format string conditional on Windows.

  • bytecode/Watchpoint.h:

(JSC::InlineWatchpointSet::encodeState): Silence warning about left-shifting 'state'
as a 32-bit value before OR-ing it with a 64-bit value.

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode): Silence warning about operator prescedence

causing the
operation to take place before the >= test.
  • dfg/DFGInPlaceAbstractState.cpp:
(JSC::DFG::InPlaceAbstractState::endBasicBlock): Ditto (
before !=)
  • testRegExp.cpp:

(testOneRegExp): Ditto %Iu format specifier.

  • yarr/YarrInterpreter.cpp:

(JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext): Silence warning about
using a 32-bit value as part of a 64-bit calculation.

Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/API/tests/testapi.c

    r173018 r174455  
    124124   
    125125    if (jsLength != (size_t)cfLength) {
    126         fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
     126#if OS(WINDOWS)
     127        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%Iu) != cfLength(%Iu)\n", jsLength, (size_t)cfLength);
     128#else
     129        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%zu) != cfLength(%zu)\n", jsLength, (size_t)cfLength);
     130#endif
    127131        failed = 1;
    128132    }
  • trunk/Source/JavaScriptCore/ChangeLog

    r174411 r174455  
     12014-10-08  Brent Fulgham  <[email protected]>
     2
     3        [Win] Resolve some static analysis warnings in JavaScriptCore
     4        https://bugs.webkit.org/show_bug.cgi?id=137508
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * API/tests/testapi.c:
     9        (assertEqualsAsCharactersPtr): MSVC insists on using %Iu as its format specifier
     10        for size_t. Make the format string conditional on Windows.
     11        * bytecode/Watchpoint.h:
     12        (JSC::InlineWatchpointSet::encodeState): Silence warning about left-shifting 'state'
     13        as a 32-bit value before OR-ing it with a 64-bit value.
     14        * dfg/DFGFixupPhase.cpp:
     15        (JSC::DFG::FixupPhase::fixupNode): Silence warning about operator prescedence
     16        causing the || operation to take place before the >= test.
     17        * dfg/DFGInPlaceAbstractState.cpp:
     18        (JSC::DFG::InPlaceAbstractState::endBasicBlock): Ditto (|| before !=)
     19        * testRegExp.cpp:
     20        (testOneRegExp): Ditto %Iu format specifier.
     21        * yarr/YarrInterpreter.cpp:
     22        (JSC::Yarr::Interpreter::allocParenthesesDisjunctionContext): Silence warning about
     23        using a 32-bit value as part of a 64-bit calculation.
     24
    1252014-10-07  Simon Fraser  <[email protected]>
    226
  • trunk/Source/JavaScriptCore/bytecode/Watchpoint.h

    r172129 r174455  
    290290    static uintptr_t encodeState(WatchpointState state)
    291291    {
    292         return (state << StateShift) | IsThinFlag;
     292        return (static_cast<uintptr_t>(state) << StateShift) | IsThinFlag;
    293293    }
    294294   
  • trunk/Source/JavaScriptCore/dfg/DFGFixupPhase.cpp

    r174226 r174455  
    440440                break;
    441441            }
    442             if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && (GPRInfo::numberOfRegisters >= 7 || isFTL(m_graph.m_plan.mode))) {
     442            if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 7) || isFTL(m_graph.m_plan.mode))) {
    443443                fixEdge<StringUse>(node->child1());
    444444                fixEdge<StringUse>(node->child2());
     
    470470                break;
    471471            }
    472             if (node->child1()->shouldSpeculateString() && (GPRInfo::numberOfRegisters >= 8 || isFTL(m_graph.m_plan.mode))) {
     472            if (node->child1()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
    473473                fixEdge<StringUse>(node->child1());
    474474                break;
    475475            }
    476             if (node->child2()->shouldSpeculateString() && (GPRInfo::numberOfRegisters >= 8 || isFTL(m_graph.m_plan.mode))) {
     476            if (node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
    477477                fixEdge<StringUse>(node->child2());
    478478                break;
  • trunk/Source/JavaScriptCore/dfg/DFGInPlaceAbstractState.cpp

    r171613 r174455  
    195195    bool changed = false;
    196196   
    197     if (mergeMode != DontMerge || !ASSERT_DISABLED) {
     197    if ((mergeMode != DontMerge) || !ASSERT_DISABLED) {
    198198        changed |= checkAndSet(block->cfaStructureClobberStateAtTail, m_structureClobberState);
    199199   
  • trunk/Source/JavaScriptCore/testRegExp.cpp

    r173949 r174455  
    207207        if (outVector.size() != regExpTest->expectVector.size()) {
    208208            result = false;
    209             if (verbose)
    210                 printf("Line %d: output vector size mismatch - expected %lu got %lu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
     209            if (verbose) {
     210#if OS(WINDOWS)
     211                printf("Line %d: output vector size mismatch - expected %Iu got %Iu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
     212#else
     213                printf("Line %d: output vector size mismatch - expected %zu got %zu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
     214#endif
     215            }
    211216        } else if (outVector.size() % 2) {
    212217            result = false;
    213             if (verbose)
    214                 printf("Line %d: output vector size is odd (%lu), should be even\n", lineNumber, outVector.size());
     218            if (verbose) {
     219#if OS(WINDOWS)
     220                printf("Line %d: output vector size is odd (%Iu), should be even\n", lineNumber, outVector.size());
     221#else
     222                printf("Line %d: output vector size is odd (%zu), should be even\n", lineNumber, outVector.size());
     223#endif
     224            }
    215225        } else {
    216226            // Check in pairs since the first value of the pair could be -1 in which case the second doesn't matter.
     
    220230                if (outVector[startIndex] != regExpTest->expectVector[startIndex]) {
    221231                    result = false;
    222                     if (verbose)
    223                         printf("Line %d: output vector mismatch at index %lu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
     232                    if (verbose) {
     233#if OS(WINDOWS)
     234                        printf("Line %d: output vector mismatch at index %Iu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
     235#else
     236                        printf("Line %d: output vector mismatch at index %zu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
     237#endif
     238                    }
    224239                }
    225240                if ((i > 0) && (regExpTest->expectVector[startIndex] != -1) && (outVector[startIndex+1] != regExpTest->expectVector[startIndex+1])) {
    226241                    result = false;
    227                     if (verbose)
    228                         printf("Line %d: output vector mismatch at index %lu - expected %d got %d\n", lineNumber, startIndex+1, regExpTest->expectVector[startIndex+1], outVector[startIndex+1]);
     242                    if (verbose) {
     243#if OS(WINDOWS)
     244                        printf("Line %d: output vector mismatch at index %Iu - expected %d got %d\n", lineNumber, startIndex + 1, regExpTest->expectVector[startIndex + 1], outVector[startIndex + 1]);
     245#else
     246                        printf("Line %d: output vector mismatch at index %zu - expected %d got %d\n", lineNumber, startIndex + 1, regExpTest->expectVector[startIndex + 1], outVector[startIndex + 1]);
     247#endif
     248                    }
    229249                }
    230250            }
  • trunk/Source/JavaScriptCore/yarr/YarrInterpreter.cpp

    r162906 r174455  
    155155    ParenthesesDisjunctionContext* allocParenthesesDisjunctionContext(ByteDisjunction* disjunction, unsigned* output, ByteTerm& term)
    156156    {
    157         size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + disjunction->m_frameSize * sizeof(uintptr_t);
     157        size_t size = sizeof(ParenthesesDisjunctionContext) - sizeof(unsigned) + (term.atom.parenthesesDisjunction->m_numSubpatterns << 1) * sizeof(unsigned) + sizeof(DisjunctionContext) - sizeof(uintptr_t) + static_cast<size_t>(disjunction->m_frameSize) * sizeof(uintptr_t);
    158158        allocatorPool = allocatorPool->ensureCapacity(size);
    159159        RELEASE_ASSERT(allocatorPool);
Note: See TracChangeset for help on using the changeset viewer.