Commit 58477dc3 authored by Mythri A's avatar Mythri A Committed by Commit Bot

[runtime-profiler] Cleanup MarkCandidatesForOptimization* functions

MarkCandidatesForOptimizationFromBytecode/
MarkCandidatesForOptimizationFromCode are called when bytecode budget
interrupt occurs from interpreted / optimized code. The logic in these
two functions is very similar. This cl merges this logic into one
function.

This cl also removes FLAG_frame_count which specifies the
number of frames we need to look at for tiering up on a bytecode
budget interrupt. The default value is set to 1 and in its current
form it isn't very useful.

Bug: v8:9684
Change-Id: I9f56034f2857672921673b9b68b3615765c0ccfe
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2565514
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#71561}
parent 059c5fa4
......@@ -303,49 +303,35 @@ RuntimeProfiler::MarkCandidatesForOptimizationScope::
profiler_->any_ic_changed_ = false;
}
void RuntimeProfiler::MarkCandidatesForOptimizationFromBytecode() {
void RuntimeProfiler::MarkCandidatesForOptimization(JavaScriptFrame* frame) {
if (!isolate_->use_optimizer()) return;
MarkCandidatesForOptimizationScope scope(this);
int i = 0;
for (JavaScriptFrameIterator it(isolate_); i < FLAG_frame_count && !it.done();
i++, it.Advance()) {
JavaScriptFrame* frame = it.frame();
if (!frame->is_interpreted()) continue;
JSFunction function = frame->function();
DCHECK(function.shared().is_compiled());
if (!function.shared().IsInterpreted()) continue;
JSFunction function = frame->function();
CodeKind code_kind = frame->is_interpreted() ? CodeKind::INTERPRETED_FUNCTION
: function.code().kind();
if (!function.has_feedback_vector()) continue;
DCHECK(function.shared().is_compiled());
DCHECK(function.shared().IsInterpreted());
function.feedback_vector().SaturatingIncrementProfilerTicks();
DCHECK_IMPLIES(CodeKindIsOptimizedJSFunction(code_kind),
function.has_feedback_vector());
if (!function.has_feedback_vector()) return;
MaybeOptimizeFrame(function, frame, CodeKind::INTERPRETED_FUNCTION);
}
function.feedback_vector().SaturatingIncrementProfilerTicks();
MaybeOptimizeFrame(function, frame, code_kind);
}
void RuntimeProfiler::MarkCandidatesForOptimizationFromCode() {
if (!isolate_->use_optimizer()) return;
MarkCandidatesForOptimizationScope scope(this);
int i = 0;
for (JavaScriptFrameIterator it(isolate_); i < FLAG_frame_count && !it.done();
i++, it.Advance()) {
JavaScriptFrame* frame = it.frame();
if (!frame->is_optimized()) continue;
JSFunction function = frame->function();
auto code_kind = function.code().kind();
if (!CodeKindIsOptimizedAndCanTierUp(code_kind)) {
continue;
}
DCHECK(function.shared().is_compiled());
DCHECK(function.has_feedback_vector());
function.feedback_vector().SaturatingIncrementProfilerTicks();
void RuntimeProfiler::MarkCandidatesForOptimizationFromBytecode() {
JavaScriptFrameIterator it(isolate_);
DCHECK(it.frame()->is_interpreted());
MarkCandidatesForOptimization(it.frame());
}
MaybeOptimizeFrame(function, frame, code_kind);
}
void RuntimeProfiler::MarkCandidatesForOptimizationFromCode() {
JavaScriptFrameIterator it(isolate_);
DCHECK(it.frame()->is_optimized());
MarkCandidatesForOptimization(it.frame());
}
} // namespace internal
......
......@@ -35,6 +35,9 @@ class RuntimeProfiler {
int nesting_levels = 1);
private:
// Helper function called from MarkCandidatesForOptimization*
void MarkCandidatesForOptimization(JavaScriptFrame* frame);
// Make the decision whether to optimize the given function, and mark it for
// optimization if the decision was 'yes'.
void MaybeOptimizeFrame(JSFunction function, JavaScriptFrame* frame,
......
......@@ -912,9 +912,6 @@ DEFINE_INT(wasm_max_initial_code_space_reservation, 0,
DEFINE_BOOL(experimental_wasm_allow_huge_modules, false,
"allow wasm modules bigger than 1GB, but below ~2GB")
// Profiler flags.
DEFINE_INT(frame_count, 1, "number of stack frames inspected by the profiler")
DEFINE_INT(stress_sampling_allocation_profiler, 0,
"Enables sampling allocation profiler with X as a sample interval")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment