Changeset 215747 in webkit


Ignore:
Timestamp:
Apr 25, 2017, 11:42:33 AM (8 years ago)
Author:
mark.lam@apple.com
Message:

Make DFG SpeculatedType dumps easier to read.
https://bugs.webkit.org/show_bug.cgi?id=171280

Reviewed by Saam Barati.

Adding a pretty printer to insert |s between each type string and changing the
dumped strings to match the SpeculatedType names case-wise.

  • bytecode/SpeculatedType.cpp:

(JSC::PrettyPrinter::PrettyPrinter):
(JSC::PrettyPrinter::print):
(JSC::dumpSpeculation):

  • bytecode/SpeculatedType.h:
Location:
trunk/Source/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r215743 r215747  
     12017-04-25  Mark Lam  <mark.lam@apple.com>
     2
     3        Make DFG SpeculatedType dumps easier to read.
     4        https://bugs.webkit.org/show_bug.cgi?id=171280
     5
     6        Reviewed by Saam Barati.
     7
     8        Adding a pretty printer to insert |s between each type string and changing the
     9        dumped strings to match the SpeculatedType names case-wise.
     10
     11        * bytecode/SpeculatedType.cpp:
     12        (JSC::PrettyPrinter::PrettyPrinter):
     13        (JSC::PrettyPrinter::print):
     14        (JSC::dumpSpeculation):
     15        * bytecode/SpeculatedType.h:
     16
    1172017-04-25  JF Bastien  <jfbastien@apple.com>
    218
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.cpp

    r211247 r215747  
    11/*
    2  * Copyright (C) 2011-2013, 2015-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4545namespace JSC {
    4646
    47 void dumpSpeculation(PrintStream& out, SpeculatedType value)
    48 {
     47struct PrettyPrinter {
     48    PrettyPrinter(PrintStream& out)
     49        : out(out)
     50        , separator("|")
     51    { }
     52   
     53    template<typename T>
     54    void print(const T& value)
     55    {
     56        out.print(separator, value);
     57    }
     58   
     59    PrintStream& out;
     60    CommaPrinter separator;
     61};
     62   
     63void dumpSpeculation(PrintStream& outStream, SpeculatedType value)
     64{
     65    StringPrintStream strStream;
     66    PrettyPrinter out(outStream);
     67    PrettyPrinter strOut(strStream);
     68   
    4969    if (value == SpecNone) {
    5070        out.print("None");
     
    5272    }
    5373   
    54     StringPrintStream myOut;
    55    
    5674    bool isTop = true;
    5775   
    5876    if ((value & SpecCell) == SpecCell)
    59         myOut.print("Cell");
     77        strOut.print("Cell");
    6078    else {
    6179        if ((value & SpecObject) == SpecObject)
    62             myOut.print("Object");
     80            strOut.print("Object");
    6381        else {
    6482            if (value & SpecCellOther)
    65                 myOut.print("Othercell");
     83                strOut.print("OtherCell");
    6684            else
    6785                isTop = false;
    6886   
    6987            if (value & SpecObjectOther)
    70                 myOut.print("Otherobj");
     88                strOut.print("OtherObj");
    7189            else
    7290                isTop = false;
    7391   
    7492            if (value & SpecFinalObject)
    75                 myOut.print("Final");
     93                strOut.print("Final");
    7694            else
    7795                isTop = false;
    7896
    7997            if (value & SpecArray)
    80                 myOut.print("Array");
     98                strOut.print("Array");
    8199            else
    82100                isTop = false;
    83101   
    84102            if (value & SpecInt8Array)
    85                 myOut.print("Int8array");
     103                strOut.print("Int8Array");
    86104            else
    87105                isTop = false;
    88106   
    89107            if (value & SpecInt16Array)
    90                 myOut.print("Int16array");
     108                strOut.print("Int16Array");
    91109            else
    92110                isTop = false;
    93111   
    94112            if (value & SpecInt32Array)
    95                 myOut.print("Int32array");
     113                strOut.print("Int32Array");
    96114            else
    97115                isTop = false;
    98116   
    99117            if (value & SpecUint8Array)
    100                 myOut.print("Uint8array");
     118                strOut.print("Uint8Array");
    101119            else
    102120                isTop = false;
    103121
    104122            if (value & SpecUint8ClampedArray)
    105                 myOut.print("Uint8clampedarray");
     123                strOut.print("Uint8ClampedArray");
    106124            else
    107125                isTop = false;
    108126   
    109127            if (value & SpecUint16Array)
    110                 myOut.print("Uint16array");
     128                strOut.print("Uint16Array");
    111129            else
    112130                isTop = false;
    113131   
    114132            if (value & SpecUint32Array)
    115                 myOut.print("Uint32array");
     133                strOut.print("Uint32Array");
    116134            else
    117135                isTop = false;
    118136   
    119137            if (value & SpecFloat32Array)
    120                 myOut.print("Float32array");
     138                strOut.print("Float32array");
    121139            else
    122140                isTop = false;
    123141   
    124142            if (value & SpecFloat64Array)
    125                 myOut.print("Float64array");
     143                strOut.print("Float64Array");
    126144            else
    127145                isTop = false;
    128146   
    129147            if (value & SpecFunction)
    130                 myOut.print("Function");
     148                strOut.print("Function");
    131149            else
    132150                isTop = false;
    133151   
    134152            if (value & SpecDirectArguments)
    135                 myOut.print("Directarguments");
     153                strOut.print("DirectArguments");
    136154            else
    137155                isTop = false;
    138156   
    139157            if (value & SpecScopedArguments)
    140                 myOut.print("Scopedarguments");
     158                strOut.print("ScopedArguments");
    141159            else
    142160                isTop = false;
    143161   
    144162            if (value & SpecStringObject)
    145                 myOut.print("Stringobject");
     163                strOut.print("StringObject");
    146164            else
    147165                isTop = false;
    148166   
    149167            if (value & SpecRegExpObject)
    150                 myOut.print("Regexpobject");
     168                strOut.print("RegExpObject");
    151169            else
    152170                isTop = false;
    153171
    154172            if (value & SpecMapObject)
    155                 myOut.print("Mapobject");
     173                strOut.print("MapObject");
    156174            else
    157175                isTop = false;
    158176
    159177            if (value & SpecSetObject)
    160                 myOut.print("Setobject");
     178                strOut.print("SetObject");
    161179            else
    162180                isTop = false;
    163181
    164182            if (value & SpecProxyObject)
    165                 myOut.print("Proxyobject");
     183                strOut.print("ProxyObject");
    166184            else
    167185                isTop = false;
    168186
    169187            if (value & SpecDerivedArray)
    170                 myOut.print("Derivedarray");
     188                strOut.print("DerivedArray");
    171189            else
    172190                isTop = false;
     
    174192
    175193        if ((value & SpecString) == SpecString)
    176             myOut.print("String");
     194            strOut.print("String");
    177195        else {
    178196            if (value & SpecStringIdent)
    179                 myOut.print("Stringident");
     197                strOut.print("StringIdent");
    180198            else
    181199                isTop = false;
    182200           
    183201            if (value & SpecStringVar)
    184                 myOut.print("Stringvar");
     202                strOut.print("StringVar");
    185203            else
    186204                isTop = false;
     
    188206
    189207        if (value & SpecSymbol)
    190             myOut.print("Symbol");
     208            strOut.print("Symbol");
    191209        else
    192210            isTop = false;
     
    194212   
    195213    if (value == SpecInt32Only)
    196         myOut.print("Int32");
     214        strOut.print("Int32");
    197215    else {
    198216        if (value & SpecBoolInt32)
    199             myOut.print("Boolint32");
     217            strOut.print("BoolInt32");
    200218        else
    201219            isTop = false;
    202220       
    203221        if (value & SpecNonBoolInt32)
    204             myOut.print("Nonboolint32");
     222            strOut.print("NonBoolInt32");
    205223        else
    206224            isTop = false;
     
    208226   
    209227    if (value & SpecInt52Only)
    210         myOut.print("Int52");
     228        strOut.print("Int52");
    211229       
    212230    if ((value & SpecBytecodeDouble) == SpecBytecodeDouble)
    213         myOut.print("Bytecodedouble");
     231        strOut.print("BytecodeDouble");
    214232    else {
    215233        if (value & SpecAnyIntAsDouble)
    216             myOut.print("AnyIntAsDouble");
     234            strOut.print("AnyIntAsDouble");
    217235        else
    218236            isTop = false;
    219237       
    220238        if (value & SpecNonIntAsDouble)
    221             myOut.print("Nonintasdouble");
     239            strOut.print("NonIntAsdouble");
    222240        else
    223241            isTop = false;
    224242       
    225243        if (value & SpecDoublePureNaN)
    226             myOut.print("Doublepurenan");
     244            strOut.print("DoublePureNan");
    227245        else
    228246            isTop = false;
     
    230248   
    231249    if (value & SpecDoubleImpureNaN)
    232         out.print("Doubleimpurenan");
     250        out.print("DoubleImpureNan");
    233251   
    234252    if (value & SpecBoolean)
    235         myOut.print("Bool");
     253        strOut.print("Bool");
    236254    else
    237255        isTop = false;
    238256   
    239257    if (value & SpecOther)
    240         myOut.print("Other");
     258        strOut.print("Other");
    241259    else
    242260        isTop = false;
     
    245263        out.print("Top");
    246264    else
    247         out.print(myOut.toCString());
     265        out.print(strStream.toCString());
    248266   
    249267    if (value & SpecEmpty)
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h

    r208320 r215747  
    11/*
    2  * Copyright (C) 2011-2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    7676static const SpeculatedType SpecNonIntAsDouble     = 1ull << 29; // It's definitely not an Int52 but it's a real number and it's a double.
    7777static const SpeculatedType SpecDoubleReal         = SpecNonIntAsDouble | SpecAnyIntAsDouble; // It's definitely a non-NaN double.
    78 static const SpeculatedType SpecDoublePureNaN      = 1ull << 30; // It's definitely a NaN that is sae to tag (i.e. pure).
     78static const SpeculatedType SpecDoublePureNaN      = 1ull << 30; // It's definitely a NaN that is safe to tag (i.e. pure).
    7979static const SpeculatedType SpecDoubleImpureNaN    = 1ull << 31; // It's definitely a NaN that is unsafe to tag (i.e. impure).
    8080static const SpeculatedType SpecDoubleNaN          = SpecDoublePureNaN | SpecDoubleImpureNaN; // It's definitely some kind of NaN.
Note: See TracChangeset for help on using the changeset viewer.