Changeset 38425 in webkit for trunk/JavaScriptCore/VM/SamplingTool.cpp
- Timestamp:
- Nov 15, 2008, 12:34:40 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/SamplingTool.cpp
r38423 r38425 55 55 if (offest < m_size) { 56 56 m_samples[offest]++; 57 m_ opcodeSampleCount++;57 m_bytecodeSampleCount++; 58 58 } 59 59 } … … 95 95 96 96 if (!sample.inHostFunction()) { 97 unsigned opcodeID = m_interpreter->getOpcodeID(sample.vPC()[0].u.opcode);98 99 ++m_ opcodeSampleCount;100 ++m_ opcodeSamples[opcodeID];97 unsigned bytecodeID = m_interpreter->getBytecodeID(sample.vPC()[0].u.bytecode); 98 99 ++m_bytecodeSampleCount; 100 ++m_bytecodeSamples[bytecodeID]; 101 101 102 102 if (sample.inCTIFunction()) 103 m_ opcodeSamplesInCTIFunctions[opcodeID]++;103 m_bytecodeSamplesInCTIFunctions[bytecodeID]++; 104 104 } 105 105 … … 141 141 } 142 142 143 #if ENABLE( OPCODE_SAMPLING)144 145 struct OpcodeSampleInfo {146 OpcodeID opcode;143 #if ENABLE(BYTECODE_SAMPLING) 144 145 struct BytecodeSampleInfo { 146 BytecodeID bytecode; 147 147 long long count; 148 148 long long countInCTIFunctions; … … 162 162 } 163 163 164 static int compare OpcodeIndicesSampling(const void* left, const void* right)165 { 166 const OpcodeSampleInfo* leftSampleInfo = reinterpret_cast<const OpcodeSampleInfo*>(left);167 const OpcodeSampleInfo* rightSampleInfo = reinterpret_cast<const OpcodeSampleInfo*>(right);164 static int compareBytecodeIndicesSampling(const void* left, const void* right) 165 { 166 const BytecodeSampleInfo* leftSampleInfo = reinterpret_cast<const BytecodeSampleInfo*>(left); 167 const BytecodeSampleInfo* rightSampleInfo = reinterpret_cast<const BytecodeSampleInfo*>(right); 168 168 169 169 return (leftSampleInfo->count < rightSampleInfo->count) ? 1 : (leftSampleInfo->count > rightSampleInfo->count) ? -1 : 0; … … 184 184 return; 185 185 186 // (1) Build and sort ' opcodeSampleInfo' array.187 188 OpcodeSampleInfo opcodeSampleInfo[numOpcodeIDs];189 for (int i = 0; i < num OpcodeIDs; ++i) {190 opcodeSampleInfo[i].opcode = static_cast<OpcodeID>(i);191 opcodeSampleInfo[i].count = m_opcodeSamples[i];192 opcodeSampleInfo[i].countInCTIFunctions = m_opcodeSamplesInCTIFunctions[i];193 } 194 195 qsort( opcodeSampleInfo, numOpcodeIDs, sizeof(OpcodeSampleInfo), compareOpcodeIndicesSampling);196 197 // (2) Print Opcode sampling results.198 199 printf("\n Opcode samples [*]\n");186 // (1) Build and sort 'bytecodeSampleInfo' array. 187 188 BytecodeSampleInfo bytecodeSampleInfo[numBytecodeIDs]; 189 for (int i = 0; i < numBytecodeIDs; ++i) { 190 bytecodeSampleInfo[i].bytecode = static_cast<BytecodeID>(i); 191 bytecodeSampleInfo[i].count = m_bytecodeSamples[i]; 192 bytecodeSampleInfo[i].countInCTIFunctions = m_bytecodeSamplesInCTIFunctions[i]; 193 } 194 195 qsort(bytecodeSampleInfo, numBytecodeIDs, sizeof(BytecodeSampleInfo), compareBytecodeIndicesSampling); 196 197 // (2) Print Bytecode sampling results. 198 199 printf("\nBytecode samples [*]\n"); 200 200 printf(" sample %% of %% of | cti cti %%\n"); 201 printf(" opcode count VM total | count of self\n");201 printf("bytecode count VM total | count of self\n"); 202 202 printf("------------------------------------------------------- | ----------------\n"); 203 203 204 for (int i = 0; i < num OpcodeIDs; ++i) {205 long long count = opcodeSampleInfo[i].count;204 for (int i = 0; i < numBytecodeIDs; ++i) { 205 long long count = bytecodeSampleInfo[i].count; 206 206 if (!count) 207 207 continue; 208 208 209 OpcodeID opcode = opcodeSampleInfo[i].opcode;209 BytecodeID bytecode = bytecodeSampleInfo[i].bytecode; 210 210 211 const char* opcodeName = opcodeNames[opcode];212 const char* opcodePadding = padOpcodeName(opcode, 28);213 double percentOfVM = (static_cast<double>(count) * 100) / m_ opcodeSampleCount;211 const char* bytecodeName = bytecodeNames[bytecode]; 212 const char* bytecodePadding = padBytecodeName(bytecode, 28); 213 double percentOfVM = (static_cast<double>(count) * 100) / m_bytecodeSampleCount; 214 214 double percentOfTotal = (static_cast<double>(count) * 100) / m_sampleCount; 215 long long countInCTIFunctions = opcodeSampleInfo[i].countInCTIFunctions;215 long long countInCTIFunctions = bytecodeSampleInfo[i].countInCTIFunctions; 216 216 double percentInCTIFunctions = (static_cast<double>(countInCTIFunctions) * 100) / count; 217 fprintf(stdout, "%s:%s%-6lld %.3f%%\t%.3f%%\t | %-6lld %.3f%%\n", opcodeName, opcodePadding, count, percentOfVM, percentOfTotal, countInCTIFunctions, percentInCTIFunctions);217 fprintf(stdout, "%s:%s%-6lld %.3f%%\t%.3f%%\t | %-6lld %.3f%%\n", bytecodeName, bytecodePadding, count, percentOfVM, percentOfTotal, countInCTIFunctions, percentInCTIFunctions); 218 218 } 219 219 220 printf("\n[*] Samples inside host code are not charged to any Opcode.\n\n");221 printf("\tSamples inside VM:\t\t%lld / %lld (%.3f%%)\n", m_ opcodeSampleCount, m_sampleCount, (static_cast<double>(m_opcodeSampleCount) * 100) / m_sampleCount);222 printf("\tSamples inside host code:\t%lld / %lld (%.3f%%)\n\n", m_sampleCount - m_ opcodeSampleCount, m_sampleCount, (static_cast<double>(m_sampleCount - m_opcodeSampleCount) * 100) / m_sampleCount);223 printf("\tsample count:\tsamples inside this opcode\n");224 printf("\t%% of VM:\tsample count / all opcode samples\n");220 printf("\n[*] Samples inside host code are not charged to any Bytecode.\n\n"); 221 printf("\tSamples inside VM:\t\t%lld / %lld (%.3f%%)\n", m_bytecodeSampleCount, m_sampleCount, (static_cast<double>(m_bytecodeSampleCount) * 100) / m_sampleCount); 222 printf("\tSamples inside host code:\t%lld / %lld (%.3f%%)\n\n", m_sampleCount - m_bytecodeSampleCount, m_sampleCount, (static_cast<double>(m_sampleCount - m_bytecodeSampleCount) * 100) / m_sampleCount); 223 printf("\tsample count:\tsamples inside this bytecode\n"); 224 printf("\t%% of VM:\tsample count / all bytecode samples\n"); 225 225 printf("\t%% of total:\tsample count / all samples\n"); 226 226 printf("\t--------------\n"); 227 printf("\tcti count:\tsamples inside a CTI function called by this opcode\n");227 printf("\tcti count:\tsamples inside a CTI function called by this bytecode\n"); 228 228 printf("\tcti %% of self:\tcti count / sample count\n"); 229 229 … … 255 255 codeBlock->dump(exec); 256 256 257 printf(" Opcode and line number samples [*]\n\n");257 printf(" Bytecode and line number samples [*]\n\n"); 258 258 for (unsigned op = 0; op < record->m_size; ++op) { 259 259 int count = record->m_samples[op]; … … 280 280 } 281 281 printf("\n"); 282 printf(" [*] Samples inside host code are charged to the calling Opcode.\n");283 printf(" Samples on a call / return boundary are not charged to a specific opcode or line.\n\n");284 printf(" Samples on a call / return boundary: %d / %d (%.3f%%)\n\n", record->m_sampleCount - record->m_ opcodeSampleCount, record->m_sampleCount, (static_cast<double>(record->m_sampleCount - record->m_opcodeSampleCount) * 100) / record->m_sampleCount);282 printf(" [*] Samples inside host code are charged to the calling Bytecode.\n"); 283 printf(" Samples on a call / return boundary are not charged to a specific bytecode or line.\n\n"); 284 printf(" Samples on a call / return boundary: %d / %d (%.3f%%)\n\n", record->m_sampleCount - record->m_bytecodeSampleCount, record->m_sampleCount, (static_cast<double>(record->m_sampleCount - record->m_bytecodeSampleCount) * 100) / record->m_sampleCount); 285 285 } 286 286 }
Note:
See TracChangeset
for help on using the changeset viewer.