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

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

Issue 8700008: New approach to Crankshaft decision-making (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: address comments Created 9 years 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.cc ('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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 52
53 void OptimizeNow(); 53 void OptimizeNow();
54 54
55 void NotifyTick(); 55 void NotifyTick();
56 56
57 void Setup(); 57 void Setup();
58 void Reset(); 58 void Reset();
59 void TearDown(); 59 void TearDown();
60 60
61 Object** SamplerWindowAddress(); 61 void NotifyICChanged() {
62 int SamplerWindowSize(); 62 any_ic_changed_ = true;
63 }
64 void NotifyCodeGenerated(int generated_code_size) {
65 code_generated_ = true;
66 total_code_generated_ += generated_code_size;
67 }
63 68
64 // Rate limiting support. 69 // Rate limiting support.
65 70
66 // VM thread interface. 71 // VM thread interface.
67 // 72 //
68 // Called by isolates when their states change. 73 // Called by isolates when their states change.
69 static inline void IsolateEnteredJS(Isolate* isolate); 74 static inline void IsolateEnteredJS(Isolate* isolate);
70 static inline void IsolateExitedJS(Isolate* isolate); 75 static inline void IsolateExitedJS(Isolate* isolate);
71 76
72 // Profiler thread interface. 77 // Profiler thread interface.
73 // 78 //
74 // IsSomeIsolateInJS(): 79 // IsSomeIsolateInJS():
75 // The profiler thread can query whether some isolate is currently 80 // The profiler thread can query whether some isolate is currently
76 // running JavaScript code. 81 // running JavaScript code.
77 // 82 //
78 // WaitForSomeIsolateToEnterJS(): 83 // WaitForSomeIsolateToEnterJS():
79 // When no isolates are running JavaScript code for some time the 84 // When no isolates are running JavaScript code for some time the
80 // profiler thread suspends itself by calling the wait function. The 85 // profiler thread suspends itself by calling the wait function. The
81 // wait function returns true after it waited or false immediately. 86 // wait function returns true after it waited or false immediately.
82 // While the function was waiting the profiler may have been 87 // While the function was waiting the profiler may have been
83 // disabled so it *must check* whether it is allowed to continue. 88 // disabled so it *must check* whether it is allowed to continue.
84 static bool IsSomeIsolateInJS(); 89 static bool IsSomeIsolateInJS();
85 static bool WaitForSomeIsolateToEnterJS(); 90 static bool WaitForSomeIsolateToEnterJS();
86 91
87 // Stops the runtime profiler thread when profiling support is being 92 // Stops the runtime profiler thread when profiling support is being
88 // turned off. 93 // turned off.
89 static void StopRuntimeProfilerThreadBeforeShutdown(Thread* thread); 94 static void StopRuntimeProfilerThreadBeforeShutdown(Thread* thread);
90 95
91 void UpdateSamplesAfterScavenge();
92 void RemoveDeadSamples();
93 void UpdateSamplesAfterCompact(ObjectVisitor* visitor);
94
95 private: 96 private:
96 static const int kSamplerWindowSize = 16;
97
98 static void HandleWakeUp(Isolate* isolate); 97 static void HandleWakeUp(Isolate* isolate);
99 98
100 void Optimize(JSFunction* function); 99 void Optimize(JSFunction* function, const char* reason);
101 100
102 void AttemptOnStackReplacement(JSFunction* function); 101 void AttemptOnStackReplacement(JSFunction* function);
103 102
104 void ClearSampleBuffer(); 103 void ClearSampleBuffer();
105 104
106 void ClearSampleBufferNewSpaceEntries(); 105 void ClearSampleBufferNewSpaceEntries();
107 106
108 int LookupSample(JSFunction* function);
109
110 void AddSample(JSFunction* function, int weight);
111
112 Isolate* isolate_; 107 Isolate* isolate_;
113 108
114 int sampler_threshold_; 109 bool any_ic_changed_;
115 int sampler_threshold_size_factor_; 110 bool code_generated_;
116 int sampler_ticks_until_threshold_adjustment_; 111 int total_code_generated_;
117
118 Object* sampler_window_[kSamplerWindowSize];
119 int sampler_window_position_;
120 int sampler_window_weight_[kSamplerWindowSize];
121 112
122 // Possible state values: 113 // Possible state values:
123 // -1 => the profiler thread is waiting on the semaphore 114 // -1 => the profiler thread is waiting on the semaphore
124 // 0 or positive => the number of isolates running JavaScript code. 115 // 0 or positive => the number of isolates running JavaScript code.
125 static Atomic32 state_; 116 static Atomic32 state_;
126 static Semaphore* semaphore_; 117 static Semaphore* semaphore_;
127 118
128 #ifdef DEBUG 119 #ifdef DEBUG
129 static bool has_been_globally_setup_; 120 static bool has_been_globally_setup_;
130 #endif 121 #endif
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 157
167 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { 158 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) {
168 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); 159 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1);
169 ASSERT(new_state >= 0); 160 ASSERT(new_state >= 0);
170 USE(new_state); 161 USE(new_state);
171 } 162 }
172 163
173 } } // namespace v8::internal 164 } } // namespace v8::internal
174 165
175 #endif // V8_RUNTIME_PROFILER_H_ 166 #endif // V8_RUNTIME_PROFILER_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/runtime-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698