Changeset 81525 in webkit for trunk/Source/JavaScriptCore/profiler
- Timestamp:
- Mar 18, 2011, 4:07:16 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore/profiler
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/profiler/ProfileGenerator.cpp
r72351 r81525 41 41 static const char* NonJSExecution = "(idle)"; 42 42 43 PassRefPtr<ProfileGenerator> ProfileGenerator::create( const UString& title, ExecState* originatingExec, unsigned uid)43 PassRefPtr<ProfileGenerator> ProfileGenerator::create(ExecState* exec, const UString& title, unsigned uid) 44 44 { 45 return adoptRef(new ProfileGenerator( title, originatingExec, uid));45 return adoptRef(new ProfileGenerator(exec, title, uid)); 46 46 } 47 47 48 ProfileGenerator::ProfileGenerator( const UString& title, ExecState* originatingExec, unsigned uid)49 : m_origin atingGlobalExec(originatingExec ? originatingExec->lexicalGlobalObject()->globalExec() : 0)50 , m_profileGroup( originatingExec ? originatingExec->lexicalGlobalObject()->profileGroup() : 0)48 ProfileGenerator::ProfileGenerator(ExecState* exec, const UString& title, unsigned uid) 49 : m_origin(exec ? exec->lexicalGlobalObject() : 0) 50 , m_profileGroup(exec ? exec->lexicalGlobalObject()->profileGroup() : 0) 51 51 { 52 52 m_profile = Profile::create(title, uid); 53 53 m_currentNode = m_head = m_profile->head(); 54 if ( originatingExec)55 addParentForConsoleStart( originatingExec);54 if (exec) 55 addParentForConsoleStart(exec); 56 56 } 57 57 … … 81 81 } 82 82 83 if (!m_origin atingGlobalExec)83 if (!m_origin) 84 84 return; 85 85 … … 96 96 } 97 97 98 if (!m_origin atingGlobalExec)98 if (!m_origin) 99 99 return; 100 100 -
trunk/Source/JavaScriptCore/profiler/ProfileGenerator.h
r72351 r81525 35 35 36 36 class ExecState; 37 class JSGlobalObject; 37 38 class Profile; 38 39 class ProfileNode; … … 42 43 class ProfileGenerator : public RefCounted<ProfileGenerator> { 43 44 public: 44 static PassRefPtr<ProfileGenerator> create( const UString& title, ExecState* originatingExec, unsigned uid);45 static PassRefPtr<ProfileGenerator> create(ExecState*, const UString& title, unsigned uid); 45 46 46 47 // Members 47 48 const UString& title() const; 48 49 PassRefPtr<Profile> profile() const { return m_profile; } 49 ExecState* originatingGlobalExec() const { return m_originatingGlobalExec; }50 JSGlobalObject* origin() const { return m_origin; } 50 51 unsigned profileGroup() const { return m_profileGroup; } 51 52 … … 62 63 63 64 private: 64 ProfileGenerator( const UString& title, ExecState* originatingExec, unsigned uid);65 ProfileGenerator(ExecState*, const UString& title, unsigned uid); 65 66 void addParentForConsoleStart(ExecState*); 66 67 … … 69 70 70 71 RefPtr<Profile> m_profile; 71 ExecState* m_originatingGlobalExec;72 JSGlobalObject* m_origin; 72 73 unsigned m_profileGroup; 73 74 RefPtr<ProfileNode> m_head; -
trunk/Source/JavaScriptCore/profiler/Profiler.cpp
r79132 r81525 67 67 // Check if we currently have a Profile for this global ExecState and title. 68 68 // If so return early and don't create a new Profile. 69 ExecState* globalExec = exec ? exec->lexicalGlobalObject()->globalExec() : 0;69 JSGlobalObject* origin = exec ? exec->lexicalGlobalObject() : 0; 70 70 71 71 for (size_t i = 0; i < m_currentProfiles.size(); ++i) { 72 72 ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); 73 if (profileGenerator->origin atingGlobalExec() == globalExec&& profileGenerator->title() == title)73 if (profileGenerator->origin() == origin && profileGenerator->title() == title) 74 74 return; 75 75 } 76 76 77 77 s_sharedEnabledProfilerReference = this; 78 RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create( title, exec, ++ProfilesUID);78 RefPtr<ProfileGenerator> profileGenerator = ProfileGenerator::create(exec, title, ++ProfilesUID); 79 79 m_currentProfiles.append(profileGenerator); 80 80 } … … 82 82 PassRefPtr<Profile> Profiler::stopProfiling(ExecState* exec, const UString& title) 83 83 { 84 ExecState* globalExec = exec ? exec->lexicalGlobalObject()->globalExec() : 0;84 JSGlobalObject* origin = exec ? exec->lexicalGlobalObject() : 0; 85 85 for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) { 86 86 ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); 87 if (profileGenerator->origin atingGlobalExec() == globalExec&& (title.isNull() || profileGenerator->title() == title)) {87 if (profileGenerator->origin() == origin && (title.isNull() || profileGenerator->title() == title)) { 88 88 profileGenerator->stopProfiling(); 89 89 RefPtr<Profile> returnProfile = profileGenerator->profile(); … … 100 100 } 101 101 102 void Profiler::stopProfiling(JSGlobalObject* origin) 103 { 104 for (ptrdiff_t i = m_currentProfiles.size() - 1; i >= 0; --i) { 105 ProfileGenerator* profileGenerator = m_currentProfiles[i].get(); 106 if (profileGenerator->origin() == origin) { 107 profileGenerator->stopProfiling(); 108 m_currentProfiles.remove(i); 109 if (!m_currentProfiles.size()) 110 s_sharedEnabledProfilerReference = 0; 111 } 112 } 113 } 114 102 115 static inline void dispatchFunctionToProfiles(ExecState* callerOrHandlerCallFrame, const Vector<RefPtr<ProfileGenerator> >& profiles, ProfileGenerator::ProfileFunction function, const CallIdentifier& callIdentifier, unsigned currentProfileTargetGroup) 103 116 { 104 117 for (size_t i = 0; i < profiles.size(); ++i) { 105 if (profiles[i]->profileGroup() == currentProfileTargetGroup || !profiles[i]->origin atingGlobalExec())118 if (profiles[i]->profileGroup() == currentProfileTargetGroup || !profiles[i]->origin()) 106 119 (profiles[i].get()->*function)(callerOrHandlerCallFrame, callIdentifier); 107 120 } -
trunk/Source/JavaScriptCore/profiler/Profiler.h
r76248 r81525 39 39 class ExecState; 40 40 class JSGlobalData; 41 class JSGlobalObject; 41 42 class JSObject; 42 43 class JSValue; … … 58 59 void startProfiling(ExecState*, const UString& title); 59 60 PassRefPtr<Profile> stopProfiling(ExecState*, const UString& title); 61 void stopProfiling(JSGlobalObject*); 60 62 61 63 void willExecute(ExecState* callerCallFrame, JSValue function);
Note:
See TracChangeset
for help on using the changeset viewer.