Title: [174455] trunk/Source/_javascript_Core
Revision
174455
Author
[email protected]
Date
2014-10-08 09:18:03 -0700 (Wed, 08 Oct 2014)

Log Message

[Win] Resolve some static analysis warnings in _javascript_Core
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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/API/tests/testapi.c (174454 => 174455)


--- trunk/Source/_javascript_Core/API/tests/testapi.c	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/API/tests/testapi.c	2014-10-08 16:18:03 UTC (rev 174455)
@@ -123,7 +123,11 @@
     }
     
     if (jsLength != (size_t)cfLength) {
-        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%ld) != cfLength(%ld)\n", jsLength, cfLength);
+#if OS(WINDOWS)
+        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%Iu) != cfLength(%Iu)\n", jsLength, (size_t)cfLength);
+#else
+        fprintf(stderr, "assertEqualsAsCharactersPtr failed: jsLength(%zu) != cfLength(%zu)\n", jsLength, (size_t)cfLength);
+#endif
         failed = 1;
     }
 

Modified: trunk/Source/_javascript_Core/ChangeLog (174454 => 174455)


--- trunk/Source/_javascript_Core/ChangeLog	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/ChangeLog	2014-10-08 16:18:03 UTC (rev 174455)
@@ -1,3 +1,27 @@
+2014-10-08  Brent Fulgham  <[email protected]>
+
+        [Win] Resolve some static analysis warnings in _javascript_Core
+        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.
+
 2014-10-07  Simon Fraser  <[email protected]>
 
         Roll-over Changelogs.

Modified: trunk/Source/_javascript_Core/bytecode/Watchpoint.h (174454 => 174455)


--- trunk/Source/_javascript_Core/bytecode/Watchpoint.h	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/bytecode/Watchpoint.h	2014-10-08 16:18:03 UTC (rev 174455)
@@ -289,7 +289,7 @@
     
     static uintptr_t encodeState(WatchpointState state)
     {
-        return (state << StateShift) | IsThinFlag;
+        return (static_cast<uintptr_t>(state) << StateShift) | IsThinFlag;
     }
     
     bool isThin() const { return isThin(m_data); }

Modified: trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp (174454 => 174455)


--- trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/dfg/DFGFixupPhase.cpp	2014-10-08 16:18:03 UTC (rev 174455)
@@ -439,7 +439,7 @@
                 fixEdge<StringIdentUse>(node->child2());
                 break;
             }
-            if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && (GPRInfo::numberOfRegisters >= 7 || isFTL(m_graph.m_plan.mode))) {
+            if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 7) || isFTL(m_graph.m_plan.mode))) {
                 fixEdge<StringUse>(node->child1());
                 fixEdge<StringUse>(node->child2());
                 break;
@@ -469,11 +469,11 @@
                 fixEdge<NotStringVarUse>(node->child1());
                 break;
             }
-            if (node->child1()->shouldSpeculateString() && (GPRInfo::numberOfRegisters >= 8 || isFTL(m_graph.m_plan.mode))) {
+            if (node->child1()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
                 fixEdge<StringUse>(node->child1());
                 break;
             }
-            if (node->child2()->shouldSpeculateString() && (GPRInfo::numberOfRegisters >= 8 || isFTL(m_graph.m_plan.mode))) {
+            if (node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
                 fixEdge<StringUse>(node->child2());
                 break;
             }

Modified: trunk/Source/_javascript_Core/dfg/DFGInPlaceAbstractState.cpp (174454 => 174455)


--- trunk/Source/_javascript_Core/dfg/DFGInPlaceAbstractState.cpp	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/dfg/DFGInPlaceAbstractState.cpp	2014-10-08 16:18:03 UTC (rev 174455)
@@ -194,7 +194,7 @@
     
     bool changed = false;
     
-    if (mergeMode != DontMerge || !ASSERT_DISABLED) {
+    if ((mergeMode != DontMerge) || !ASSERT_DISABLED) {
         changed |= checkAndSet(block->cfaStructureClobberStateAtTail, m_structureClobberState);
     
         switch (m_graph.m_form) {

Modified: trunk/Source/_javascript_Core/testRegExp.cpp (174454 => 174455)


--- trunk/Source/_javascript_Core/testRegExp.cpp	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/testRegExp.cpp	2014-10-08 16:18:03 UTC (rev 174455)
@@ -206,12 +206,22 @@
     } else if (matchResult != -1) {
         if (outVector.size() != regExpTest->expectVector.size()) {
             result = false;
-            if (verbose)
-                printf("Line %d: output vector size mismatch - expected %lu got %lu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
+            if (verbose) {
+#if OS(WINDOWS)
+                printf("Line %d: output vector size mismatch - expected %Iu got %Iu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
+#else
+                printf("Line %d: output vector size mismatch - expected %zu got %zu\n", lineNumber, regExpTest->expectVector.size(), outVector.size());
+#endif
+            }
         } else if (outVector.size() % 2) {
             result = false;
-            if (verbose)
-                printf("Line %d: output vector size is odd (%lu), should be even\n", lineNumber, outVector.size());
+            if (verbose) {
+#if OS(WINDOWS)
+                printf("Line %d: output vector size is odd (%Iu), should be even\n", lineNumber, outVector.size());
+#else
+                printf("Line %d: output vector size is odd (%zu), should be even\n", lineNumber, outVector.size());
+#endif
+            }
         } else {
             // Check in pairs since the first value of the pair could be -1 in which case the second doesn't matter.
             size_t pairCount = outVector.size() / 2;
@@ -219,13 +229,23 @@
                 size_t startIndex = i*2;
                 if (outVector[startIndex] != regExpTest->expectVector[startIndex]) {
                     result = false;
-                    if (verbose)
-                        printf("Line %d: output vector mismatch at index %lu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
+                    if (verbose) {
+#if OS(WINDOWS)
+                        printf("Line %d: output vector mismatch at index %Iu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
+#else
+                        printf("Line %d: output vector mismatch at index %zu - expected %d got %d\n", lineNumber, startIndex, regExpTest->expectVector[startIndex], outVector[startIndex]);
+#endif
+                    }
                 }
                 if ((i > 0) && (regExpTest->expectVector[startIndex] != -1) && (outVector[startIndex+1] != regExpTest->expectVector[startIndex+1])) {
                     result = false;
-                    if (verbose)
-                        printf("Line %d: output vector mismatch at index %lu - expected %d got %d\n", lineNumber, startIndex+1, regExpTest->expectVector[startIndex+1], outVector[startIndex+1]);
+                    if (verbose) {
+#if OS(WINDOWS)
+                        printf("Line %d: output vector mismatch at index %Iu - expected %d got %d\n", lineNumber, startIndex + 1, regExpTest->expectVector[startIndex + 1], outVector[startIndex + 1]);
+#else
+                        printf("Line %d: output vector mismatch at index %zu - expected %d got %d\n", lineNumber, startIndex + 1, regExpTest->expectVector[startIndex + 1], outVector[startIndex + 1]);
+#endif
+                    }
                 }
             }
         }

Modified: trunk/Source/_javascript_Core/yarr/YarrInterpreter.cpp (174454 => 174455)


--- trunk/Source/_javascript_Core/yarr/YarrInterpreter.cpp	2014-10-08 15:16:23 UTC (rev 174454)
+++ trunk/Source/_javascript_Core/yarr/YarrInterpreter.cpp	2014-10-08 16:18:03 UTC (rev 174455)
@@ -154,7 +154,7 @@
 
     ParenthesesDisjunctionContext* allocParenthesesDisjunctionContext(ByteDisjunction* disjunction, unsigned* output, ByteTerm& term)
     {
-        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);
+        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);
         allocatorPool = allocatorPool->ensureCapacity(size);
         RELEASE_ASSERT(allocatorPool);
         return new (allocatorPool->alloc(size)) ParenthesesDisjunctionContext(output, term);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to