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

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

Issue 6826026: Fix JS ratio computation on startup. (Closed)
Patch Set: Created 9 years, 8 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
« no previous file with comments | « no previous file | src/runtime-profiler.cc » ('j') | src/runtime-profiler.cc » ('J')
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
50 class RuntimeProfiler { 43 class RuntimeProfiler {
51 public: 44 public:
52 explicit RuntimeProfiler(Isolate* isolate); 45 explicit RuntimeProfiler(Isolate* isolate);
53 46
54 static bool IsEnabled(); 47 static bool IsEnabled();
55 48
56 void OptimizeNow(); 49 void OptimizeNow();
57 void OptimizeSoon(JSFunction* function); 50 void OptimizeSoon(JSFunction* function);
58 51
59 void NotifyTick(); 52 void NotifyTick();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 static void WakeUpRuntimeProfilerThreadBeforeShutdown(); 87 static void WakeUpRuntimeProfilerThreadBeforeShutdown();
95 88
96 void UpdateSamplesAfterScavenge(); 89 void UpdateSamplesAfterScavenge();
97 void RemoveDeadSamples(); 90 void RemoveDeadSamples();
98 void UpdateSamplesAfterCompact(ObjectVisitor* visitor); 91 void UpdateSamplesAfterCompact(ObjectVisitor* visitor);
99 92
100 private: 93 private:
101 static const int kSamplerWindowSize = 16; 94 static const int kSamplerWindowSize = 16;
102 static const int kStateWindowSize = 128; 95 static const int kStateWindowSize = 128;
103 96
97 enum SamplerState {
98 IN_NON_JS_STATE = 0,
99 IN_JS_STATE = 1
100 };
101
104 static void HandleWakeUp(Isolate* isolate); 102 static void HandleWakeUp(Isolate* isolate);
105 103
106 void Optimize(JSFunction* function, bool eager, int delay); 104 void Optimize(JSFunction* function, bool eager, int delay);
107 105
108 void AttemptOnStackReplacement(JSFunction* function); 106 void AttemptOnStackReplacement(JSFunction* function);
109 107
110 void ClearSampleBuffer(); 108 void ClearSampleBuffer();
111 109
112 void ClearSampleBufferNewSpaceEntries(); 110 void ClearSampleBufferNewSpaceEntries();
113 111
(...skipping 16 matching lines...) Expand all
130 128
131 Object* sampler_window_[kSamplerWindowSize]; 129 Object* sampler_window_[kSamplerWindowSize];
132 int sampler_window_position_; 130 int sampler_window_position_;
133 int sampler_window_weight_[kSamplerWindowSize]; 131 int sampler_window_weight_[kSamplerWindowSize];
134 132
135 // Support for pending 'optimize soon' requests. 133 // Support for pending 'optimize soon' requests.
136 PendingListNode* optimize_soon_list_; 134 PendingListNode* optimize_soon_list_;
137 135
138 SamplerState state_window_[kStateWindowSize]; 136 SamplerState state_window_[kStateWindowSize];
139 int state_window_position_; 137 int state_window_position_;
138 int state_window_ticks_;
140 int state_counts_[2]; 139 int state_counts_[2];
141 140
142 // Possible state values: 141 // Possible state values:
143 // -1 => the profiler thread is waiting on the semaphore 142 // -1 => the profiler thread is waiting on the semaphore
144 // 0 or positive => the number of isolates running JavaScript code. 143 // 0 or positive => the number of isolates running JavaScript code.
145 static Atomic32 state_; 144 static Atomic32 state_;
146 static Semaphore* semaphore_; 145 static Semaphore* semaphore_;
147 }; 146 };
148 147
149 148
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 182
184 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { 183 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) {
185 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); 184 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1);
186 ASSERT(new_state >= 0); 185 ASSERT(new_state >= 0);
187 USE(new_state); 186 USE(new_state);
188 } 187 }
189 188
190 } } // namespace v8::internal 189 } } // namespace v8::internal
191 190
192 #endif // V8_RUNTIME_PROFILER_H_ 191 #endif // V8_RUNTIME_PROFILER_H_
OLDNEW
« no previous file with comments | « no previous file | src/runtime-profiler.cc » ('j') | src/runtime-profiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698