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/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 248 matching lines...) Loading... | |
259 int ticks = shared_code->profiler_ticks(); | 259 int ticks = shared_code->profiler_ticks(); |
260 if (ticks >= kProfilerTicksBeforeReenablingOptimization) { | 260 if (ticks >= kProfilerTicksBeforeReenablingOptimization) { |
261 shared_code->set_profiler_ticks(0); | 261 shared_code->set_profiler_ticks(0); |
262 shared->TryReenableOptimization(); | 262 shared->TryReenableOptimization(); |
263 } else { | 263 } else { |
264 shared_code->set_profiler_ticks(ticks + 1); | 264 shared_code->set_profiler_ticks(ticks + 1); |
265 } | 265 } |
266 } | 266 } |
267 return; | 267 return; |
268 } | 268 } |
269 if (function->IsOptimized()) return; | 269 if (frame->is_optimized()) return; |
270 | 270 |
271 int ticks = shared_code->profiler_ticks(); | 271 int ticks = shared_code->profiler_ticks(); |
272 | 272 |
273 if (ticks >= kProfilerTicksBeforeOptimization) { | 273 if (ticks >= kProfilerTicksBeforeOptimization) { |
274 int typeinfo, generic, total, type_percentage, generic_percentage; | 274 int typeinfo, generic, total, type_percentage, generic_percentage; |
275 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, | 275 GetICCounts(function, &typeinfo, &generic, &total, &type_percentage, |
276 &generic_percentage); | 276 &generic_percentage); |
277 if (type_percentage >= FLAG_type_info_threshold && | 277 if (type_percentage >= FLAG_type_info_threshold && |
278 generic_percentage <= FLAG_generic_ic_threshold) { | 278 generic_percentage <= FLAG_generic_ic_threshold) { |
279 // If this particular function hasn't had any ICs patched for enough | 279 // If this particular function hasn't had any ICs patched for enough |
(...skipping 54 matching lines...) Loading... | |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 void RuntimeProfiler::MaybeOptimizeIgnition(JSFunction* function, | 337 void RuntimeProfiler::MaybeOptimizeIgnition(JSFunction* function, |
338 JavaScriptFrame* frame) { | 338 JavaScriptFrame* frame) { |
339 if (function->IsInOptimizationQueue()) return; | 339 if (function->IsInOptimizationQueue()) return; |
340 | 340 |
341 if (FLAG_always_osr) { | 341 if (FLAG_always_osr) { |
342 AttemptOnStackReplacement(frame, AbstractCode::kMaxLoopNestingMarker); | 342 AttemptOnStackReplacement(frame, AbstractCode::kMaxLoopNestingMarker); |
343 // Fall through and do a normal optimized compile as well. | 343 // Fall through and do a normal optimized compile as well. |
344 } else if (MaybeOSRIgnition(function, frame)) { | 344 } else if (MaybeOSRIgnition(function, frame)) { |
mythria
2016/10/31 16:02:03
when FLAG_ignition_osr is disabled MaybeOSRIgnitio
Michael Starzinger
2016/11/03 11:40:27
I would also prefer (1), especially given that we
mythria
2016/11/04 11:12:32
Done.
| |
345 return; | 345 return; |
346 } | 346 } |
347 | 347 |
348 SharedFunctionInfo* shared = function->shared(); | 348 SharedFunctionInfo* shared = function->shared(); |
349 int ticks = shared->profiler_ticks(); | 349 int ticks = shared->profiler_ticks(); |
350 | 350 |
351 if (shared->optimization_disabled()) { | 351 if (shared->optimization_disabled()) { |
352 if (shared->deopt_count() >= FLAG_max_opt_count) { | 352 if (shared->deopt_count() >= FLAG_max_opt_count) { |
353 // If optimization was disabled due to many deoptimizations, | 353 // If optimization was disabled due to many deoptimizations, |
354 // then check if the function is hot and try to reenable optimization. | 354 // then check if the function is hot and try to reenable optimization. |
355 if (ticks >= kProfilerTicksBeforeReenablingOptimization) { | 355 if (ticks >= kProfilerTicksBeforeReenablingOptimization) { |
356 shared->set_profiler_ticks(0); | 356 shared->set_profiler_ticks(0); |
357 shared->TryReenableOptimization(); | 357 shared->TryReenableOptimization(); |
358 } | 358 } |
359 } | 359 } |
360 return; | 360 return; |
361 } | 361 } |
362 | 362 |
363 if (function->IsOptimized()) return; | 363 if (frame->is_optimized()) return; |
364 | 364 |
365 OptimizationReason reason = ShouldOptimizeIgnition(function, frame); | 365 OptimizationReason reason = ShouldOptimizeIgnition(function, frame); |
366 | 366 |
367 if (reason != OptimizationReason::kDoNotOptimize) { | 367 if (reason != OptimizationReason::kDoNotOptimize) { |
368 Optimize(function, reason); | 368 Optimize(function, reason); |
369 } | 369 } |
370 } | 370 } |
371 | 371 |
372 bool RuntimeProfiler::MaybeOSRIgnition(JSFunction* function, | 372 bool RuntimeProfiler::MaybeOSRIgnition(JSFunction* function, |
373 JavaScriptFrame* frame) { | 373 JavaScriptFrame* frame) { |
374 if (!FLAG_ignition_osr) return false; | 374 if (!FLAG_ignition_osr) return false; |
mythria
2016/10/31 16:02:03
This is the check I was referring to in my earlier
| |
375 | 375 |
376 SharedFunctionInfo* shared = function->shared(); | 376 SharedFunctionInfo* shared = function->shared(); |
377 int ticks = shared->profiler_ticks(); | 377 int ticks = shared->profiler_ticks(); |
378 | 378 |
379 // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller | 379 // TODO(rmcilroy): Also ensure we only OSR top-level code if it is smaller |
380 // than kMaxToplevelSourceSize. | 380 // than kMaxToplevelSourceSize. |
381 | 381 |
382 bool osr_before_baselined = function->IsMarkedForBaseline() && | 382 bool osr_before_baselined = function->IsMarkedForBaseline() && |
383 ShouldOptimizeIgnition(function, frame) != | 383 ShouldOptimizeIgnition(function, frame) != |
384 OptimizationReason::kDoNotOptimize; | 384 OptimizationReason::kDoNotOptimize; |
(...skipping 94 matching lines...) Loading... | |
479 } else { | 479 } else { |
480 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); | 480 DCHECK_EQ(next_tier, Compiler::OPTIMIZED); |
481 MaybeOptimizeFullCodegen(function, frame, frame_count); | 481 MaybeOptimizeFullCodegen(function, frame, frame_count); |
482 } | 482 } |
483 } | 483 } |
484 any_ic_changed_ = false; | 484 any_ic_changed_ = false; |
485 } | 485 } |
486 | 486 |
487 } // namespace internal | 487 } // namespace internal |
488 } // namespace v8 | 488 } // namespace v8 |
OLD | NEW |