Changeset 34371 in webkit for trunk/JavaScriptCore/VM/Opcode.cpp
- Timestamp:
- Jun 4, 2008, 9:39:09 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/Opcode.cpp
r33979 r34371 1 1 /* 2 2 * Copyright (C) 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2008 Cameron Zwarich <[email protected]> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 29 30 #include "Opcode.h" 30 31 32 namespace KJS { 33 34 #if DUMP_OPCODE_STATS 35 36 unsigned OpcodeStats::opcodeCounts[numOpcodeIDs]; 37 38 static OpcodeStats logger; 39 40 static const char* opcodeNames[] = { 41 "load", 42 "new_object", 43 "new_array", 44 "new_regexp", 45 "mov", 46 47 "not", 48 "eq", 49 "neq", 50 "stricteq", 51 "nstricteq", 52 "less", 53 "lesseq", 54 55 "pre_inc", 56 "pre_dec", 57 "post_inc", 58 "post_dec", 59 "to_jsnumber", 60 "negate", 61 "add", 62 "mul", 63 "div", 64 "mod", 65 "sub", 66 67 "lshift", 68 "rshift", 69 "urshift", 70 "bitand", 71 "bitxor", 72 "bitor", 73 "bitnot", 74 75 "instanceof", 76 "typeof", 77 "in", 78 79 "resolve", 80 "resolve_skip", 81 "get_scoped_var", 82 "put_scoped_var", 83 "resolve_base", 84 "resolve_with_base", 85 "resolve_func", 86 "get_by_id", 87 "put_by_id", 88 "del_by_id", 89 "get_by_val", 90 "put_by_val", 91 "del_by_val", 92 "put_by_index", 93 "put_getter", 94 "put_setter", 95 96 "jmp", 97 "jtrue", 98 "jfalse", 99 "jmp_scopes", 100 101 "new_func", 102 "new_func_exp", 103 "call", 104 "call_eval", 105 "ret", 106 107 "construct", 108 109 "get_pnames", 110 "next_pname", 111 112 "push_scope", 113 "pop_scope", 114 115 "catch", 116 "throw", 117 "new_error", 118 119 "jsr", 120 "sret", 121 122 "debug", 123 124 "end" 125 }; 126 127 OpcodeStats::OpcodeStats() 128 { 129 for (int i = 0; i < numOpcodeIDs; ++i) 130 opcodeCounts[i] = 0; 131 } 132 133 OpcodeStats::~OpcodeStats() 134 { 135 int totalInstructions = 0; 136 int sortedIndices[numOpcodeIDs]; 137 138 for (int i = 0; i < numOpcodeIDs; ++i) { 139 totalInstructions += opcodeCounts[i]; 140 sortedIndices[i] = i; 141 } 142 143 for (int i = 0; i < numOpcodeIDs - 1; ++i) { 144 int max = i; 145 146 for (int j = i + 1; j < numOpcodeIDs; ++j) { 147 if (opcodeCounts[sortedIndices[j]] > opcodeCounts[sortedIndices[max]]) 148 max = j; 149 } 150 151 int temp = sortedIndices[i]; 152 sortedIndices[i] = sortedIndices[max]; 153 sortedIndices[max] = temp; 154 } 155 156 printf("\nExecuted opcode statistics:\n\n"); 157 158 printf("Total instructions executed: %d\n\n", totalInstructions); 159 160 for (int i = 0; i < numOpcodeIDs; ++i) { 161 int index = sortedIndices[i]; 162 printf("%s: %.2f%%\n", opcodeNames[index], ((double) opcodeCounts[index]) / ((double) totalInstructions) * 100.0); 163 } 164 165 printf("\n"); 166 } 167 168 void OpcodeStats::recordInstruction(int opcode) 169 { 170 opcodeCounts[opcode]++; 171 } 172 173 #endif 174 175 } // namespace WTF
Note:
See TracChangeset
for help on using the changeset viewer.