OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime-profiler.h" | 5 #include "src/runtime-profiler.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/ast/scopeinfo.h" | 8 #include "src/ast/scopeinfo.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 | 262 |
263 void RuntimeProfiler::MaybeBaselineIgnition(JSFunction* function) { | 263 void RuntimeProfiler::MaybeBaselineIgnition(JSFunction* function) { |
264 if (function->IsInOptimizationQueue()) return; | 264 if (function->IsInOptimizationQueue()) return; |
265 | 265 |
266 SharedFunctionInfo* shared = function->shared(); | 266 SharedFunctionInfo* shared = function->shared(); |
267 int ticks = shared->profiler_ticks(); | 267 int ticks = shared->profiler_ticks(); |
268 | 268 |
269 // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller | 269 // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller |
270 // than kMaxToplevelSourceSize. | 270 // than kMaxToplevelSourceSize. |
271 | 271 |
272 if (function->IsMarkedForBaseline() || function->IsMarkedForOptimization() || | 272 if (FLAG_ignition_osr && FLAG_always_osr) { |
273 function->IsMarkedForConcurrentOptimization() || | 273 AttemptOnStackReplacement(function, AbstractCode::kMaxLoopNestingMarker); |
274 function->IsOptimized()) { | 274 // Fall through and do a normal baseline compile as well. |
275 // TODO(rmcilroy): Support OSR in these cases. | 275 } else if (function->IsMarkedForBaseline() || |
276 function->IsMarkedForOptimization() || | |
277 function->IsMarkedForConcurrentOptimization() || | |
278 function->IsOptimized()) { | |
279 // Attempt OSR if we are still running interpreted code even though the | |
280 // the function has long been marked or even already been optimized. | |
281 int ticks = shared->profiler_ticks(); | |
rmcilroy
2016/07/28 16:19:21
no need for this - just use ticks which is already
Michael Starzinger
2016/07/28 17:57:24
Done.
| |
282 int64_t allowance = | |
283 kOSRCodeSizeAllowanceBase + | |
284 static_cast<int64_t>(ticks) * kOSRCodeSizeAllowancePerTick; | |
rmcilroy
2016/07/28 16:19:21
kOSRCodeSizeAllowanceBase and kOSRCodeSizeAllowanc
Michael Starzinger
2016/07/28 17:57:24
Done.
| |
285 if (FLAG_ignition_osr && shared->HasBytecodeArray() && | |
286 shared->bytecode_array()->Size() <= allowance) { | |
287 AttemptOnStackReplacement(function); | |
288 } | |
276 return; | 289 return; |
277 } | 290 } |
278 | 291 |
279 if (shared->optimization_disabled() && | 292 if (shared->optimization_disabled() && |
280 shared->disable_optimization_reason() == kOptimizationDisabledForTest) { | 293 shared->disable_optimization_reason() == kOptimizationDisabledForTest) { |
281 // Don't baseline functions which have been marked by NeverOptimizeFunction | 294 // Don't baseline functions which have been marked by NeverOptimizeFunction |
282 // in a test. | 295 // in a test. |
283 return; | 296 return; |
284 } | 297 } |
285 | 298 |
286 if (ticks >= kProfilerTicksBeforeBaseline) { | 299 if (ticks >= kProfilerTicksBeforeBaseline) { |
287 Baseline(function, "hot enough for baseline"); | 300 Baseline(function, "hot enough for baseline"); |
288 } | 301 } |
289 } | 302 } |
290 | 303 |
291 void RuntimeProfiler::MaybeOptimizeIgnition(JSFunction* function) { | 304 void RuntimeProfiler::MaybeOptimizeIgnition(JSFunction* function) { |
292 if (function->IsInOptimizationQueue()) return; | 305 if (function->IsInOptimizationQueue()) return; |
293 | 306 |
294 SharedFunctionInfo* shared = function->shared(); | 307 SharedFunctionInfo* shared = function->shared(); |
295 int ticks = shared->profiler_ticks(); | 308 int ticks = shared->profiler_ticks(); |
296 | 309 |
297 // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller | 310 // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller |
298 // than kMaxToplevelSourceSize. | 311 // than kMaxToplevelSourceSize. |
299 if (function->IsMarkedForBaseline() || function->IsMarkedForOptimization() || | 312 |
300 function->IsMarkedForConcurrentOptimization() || | 313 if (FLAG_ignition_osr && FLAG_always_osr) { |
301 function->IsOptimized()) { | 314 AttemptOnStackReplacement(function, AbstractCode::kMaxLoopNestingMarker); |
302 // TODO(rmcilroy): Support OSR in these cases. | 315 // Fall through and do a normal optimized compile as well. |
316 } else if (function->IsMarkedForBaseline() || | |
317 function->IsMarkedForOptimization() || | |
318 function->IsMarkedForConcurrentOptimization() || | |
319 function->IsOptimized()) { | |
320 // Attempt OSR if we are still running interpreted code even though the | |
321 // the function has long been marked or even already been optimized. | |
322 int ticks = shared->profiler_ticks(); | |
323 int64_t allowance = | |
324 kOSRCodeSizeAllowanceBase + | |
325 static_cast<int64_t>(ticks) * kOSRCodeSizeAllowancePerTick; | |
326 if (FLAG_ignition_osr && shared->HasBytecodeArray() && | |
327 shared->bytecode_array()->Size() <= allowance) { | |
328 AttemptOnStackReplacement(function); | |
329 } | |
303 return; | 330 return; |
304 } | 331 } |
305 | 332 |
306 if (shared->optimization_disabled()) { | 333 if (shared->optimization_disabled()) { |
307 if (shared->deopt_count() >= FLAG_max_opt_count) { | 334 if (shared->deopt_count() >= FLAG_max_opt_count) { |
308 // If optimization was disabled due to many deoptimizations, | 335 // If optimization was disabled due to many deoptimizations, |
309 // then check if the function is hot and try to reenable optimization. | 336 // then check if the function is hot and try to reenable optimization. |
310 if (ticks >= kProfilerTicksBeforeReenablingOptimization) { | 337 if (ticks >= kProfilerTicksBeforeReenablingOptimization) { |
311 shared->set_profiler_ticks(0); | 338 shared->set_profiler_ticks(0); |
312 shared->TryReenableOptimization(); | 339 shared->TryReenableOptimization(); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); | 409 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); |
383 MaybeOptimizeFullCodegen(function, frame_count, frame->is_optimized()); | 410 MaybeOptimizeFullCodegen(function, frame_count, frame->is_optimized()); |
384 } | 411 } |
385 } | 412 } |
386 any_ic_changed_ = false; | 413 any_ic_changed_ = false; |
387 } | 414 } |
388 | 415 |
389 | 416 |
390 } // namespace internal | 417 } // namespace internal |
391 } // namespace v8 | 418 } // namespace v8 |
OLD | NEW |