Changeset 166413 in webkit


Ignore:
Timestamp:
Mar 28, 2014 10:51:51 AM (10 years ago)
Author:
tonikitoo@webkit.org
Message:

constants are always typed to 'int' https://bugs.webkit.org/show_bug.cgi?id=130775

Reviewed by Darin Adler.
Patch by Antonio Gomes <a1.gomes@sisa.samsung.com>

Patch fixes a bug where all constant getter generated
methods were returning 'integer' values due to static_cast.

Compilers should be smarth enough to properly infer which
jsNumber class construtor to call given a literal value.

Patch also fixes a bug where values whose representation
is bigger an integer maximum were overflowing. For instance,
NodeFilter.SHOW_ALL (0xFFFFFFFF).

Tests:
Binding tests updated.
Rebaselined fast/dom/constants.html

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateImplementation):

  • bindings/scripts/test/JS/JSTestInterface.cpp:

(WebCore::jsTestInterfaceIMPLEMENTSCONSTANT1):
(WebCore::jsTestInterfaceIMPLEMENTSCONSTANT2):
(WebCore::jsTestInterfaceSUPPLEMENTALCONSTANT1):
(WebCore::jsTestInterfaceSUPPLEMENTALCONSTANT2):

  • bindings/scripts/test/JS/JSTestObj.cpp:

(WebCore::jsTestObjCONDITIONAL_CONST):
(WebCore::jsTestObjCONST_VALUE_0):
(WebCore::jsTestObjCONST_VALUE_1):
(WebCore::jsTestObjCONST_VALUE_2):
(WebCore::jsTestObjCONST_VALUE_4):
(WebCore::jsTestObjCONST_VALUE_8):
(WebCore::jsTestObjCONST_VALUE_9):
(WebCore::jsTestObjCONST_VALUE_11):
(WebCore::jsTestObjCONST_VALUE_12):
(WebCore::jsTestObjCONST_VALUE_13):
(WebCore::jsTestObjCONST_VALUE_14):
(WebCore::jsTestObjCONST_JAVASCRIPT):
(WebCore::jsTestObjReadonly):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/fast/dom/constants-expected.txt

    r116039 r166413  
    2828PASS: nodeFilter.FILTER_REJECT should be 2 and is.
    2929PASS: nodeFilter.FILTER_SKIP should be 3 and is.
    30 PASS: nodeFilter.SHOW_ALL should be -1 and is.
     30PASS: nodeFilter.SHOW_ALL should be 4294967295 and is.
    3131PASS: nodeFilter.SHOW_ELEMENT should be 1 and is.
    3232PASS: nodeFilter.SHOW_ATTRIBUTE should be 2 and is.
     
    4444PASS: window.NodeFilter.FILTER_REJECT should be 2 and is.
    4545PASS: window.NodeFilter.FILTER_SKIP should be 3 and is.
    46 PASS: window.NodeFilter.SHOW_ALL should be -1 and is.
     46PASS: window.NodeFilter.SHOW_ALL should be 4294967295 and is.
    4747PASS: window.NodeFilter.SHOW_ELEMENT should be 1 and is.
    4848PASS: window.NodeFilter.SHOW_ATTRIBUTE should be 2 and is.
  • trunk/LayoutTests/fast/dom/constants.html

    r120792 r166413  
    8181    shouldBe("nodeFilter.FILTER_REJECT", 2);
    8282    shouldBe("nodeFilter.FILTER_SKIP", 3);
    83     shouldBe("nodeFilter.SHOW_ALL", -1);
     83    shouldBe("nodeFilter.SHOW_ALL", 0xFFFFFFFF);
    8484    shouldBe("nodeFilter.SHOW_ELEMENT", 0x00000001);
    8585    shouldBe("nodeFilter.SHOW_ATTRIBUTE", 0x00000002);
     
    9898    shouldBe("window.NodeFilter.FILTER_REJECT", 2);
    9999    shouldBe("window.NodeFilter.FILTER_SKIP", 3);
    100     shouldBe("window.NodeFilter.SHOW_ALL", -1);
     100    shouldBe("window.NodeFilter.SHOW_ALL", 0xFFFFFFFF);
    101101    shouldBe("window.NodeFilter.SHOW_ELEMENT", 0x00000001);
    102102    shouldBe("window.NodeFilter.SHOW_ATTRIBUTE", 0x00000002);
  • trunk/Source/WebCore/ChangeLog

    r166412 r166413  
     12014-03-26  Antonio Gomes  <a1.gomes@sisa.samsung.com>
     2
     3        [Bindings] constants are always typed to 'int'
     4        https://bugs.webkit.org/show_bug.cgi?id=130775
     5
     6        Reviewed by Darin Adler.
     7
     8        Patch fixes a bug where all constant getter generated
     9        methods were returning 'integer' values due to static_cast.
     10
     11        Compilers should be smarth enough to properly infer which
     12        jsNumber class construtor to call given a literal value.
     13
     14        Patch also fixes a bug where values whose representation
     15        is bigger an integer maximum were overflowing. For instance,
     16        NodeFilter.SHOW_ALL (0xFFFFFFFF).
     17
     18        Tests:
     19        Binding tests updated.
     20        Rebaselined fast/dom/constants.html
     21
     22        * bindings/scripts/CodeGeneratorJS.pm:
     23        (GenerateImplementation):
     24        * bindings/scripts/test/JS/JSTestInterface.cpp:
     25        (WebCore::jsTestInterfaceIMPLEMENTSCONSTANT1):
     26        (WebCore::jsTestInterfaceIMPLEMENTSCONSTANT2):
     27        (WebCore::jsTestInterfaceSUPPLEMENTALCONSTANT1):
     28        (WebCore::jsTestInterfaceSUPPLEMENTALCONSTANT2):
     29        * bindings/scripts/test/JS/JSTestObj.cpp:
     30        (WebCore::jsTestObjCONDITIONAL_CONST):
     31        (WebCore::jsTestObjCONST_VALUE_0):
     32        (WebCore::jsTestObjCONST_VALUE_1):
     33        (WebCore::jsTestObjCONST_VALUE_2):
     34        (WebCore::jsTestObjCONST_VALUE_4):
     35        (WebCore::jsTestObjCONST_VALUE_8):
     36        (WebCore::jsTestObjCONST_VALUE_9):
     37        (WebCore::jsTestObjCONST_VALUE_11):
     38        (WebCore::jsTestObjCONST_VALUE_12):
     39        (WebCore::jsTestObjCONST_VALUE_13):
     40        (WebCore::jsTestObjCONST_VALUE_14):
     41        (WebCore::jsTestObjCONST_JAVASCRIPT):
     42        (WebCore::jsTestObjReadonly):
     43
    1442014-03-28  Myles C. Maxfield  <mmaxfield@apple.com>
    245
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

    r166411 r166413  
    28222822            }
    28232823
    2824             # FIXME: this casts into int to match our previous behavior which turned 0xFFFFFFFF in -1 for NodeFilter.SHOW_ALL
    28252824            push(@implContent, "EncodedJSValue ${getter}(ExecState* exec, JSObject*, EncodedJSValue, PropertyName)\n");
    28262825            push(@implContent, "{\n");
     
    28292828            } else {
    28302829                push(@implContent, "    UNUSED_PARAM(exec);\n");
    2831                 push(@implContent, "    return JSValue::encode(jsNumber(static_cast<int>(" . $constant->value . ")));\n");
     2830                push(@implContent, "    return JSValue::encode(jsNumber(" . $constant->value . "));\n");
    28322831            }
    28332832            push(@implContent, "}\n\n");
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

    r166128 r166413  
    933933{
    934934    UNUSED_PARAM(exec);
    935     return JSValue::encode(jsNumber(static_cast<int>(1)));
     935    return JSValue::encode(jsNumber(1));
    936936}
    937937
     
    941941{
    942942    UNUSED_PARAM(exec);
    943     return JSValue::encode(jsNumber(static_cast<int>(2)));
     943    return JSValue::encode(jsNumber(2));
    944944}
    945945
     
    949949{
    950950    UNUSED_PARAM(exec);
    951     return JSValue::encode(jsNumber(static_cast<int>(1)));
     951    return JSValue::encode(jsNumber(1));
    952952}
    953953
     
    957957{
    958958    UNUSED_PARAM(exec);
    959     return JSValue::encode(jsNumber(static_cast<int>(2)));
     959    return JSValue::encode(jsNumber(2));
    960960}
    961961
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp

    r166128 r166413  
    46904690{
    46914691    UNUSED_PARAM(exec);
    4692     return JSValue::encode(jsNumber(static_cast<int>(0)));
     4692    return JSValue::encode(jsNumber(0));
    46934693}
    46944694
     
    46974697{
    46984698    UNUSED_PARAM(exec);
    4699     return JSValue::encode(jsNumber(static_cast<int>(0)));
     4699    return JSValue::encode(jsNumber(0));
    47004700}
    47014701
     
    47034703{
    47044704    UNUSED_PARAM(exec);
    4705     return JSValue::encode(jsNumber(static_cast<int>(1)));
     4705    return JSValue::encode(jsNumber(1));
    47064706}
    47074707
     
    47094709{
    47104710    UNUSED_PARAM(exec);
    4711     return JSValue::encode(jsNumber(static_cast<int>(2)));
     4711    return JSValue::encode(jsNumber(2));
    47124712}
    47134713
     
    47154715{
    47164716    UNUSED_PARAM(exec);
    4717     return JSValue::encode(jsNumber(static_cast<int>(4)));
     4717    return JSValue::encode(jsNumber(4));
    47184718}
    47194719
     
    47214721{
    47224722    UNUSED_PARAM(exec);
    4723     return JSValue::encode(jsNumber(static_cast<int>(8)));
     4723    return JSValue::encode(jsNumber(8));
    47244724}
    47254725
     
    47274727{
    47284728    UNUSED_PARAM(exec);
    4729     return JSValue::encode(jsNumber(static_cast<int>(-1)));
     4729    return JSValue::encode(jsNumber(-1));
    47304730}
    47314731
     
    47384738{
    47394739    UNUSED_PARAM(exec);
    4740     return JSValue::encode(jsNumber(static_cast<int>(0xffffffff)));
     4740    return JSValue::encode(jsNumber(0xffffffff));
    47414741}
    47424742
     
    47444744{
    47454745    UNUSED_PARAM(exec);
    4746     return JSValue::encode(jsNumber(static_cast<int>(0x01)));
     4746    return JSValue::encode(jsNumber(0x01));
    47474747}
    47484748
     
    47504750{
    47514751    UNUSED_PARAM(exec);
    4752     return JSValue::encode(jsNumber(static_cast<int>(0X20)));
     4752    return JSValue::encode(jsNumber(0X20));
    47534753}
    47544754
     
    47564756{
    47574757    UNUSED_PARAM(exec);
    4758     return JSValue::encode(jsNumber(static_cast<int>(0x1abc)));
     4758    return JSValue::encode(jsNumber(0x1abc));
    47594759}
    47604760
     
    47624762{
    47634763    UNUSED_PARAM(exec);
    4764     return JSValue::encode(jsNumber(static_cast<int>(15)));
     4764    return JSValue::encode(jsNumber(15));
    47654765}
    47664766
     
    47684768{
    47694769    UNUSED_PARAM(exec);
    4770     return JSValue::encode(jsNumber(static_cast<int>(0)));
     4770    return JSValue::encode(jsNumber(0));
    47714771}
    47724772
Note: See TracChangeset for help on using the changeset viewer.