⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136096 in webkit


Ignore:
Timestamp:
Nov 28, 2012, 10:01:40 PM (14 years ago)
Author:
fpizlo@apple.com
Message:

SpeculatedType dumping should not use the static char buffer[thingy] idiom
​https://bugs.webkit.org/show_bug.cgi?id=103584

Reviewed by Michael Saboff.

Source/JavaScriptCore:

Changed SpeculatedType to be "dumpable" by saying things like:

dataLog("thingy = ", SpeculationDump(thingy))

Removed the old stringification functions, and changed all code that referred to them
to use the new dataLog()/print() style.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Target.pri:
  • bytecode/SpeculatedType.cpp:

(JSC::dumpSpeculation):
(JSC::speculationToAbbreviatedString):
(JSC::dumpSpeculationAbbreviated):

  • bytecode/SpeculatedType.h:
  • bytecode/ValueProfile.h:

(JSC::ValueProfileBase::dump):

  • bytecode/VirtualRegister.h:

(WTF::printInternal):

  • dfg/DFGAbstractValue.h:

(JSC::DFG::AbstractValue::dump):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::injectLazyOperandSpeculation):
(JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::dump):
(JSC::DFG::Graph::predictArgumentTypes):

  • dfg/DFGGraph.h:

(Graph):

  • dfg/DFGStructureAbstractValue.h:
  • dfg/DFGVariableAccessDataDump.cpp: Added.

(JSC::DFG::VariableAccessDataDump::VariableAccessDataDump):
(JSC::DFG::VariableAccessDataDump::dump):

  • dfg/DFGVariableAccessDataDump.h: Added.

(VariableAccessDataDump):

Source/WTF:

Added a StringPrintStream, and made it easy to create dumpers for typedefs to primitives.

  • GNUmakefile.list.am:
  • WTF.gypi:
  • WTF.pro:
  • WTF.vcproj/WTF.vcproj:
  • WTF.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/PrintStream.cpp:

(WTF::dumpCharacter):

  • wtf/PrintStream.h:

(WTF::printInternal):

  • wtf/StringPrintStream.cpp: Added.

(WTF::StringPrintStream::StringPrintStream):
(WTF::StringPrintStream::~StringPrintStream):
(WTF::StringPrintStream::vprintf):
(WTF::StringPrintStream::toCString):
(WTF::StringPrintStream::increaseSize):

  • wtf/StringPrintStream.h: Added.

(StringPrintStream):
(WTF::toCString):

Location:
trunk/Source
Files:
4 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r135466 r136096  
    101101    dfg/DFGThunks.cpp
    102102    dfg/DFGValueSource.cpp
     103    dfg/DFGVariableAccessDataDump.cpp
    103104    dfg/DFGVariableEvent.cpp
    104105    dfg/DFGVariableEventStream.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r136086 r136096  
     12012-11-28  Filip Pizlo  <fpizlo@apple.com>
     2
     3        SpeculatedType dumping should not use the static char buffer[thingy] idiom
     4        https://bugs.webkit.org/show_bug.cgi?id=103584
     5
     6        Reviewed by Michael Saboff.
     7
     8        Changed SpeculatedType to be "dumpable" by saying things like:
     9       
     10        dataLog("thingy = ", SpeculationDump(thingy))
     11       
     12        Removed the old stringification functions, and changed all code that referred to them
     13        to use the new dataLog()/print() style.
     14
     15        * CMakeLists.txt:
     16        * GNUmakefile.list.am:
     17        * JavaScriptCore.xcodeproj/project.pbxproj:
     18        * Target.pri:
     19        * bytecode/SpeculatedType.cpp:
     20        (JSC::dumpSpeculation):
     21        (JSC::speculationToAbbreviatedString):
     22        (JSC::dumpSpeculationAbbreviated):
     23        * bytecode/SpeculatedType.h:
     24        * bytecode/ValueProfile.h:
     25        (JSC::ValueProfileBase::dump):
     26        * bytecode/VirtualRegister.h:
     27        (WTF::printInternal):
     28        * dfg/DFGAbstractValue.h:
     29        (JSC::DFG::AbstractValue::dump):
     30        * dfg/DFGByteCodeParser.cpp:
     31        (JSC::DFG::ByteCodeParser::injectLazyOperandSpeculation):
     32        (JSC::DFG::ByteCodeParser::getPredictionWithoutOSRExit):
     33        * dfg/DFGGraph.cpp:
     34        (JSC::DFG::Graph::dump):
     35        (JSC::DFG::Graph::predictArgumentTypes):
     36        * dfg/DFGGraph.h:
     37        (Graph):
     38        * dfg/DFGStructureAbstractValue.h:
     39        * dfg/DFGVariableAccessDataDump.cpp: Added.
     40        (JSC::DFG::VariableAccessDataDump::VariableAccessDataDump):
     41        (JSC::DFG::VariableAccessDataDump::dump):
     42        * dfg/DFGVariableAccessDataDump.h: Added.
     43        (VariableAccessDataDump):
     44
    1452012-11-28  Michael Saboff  <msaboff@apple.com>
    246
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r135466 r136096  
    251251        Source/JavaScriptCore/dfg/DFGValidate.h \
    252252        Source/JavaScriptCore/dfg/DFGVariableAccessData.h \
     253        Source/JavaScriptCore/dfg/DFGVariableAccessDataDump.cpp \
     254        Source/JavaScriptCore/dfg/DFGVariableAccessDataDump.h \
    253255        Source/JavaScriptCore/dfg/DFGVirtualRegisterAllocationPhase.cpp \
    254256        Source/JavaScriptCore/dfg/DFGVirtualRegisterAllocationPhase.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r136077 r136096  
    238238                0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */; settings = {ATTRIBUTES = (Private, ); }; };
    239239                0FD82E86141F3FF100179C94 /* SpeculatedType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FD82E84141F3FDA00179C94 /* SpeculatedType.cpp */; };
     240                0FDDBFB51666EED800C55FEF /* DFGVariableAccessDataDump.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDDBFB21666EED500C55FEF /* DFGVariableAccessDataDump.cpp */; };
     241                0FDDBFB61666EEDA00C55FEF /* DFGVariableAccessDataDump.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDDBFB31666EED500C55FEF /* DFGVariableAccessDataDump.h */; settings = {ATTRIBUTES = (Private, ); }; };
    240242                0FE228ED1436AB2700196C48 /* Options.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE228EB1436AB2300196C48 /* Options.h */; settings = {ATTRIBUTES = (Private, ); }; };
    241243                0FE228EE1436AB2C00196C48 /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE228EA1436AB2300196C48 /* Options.cpp */; };
    … …  
    10371039                0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSREntry.h; path = dfg/DFGOSREntry.h; sourceTree = "<group>"; };
    10381040                0FD82E84141F3FDA00179C94 /* SpeculatedType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpeculatedType.cpp; sourceTree = "<group>"; };
     1041                0FDDBFB21666EED500C55FEF /* DFGVariableAccessDataDump.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGVariableAccessDataDump.cpp; path = dfg/DFGVariableAccessDataDump.cpp; sourceTree = "<group>"; };
     1042                0FDDBFB31666EED500C55FEF /* DFGVariableAccessDataDump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGVariableAccessDataDump.h; path = dfg/DFGVariableAccessDataDump.h; sourceTree = "<group>"; };
    10391043                0FE228EA1436AB2300196C48 /* Options.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Options.cpp; sourceTree = "<group>"; };
    10401044                0FE228EB1436AB2300196C48 /* Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Options.h; sourceTree = "<group>"; };
    … …  
    24712475                                0F2BDC401522801700CD8910 /* DFGValueSource.h */,
    24722476                                0F620172143FCD2F0068B77C /* DFGVariableAccessData.h */,
     2477                                0FDDBFB21666EED500C55FEF /* DFGVariableAccessDataDump.cpp */,
     2478                                0FDDBFB31666EED500C55FEF /* DFGVariableAccessDataDump.h */,
    24732479                                0F2BDC5015228FFA00CD8910 /* DFGVariableEvent.cpp */,
    24742480                                0F2BDC411522801700CD8910 /* DFGVariableEvent.h */,
    … …  
    30483054                                0FAF7EFE165BA91F000C8455 /* JITDisassembler.h in Headers */,
    30493055                                0F73D7AF165A143000ACAB71 /* ClosureCallStubRoutine.h in Headers */,
     3056                                0FDDBFB61666EEDA00C55FEF /* DFGVariableAccessDataDump.h in Headers */,
    30503057                        );
    30513058                        runOnlyForDeploymentPostprocessing = 0;
    … …  
    36303637                                0F73D7AE165A142D00ACAB71 /* ClosureCallStubRoutine.cpp in Sources */,
    36313638                                0F9D3370165DBB90005AD387 /* Disassembler.cpp in Sources */,
     3639                                0FDDBFB51666EED800C55FEF /* DFGVariableAccessDataDump.cpp in Sources */,
    36323640                        );
    36333641                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/Target.pri

    r135466 r136096  
    137137    dfg/DFGThunks.cpp \
    138138    dfg/DFGValueSource.cpp \
     139    dfg/DFGVariableAccessDataDump.cpp \
    139140    dfg/DFGVariableEvent.cpp \
    140141    dfg/DFGVariableEventStream.cpp \
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.cpp

    r124476 r136096  
    3535#include "ValueProfile.h"
    3636#include <wtf/BoundsCheckedPointer.h>
     37#include <wtf/StringPrintStream.h>
    3738
    3839namespace JSC {
    3940
    40 const char* speculationToString(SpeculatedType value)
    41 {
    42     if (value == SpecNone)
    43         return "None";
    44    
    45     static const int size = 256;
    46     static char description[size];
    47     BoundsCheckedPointer<char> ptr(description, size);
     41void dumpSpeculation(PrintStream& out, SpeculatedType value)
     42{
     43    if (value == SpecNone) {
     44        out.print("None");
     45        return;
     46    }
     47   
     48    StringPrintStream myOut;
    4849   
    4950    bool isTop = true;
    5051   
    5152    if (value & SpecCellOther)
    52         ptr.strcat("Othercell");
     53        myOut.print("Othercell");
    5354    else
    5455        isTop = false;
    5556   
    5657    if (value & SpecObjectOther)
    57         ptr.strcat("Otherobj");
     58        myOut.print("Otherobj");
    5859    else
    5960        isTop = false;
    6061   
    6162    if (value & SpecFinalObject)
    62         ptr.strcat("Final");
     63        myOut.print("Final");
    6364    else
    6465        isTop = false;
    6566
    6667    if (value & SpecArray)
    67         ptr.strcat("Array");
     68        myOut.print("Array");
    6869    else
    6970        isTop = false;
    7071   
    7172    if (value & SpecInt8Array)
    72         ptr.strcat("Int8array");
     73        myOut.print("Int8array");
    7374    else
    7475        isTop = false;
    7576   
    7677    if (value & SpecInt16Array)
    77         ptr.strcat("Int16array");
     78        myOut.print("Int16array");
    7879    else
    7980        isTop = false;
    8081   
    8182    if (value & SpecInt32Array)
    82         ptr.strcat("Int32array");
     83        myOut.print("Int32array");
    8384    else
    8485        isTop = false;
    8586   
    8687    if (value & SpecUint8Array)
    87         ptr.strcat("Uint8array");
     88        myOut.print("Uint8array");
    8889    else
    8990        isTop = false;
    9091
    9192    if (value & SpecUint8ClampedArray)
    92         ptr.strcat("Uint8clampedarray");
     93        myOut.print("Uint8clampedarray");
    9394    else
    9495        isTop = false;
    9596   
    9697    if (value & SpecUint16Array)
    97         ptr.strcat("Uint16array");
     98        myOut.print("Uint16array");
    9899    else
    99100        isTop = false;
    100101   
    101102    if (value & SpecUint32Array)
    102         ptr.strcat("Uint32array");
     103        myOut.print("Uint32array");
    103104    else
    104105        isTop = false;
    105106   
    106107    if (value & SpecFloat32Array)
    107         ptr.strcat("Float32array");
     108        myOut.print("Float32array");
    108109    else
    109110        isTop = false;
    110111   
    111112    if (value & SpecFloat64Array)
    112         ptr.strcat("Float64array");
     113        myOut.print("Float64array");
    113114    else
    114115        isTop = false;
    115116   
    116117    if (value & SpecFunction)
    117         ptr.strcat("Function");
     118        myOut.print("Function");
    118119    else
    119120        isTop = false;
    120121   
    121122    if (value & SpecMyArguments)
    122         ptr.strcat("Myarguments");
     123        myOut.print("Myarguments");
    123124    else
    124125        isTop = false;
    125126   
    126127    if (value & SpecForeignArguments)
    127         ptr.strcat("Foreignarguments");
     128        myOut.print("Foreignarguments");
    128129    else
    129130        isTop = false;
    130131   
    131132    if (value & SpecString)
    132         ptr.strcat("String");
     133        myOut.print("String");
    133134    else
    134135        isTop = false;
    135136   
    136137    if (value & SpecInt32)
    137         ptr.strcat("Int");
     138        myOut.print("Int");
    138139    else
    139140        isTop = false;
    140141   
    141142    if (value & SpecDoubleReal)
    142         ptr.strcat("Doublereal");
     143        myOut.print("Doublereal");
    143144    else
    144145        isTop = false;
    145146   
    146147    if (value & SpecDoubleNaN)
    147         ptr.strcat("Doublenan");
     148        myOut.print("Doublenan");
    148149    else
    149150        isTop = false;
    150151   
    151152    if (value & SpecBoolean)
    152         ptr.strcat("Bool");
     153        myOut.print("Bool");
    153154    else
    154155        isTop = false;
    155156   
    156157    if (value & SpecOther)
    157         ptr.strcat("Other");
    158     else
    159         isTop = false;
    160    
    161     if (isTop) {
    162         ptr = description;
    163         ptr.strcat("Top");
    164     }
     158        myOut.print("Other");
     159    else
     160        isTop = false;
     161   
     162    if (isTop)
     163        out.print("Top");
     164    else
     165        out.print(myOut.toCString());
    165166   
    166167    if (value & SpecEmpty)
    167         ptr.strcat("Empty");
    168    
    169     *ptr++ = 0;
    170    
    171     return description;
    172 }
    173 
    174 const char* speculationToAbbreviatedString(SpeculatedType prediction)
     168        out.print("Empty");
     169}
     170
     171// We don't expose this because we don't want anyone relying on the fact that this method currently
     172// just returns string constants.
     173static const char* speculationToAbbreviatedString(SpeculatedType prediction)
    175174{
    176175    if (isFinalObjectSpeculation(prediction))
    … …  
    219218}
    220219
     220void dumpSpeculationAbbreviated(PrintStream& out, SpeculatedType value)
     221{
     222    out.print(speculationToAbbreviatedString(value));
     223}
     224
    221225SpeculatedType speculationFromClassInfo(const ClassInfo* classInfo)
    222226{
  • trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h

    r133956 r136096  
    290290}
    291291
    292 const char* speculationToString(SpeculatedType value);
    293 const char* speculationToAbbreviatedString(SpeculatedType value);
     292void dumpSpeculation(PrintStream&, SpeculatedType);
     293void dumpSpeculationAbbreviated(PrintStream&, SpeculatedType);
     294
     295MAKE_PRINT_ADAPTOR(SpeculationDump, SpeculatedType, dumpSpeculation);
     296MAKE_PRINT_ADAPTOR(AbbreviatedSpeculationDump, SpeculatedType, dumpSpeculationAbbreviated);
    294297
    295298// Merge two predictions. Note that currently this just does left | right. It may
  • trunk/Source/JavaScriptCore/bytecode/ValueProfile.h

    r135957 r136096  
    113113    void dump(PrintStream& out)
    114114    {
    115         out.printf(
    116             "samples = %u, prediction = %s",
    117             totalNumberOfSamples(),
    118             speculationToString(m_prediction));
     115        out.print("samples = ", totalNumberOfSamples(), " prediction = ", SpeculationDump(m_prediction));
    119116        out.printf(", value = ");
    120117        if (m_singletonValueIsTop)
  • trunk/Source/JavaScriptCore/bytecode/VirtualRegister.h

    r99144 r136096  
    2828
    2929#include <wtf/Platform.h>
     30#include <wtf/PrintStream.h>
    3031
    3132namespace JSC {
    … …  
    3839} // namespace JSC
    3940
     41namespace WTF {
     42
     43inline void printInternal(PrintStream& out, JSC::VirtualRegister value)
     44{
     45    out.print(static_cast<int>(value));
     46}
     47
     48} // namespace WTF
     49
    4050#endif // VirtualRegister_h
  • trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.h

    r136066 r136096  
    375375    {
    376376        out.print(
    377             "(", speculationToString(m_type), ", ", arrayModesToString(m_arrayModes), ", ",
     377            "(", SpeculationDump(m_type), ", ", arrayModesToString(m_arrayModes), ", ",
    378378            m_currentKnownStructure, ", ", m_futurePossibleStructure);
    379379        if (!!m_value)
    … …  
    533533} } // namespace JSC::DFG
    534534
    535 namespace WTF {
    536 
    537 inline void printInternal(PrintStream& out, const JSC::DFG::AbstractValue& value)
    538 {
    539     value.dump(out);
    540 }
    541 
    542 } // namespace WTF
    543 
    544535#endif // ENABLE(DFG_JIT)
    545536
  • trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp

    r135957 r136096  
    268268                LazyOperandValueProfileKey(m_currentIndex, node.local()));
    269269#if DFG_ENABLE(DEBUG_VERBOSE)
    270         dataLogF("Lazy operand [@%u, bc#%u, r%d] prediction: %s\n",
    271                 nodeIndex, m_currentIndex, node.local(), speculationToString(prediction));
     270        dataLog("Lazy operand [@", nodeIndex, ", bc#", m_currentIndex, ", r", node.local(), "] prediction: ", SpeculationDump(prediction), "\n");
    272271#endif
    273272        node.variableAccessData()->predict(prediction);
    … …  
    888887        SpeculatedType prediction = m_inlineStackTop->m_profiledBlock->valueProfilePredictionForBytecodeOffset(bytecodeIndex);
    889888#if DFG_ENABLE(DEBUG_VERBOSE)
    890         dataLogF("Dynamic [@%u, bc#%u] prediction: %s\n", nodeIndex, bytecodeIndex, speculationToString(prediction));
     889        dataLog("Dynamic [@", nodeIndex, ", bc#", bytecodeIndex, "] prediction: ", SpeculationDump(prediction), "\n");
    891890#endif
    892891       
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp

    r136069 r136096  
    2828
    2929#include "CodeBlock.h"
    30 #include <wtf/BoundsCheckedPointer.h>
     30#include "DFGVariableAccessDataDump.h"
    3131
    3232#if ENABLE(DFG_JIT)
    … …  
    5858}
    5959
    60 const char* Graph::nameOfVariableAccessData(VariableAccessData* variableAccessData)
    61 {
    62     // Variables are already numbered. For readability of IR dumps, this returns
    63     // an alphabetic name for the variable access data, so that you don't have to
    64     // reason about two numbers (variable number and live range number), but instead
    65     // a number and a letter.
    66    
    67     unsigned index = std::numeric_limits<unsigned>::max();
    68     for (unsigned i = 0; i < m_variableAccessData.size(); ++i) {
    69         if (&m_variableAccessData[i] == variableAccessData) {
    70             index = i;
    71             break;
    72         }
    73     }
    74    
    75     ASSERT(index != std::numeric_limits<unsigned>::max());
    76    
    77     if (!index)
    78         return "A";
    79 
    80     static char buf[100];
    81     BoundsCheckedPointer<char> ptr(buf, sizeof(buf));
    82    
    83     while (index) {
    84         *ptr++ = 'A' + (index % 26);
    85         index /= 26;
    86     }
    87    
    88     if (variableAccessData->isCaptured())
    89         *ptr++ = '*';
    90    
    91     ptr.strcat(speculationToAbbreviatedString(variableAccessData->prediction()));
    92    
    93     *ptr++ = 0;
    94    
    95     return buf;
    96 }
    97 
    9860static void printWhiteSpace(PrintStream& out, unsigned amount)
    9961{
    … …  
    153115        useKindToString(edge.useKind()),
    154116        "@", edge.index(),
    155         speculationToAbbreviatedString(
    156             at(edge).prediction()));
     117        AbbreviatedSpeculationDump(at(edge).prediction()));
    157118}
    158119
    … …  
    265226        StorageAccessData& storageAccessData = m_storageAccessData[node.storageAccessDataIndex()];
    266227        out.print(hasPrinted ? ", " : "", "id", storageAccessData.identifierNumber, "{", m_codeBlock->identifier(storageAccessData.identifierNumber).string(), "}");
    267         out.print(", ", storageAccessData.offset);
     228        out.print(", ", static_cast<ptrdiff_t>(storageAccessData.offset));
    268229        hasPrinted = true;
    269230    }
    … …  
    273234        int operand = variableAccessData->operand();
    274235        if (operandIsArgument(operand))
    275             out.print(hasPrinted ? ", " : "", "arg", operandToArgument(operand), "(", nameOfVariableAccessData(variableAccessData), ")");
     236            out.print(hasPrinted ? ", " : "", "arg", operandToArgument(operand), "(", VariableAccessDataDump(*this, variableAccessData), ")");
    276237        else
    277             out.print(hasPrinted ? ", " : "", "r", operand, "(", nameOfVariableAccessData(variableAccessData), ")");
     238            out.print(hasPrinted ? ", " : "", "r", operand, "(", VariableAccessDataDump(*this, variableAccessData), ")");
    278239        hasPrinted = true;
    279240    }
    … …  
    322283    if (!skipped) {
    323284        if (node.hasVariableAccessData())
    324             out.print("  predicting ", speculationToString(node.variableAccessData()->prediction()), node.variableAccessData()->shouldUseDoubleFormat() ? ", forcing double" : "");
     285            out.print("  predicting ", SpeculationDump(node.variableAccessData()->prediction()), node.variableAccessData()->shouldUseDoubleFormat() ? ", forcing double" : "");
    325286        else if (node.hasHeapPrediction())
    326             out.print("  predicting ", speculationToString(node.getHeapPrediction()));
     287            out.print("  predicting ", SpeculationDump(node.getHeapPrediction()));
    327288    }
    328289   
    … …  
    460421       
    461422#if DFG_ENABLE(DEBUG_VERBOSE)
    462         dataLogF("Argument [%zu] prediction: %s\n", arg, speculationToString(at(m_arguments[arg]).variableAccessData()->prediction()));
     423        dataLog(
     424            "Argument [", arg, "] prediction: ",
     425            SpeculationDump(at(m_arguments[arg]).variableAccessData()->prediction()), "\n");
    463426#endif
    464427    }
  • trunk/Source/JavaScriptCore/dfg/DFGGraph.h

    r136069 r136096  
    328328    static const char *opName(NodeType);
    329329   
    330     // This is O(n), and should only be used for verbose dumps.
    331     const char* nameOfVariableAccessData(VariableAccessData*);
    332 
    333330    void predictArgumentTypes();
    334331   
  • trunk/Source/JavaScriptCore/dfg/DFGStructureAbstractValue.h

    r136066 r136096  
    321321} } // namespace JSC::DFG
    322322
    323 namespace WTF {
    324 
    325 inline void printInternal(PrintStream& out, const JSC::DFG::StructureAbstractValue& value)
    326 {
    327     value.dump(out);
    328 }
    329 
    330 } // namespace WTF
    331 
    332323#endif // ENABLE(DFG_JIT)
    333324
  • trunk/Source/WTF/ChangeLog

    r136082 r136096  
     12012-11-28  Filip Pizlo  <fpizlo@apple.com>
     2
     3        SpeculatedType dumping should not use the static char buffer[thingy] idiom
     4        https://bugs.webkit.org/show_bug.cgi?id=103584
     5
     6        Reviewed by Michael Saboff.
     7
     8        Added a StringPrintStream, and made it easy to create dumpers for typedefs to primitives.
     9
     10        * GNUmakefile.list.am:
     11        * WTF.gypi:
     12        * WTF.pro:
     13        * WTF.vcproj/WTF.vcproj:
     14        * WTF.xcodeproj/project.pbxproj:
     15        * wtf/CMakeLists.txt:
     16        * wtf/PrintStream.cpp:
     17        (WTF::dumpCharacter):
     18        * wtf/PrintStream.h:
     19        (WTF::printInternal):
     20        * wtf/StringPrintStream.cpp: Added.
     21        (WTF::StringPrintStream::StringPrintStream):
     22        (WTF::StringPrintStream::~StringPrintStream):
     23        (WTF::StringPrintStream::vprintf):
     24        (WTF::StringPrintStream::toCString):
     25        (WTF::StringPrintStream::increaseSize):
     26        * wtf/StringPrintStream.h: Added.
     27        (StringPrintStream):
     28        (WTF::toCString):
     29
    1302012-11-28  Michael Saboff  <msaboff@apple.com>
    231
  • trunk/Source/WTF/GNUmakefile.list.am

    r136066 r136096  
    160160    Source/WTF/wtf/StreamBuffer.h \
    161161    Source/WTF/wtf/StringExtras.h \
     162    Source/WTF/wtf/StringPrintStream.cpp \
     163    Source/WTF/wtf/StringPrintStream.h \
    162164    Source/WTF/wtf/StringHasher.h \
    163165    Source/WTF/wtf/TCPackedCache.h \
  • trunk/Source/WTF/WTF.gypi

    r136066 r136096  
    100100            'wtf/StringExtras.h',
    101101            'wtf/StringHasher.h',
     102            'wtf/StringPrintStream.h',
    102103            'wtf/TemporaryChange.h',
    103104            'wtf/ThreadRestrictionVerifier.h',
    … …  
    201202            'wtf/StackBounds.cpp',
    202203            'wtf/StringExtras.cpp',
     204            'wtf/StringPrintStream.cpp',
    203205            'wtf/TCPackedCache.h',
    204206            'wtf/TCPageMap.h',
  • trunk/Source/WTF/WTF.pro

    r136066 r136096  
    147147    StringExtras.h \
    148148    StringHasher.h \
     149    StringPrintStream.h \
    149150    TCPackedCache.h \
    150151    TCSpinLock.h \
    … …  
    236237    SHA1.cpp \
    237238    StackBounds.cpp \
     239    StringPrintStream.cpp \
    238240    TCSystemAlloc.cpp \
    239241    Threading.cpp \
  • trunk/Source/WTF/WTF.vcproj/WTF.vcproj

    r136066 r136096  
    12141214                </File>
    12151215                <File
     1216                        RelativePath="..\wtf\StringPrintStream.cpp"
     1217                        >
     1218                </File>
     1219                <File
     1220                        RelativePath="..\wtf\StringPrintStream.h"
     1221                        >
     1222                </File>
     1223                <File
    12161224                        RelativePath="..\wtf\TCPackedCache.h"
    12171225                        >
  • trunk/Source/WTF/WTF.xcodeproj/project.pbxproj

    r136066 r136096  
    2828                0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335E165DBA73005AD387 /* PrintStream.h */; };
    2929                0FD81AC5154FB22E00983E72 /* FastBitVector.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD81AC4154FB22E00983E72 /* FastBitVector.h */; settings = {ATTRIBUTES = (); }; };
     30                0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */; };
     31                0FDDBFA81666DFA300C55FEF /* StringPrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */; };
    3032                143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; };
    3133                143F61201565F0F900DB514A /* RAMSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 143F611E1565F0F900DB514A /* RAMSize.h */; settings = {ATTRIBUTES = (); }; };
    … …  
    326328                0F9D335E165DBA73005AD387 /* PrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintStream.h; sourceTree = "<group>"; };
    327329                0FD81AC4154FB22E00983E72 /* FastBitVector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastBitVector.h; sourceTree = "<group>"; };
     330                0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringPrintStream.cpp; sourceTree = "<group>"; };
     331                0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringPrintStream.h; sourceTree = "<group>"; };
    328332                143F611D1565F0F900DB514A /* RAMSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RAMSize.cpp; sourceTree = "<group>"; };
    329333                143F611E1565F0F900DB514A /* RAMSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAMSize.h; sourceTree = "<group>"; };
    … …  
    838842                                A8A47313151A825B004123FF /* StringExtras.h */,
    839843                                A8A47314151A825B004123FF /* StringHasher.h */,
     844                                0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */,
     845                                0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */,
    840846                                A8A47315151A825B004123FF /* TCPackedCache.h */,
    841847                                A8A47316151A825B004123FF /* TCPageMap.h */,
    … …  
    12421248                                0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */,
    12431249                                0F87105A16643F190090B0AD /* RawPointer.h in Headers */,
     1250                                0FDDBFA81666DFA300C55FEF /* StringPrintStream.h in Headers */,
    12441251                        );
    12451252                        runOnlyForDeploymentPostprocessing = 0;
    … …  
    14121419                                0F9D3360165DBA73005AD387 /* FilePrintStream.cpp in Sources */,
    14131420                                0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */,
     1421                                0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */,
    14141422                        );
    14151423                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WTF/wtf/CMakeLists.txt

    r136066 r136096  
    106106    StringExtras.h
    107107    StringHasher.h
     108    StringPrintStream.h
    108109    TCPackedCache.h
    109110    TCPageMap.h
    … …  
    185186    StackBounds.cpp
    186187    StringExtras.cpp
     188    StringPrintStream.cpp
    187189    Threading.cpp
    188190    TypeTraits.cpp
  • trunk/Source/WTF/wtf/PrintStream.cpp

    r136066 r136096  
    116116}
    117117
     118void dumpCharacter(PrintStream& out, char value)
     119{
     120    out.printf("%c", value);
     121}
     122
    118123} // namespace WTF
    119124
  • trunk/Source/WTF/wtf/PrintStream.h

    r136066 r136096  
    161161void printInternal(PrintStream&, const CString&);
    162162void printInternal(PrintStream&, const String&);
     163inline void printInternal(PrintStream& out, char* value) { printInternal(out, static_cast<const char*>(value)); }
     164inline void printInternal(PrintStream& out, CString& value) { printInternal(out, static_cast<const CString&>(value)); }
     165inline void printInternal(PrintStream& out, String& value) { printInternal(out, static_cast<const String&>(value)); }
    163166void printInternal(PrintStream&, bool);
    164167void printInternal(PrintStream&, int);
    … …  
    172175void printInternal(PrintStream&, RawPointer);
    173176
     177template<typename T>
     178void printInternal(PrintStream& out, const T& value)
     179{
     180    value.dump(out);
     181}
     182
     183#define MAKE_PRINT_ADAPTOR(Name, Type, function) \
     184    class Name {                                 \
     185    public:                                      \
     186        Name(const Type& value)                  \
     187            : m_value(value)                     \
     188        {                                        \
     189        }                                        \
     190        void dump(PrintStream& out) const        \
     191        {                                        \
     192            function(out, m_value);              \
     193        }                                        \
     194    private:                                     \
     195        Type m_value;                            \
     196    }
     197
     198#define MAKE_PRINT_METHOD_ADAPTOR(Name, Type, method) \
     199    class Name {                                 \
     200    public:                                      \
     201        Name(const Type& value)                  \
     202            : m_value(value)                     \
     203        {                                        \
     204        }                                        \
     205        void dump(PrintStream& out) const        \
     206        {                                        \
     207            m_value.method(out);                 \
     208        }                                        \
     209    private:                                     \
     210        Type m_value;                            \
     211    }
     212
     213// Use an adaptor-based dumper for characters to avoid situations where
     214// you've "compressed" an integer to a character and it ends up printing
     215// as ASCII when you wanted it to print as a number.
     216void dumpCharacter(PrintStream&, char);
     217MAKE_PRINT_ADAPTOR(CharacterDump, char, dumpCharacter);
     218
    174219} // namespace WTF
    175220
     221using WTF::CharacterDump;
    176222using WTF::PrintStream;
    177223
Note: See TracChangeset for help on using the changeset viewer.