Changeset 136096 in webkit
- Timestamp:
- Nov 28, 2012, 10:01:40 PM (14 years ago)
- Location:
- trunk/Source
- Files:
-
- 4 added
- 23 edited
-
JavaScriptCore/CMakeLists.txt (modified) (1 diff)
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/GNUmakefile.list.am (modified) (1 diff)
-
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (modified) (5 diffs)
-
JavaScriptCore/Target.pri (modified) (1 diff)
-
JavaScriptCore/bytecode/SpeculatedType.cpp (modified) (2 diffs)
-
JavaScriptCore/bytecode/SpeculatedType.h (modified) (1 diff)
-
JavaScriptCore/bytecode/ValueProfile.h (modified) (1 diff)
-
JavaScriptCore/bytecode/VirtualRegister.h (modified) (2 diffs)
-
JavaScriptCore/dfg/DFGAbstractValue.h (modified) (2 diffs)
-
JavaScriptCore/dfg/DFGByteCodeParser.cpp (modified) (2 diffs)
-
JavaScriptCore/dfg/DFGGraph.cpp (modified) (7 diffs)
-
JavaScriptCore/dfg/DFGGraph.h (modified) (1 diff)
-
JavaScriptCore/dfg/DFGStructureAbstractValue.h (modified) (1 diff)
-
JavaScriptCore/dfg/DFGVariableAccessDataDump.cpp (added)
-
JavaScriptCore/dfg/DFGVariableAccessDataDump.h (added)
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/GNUmakefile.list.am (modified) (1 diff)
-
WTF/WTF.gypi (modified) (2 diffs)
-
WTF/WTF.pro (modified) (2 diffs)
-
WTF/WTF.vcproj/WTF.vcproj (modified) (1 diff)
-
WTF/WTF.xcodeproj/project.pbxproj (modified) (5 diffs)
-
WTF/wtf/CMakeLists.txt (modified) (2 diffs)
-
WTF/wtf/PrintStream.cpp (modified) (1 diff)
-
WTF/wtf/PrintStream.h (modified) (2 diffs)
-
WTF/wtf/StringPrintStream.cpp (added)
-
WTF/wtf/StringPrintStream.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/CMakeLists.txt
r135466 r136096 101 101 dfg/DFGThunks.cpp 102 102 dfg/DFGValueSource.cpp 103 dfg/DFGVariableAccessDataDump.cpp 103 104 dfg/DFGVariableEvent.cpp 104 105 dfg/DFGVariableEventStream.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r136086 r136096 1 2012-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 1 45 2012-11-28 Michael Saboff <msaboff@apple.com> 2 46 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r135466 r136096 251 251 Source/JavaScriptCore/dfg/DFGValidate.h \ 252 252 Source/JavaScriptCore/dfg/DFGVariableAccessData.h \ 253 Source/JavaScriptCore/dfg/DFGVariableAccessDataDump.cpp \ 254 Source/JavaScriptCore/dfg/DFGVariableAccessDataDump.h \ 253 255 Source/JavaScriptCore/dfg/DFGVirtualRegisterAllocationPhase.cpp \ 254 256 Source/JavaScriptCore/dfg/DFGVirtualRegisterAllocationPhase.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r136077 r136096 238 238 0FD82E57141DAF1000179C94 /* DFGOSREntry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */; settings = {ATTRIBUTES = (Private, ); }; }; 239 239 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, ); }; }; 240 242 0FE228ED1436AB2700196C48 /* Options.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FE228EB1436AB2300196C48 /* Options.h */; settings = {ATTRIBUTES = (Private, ); }; }; 241 243 0FE228EE1436AB2C00196C48 /* Options.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FE228EA1436AB2300196C48 /* Options.cpp */; }; … … 1037 1039 0FD82E53141DAEDE00179C94 /* DFGOSREntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGOSREntry.h; path = dfg/DFGOSREntry.h; sourceTree = "<group>"; }; 1038 1040 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>"; }; 1039 1043 0FE228EA1436AB2300196C48 /* Options.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Options.cpp; sourceTree = "<group>"; }; 1040 1044 0FE228EB1436AB2300196C48 /* Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Options.h; sourceTree = "<group>"; }; … … 2471 2475 0F2BDC401522801700CD8910 /* DFGValueSource.h */, 2472 2476 0F620172143FCD2F0068B77C /* DFGVariableAccessData.h */, 2477 0FDDBFB21666EED500C55FEF /* DFGVariableAccessDataDump.cpp */, 2478 0FDDBFB31666EED500C55FEF /* DFGVariableAccessDataDump.h */, 2473 2479 0F2BDC5015228FFA00CD8910 /* DFGVariableEvent.cpp */, 2474 2480 0F2BDC411522801700CD8910 /* DFGVariableEvent.h */, … … 3048 3054 0FAF7EFE165BA91F000C8455 /* JITDisassembler.h in Headers */, 3049 3055 0F73D7AF165A143000ACAB71 /* ClosureCallStubRoutine.h in Headers */, 3056 0FDDBFB61666EEDA00C55FEF /* DFGVariableAccessDataDump.h in Headers */, 3050 3057 ); 3051 3058 runOnlyForDeploymentPostprocessing = 0; … … 3630 3637 0F73D7AE165A142D00ACAB71 /* ClosureCallStubRoutine.cpp in Sources */, 3631 3638 0F9D3370165DBB90005AD387 /* Disassembler.cpp in Sources */, 3639 0FDDBFB51666EED800C55FEF /* DFGVariableAccessDataDump.cpp in Sources */, 3632 3640 ); 3633 3641 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/JavaScriptCore/Target.pri
r135466 r136096 137 137 dfg/DFGThunks.cpp \ 138 138 dfg/DFGValueSource.cpp \ 139 dfg/DFGVariableAccessDataDump.cpp \ 139 140 dfg/DFGVariableEvent.cpp \ 140 141 dfg/DFGVariableEventStream.cpp \ -
trunk/Source/JavaScriptCore/bytecode/SpeculatedType.cpp
r124476 r136096 35 35 #include "ValueProfile.h" 36 36 #include <wtf/BoundsCheckedPointer.h> 37 #include <wtf/StringPrintStream.h> 37 38 38 39 namespace JSC { 39 40 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);41 void dumpSpeculation(PrintStream& out, SpeculatedType value) 42 { 43 if (value == SpecNone) { 44 out.print("None"); 45 return; 46 } 47 48 StringPrintStream myOut; 48 49 49 50 bool isTop = true; 50 51 51 52 if (value & SpecCellOther) 52 ptr.strcat("Othercell");53 myOut.print("Othercell"); 53 54 else 54 55 isTop = false; 55 56 56 57 if (value & SpecObjectOther) 57 ptr.strcat("Otherobj");58 myOut.print("Otherobj"); 58 59 else 59 60 isTop = false; 60 61 61 62 if (value & SpecFinalObject) 62 ptr.strcat("Final");63 myOut.print("Final"); 63 64 else 64 65 isTop = false; 65 66 66 67 if (value & SpecArray) 67 ptr.strcat("Array");68 myOut.print("Array"); 68 69 else 69 70 isTop = false; 70 71 71 72 if (value & SpecInt8Array) 72 ptr.strcat("Int8array");73 myOut.print("Int8array"); 73 74 else 74 75 isTop = false; 75 76 76 77 if (value & SpecInt16Array) 77 ptr.strcat("Int16array");78 myOut.print("Int16array"); 78 79 else 79 80 isTop = false; 80 81 81 82 if (value & SpecInt32Array) 82 ptr.strcat("Int32array");83 myOut.print("Int32array"); 83 84 else 84 85 isTop = false; 85 86 86 87 if (value & SpecUint8Array) 87 ptr.strcat("Uint8array");88 myOut.print("Uint8array"); 88 89 else 89 90 isTop = false; 90 91 91 92 if (value & SpecUint8ClampedArray) 92 ptr.strcat("Uint8clampedarray");93 myOut.print("Uint8clampedarray"); 93 94 else 94 95 isTop = false; 95 96 96 97 if (value & SpecUint16Array) 97 ptr.strcat("Uint16array");98 myOut.print("Uint16array"); 98 99 else 99 100 isTop = false; 100 101 101 102 if (value & SpecUint32Array) 102 ptr.strcat("Uint32array");103 myOut.print("Uint32array"); 103 104 else 104 105 isTop = false; 105 106 106 107 if (value & SpecFloat32Array) 107 ptr.strcat("Float32array");108 myOut.print("Float32array"); 108 109 else 109 110 isTop = false; 110 111 111 112 if (value & SpecFloat64Array) 112 ptr.strcat("Float64array");113 myOut.print("Float64array"); 113 114 else 114 115 isTop = false; 115 116 116 117 if (value & SpecFunction) 117 ptr.strcat("Function");118 myOut.print("Function"); 118 119 else 119 120 isTop = false; 120 121 121 122 if (value & SpecMyArguments) 122 ptr.strcat("Myarguments");123 myOut.print("Myarguments"); 123 124 else 124 125 isTop = false; 125 126 126 127 if (value & SpecForeignArguments) 127 ptr.strcat("Foreignarguments");128 myOut.print("Foreignarguments"); 128 129 else 129 130 isTop = false; 130 131 131 132 if (value & SpecString) 132 ptr.strcat("String");133 myOut.print("String"); 133 134 else 134 135 isTop = false; 135 136 136 137 if (value & SpecInt32) 137 ptr.strcat("Int");138 myOut.print("Int"); 138 139 else 139 140 isTop = false; 140 141 141 142 if (value & SpecDoubleReal) 142 ptr.strcat("Doublereal");143 myOut.print("Doublereal"); 143 144 else 144 145 isTop = false; 145 146 146 147 if (value & SpecDoubleNaN) 147 ptr.strcat("Doublenan");148 myOut.print("Doublenan"); 148 149 else 149 150 isTop = false; 150 151 151 152 if (value & SpecBoolean) 152 ptr.strcat("Bool");153 myOut.print("Bool"); 153 154 else 154 155 isTop = false; 155 156 156 157 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()); 165 166 166 167 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. 173 static const char* speculationToAbbreviatedString(SpeculatedType prediction) 175 174 { 176 175 if (isFinalObjectSpeculation(prediction)) … … 219 218 } 220 219 220 void dumpSpeculationAbbreviated(PrintStream& out, SpeculatedType value) 221 { 222 out.print(speculationToAbbreviatedString(value)); 223 } 224 221 225 SpeculatedType speculationFromClassInfo(const ClassInfo* classInfo) 222 226 { -
trunk/Source/JavaScriptCore/bytecode/SpeculatedType.h
r133956 r136096 290 290 } 291 291 292 const char* speculationToString(SpeculatedType value); 293 const char* speculationToAbbreviatedString(SpeculatedType value); 292 void dumpSpeculation(PrintStream&, SpeculatedType); 293 void dumpSpeculationAbbreviated(PrintStream&, SpeculatedType); 294 295 MAKE_PRINT_ADAPTOR(SpeculationDump, SpeculatedType, dumpSpeculation); 296 MAKE_PRINT_ADAPTOR(AbbreviatedSpeculationDump, SpeculatedType, dumpSpeculationAbbreviated); 294 297 295 298 // Merge two predictions. Note that currently this just does left | right. It may -
trunk/Source/JavaScriptCore/bytecode/ValueProfile.h
r135957 r136096 113 113 void dump(PrintStream& out) 114 114 { 115 out.printf( 116 "samples = %u, prediction = %s", 117 totalNumberOfSamples(), 118 speculationToString(m_prediction)); 115 out.print("samples = ", totalNumberOfSamples(), " prediction = ", SpeculationDump(m_prediction)); 119 116 out.printf(", value = "); 120 117 if (m_singletonValueIsTop) -
trunk/Source/JavaScriptCore/bytecode/VirtualRegister.h
r99144 r136096 28 28 29 29 #include <wtf/Platform.h> 30 #include <wtf/PrintStream.h> 30 31 31 32 namespace JSC { … … 38 39 } // namespace JSC 39 40 41 namespace WTF { 42 43 inline void printInternal(PrintStream& out, JSC::VirtualRegister value) 44 { 45 out.print(static_cast<int>(value)); 46 } 47 48 } // namespace WTF 49 40 50 #endif // VirtualRegister_h -
trunk/Source/JavaScriptCore/dfg/DFGAbstractValue.h
r136066 r136096 375 375 { 376 376 out.print( 377 "(", speculationToString(m_type), ", ", arrayModesToString(m_arrayModes), ", ",377 "(", SpeculationDump(m_type), ", ", arrayModesToString(m_arrayModes), ", ", 378 378 m_currentKnownStructure, ", ", m_futurePossibleStructure); 379 379 if (!!m_value) … … 533 533 } } // namespace JSC::DFG 534 534 535 namespace WTF {536 537 inline void printInternal(PrintStream& out, const JSC::DFG::AbstractValue& value)538 {539 value.dump(out);540 }541 542 } // namespace WTF543 544 535 #endif // ENABLE(DFG_JIT) 545 536 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r135957 r136096 268 268 LazyOperandValueProfileKey(m_currentIndex, node.local())); 269 269 #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"); 272 271 #endif 273 272 node.variableAccessData()->predict(prediction); … … 888 887 SpeculatedType prediction = m_inlineStackTop->m_profiledBlock->valueProfilePredictionForBytecodeOffset(bytecodeIndex); 889 888 #if DFG_ENABLE(DEBUG_VERBOSE) 890 dataLog F("Dynamic [@%u, bc#%u] prediction: %s\n", nodeIndex, bytecodeIndex, speculationToString(prediction));889 dataLog("Dynamic [@", nodeIndex, ", bc#", bytecodeIndex, "] prediction: ", SpeculationDump(prediction), "\n"); 891 890 #endif 892 891 -
trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp
r136069 r136096 28 28 29 29 #include "CodeBlock.h" 30 #include <wtf/BoundsCheckedPointer.h>30 #include "DFGVariableAccessDataDump.h" 31 31 32 32 #if ENABLE(DFG_JIT) … … 58 58 } 59 59 60 const char* Graph::nameOfVariableAccessData(VariableAccessData* variableAccessData)61 {62 // Variables are already numbered. For readability of IR dumps, this returns63 // an alphabetic name for the variable access data, so that you don't have to64 // reason about two numbers (variable number and live range number), but instead65 // 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 98 60 static void printWhiteSpace(PrintStream& out, unsigned amount) 99 61 { … … 153 115 useKindToString(edge.useKind()), 154 116 "@", edge.index(), 155 speculationToAbbreviatedString( 156 at(edge).prediction())); 117 AbbreviatedSpeculationDump(at(edge).prediction())); 157 118 } 158 119 … … 265 226 StorageAccessData& storageAccessData = m_storageAccessData[node.storageAccessDataIndex()]; 266 227 out.print(hasPrinted ? ", " : "", "id", storageAccessData.identifierNumber, "{", m_codeBlock->identifier(storageAccessData.identifierNumber).string(), "}"); 267 out.print(", ", st orageAccessData.offset);228 out.print(", ", static_cast<ptrdiff_t>(storageAccessData.offset)); 268 229 hasPrinted = true; 269 230 } … … 273 234 int operand = variableAccessData->operand(); 274 235 if (operandIsArgument(operand)) 275 out.print(hasPrinted ? ", " : "", "arg", operandToArgument(operand), "(", nameOfVariableAccessData(variableAccessData), ")");236 out.print(hasPrinted ? ", " : "", "arg", operandToArgument(operand), "(", VariableAccessDataDump(*this, variableAccessData), ")"); 276 237 else 277 out.print(hasPrinted ? ", " : "", "r", operand, "(", nameOfVariableAccessData(variableAccessData), ")");238 out.print(hasPrinted ? ", " : "", "r", operand, "(", VariableAccessDataDump(*this, variableAccessData), ")"); 278 239 hasPrinted = true; 279 240 } … … 322 283 if (!skipped) { 323 284 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" : ""); 325 286 else if (node.hasHeapPrediction()) 326 out.print(" predicting ", speculationToString(node.getHeapPrediction()));287 out.print(" predicting ", SpeculationDump(node.getHeapPrediction())); 327 288 } 328 289 … … 460 421 461 422 #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"); 463 426 #endif 464 427 } -
trunk/Source/JavaScriptCore/dfg/DFGGraph.h
r136069 r136096 328 328 static const char *opName(NodeType); 329 329 330 // This is O(n), and should only be used for verbose dumps.331 const char* nameOfVariableAccessData(VariableAccessData*);332 333 330 void predictArgumentTypes(); 334 331 -
trunk/Source/JavaScriptCore/dfg/DFGStructureAbstractValue.h
r136066 r136096 321 321 } } // namespace JSC::DFG 322 322 323 namespace WTF {324 325 inline void printInternal(PrintStream& out, const JSC::DFG::StructureAbstractValue& value)326 {327 value.dump(out);328 }329 330 } // namespace WTF331 332 323 #endif // ENABLE(DFG_JIT) 333 324 -
trunk/Source/WTF/ChangeLog
r136082 r136096 1 2012-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 1 30 2012-11-28 Michael Saboff <msaboff@apple.com> 2 31 -
trunk/Source/WTF/GNUmakefile.list.am
r136066 r136096 160 160 Source/WTF/wtf/StreamBuffer.h \ 161 161 Source/WTF/wtf/StringExtras.h \ 162 Source/WTF/wtf/StringPrintStream.cpp \ 163 Source/WTF/wtf/StringPrintStream.h \ 162 164 Source/WTF/wtf/StringHasher.h \ 163 165 Source/WTF/wtf/TCPackedCache.h \ -
trunk/Source/WTF/WTF.gypi
r136066 r136096 100 100 'wtf/StringExtras.h', 101 101 'wtf/StringHasher.h', 102 'wtf/StringPrintStream.h', 102 103 'wtf/TemporaryChange.h', 103 104 'wtf/ThreadRestrictionVerifier.h', … … 201 202 'wtf/StackBounds.cpp', 202 203 'wtf/StringExtras.cpp', 204 'wtf/StringPrintStream.cpp', 203 205 'wtf/TCPackedCache.h', 204 206 'wtf/TCPageMap.h', -
trunk/Source/WTF/WTF.pro
r136066 r136096 147 147 StringExtras.h \ 148 148 StringHasher.h \ 149 StringPrintStream.h \ 149 150 TCPackedCache.h \ 150 151 TCSpinLock.h \ … … 236 237 SHA1.cpp \ 237 238 StackBounds.cpp \ 239 StringPrintStream.cpp \ 238 240 TCSystemAlloc.cpp \ 239 241 Threading.cpp \ -
trunk/Source/WTF/WTF.vcproj/WTF.vcproj
r136066 r136096 1214 1214 </File> 1215 1215 <File 1216 RelativePath="..\wtf\StringPrintStream.cpp" 1217 > 1218 </File> 1219 <File 1220 RelativePath="..\wtf\StringPrintStream.h" 1221 > 1222 </File> 1223 <File 1216 1224 RelativePath="..\wtf\TCPackedCache.h" 1217 1225 > -
trunk/Source/WTF/WTF.xcodeproj/project.pbxproj
r136066 r136096 28 28 0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F9D335E165DBA73005AD387 /* PrintStream.h */; }; 29 29 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 */; }; 30 32 143F611F1565F0F900DB514A /* RAMSize.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143F611D1565F0F900DB514A /* RAMSize.cpp */; }; 31 33 143F61201565F0F900DB514A /* RAMSize.h in Headers */ = {isa = PBXBuildFile; fileRef = 143F611E1565F0F900DB514A /* RAMSize.h */; settings = {ATTRIBUTES = (); }; }; … … 326 328 0F9D335E165DBA73005AD387 /* PrintStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PrintStream.h; sourceTree = "<group>"; }; 327 329 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>"; }; 328 332 143F611D1565F0F900DB514A /* RAMSize.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RAMSize.cpp; sourceTree = "<group>"; }; 329 333 143F611E1565F0F900DB514A /* RAMSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RAMSize.h; sourceTree = "<group>"; }; … … 838 842 A8A47313151A825B004123FF /* StringExtras.h */, 839 843 A8A47314151A825B004123FF /* StringHasher.h */, 844 0FDDBFA51666DFA300C55FEF /* StringPrintStream.cpp */, 845 0FDDBFA61666DFA300C55FEF /* StringPrintStream.h */, 840 846 A8A47315151A825B004123FF /* TCPackedCache.h */, 841 847 A8A47316151A825B004123FF /* TCPageMap.h */, … … 1242 1248 0F9D3363165DBA73005AD387 /* PrintStream.h in Headers */, 1243 1249 0F87105A16643F190090B0AD /* RawPointer.h in Headers */, 1250 0FDDBFA81666DFA300C55FEF /* StringPrintStream.h in Headers */, 1244 1251 ); 1245 1252 runOnlyForDeploymentPostprocessing = 0; … … 1412 1419 0F9D3360165DBA73005AD387 /* FilePrintStream.cpp in Sources */, 1413 1420 0F9D3362165DBA73005AD387 /* PrintStream.cpp in Sources */, 1421 0FDDBFA71666DFA300C55FEF /* StringPrintStream.cpp in Sources */, 1414 1422 ); 1415 1423 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WTF/wtf/CMakeLists.txt
r136066 r136096 106 106 StringExtras.h 107 107 StringHasher.h 108 StringPrintStream.h 108 109 TCPackedCache.h 109 110 TCPageMap.h … … 185 186 StackBounds.cpp 186 187 StringExtras.cpp 188 StringPrintStream.cpp 187 189 Threading.cpp 188 190 TypeTraits.cpp -
trunk/Source/WTF/wtf/PrintStream.cpp
r136066 r136096 116 116 } 117 117 118 void dumpCharacter(PrintStream& out, char value) 119 { 120 out.printf("%c", value); 121 } 122 118 123 } // namespace WTF 119 124 -
trunk/Source/WTF/wtf/PrintStream.h
r136066 r136096 161 161 void printInternal(PrintStream&, const CString&); 162 162 void printInternal(PrintStream&, const String&); 163 inline void printInternal(PrintStream& out, char* value) { printInternal(out, static_cast<const char*>(value)); } 164 inline void printInternal(PrintStream& out, CString& value) { printInternal(out, static_cast<const CString&>(value)); } 165 inline void printInternal(PrintStream& out, String& value) { printInternal(out, static_cast<const String&>(value)); } 163 166 void printInternal(PrintStream&, bool); 164 167 void printInternal(PrintStream&, int); … … 172 175 void printInternal(PrintStream&, RawPointer); 173 176 177 template<typename T> 178 void 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. 216 void dumpCharacter(PrintStream&, char); 217 MAKE_PRINT_ADAPTOR(CharacterDump, char, dumpCharacter); 218 174 219 } // namespace WTF 175 220 221 using WTF::CharacterDump; 176 222 using WTF::PrintStream; 177 223
Note:
See TracChangeset
for help on using the changeset viewer.