Title: [189184] trunk
Revision
189184
Author
[email protected]
Date
2015-08-31 14:05:25 -0700 (Mon, 31 Aug 2015)

Log Message

NodeFilter.SHOW_ALL has wrong value on 32-bit
https://bugs.webkit.org/show_bug.cgi?id=148602

Reviewed by Geoffrey Garen.

Source/_javascript_Core:

NodeFilter.SHOW_ALL has wrong value on 32-bit. This is because
NodeFilter.SHOW_ALL is an unsigned long whose value is 0xFFFFFFFF but
our bindings code is casting it to an intptr_t type which is not wide
enough on 32-bit.

* create_hash_table:
Add extra curly brackets to initialize the union.

* runtime/Lookup.h:
Use a union type to store either a struct containing 2 intptr_t members
(value1 / value2) or a large constant of type unsigned long long. When
storing a constant, we only need one of the values so this allows us to
support larger constants without increasing the actual HashTableValue
size.

Source/WebCore:

NodeFilter.SHOW_ALL has wrong value on 32-bit. This is because
NodeFilter.SHOW_ALL is an unsigned long whose value is 0xFFFFFFFF but
our bindings code is casting it to an intptr_t type which is not wide
enough on 32-bit.

No new tests, already covered by fast/dom/node-filter-interface.html
which is now unskipped on Windows / 32bit.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHashTableValueArray):
Generate extra curly brackets to initialize the new union member.
Also cast to long long the constant instead of intptr_t.

* dom/NodeFilter.h:
Explicitly mark the enum underlying type to be an unsigned long
to make sure it can hold the value for SHOW_ALL on all platforms.
On Windows, it seems the default underlying type is an int for
e.g.

LayoutTests:

Unskip tests that are now passing on Windows / 32bit.

* platform/win/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189183 => 189184)


--- trunk/LayoutTests/ChangeLog	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/LayoutTests/ChangeLog	2015-08-31 21:05:25 UTC (rev 189184)
@@ -1,5 +1,16 @@
 2015-08-31  Chris Dumez  <[email protected]>
 
+        NodeFilter.SHOW_ALL has wrong value on 32-bit
+        https://bugs.webkit.org/show_bug.cgi?id=148602
+
+        Reviewed by Geoffrey Garen.
+
+        Unskip tests that are now passing on Windows / 32bit.
+
+        * platform/win/TestExpectations:
+
+2015-08-31  Chris Dumez  <[email protected]>
+
         Range.detach() / NodeIterator.detach() should be no-ops as per the latest DOM specification
         https://bugs.webkit.org/show_bug.cgi?id=148454
 

Modified: trunk/LayoutTests/platform/win/TestExpectations (189183 => 189184)


--- trunk/LayoutTests/platform/win/TestExpectations	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/LayoutTests/platform/win/TestExpectations	2015-08-31 21:05:25 UTC (rev 189184)
@@ -952,11 +952,6 @@
 webkit.org/b/122166 media/media-volume-slider-rendered-normal.html [ Skip ] # Crashing
 webkit.org/b/122166 media/video-controls-visible-audio-only.html [ Skip ] # Crashing
 
-# 32-bit bug in the bindings.
-webkit.org/b/148602 fast/dom/node-filter-interface.html [ Failure ]
-webkit.org/b/148602 http/tests/w3c/dom/interfaces.html [ Failure ]
-webkit.org/b/148602 http/tests/w3c/dom/traversal/NodeFilter-constants.html [ Failure ]
-
 # Test introduced in r157133 fails. State of colorspace management on Windows is unclear.
 media/video-canvas-drawing-output.html [ Skip ] #  [ Timeout ]
 # Mock media source does not work on Windows

Modified: trunk/Source/_javascript_Core/ChangeLog (189183 => 189184)


--- trunk/Source/_javascript_Core/ChangeLog	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/Source/_javascript_Core/ChangeLog	2015-08-31 21:05:25 UTC (rev 189184)
@@ -1,3 +1,25 @@
+2015-08-31  Chris Dumez  <[email protected]>
+
+        NodeFilter.SHOW_ALL has wrong value on 32-bit
+        https://bugs.webkit.org/show_bug.cgi?id=148602
+
+        Reviewed by Geoffrey Garen.
+
+        NodeFilter.SHOW_ALL has wrong value on 32-bit. This is because
+        NodeFilter.SHOW_ALL is an unsigned long whose value is 0xFFFFFFFF but
+        our bindings code is casting it to an intptr_t type which is not wide
+        enough on 32-bit.
+
+        * create_hash_table:
+        Add extra curly brackets to initialize the union.
+
+        * runtime/Lookup.h:
+        Use a union type to store either a struct containing 2 intptr_t members
+        (value1 / value2) or a large constant of type unsigned long long. When
+        storing a constant, we only need one of the values so this allows us to
+        support larger constants without increasing the actual HashTableValue
+        size.
+
 2015-08-31  Mark Lam  <[email protected]>
 
         Watchdog timer callback should release the lock before deref'ing the watchdog.

Modified: trunk/Source/_javascript_Core/create_hash_table (189183 => 189184)


--- trunk/Source/_javascript_Core/create_hash_table	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/Source/_javascript_Core/create_hash_table	2015-08-31 21:05:25 UTC (rev 189184)
@@ -320,10 +320,10 @@
             my $tableHead = $name;
             $tableHead =~ s/Table$//;
             print " #if JSC_BUILTIN_EXISTS(" . uc($tableHead . $key) .")\n";
-            print "   { \"$key\", (($attrs[$i]) & ~Function) | Builtin, $intrinsic, (intptr_t)static_cast<BuiltinGenerator>(" . $tableHead . ucfirst($key) . "CodeGenerator), (intptr_t)$secondValue },\n";
+            print "   { \"$key\", (($attrs[$i]) & ~Function) | Builtin, $intrinsic, { (intptr_t)static_cast<BuiltinGenerator>(" . $tableHead . ucfirst($key) . "CodeGenerator), (intptr_t)$secondValue } },\n";
             print " #else\n"
         }
-        print "   { \"$key\", $attrs[$i], $intrinsic, (intptr_t)" . $firstCastStr . "($firstValue), (intptr_t)" . $secondCastStr . "($secondValue) },\n";
+        print "   { \"$key\", $attrs[$i], $intrinsic, { (intptr_t)" . $firstCastStr . "($firstValue), (intptr_t)" . $secondCastStr . "($secondValue) } },\n";
         if ($values[$i]{"type"} eq "Function")  {
             print " #endif\n"
         }

Modified: trunk/Source/_javascript_Core/runtime/Lookup.h (189183 => 189184)


--- trunk/Source/_javascript_Core/runtime/Lookup.h	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/Source/_javascript_Core/runtime/Lookup.h	2015-08-31 21:05:25 UTC (rev 189184)
@@ -50,25 +50,38 @@
     const char* m_key; // property name
     unsigned m_attributes; // JSObject attributes
     Intrinsic m_intrinsic;
-    intptr_t m_value1;
-    intptr_t m_value2;
+    union ValueStorage {
+        constexpr ValueStorage(intptr_t value1, intptr_t value2)
+            : value1(value1)
+            , value2(value2)
+        { }
+        constexpr ValueStorage(long long constant)
+            : constant(constant)
+        { }
 
+        struct {
+            intptr_t value1;
+            intptr_t value2;
+        };
+        long long constant;
+    } m_values;
+
     unsigned attributes() const { return m_attributes; }
 
     Intrinsic intrinsic() const { ASSERT(m_attributes & Function); return m_intrinsic; }
-    BuiltinGenerator builtinGenerator() const { ASSERT(m_attributes & Builtin); return reinterpret_cast<BuiltinGenerator>(m_value1); }
-    NativeFunction function() const { ASSERT(m_attributes & Function); return reinterpret_cast<NativeFunction>(m_value1); }
-    unsigned char functionLength() const { ASSERT(m_attributes & Function); return static_cast<unsigned char>(m_value2); }
+    BuiltinGenerator builtinGenerator() const { ASSERT(m_attributes & Builtin); return reinterpret_cast<BuiltinGenerator>(m_values.value1); }
+    NativeFunction function() const { ASSERT(m_attributes & Function); return reinterpret_cast<NativeFunction>(m_values.value1); }
+    unsigned char functionLength() const { ASSERT(m_attributes & Function); return static_cast<unsigned char>(m_values.value2); }
 
-    GetFunction propertyGetter() const { ASSERT(!(m_attributes & BuiltinOrFunctionOrAccessorOrConstant)); return reinterpret_cast<GetFunction>(m_value1); }
-    PutFunction propertyPutter() const { ASSERT(!(m_attributes & BuiltinOrFunctionOrAccessorOrConstant)); return reinterpret_cast<PutFunction>(m_value2); }
+    GetFunction propertyGetter() const { ASSERT(!(m_attributes & BuiltinOrFunctionOrAccessorOrConstant)); return reinterpret_cast<GetFunction>(m_values.value1); }
+    PutFunction propertyPutter() const { ASSERT(!(m_attributes & BuiltinOrFunctionOrAccessorOrConstant)); return reinterpret_cast<PutFunction>(m_values.value2); }
 
-    NativeFunction accessorGetter() const { ASSERT(m_attributes & Accessor); return reinterpret_cast<NativeFunction>(m_value1); }
-    NativeFunction accessorSetter() const { ASSERT(m_attributes & Accessor); return reinterpret_cast<NativeFunction>(m_value2); }
+    NativeFunction accessorGetter() const { ASSERT(m_attributes & Accessor); return reinterpret_cast<NativeFunction>(m_values.value1); }
+    NativeFunction accessorSetter() const { ASSERT(m_attributes & Accessor); return reinterpret_cast<NativeFunction>(m_values.value2); }
 
-    intptr_t constantInteger() const { ASSERT(m_attributes & ConstantInteger); return m_value1; }
+    long long constantInteger() const { ASSERT(m_attributes & ConstantInteger); return m_values.constant; }
 
-    intptr_t lexerValue() const { ASSERT(!m_attributes); return m_value1; }
+    intptr_t lexerValue() const { ASSERT(!m_attributes); return m_values.value1; }
 };
 
 struct HashTable {

Modified: trunk/Source/WebCore/ChangeLog (189183 => 189184)


--- trunk/Source/WebCore/ChangeLog	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/Source/WebCore/ChangeLog	2015-08-31 21:05:25 UTC (rev 189184)
@@ -1,5 +1,31 @@
 2015-08-31  Chris Dumez  <[email protected]>
 
+        NodeFilter.SHOW_ALL has wrong value on 32-bit
+        https://bugs.webkit.org/show_bug.cgi?id=148602
+
+        Reviewed by Geoffrey Garen.
+
+        NodeFilter.SHOW_ALL has wrong value on 32-bit. This is because
+        NodeFilter.SHOW_ALL is an unsigned long whose value is 0xFFFFFFFF but
+        our bindings code is casting it to an intptr_t type which is not wide
+        enough on 32-bit.
+
+        No new tests, already covered by fast/dom/node-filter-interface.html
+        which is now unskipped on Windows / 32bit.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHashTableValueArray):
+        Generate extra curly brackets to initialize the new union member.
+        Also cast to long long the constant instead of intptr_t.
+
+        * dom/NodeFilter.h:
+        Explicitly mark the enum underlying type to be an unsigned long
+        to make sure it can hold the value for SHOW_ALL on all platforms.
+        On Windows, it seems the default underlying type is an int for
+        e.g.
+
+2015-08-31  Chris Dumez  <[email protected]>
+
         Range.detach() / NodeIterator.detach() should be no-ops as per the latest DOM specification
         https://bugs.webkit.org/show_bug.cgi?id=148454
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (189183 => 189184)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2015-08-31 21:05:25 UTC (rev 189184)
@@ -4198,16 +4198,20 @@
             $secondTargetType = "static_cast<PutPropertySlot::PutValueFunc>";
             $hasSetter = "true";
         }
-        push(@implContent, "    { \"$key\", @$specials[$i], NoIntrinsic, (intptr_t)" . $firstTargetType . "(@$value1[$i]), (intptr_t) " . $secondTargetType . "(@$value2[$i]) },\n");
+        if ("@$specials[$i]" =~ m/ConstantInteger/) {
+            push(@implContent, "    { \"$key\", @$specials[$i], NoIntrinsic, { (long long)" . $firstTargetType . "(@$value1[$i]) } },\n");
+        } else {
+            push(@implContent, "    { \"$key\", @$specials[$i], NoIntrinsic, { (intptr_t)" . $firstTargetType . "(@$value1[$i]), (intptr_t) " . $secondTargetType . "(@$value2[$i]) } },\n");
+        }
         if ($conditional) {
             push(@implContent, "#else\n") ;
-            push(@implContent, "    { 0, 0, NoIntrinsic, 0, 0 },\n");
+            push(@implContent, "    { 0, 0, NoIntrinsic, { 0, 0 } },\n");
             push(@implContent, "#endif\n") ;
         }
         ++$i;
     }
 
-    push(@implContent, "    { 0, 0, NoIntrinsic, 0, 0 }\n") if (!$packedSize);
+    push(@implContent, "    { 0, 0, NoIntrinsic, { 0, 0 } }\n") if (!$packedSize);
     push(@implContent, "};\n\n");
 
     return $hasSetter;

Modified: trunk/Source/WebCore/dom/NodeFilter.h (189183 => 189184)


--- trunk/Source/WebCore/dom/NodeFilter.h	2015-08-31 20:57:49 UTC (rev 189183)
+++ trunk/Source/WebCore/dom/NodeFilter.h	2015-08-31 21:05:25 UTC (rev 189184)
@@ -49,7 +49,7 @@
          * their values are derived by using a bit position corresponding
          * to the value of NodeType for the equivalent node type.
          */
-        enum {
+        enum : unsigned long {
             SHOW_ALL                       = 0xFFFFFFFF,
             SHOW_ELEMENT                   = 0x00000001,
             SHOW_ATTRIBUTE                 = 0x00000002,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to