Changeset 35305 in webkit for trunk/JavaScriptCore/VM/Opcode.h
- Timestamp:
- Jul 23, 2008, 3:36:39 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/Opcode.h
r34883 r35305 32 32 33 33 #include <wtf/Assertions.h> 34 #include <wtf/HashMap.h> 34 35 35 36 namespace KJS { 36 37 38 #define SAMPLING_TOOL_ENABLED 0 37 39 #define DUMP_OPCODE_STATS 0 38 40 … … 144 146 #endif 145 147 148 class ExecState; 149 class ScopeNode; 150 class CodeBlock; 151 struct Instruction; 152 153 struct ScopeSampleRecord 154 { 155 RefPtr<ScopeNode> m_scope; 156 CodeBlock* m_codeBlock; 157 int m_totalCount; 158 int* m_vpcCounts; 159 unsigned m_size; 160 161 ScopeSampleRecord(ScopeNode* scope) 162 : m_scope(scope) 163 , m_codeBlock(0) 164 , m_totalCount(0) 165 , m_vpcCounts(0) 166 , m_size(0) 167 { 168 } 169 170 ~ScopeSampleRecord() 171 { 172 if (m_vpcCounts) 173 free(m_vpcCounts); 174 } 175 176 void sample(CodeBlock* codeBlock, Instruction* vPC); 177 }; 178 179 typedef WTF::HashMap<ScopeNode*, ScopeSampleRecord*> ScopeSampleRecordMap; 180 181 class SamplingTool 182 { 183 public: 184 SamplingTool() 185 : m_running(false) 186 , m_recordedCodeBlock(0) 187 , m_recordedVPC(0) 188 , m_totalSamples(0) 189 , m_scopeSampleMap(new ScopeSampleRecordMap()) 190 { 191 } 192 193 ~SamplingTool() 194 { 195 for (ScopeSampleRecordMap::iterator iter = m_scopeSampleMap->begin(); iter != m_scopeSampleMap->end(); ++iter) 196 delete iter->second; 197 delete m_scopeSampleMap; 198 } 199 200 void start(unsigned hertz=1000); 201 void stop(); 202 void dump(ExecState*); 203 204 void notifyOfScope(ScopeNode* scope); 205 206 void sample(CodeBlock* recordedCodeBlock, Instruction* recordedVPC) 207 { 208 m_recordedCodeBlock = recordedCodeBlock; 209 m_recordedVPC = recordedVPC; 210 } 211 212 void privateExecuteReturned() 213 { 214 m_recordedCodeBlock = 0; 215 m_recordedVPC = 0; 216 } 217 218 void callingNativeFunction() 219 { 220 m_recordedCodeBlock = 0; 221 m_recordedVPC = 0; 222 } 223 224 private: 225 static void* threadStartFunc(void*); 226 void run(); 227 228 // Sampling thread state. 229 bool m_running; 230 unsigned m_hertz; 231 pthread_t m_samplingThread; 232 233 // State tracked by the main thread, used by the sampling thread. 234 CodeBlock* m_recordedCodeBlock; 235 Instruction* m_recordedVPC; 236 237 // Gathered sample data. 238 long long m_totalSamples; 239 ScopeSampleRecordMap* m_scopeSampleMap; 240 }; 241 242 // SCOPENODE_ / MACHINE_ macros for use from within member methods on ScopeNode / Machine respectively. 243 #if SAMPLING_TOOL_ENABLED 244 #define SCOPENODE_SAMPLING_notifyOfScope(sampler) sampler->notifyOfScope(this) 245 #define MACHINE_SAMPLING_sample(codeBlock, vPC) m_sampler->sample(codeBlock, vPC) 246 #define MACHINE_SAMPLING_privateExecuteReturned() m_sampler->privateExecuteReturned() 247 #define MACHINE_SAMPLING_callingNativeFunction() m_sampler->callingNativeFunction() 248 #else 249 #define SCOPENODE_SAMPLING_notifyOfScope(sampler) 250 #define MACHINE_SAMPLING_sample(codeBlock, vPC) 251 #define MACHINE_SAMPLING_privateExecuteReturned() 252 #define MACHINE_SAMPLING_callingNativeFunction() 253 #endif 254 255 146 256 #if DUMP_OPCODE_STATS 147 257
Note:
See TracChangeset
for help on using the changeset viewer.