Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(323)

Side by Side Diff: src/runtime-profiler.h

Issue 6580038: [Isolates] Merge from bleeding_edge, revisions 5934-6100. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/isolates/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.js ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 22 matching lines...) Expand all
33 33
34 namespace v8 { 34 namespace v8 {
35 namespace internal { 35 namespace internal {
36 36
37 class Isolate; 37 class Isolate;
38 class JSFunction; 38 class JSFunction;
39 class Object; 39 class Object;
40 class PendingListNode; 40 class PendingListNode;
41 class Semaphore; 41 class Semaphore;
42 42
43
44 enum SamplerState {
45 IN_NON_JS_STATE = 0,
46 IN_JS_STATE = 1
47 };
48
49
43 class RuntimeProfiler { 50 class RuntimeProfiler {
44 public: 51 public:
45 explicit RuntimeProfiler(Isolate* isolate); 52 explicit RuntimeProfiler(Isolate* isolate);
46 53
47 static bool IsEnabled(); 54 static bool IsEnabled();
48 55
49 void OptimizeNow(); 56 void OptimizeNow();
50 void OptimizeSoon(JSFunction* function); 57 void OptimizeSoon(JSFunction* function);
51 58
52 void NotifyTick(); 59 void NotifyTick();
(...skipping 29 matching lines...) Expand all
82 static bool IsSomeIsolateInJS(); 89 static bool IsSomeIsolateInJS();
83 static bool WaitForSomeIsolateToEnterJS(); 90 static bool WaitForSomeIsolateToEnterJS();
84 91
85 // When shutting down we join the profiler thread. Doing so while 92 // When shutting down we join the profiler thread. Doing so while
86 // it's waiting on a semaphore will cause a deadlock, so we have to 93 // it's waiting on a semaphore will cause a deadlock, so we have to
87 // wake it up first. 94 // wake it up first.
88 static void WakeUpRuntimeProfilerThreadBeforeShutdown(); 95 static void WakeUpRuntimeProfilerThreadBeforeShutdown();
89 96
90 private: 97 private:
91 static const int kSamplerWindowSize = 16; 98 static const int kSamplerWindowSize = 16;
99 static const int kStateWindowSize = 128;
92 100
93 static void HandleWakeUp(Isolate* isolate); 101 static void HandleWakeUp(Isolate* isolate);
94 102
95 void Optimize(JSFunction* function, bool eager, int delay); 103 void Optimize(JSFunction* function, bool eager, int delay);
96 104
97 void AttemptOnStackReplacement(JSFunction* function); 105 void AttemptOnStackReplacement(JSFunction* function);
98 106
99 void ClearSampleBuffer(); 107 void ClearSampleBuffer();
100 108
101 void ClearSampleBufferNewSpaceEntries(); 109 void ClearSampleBufferNewSpaceEntries();
102 110
103 int LookupSample(JSFunction* function); 111 int LookupSample(JSFunction* function);
104 112
105 void AddSample(JSFunction* function, int weight); 113 void AddSample(JSFunction* function, int weight);
106 114
115 #ifdef ENABLE_LOGGING_AND_PROFILING
116 void UpdateStateRatio(SamplerState current_state);
117 #endif
118
107 Isolate* isolate_; 119 Isolate* isolate_;
108 120
109 int sampler_threshold_; 121 int sampler_threshold_;
110 int sampler_threshold_size_factor_; 122 int sampler_threshold_size_factor_;
123 int sampler_ticks_until_threshold_adjustment_;
124
125 // The ratio of ticks spent in JS code in percent.
126 Atomic32 js_ratio_;
111 127
112 // The JSFunctions in the sampler window are not GC safe. Old-space 128 // The JSFunctions in the sampler window are not GC safe. Old-space
113 // pointers are not cleared during mark-sweep collection and therefore 129 // pointers are not cleared during mark-sweep collection and therefore
114 // the window might contain stale pointers. The window is updated on 130 // the window might contain stale pointers. The window is updated on
115 // scavenges and (parts of it) cleared on mark-sweep and 131 // scavenges and (parts of it) cleared on mark-sweep and
116 // mark-sweep-compact. 132 // mark-sweep-compact.
117 Object* sampler_window_[kSamplerWindowSize]; 133 Object* sampler_window_[kSamplerWindowSize];
118 int sampler_window_position_; 134 int sampler_window_position_;
119 int sampler_window_weight_[kSamplerWindowSize]; 135 int sampler_window_weight_[kSamplerWindowSize];
120 136
121 // Support for pending 'optimize soon' requests. 137 // Support for pending 'optimize soon' requests.
122 PendingListNode* optimize_soon_list_; 138 PendingListNode* optimize_soon_list_;
123 139
140 SamplerState state_window_[kStateWindowSize];
141 int state_window_position_;
142 int state_counts_[2];
143
124 // Possible state values: 144 // Possible state values:
125 // -1 => the profiler thread is waiting on the semaphore 145 // -1 => the profiler thread is waiting on the semaphore
126 // 0 or positive => the number of isolates running JavaScript code. 146 // 0 or positive => the number of isolates running JavaScript code.
127 static Atomic32 state_; 147 static Atomic32 state_;
128 static Semaphore* semaphore_; 148 static Semaphore* semaphore_;
129 }; 149 };
130 150
131 151
132 // Rate limiter intended to be used in the profiler thread. 152 // Rate limiter intended to be used in the profiler thread.
133 class RuntimeProfilerRateLimiter BASE_EMBEDDED { 153 class RuntimeProfilerRateLimiter BASE_EMBEDDED {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 185
166 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { 186 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) {
167 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); 187 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1);
168 ASSERT(new_state >= 0); 188 ASSERT(new_state >= 0);
169 USE(new_state); 189 USE(new_state);
170 } 190 }
171 191
172 } } // namespace v8::internal 192 } } // namespace v8::internal
173 193
174 #endif // V8_RUNTIME_PROFILER_H_ 194 #endif // V8_RUNTIME_PROFILER_H_
OLDNEW
« no previous file with comments | « src/runtime.js ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698