Changeset 36402 in webkit for trunk/JavaScriptCore/VM/SamplingTool.cpp
- Timestamp:
- Sep 14, 2008, 1:33:03 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/SamplingTool.cpp
r36263 r36402 81 81 82 82 #if ENABLE(SAMPLING_TOOL) 83 extern OpcodeID what; 84 extern unsigned incall; 85 unsigned cowdogs = 0; 86 unsigned sampleCows[numOpcodeIDs] = {0}; 87 unsigned sampleDogs[numOpcodeIDs] = {0}; 83 unsigned totalOpcodeIDCount = 0; 84 unsigned opcodeIDCountInCalledCode[numOpcodeIDs] = {0}; 85 unsigned opcodeIDCountInJITCode[numOpcodeIDs] = {0}; 88 86 #endif 89 87 … … 95 93 m_totalSamples++; 96 94 #if ENABLE(SAMPLING_TOOL) 97 if ( what != (OpcodeID)-1) {98 ++ cowdogs;99 if (in call)100 sampleDogs[what]++;95 if (currentOpcodeID != static_cast<OpcodeID>(-1)) { 96 ++totalOpcodeIDCount; 97 if (inCalledCode) 98 opcodeIDCountInCalledCode[currentOpcodeID]++; 101 99 else 102 sampleCows[what]++;100 opcodeIDCountInJITCode[currentOpcodeID]++; 103 101 } 104 102 #endif … … 142 140 #if ENABLE(SAMPLING_TOOL) 143 141 144 struct OpcodeSampleInfo 145 { 142 struct OpcodeSampleInfo { 146 143 OpcodeID opcode; 147 144 long long count; 148 long long count incall;145 long long countInCalledCode; 149 146 }; 150 147 151 struct LineCountInfo 152 { 148 struct LineCountInfo { 153 149 unsigned line; 154 150 unsigned count; … … 195 191 totalCodeBlockSamples += codeBlockSamples[i]->m_totalCount; 196 192 } 197 #if HAVE(MERGESORT) 198 mergesort(codeBlockSamples.begin(), scopeCount, sizeof(ScopeSampleRecord*), compareScopeSampleRecords); 199 #else 193 200 194 qsort(codeBlockSamples.begin(), scopeCount, sizeof(ScopeSampleRecord*), compareScopeSampleRecords); 201 #endif202 195 203 196 // (2) Print data from 'codeBlockSamples' array, calculate 'totalOpcodeSamples', populate 'opcodeSampleCounts' array. … … 209 202 printf("Total blocks sampled (total samples): %lld (%lld)\n\n", totalCodeBlockSamples, m_totalSamples); 210 203 211 for (int i =0; i < scopeCount; i++) {204 for (int i = 0; i < scopeCount; ++i) { 212 205 ScopeSampleRecord* record = codeBlockSamples[i]; 213 206 CodeBlock* codeBlock = record->m_codeBlock; … … 238 231 lineCountInfo[lineno].count = iter->second; 239 232 } 240 #if HAVE(MERGESORT) 241 mergesort(lineCountInfo.begin(), linesCount, sizeof(LineCountInfo), compareLineCountInfoSampling); 242 #else 233 243 234 qsort(lineCountInfo.begin(), linesCount, sizeof(LineCountInfo), compareLineCountInfoSampling); 244 #endif 235 245 236 for (lineno = 0; lineno < linesCount; ++lineno) { 246 237 printf(" Line #%d has sample count %d.\n", lineCountInfo[lineno].line, lineCountInfo[lineno].count); … … 267 258 OpcodeSampleInfo opcodeSampleInfo[numOpcodeIDs]; 268 259 for (int i = 0; i < numOpcodeIDs; ++i) { 269 opcodeSampleInfo[i].opcode = (OpcodeID)i; 270 opcodeSampleInfo[i].count = sampleCows[i]+sampleDogs[i]; 271 opcodeSampleInfo[i].countincall = sampleDogs[i]; 272 } 273 #if HAVE(MERGESORT) 274 mergesort(opcodeSampleInfo, numOpcodeIDs, sizeof(OpcodeSampleInfo), compareOpcodeIndicesSampling); 275 #else 260 opcodeSampleInfo[i].opcode = static_cast<OpcodeID>(i); 261 opcodeSampleInfo[i].count = opcodeIDCountInJITCode[i] + opcodeIDCountInCalledCode[i]; 262 opcodeSampleInfo[i].countInCalledCode = opcodeIDCountInCalledCode[i]; 263 } 264 276 265 qsort(opcodeSampleInfo, numOpcodeIDs, sizeof(OpcodeSampleInfo), compareOpcodeIndicesSampling); 277 #endif278 266 279 267 // (4) Print Opcode sampling results. 280 268 281 282 269 printf("\nOpcode sampling results\n\n"); 283 284 // printf("Total opcodes sampled (total samples): %lld (%lld)\n\n", totalOpcodeSamples, m_totalSamples);285 // printf("Opcodes in order:\n\n");286 // for (int i = 0; i < numOpcodeIDs; ++i) {287 // long long count = opcodeSampleCounts[i];288 // printf("%s:%s%6lld\t%.3f%%\t(%.3f%%)\n", opcodeNames[i], padOpcodeName(static_cast<OpcodeID>(i), 20), count, (static_cast<double>(count) * 100) / totalOpcodeSamples, (static_cast<double>(count) * 100) / m_totalSamples);289 // }290 // printf("\n");291 // printf("Opcodes by sample count:\n\n");292 270 293 271 for (int i = 0; i < numOpcodeIDs; ++i) { 294 272 OpcodeID opcode = opcodeSampleInfo[i].opcode; 295 273 long long count = opcodeSampleInfo[i].count; 296 // printf("%s:%s%6lld\t%.3f%%\t(%.3f%%)\n", opcodeNames[opcode], padOpcodeName(opcode, 20), count, (static_cast<double>(count) * 100) / totalOpcodeSamples, (static_cast<double>(count) * 100) / m_totalSamples); 297 long long countincall = opcodeSampleInfo[i].countincall; 298 fprintf(stdout, "%s:%s%6lld\t%6lld\t%.3f%%\t%.3f%%\t(%.3f%%)\n", opcodeNames[opcode], padOpcodeName(opcode, 20), count, countincall, ((double)count * 100)/cowdogs, ((double)count * 100)/m_totalSamples, ((double)countincall * 100)/m_totalSamples); 274 long long countInCalledCode = opcodeSampleInfo[i].countInCalledCode; 275 fprintf(stdout, "%s:%s%6lld\t%6lld\t%.3f%%\t%.3f%%\t(%.3f%%)\n", opcodeNames[opcode], padOpcodeName(opcode, 20), count, countInCalledCode, (static_cast<double>(count) * 100) / totalOpcodeIDCount, (static_cast<double>(count) * 100) / m_totalSamples, (static_cast<double>(countInCalledCode) * 100) / m_totalSamples); 299 276 } 300 277 printf("\n");
Note:
See TracChangeset
for help on using the changeset viewer.