Changeset 93560 in webkit
- Timestamp:
- Aug 22, 2011, 4:41:20 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r93492 r93560 1 2011-08-22 Filip Pizlo <fpizlo@apple.com> 2 3 Sampling counter support is in the bytecode directory 4 https://bugs.webkit.org/show_bug.cgi?id=66724 5 6 Reviewed by Darin Adler. 7 8 Moved SamplingCounter to a separate header in runtime/. 9 10 * GNUmakefile.list.am: 11 * JavaScriptCore.pro: 12 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 13 * JavaScriptCore.xcodeproj/project.pbxproj: 14 * bytecode/SamplingTool.cpp: 15 * bytecode/SamplingTool.h: 16 * runtime/SamplingCounter.cpp: Added. 17 (JSC::AbstractSamplingCounter::dump): 18 * runtime/SamplingCounter.h: Added. 19 (JSC::AbstractSamplingCounter::count): 20 (JSC::AbstractSamplingCounter::addressOfCounter): 21 (JSC::AbstractSamplingCounter::init): 22 (JSC::SamplingCounter::SamplingCounter): 23 (JSC::GlobalSamplingCounter::name): 24 (JSC::DeletableSamplingCounter::DeletableSamplingCounter): 25 (JSC::DeletableSamplingCounter::~DeletableSamplingCounter): 26 1 27 2011-08-21 Martin Robinson <mrobinson@igalia.com> 2 28 -
trunk/Source/JavaScriptCore/GNUmakefile.list.am
r93492 r93560 407 407 Source/JavaScriptCore/runtime/RopeImpl.cpp \ 408 408 Source/JavaScriptCore/runtime/RopeImpl.h \ 409 Source/JavaScriptCore/runtime/SamplingCounter.cpp \ 410 Source/JavaScriptCore/runtime/SamplingCounter.h \ 409 411 Source/JavaScriptCore/runtime/ScopeChain.cpp \ 410 412 Source/JavaScriptCore/runtime/ScopeChain.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.pro
r92046 r93560 184 184 runtime/RegExpCache.cpp \ 185 185 runtime/RopeImpl.cpp \ 186 runtime/SamplingCounter.cpp \ 186 187 runtime/ScopeChain.cpp \ 187 188 runtime/SmallStrings.cpp \ -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r92046 r93560 1114 1114 > 1115 1115 </File> 1116 <File 1117 RelativePath="..\..\runtime\SamplingCounter.cpp" 1118 > 1119 </File> 1120 <File 1121 RelativePath="..\..\runtime\SamplingCounter.h" 1122 > 1123 </File> 1116 1124 <File 1117 1125 RelativePath="..\..\runtime\SmallStrings.cpp" -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r93466 r93560 50 50 0BF28A2911A33DC300638F84 /* SizeLimits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */; }; 51 51 0F29479C126E698C00B3ABF5 /* DecimalNumber.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F29479B126E698C00B3ABF5 /* DecimalNumber.cpp */; }; 52 0F7700901402FDE40078EB39 /* SamplingCounter.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F77008E1402FDD60078EB39 /* SamplingCounter.h */; }; 53 0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7700911402FF280078EB39 /* SamplingCounter.cpp */; }; 52 54 0F963B3813FC6FE90002D9B2 /* ValueProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */; settings = {ATTRIBUTES = (Private, ); }; }; 53 55 1400067712A6F7830064D123 /* OSAllocator.h in Headers */ = {isa = PBXBuildFile; fileRef = 1400067612A6F7830064D123 /* OSAllocator.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 731 733 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SizeLimits.cpp; sourceTree = "<group>"; }; 732 734 0F29479B126E698C00B3ABF5 /* DecimalNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DecimalNumber.cpp; sourceTree = "<group>"; }; 735 0F77008E1402FDD60078EB39 /* SamplingCounter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SamplingCounter.h; sourceTree = "<group>"; }; 736 0F7700911402FF280078EB39 /* SamplingCounter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SamplingCounter.cpp; sourceTree = "<group>"; }; 733 737 0F963B3613FC6FDE0002D9B2 /* ValueProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ValueProfile.h; sourceTree = "<group>"; }; 734 738 1400067612A6F7830064D123 /* OSAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSAllocator.h; sourceTree = "<group>"; }; … … 1840 1844 isa = PBXGroup; 1841 1845 children = ( 1846 0F7700911402FF280078EB39 /* SamplingCounter.cpp */, 1847 0F77008E1402FDD60078EB39 /* SamplingCounter.h */, 1842 1848 BCF605110E203EF800B9A64D /* ArgList.cpp */, 1843 1849 BCF605120E203EF800B9A64D /* ArgList.h */, … … 2469 2475 BC18C4580E16F5CD00B34460 /* RefPtr.h in Headers */, 2470 2476 BC18C4590E16F5CD00B34460 /* RefPtrHashMap.h in Headers */, 2477 0F7700901402FDE40078EB39 /* SamplingCounter.h in Headers */, 2471 2478 BC18C45A0E16F5CD00B34460 /* RegExp.h in Headers */, 2472 2479 A1712B3F11C7B228007A5315 /* RegExpCache.h in Headers */, … … 2842 2849 buildActionMask = 2147483647; 2843 2850 files = ( 2851 0F7700921402FF3C0078EB39 /* SamplingCounter.cpp in Sources */, 2844 2852 147F39BD107EC37600427A48 /* ArgList.cpp in Sources */, 2845 2853 147F39BE107EC37600427A48 /* Arguments.cpp in Sources */, -
trunk/Source/JavaScriptCore/bytecode/SamplingTool.cpp
r89973 r93560 388 388 #endif 389 389 390 void AbstractSamplingCounter::dump()391 {392 #if ENABLE(SAMPLING_COUNTERS)393 if (s_abstractSamplingCounterChain != &s_abstractSamplingCounterChainEnd) {394 printf("\nSampling Counter Values:\n");395 for (AbstractSamplingCounter* currCounter = s_abstractSamplingCounterChain; (currCounter != &s_abstractSamplingCounterChainEnd); currCounter = currCounter->m_next)396 printf("\t%s\t: %lld\n", currCounter->m_name, currCounter->m_counter);397 printf("\n\n");398 }399 s_completed = true;400 #endif401 }402 403 AbstractSamplingCounter AbstractSamplingCounter::s_abstractSamplingCounterChainEnd;404 AbstractSamplingCounter* AbstractSamplingCounter::s_abstractSamplingCounterChain = &s_abstractSamplingCounterChainEnd;405 bool AbstractSamplingCounter::s_completed = false;406 407 390 } // namespace JSC -
trunk/Source/JavaScriptCore/bytecode/SamplingTool.h
r89973 r93560 33 33 #include "Nodes.h" 34 34 #include "Opcode.h" 35 #include "SamplingCounter.h" 35 36 #include <wtf/Assertions.h> 36 37 #include <wtf/HashMap.h> … … 280 281 }; 281 282 282 // AbstractSamplingCounter:283 //284 // Implements a named set of counters, printed on exit if ENABLE(SAMPLING_COUNTERS).285 // See subclasses below, SamplingCounter, GlobalSamplingCounter and DeletableSamplingCounter.286 class AbstractSamplingCounter {287 friend class DeletableSamplingCounter;288 public:289 void count(uint32_t count = 1)290 {291 m_counter += count;292 }293 294 static void dump();295 296 int64_t* addressOfCounter() { return &m_counter; }297 298 protected:299 // Effectively the contructor, however called lazily in the case of GlobalSamplingCounter.300 void init(const char* name)301 {302 m_counter = 0;303 m_name = name;304 305 // Set m_next to point to the head of the chain, and inform whatever is306 // currently at the head that this node will now hold the pointer to it.307 m_next = s_abstractSamplingCounterChain;308 s_abstractSamplingCounterChain->m_referer = &m_next;309 // Add this node to the head of the list.310 s_abstractSamplingCounterChain = this;311 m_referer = &s_abstractSamplingCounterChain;312 }313 314 int64_t m_counter;315 const char* m_name;316 AbstractSamplingCounter* m_next;317 // This is a pointer to the pointer to this node in the chain; used to318 // allow fast linked list deletion.319 AbstractSamplingCounter** m_referer;320 // Null object used to detect end of static chain.321 static AbstractSamplingCounter s_abstractSamplingCounterChainEnd;322 static AbstractSamplingCounter* s_abstractSamplingCounterChain;323 static bool s_completed;324 };325 326 #if ENABLE(SAMPLING_COUNTERS)327 // SamplingCounter:328 //329 // This class is suitable and (hopefully!) convenient for cases where a counter is330 // required within the scope of a single function. It can be instantiated as a331 // static variable since it contains a constructor but not a destructor (static332 // variables in WebKit cannot have destructors).333 //334 // For example:335 //336 // void someFunction()337 // {338 // static SamplingCounter countMe("This is my counter. There are many like it, but this one is mine.");339 // countMe.count();340 // // ...341 // }342 //343 class SamplingCounter : public AbstractSamplingCounter {344 public:345 SamplingCounter(const char* name) { init(name); }346 };347 348 // GlobalSamplingCounter:349 //350 // This class is suitable for use where a counter is to be declared globally,351 // since it contains neither a constructor nor destructor. Instead, ensure352 // that 'name()' is called to provide the counter with a name (and also to353 // allow it to be printed out on exit).354 //355 // GlobalSamplingCounter globalCounter;356 //357 // void firstFunction()358 // {359 // // Put this within a function that is definitely called!360 // // (Or alternatively alongside all calls to 'count()').361 // globalCounter.name("I Name You Destroyer.");362 // globalCounter.count();363 // // ...364 // }365 //366 // void secondFunction()367 // {368 // globalCounter.count();369 // // ...370 // }371 //372 class GlobalSamplingCounter : public AbstractSamplingCounter {373 public:374 void name(const char* name)375 {376 // Global objects should be mapped in zero filled memory, so this should377 // be a safe (albeit not necessarily threadsafe) check for 'first call'.378 if (!m_next)379 init(name);380 }381 };382 383 // DeletableSamplingCounter:384 //385 // The above classes (SamplingCounter, GlobalSamplingCounter), are intended for386 // use within a global or static scope, and as such cannot have a destructor.387 // This means there is no convenient way for them to remove themselves from the388 // static list of counters, and should an instance of either class be freed389 // before 'dump()' has walked over the list it will potentially walk over an390 // invalid pointer.391 //392 // This class is intended for use where the counter may possibly be deleted before393 // the program exits. Should this occur, the counter will print it's value to394 // stderr, and remove itself from the static list. Example:395 //396 // DeletableSamplingCounter* counter = new DeletableSamplingCounter("The Counter With No Name");397 // counter->count();398 // delete counter;399 //400 class DeletableSamplingCounter : public AbstractSamplingCounter {401 public:402 DeletableSamplingCounter(const char* name) { init(name); }403 404 ~DeletableSamplingCounter()405 {406 if (!s_completed)407 fprintf(stderr, "DeletableSamplingCounter \"%s\" deleted early (with count %lld)\n", m_name, m_counter);408 // Our m_referer pointer should know where the pointer to this node is,409 // and m_next should know that this node is the previous node in the list.410 ASSERT(*m_referer == this);411 ASSERT(m_next->m_referer == &m_next);412 // Remove this node from the list, and inform m_next that we have done so.413 m_next->m_referer = m_referer;414 *m_referer = m_next;415 }416 };417 #endif418 419 283 } // namespace JSC 420 284
Note:
See TracChangeset
for help on using the changeset viewer.