| OLD | NEW |
| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 void OptimizeNow(); | 56 void OptimizeNow(); |
| 57 void OptimizeSoon(JSFunction* function); | 57 void OptimizeSoon(JSFunction* function); |
| 58 | 58 |
| 59 void NotifyTick(); | 59 void NotifyTick(); |
| 60 | 60 |
| 61 void Setup(); | 61 void Setup(); |
| 62 void Reset(); | 62 void Reset(); |
| 63 void TearDown(); | 63 void TearDown(); |
| 64 | 64 |
| 65 void MarkCompactPrologue(bool is_compacting); | |
| 66 Object** SamplerWindowAddress(); | 65 Object** SamplerWindowAddress(); |
| 67 int SamplerWindowSize(); | 66 int SamplerWindowSize(); |
| 68 | 67 |
| 69 // Rate limiting support. | 68 // Rate limiting support. |
| 70 | 69 |
| 71 // VM thread interface. | 70 // VM thread interface. |
| 72 // | 71 // |
| 73 // Called by isolates when their states change. | 72 // Called by isolates when their states change. |
| 74 static inline void IsolateEnteredJS(Isolate* isolate); | 73 static inline void IsolateEnteredJS(Isolate* isolate); |
| 75 static inline void IsolateExitedJS(Isolate* isolate); | 74 static inline void IsolateExitedJS(Isolate* isolate); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 87 // While the function was waiting the profiler may have been | 86 // While the function was waiting the profiler may have been |
| 88 // disabled so it *must check* whether it is allowed to continue. | 87 // disabled so it *must check* whether it is allowed to continue. |
| 89 static bool IsSomeIsolateInJS(); | 88 static bool IsSomeIsolateInJS(); |
| 90 static bool WaitForSomeIsolateToEnterJS(); | 89 static bool WaitForSomeIsolateToEnterJS(); |
| 91 | 90 |
| 92 // When shutting down we join the profiler thread. Doing so while | 91 // When shutting down we join the profiler thread. Doing so while |
| 93 // it's waiting on a semaphore will cause a deadlock, so we have to | 92 // it's waiting on a semaphore will cause a deadlock, so we have to |
| 94 // wake it up first. | 93 // wake it up first. |
| 95 static void WakeUpRuntimeProfilerThreadBeforeShutdown(); | 94 static void WakeUpRuntimeProfilerThreadBeforeShutdown(); |
| 96 | 95 |
| 96 void UpdateSamplesAfterScavenge(); |
| 97 void RemoveDeadSamples(); |
| 98 void UpdateSamplesAfterCompact(ObjectVisitor* visitor); |
| 99 |
| 97 private: | 100 private: |
| 98 static const int kSamplerWindowSize = 16; | 101 static const int kSamplerWindowSize = 16; |
| 99 static const int kStateWindowSize = 128; | 102 static const int kStateWindowSize = 128; |
| 100 | 103 |
| 101 static void HandleWakeUp(Isolate* isolate); | 104 static void HandleWakeUp(Isolate* isolate); |
| 102 | 105 |
| 103 void Optimize(JSFunction* function, bool eager, int delay); | 106 void Optimize(JSFunction* function, bool eager, int delay); |
| 104 | 107 |
| 105 void AttemptOnStackReplacement(JSFunction* function); | 108 void AttemptOnStackReplacement(JSFunction* function); |
| 106 | 109 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 118 | 121 |
| 119 Isolate* isolate_; | 122 Isolate* isolate_; |
| 120 | 123 |
| 121 int sampler_threshold_; | 124 int sampler_threshold_; |
| 122 int sampler_threshold_size_factor_; | 125 int sampler_threshold_size_factor_; |
| 123 int sampler_ticks_until_threshold_adjustment_; | 126 int sampler_ticks_until_threshold_adjustment_; |
| 124 | 127 |
| 125 // The ratio of ticks spent in JS code in percent. | 128 // The ratio of ticks spent in JS code in percent. |
| 126 Atomic32 js_ratio_; | 129 Atomic32 js_ratio_; |
| 127 | 130 |
| 128 // The JSFunctions in the sampler window are not GC safe. Old-space | |
| 129 // pointers are not cleared during mark-sweep collection and therefore | |
| 130 // the window might contain stale pointers. The window is updated on | |
| 131 // scavenges and (parts of it) cleared on mark-sweep and | |
| 132 // mark-sweep-compact. | |
| 133 Object* sampler_window_[kSamplerWindowSize]; | 131 Object* sampler_window_[kSamplerWindowSize]; |
| 134 int sampler_window_position_; | 132 int sampler_window_position_; |
| 135 int sampler_window_weight_[kSamplerWindowSize]; | 133 int sampler_window_weight_[kSamplerWindowSize]; |
| 136 | 134 |
| 137 // Support for pending 'optimize soon' requests. | 135 // Support for pending 'optimize soon' requests. |
| 138 PendingListNode* optimize_soon_list_; | 136 PendingListNode* optimize_soon_list_; |
| 139 | 137 |
| 140 SamplerState state_window_[kStateWindowSize]; | 138 SamplerState state_window_[kStateWindowSize]; |
| 141 int state_window_position_; | 139 int state_window_position_; |
| 142 int state_counts_[2]; | 140 int state_counts_[2]; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 183 |
| 186 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { | 184 void RuntimeProfiler::IsolateExitedJS(Isolate* isolate) { |
| 187 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); | 185 Atomic32 new_state = NoBarrier_AtomicIncrement(&state_, -1); |
| 188 ASSERT(new_state >= 0); | 186 ASSERT(new_state >= 0); |
| 189 USE(new_state); | 187 USE(new_state); |
| 190 } | 188 } |
| 191 | 189 |
| 192 } } // namespace v8::internal | 190 } } // namespace v8::internal |
| 193 | 191 |
| 194 #endif // V8_RUNTIME_PROFILER_H_ | 192 #endif // V8_RUNTIME_PROFILER_H_ |
| OLD | NEW |