OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (isolate_->concurrent_recompilation_enabled() && | 117 if (isolate_->concurrent_recompilation_enabled() && |
118 !isolate_->bootstrapper()->IsActive()) { | 118 !isolate_->bootstrapper()->IsActive()) { |
119 if (isolate_->concurrent_osr_enabled() && | 119 if (isolate_->concurrent_osr_enabled() && |
120 isolate_->optimizing_compiler_thread()->IsQueuedForOSR(function)) { | 120 isolate_->optimizing_compiler_thread()->IsQueuedForOSR(function)) { |
121 // Do not attempt regular recompilation if we already queued this for OSR. | 121 // Do not attempt regular recompilation if we already queued this for OSR. |
122 // TODO(yangguo): This is necessary so that we don't install optimized | 122 // TODO(yangguo): This is necessary so that we don't install optimized |
123 // code on a function that is already optimized, since OSR and regular | 123 // code on a function that is already optimized, since OSR and regular |
124 // recompilation race. This goes away as soon as OSR becomes one-shot. | 124 // recompilation race. This goes away as soon as OSR becomes one-shot. |
125 return; | 125 return; |
126 } | 126 } |
127 ASSERT(!function->IsInRecompileQueue()); | 127 ASSERT(!function->IsInOptimizationQueue()); |
128 function->MarkForConcurrentRecompilation(); | 128 function->MarkForCompileOptimizedConcurrent(); |
129 } else { | 129 } else { |
130 // The next call to the function will trigger optimization. | 130 // The next call to the function will trigger optimization. |
131 function->MarkForLazyRecompilation(); | 131 function->MarkForCompileOptimized(); |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 | 135 |
136 void RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function) { | 136 void RuntimeProfiler::AttemptOnStackReplacement(JSFunction* function) { |
137 // See AlwaysFullCompiler (in compiler.cc) comment on why we need | 137 // See AlwaysFullCompiler (in compiler.cc) comment on why we need |
138 // Debug::has_break_points(). | 138 // Debug::has_break_points(). |
139 if (!FLAG_use_osr || | 139 if (!FLAG_use_osr || |
140 isolate_->DebuggerHasBreakPoints() || | 140 isolate_->DebuggerHasBreakPoints() || |
141 function->IsBuiltin()) { | 141 function->IsBuiltin()) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 for (JavaScriptFrameIterator it(isolate_); | 179 for (JavaScriptFrameIterator it(isolate_); |
180 frame_count++ < frame_count_limit && !it.done(); | 180 frame_count++ < frame_count_limit && !it.done(); |
181 it.Advance()) { | 181 it.Advance()) { |
182 JavaScriptFrame* frame = it.frame(); | 182 JavaScriptFrame* frame = it.frame(); |
183 JSFunction* function = frame->function(); | 183 JSFunction* function = frame->function(); |
184 | 184 |
185 SharedFunctionInfo* shared = function->shared(); | 185 SharedFunctionInfo* shared = function->shared(); |
186 Code* shared_code = shared->code(); | 186 Code* shared_code = shared->code(); |
187 | 187 |
188 if (shared_code->kind() != Code::FUNCTION) continue; | 188 if (shared_code->kind() != Code::FUNCTION) continue; |
189 if (function->IsInRecompileQueue()) continue; | 189 if (function->IsInOptimizationQueue()) continue; |
190 | 190 |
191 if (FLAG_always_osr && | 191 if (FLAG_always_osr && |
192 shared_code->allow_osr_at_loop_nesting_level() == 0) { | 192 shared_code->allow_osr_at_loop_nesting_level() == 0) { |
193 // Testing mode: always try an OSR compile for every function. | 193 // Testing mode: always try an OSR compile for every function. |
194 for (int i = 0; i < Code::kMaxLoopNestingMarker; i++) { | 194 for (int i = 0; i < Code::kMaxLoopNestingMarker; i++) { |
195 // TODO(titzer): fix AttemptOnStackReplacement to avoid this dumb loop. | 195 // TODO(titzer): fix AttemptOnStackReplacement to avoid this dumb loop. |
196 shared_code->set_allow_osr_at_loop_nesting_level(i); | 196 shared_code->set_allow_osr_at_loop_nesting_level(i); |
197 AttemptOnStackReplacement(function); | 197 AttemptOnStackReplacement(function); |
198 } | 198 } |
199 // Fall through and do a normal optimized compile as well. | 199 // Fall through and do a normal optimized compile as well. |
200 } else if (!frame->is_optimized() && | 200 } else if (!frame->is_optimized() && |
201 (function->IsMarkedForLazyRecompilation() || | 201 (function->IsMarkedForCompileOptimized() || |
202 function->IsMarkedForConcurrentRecompilation() || | 202 function->IsMarkedForCompileOptimizedConcurrent() || |
203 function->IsOptimized())) { | 203 function->IsOptimized())) { |
204 // Attempt OSR if we are still running unoptimized code even though the | 204 // Attempt OSR if we are still running unoptimized code even though the |
205 // the function has long been marked or even already been optimized. | 205 // the function has long been marked or even already been optimized. |
206 int ticks = shared_code->profiler_ticks(); | 206 int ticks = shared_code->profiler_ticks(); |
207 int allowance = kOSRCodeSizeAllowanceBase + | 207 int allowance = kOSRCodeSizeAllowanceBase + |
208 ticks * kOSRCodeSizeAllowancePerTick; | 208 ticks * kOSRCodeSizeAllowancePerTick; |
209 if (shared_code->CodeSize() > allowance) { | 209 if (shared_code->CodeSize() > allowance) { |
210 if (ticks < 255) shared_code->set_profiler_ticks(ticks + 1); | 210 if (ticks < 255) shared_code->set_profiler_ticks(ticks + 1); |
211 } else { | 211 } else { |
212 int nesting = shared_code->allow_osr_at_loop_nesting_level(); | 212 int nesting = shared_code->allow_osr_at_loop_nesting_level(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 Optimize(function, "small function"); | 272 Optimize(function, "small function"); |
273 } else { | 273 } else { |
274 shared_code->set_profiler_ticks(ticks + 1); | 274 shared_code->set_profiler_ticks(ticks + 1); |
275 } | 275 } |
276 } | 276 } |
277 any_ic_changed_ = false; | 277 any_ic_changed_ = false; |
278 } | 278 } |
279 | 279 |
280 | 280 |
281 } } // namespace v8::internal | 281 } } // namespace v8::internal |
OLD | NEW |