Changeset 34013 in webkit for trunk/JavaScriptCore/profiler/Profiler.cpp
- Timestamp:
- May 21, 2008, 11:21:59 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/profiler/Profiler.cpp
r33979 r34013 41 41 42 42 static Profiler* sharedProfiler = 0; 43 static const char* GlobalCodeExecution = "( global code)";43 static const char* GlobalCodeExecution = "(program)"; 44 44 static const char* AnonymousFunction = "(anonymous function)"; 45 45 46 46 static void getCallIdentifiers(ExecState*, Vector<CallIdentifier>& callIdentifiers); 47 static void getCallIdentifiers(ExecState*, JSObject*, Vector<CallIdentifier>& callIdentifiers);48 static void getCallIdentifiers(ExecState*, const UString& sourceURL, int startingLineNumber, Vector<CallIdentifier>& callIdentifiers);49 static void getCallIdentifierFromFunctionImp(FunctionImp*, Vector<CallIdentifier>& callIdentifiers);47 static CallIdentifier createCallIdentifier(JSObject*); 48 static CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber); 49 static CallIdentifier createCallIdentifierFromFunctionImp(FunctionImp*); 50 50 51 51 Profiler* Profiler::profiler() … … 82 82 Vector<CallIdentifier> callIdentifiers; 83 83 getCallIdentifiers(exec, callIdentifiers); 84 profile->willExecute(callIdentifiers); 84 for (unsigned i = 0; i< callIdentifiers.size(); ++i) 85 profile->willExecute(callIdentifiers[i]); 85 86 } 86 87 … … 113 114 } 114 115 115 static inline void dispatchFunctionToProfiles(const Vector<RefPtr<Profile> >& profiles, Profile::ProfileFunction function, const Vector<CallIdentifier>& callIdentifiers, unsigned currentPageGroupIdentifier)116 static inline void dispatchFunctionToProfiles(const Vector<RefPtr<Profile> >& profiles, Profile::ProfileFunction function, const CallIdentifier& callIdentifier, unsigned currentPageGroupIdentifier) 116 117 { 117 118 for (size_t i = 0; i < profiles.size(); ++i) 118 119 if (profiles[i]->pageGroupIdentifier() == currentPageGroupIdentifier) 119 (profiles[i].get()->*function)(callIdentifier s);120 (profiles[i].get()->*function)(callIdentifier); 120 121 } 121 122 … … 128 129 return; 129 130 130 Vector<CallIdentifier> callIdentifiers; 131 getCallIdentifiers(exec, calledFunction, callIdentifiers); 132 133 dispatchFunctionToProfiles(m_currentProfiles, &Profile::willExecute, callIdentifiers, exec->lexicalGlobalObject()->pageGroupIdentifier()); 131 dispatchFunctionToProfiles(m_currentProfiles, &Profile::willExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->pageGroupIdentifier()); 134 132 } 135 133 … … 139 137 return; 140 138 141 Vector<CallIdentifier> callIdentifiers; 142 getCallIdentifiers(exec, sourceURL, startingLineNumber, callIdentifiers); 143 144 dispatchFunctionToProfiles(m_currentProfiles, &Profile::willExecute, callIdentifiers, exec->lexicalGlobalObject()->pageGroupIdentifier()); 139 CallIdentifier callIdentifier = createCallIdentifier(sourceURL, startingLineNumber); 140 141 dispatchFunctionToProfiles(m_currentProfiles, &Profile::willExecute, callIdentifier, exec->lexicalGlobalObject()->pageGroupIdentifier()); 145 142 } 146 143 … … 153 150 return; 154 151 155 Vector<CallIdentifier> callIdentifiers; 156 getCallIdentifiers(exec, calledFunction, callIdentifiers); 157 158 dispatchFunctionToProfiles(m_currentProfiles, &Profile::didExecute, callIdentifiers, exec->lexicalGlobalObject()->pageGroupIdentifier()); 152 dispatchFunctionToProfiles(m_currentProfiles, &Profile::didExecute, createCallIdentifier(calledFunction), exec->lexicalGlobalObject()->pageGroupIdentifier()); 159 153 } 160 154 … … 164 158 return; 165 159 166 Vector<CallIdentifier> callIdentifiers; 167 getCallIdentifiers(exec, sourceURL, startingLineNumber, callIdentifiers); 168 169 dispatchFunctionToProfiles(m_currentProfiles, &Profile::didExecute, callIdentifiers, exec->lexicalGlobalObject()->pageGroupIdentifier()); 160 dispatchFunctionToProfiles(m_currentProfiles, &Profile::didExecute, createCallIdentifier(sourceURL, startingLineNumber), exec->lexicalGlobalObject()->pageGroupIdentifier()); 170 161 } 171 162 … … 183 174 } 184 175 185 void getCallIdentifiers(ExecState* exec, JSObject* calledFunction, Vector<CallIdentifier>& callIdentifiers)176 CallIdentifier createCallIdentifier(JSObject* calledFunction) 186 177 { 187 178 if (calledFunction->inherits(&FunctionImp::info)) 188 getCallIdentifierFromFunctionImp(static_cast<FunctionImp*>(calledFunction), callIdentifiers); 189 else if (calledFunction->inherits(&InternalFunctionImp::info)) 190 callIdentifiers.append(CallIdentifier(static_cast<InternalFunctionImp*>(calledFunction)->functionName().ustring(), "", 0) ); 191 getCallIdentifiers(exec, callIdentifiers); 192 } 193 194 void getCallIdentifiers(ExecState* exec, const UString& sourceURL, int startingLineNumber, Vector<CallIdentifier>& callIdentifiers) 195 { 196 callIdentifiers.append(CallIdentifier(GlobalCodeExecution, sourceURL, (startingLineNumber + 1)) ); 197 getCallIdentifiers(exec, callIdentifiers); 198 } 199 200 void getCallIdentifierFromFunctionImp(FunctionImp* functionImp, Vector<CallIdentifier>& callIdentifiers) 179 return createCallIdentifierFromFunctionImp(static_cast<FunctionImp*>(calledFunction)); 180 if (calledFunction->inherits(&InternalFunctionImp::info)) 181 return CallIdentifier(static_cast<InternalFunctionImp*>(calledFunction)->functionName().ustring(), "", 0); 182 183 ASSERT_NOT_REACHED(); 184 return CallIdentifier("", 0, 0); 185 } 186 187 CallIdentifier createCallIdentifier(const UString& sourceURL, int startingLineNumber) 188 { 189 return CallIdentifier(GlobalCodeExecution, sourceURL, (startingLineNumber + 1)); 190 } 191 192 CallIdentifier createCallIdentifierFromFunctionImp(FunctionImp* functionImp) 201 193 { 202 194 UString name = functionImp->functionName().ustring(); … … 204 196 name = AnonymousFunction; 205 197 206 callIdentifiers.append(CallIdentifier(name, functionImp->body->sourceURL(), functionImp->body->lineNo()));198 return CallIdentifier(name, functionImp->body->sourceURL(), functionImp->body->lineNo()); 207 199 } 208 200
Note:
See TracChangeset
for help on using the changeset viewer.