Commit e44c607b authored by titzer's avatar titzer Committed by Commit Bot

[objects] Move AllocationSite::MakePretenureDecision() and...

[objects] Move AllocationSite::MakePretenureDecision() and AllocationSite::DigestPretenuringFeedback() into heap.cc

These two methods were only called in heap.cc. Since they are pretty
heavyweight and objects-inl.h is included in many V8 files, this saves
build time.

R=ulan@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2961053002
Cr-Commit-Position: refs/heads/master@{#46290}
parent d02cb6f0
......@@ -554,6 +554,65 @@ class Heap::PretenuringScope {
Heap* heap_;
};
namespace {
inline bool MakePretenureDecision(
AllocationSite* site, AllocationSite::PretenureDecision current_decision,
double ratio, bool maximum_size_scavenge) {
// Here we just allow state transitions from undecided or maybe tenure
// to don't tenure, maybe tenure, or tenure.
if ((current_decision == AllocationSite::kUndecided ||
current_decision == AllocationSite::kMaybeTenure)) {
if (ratio >= AllocationSite::kPretenureRatio) {
// We just transition into tenure state when the semi-space was at
// maximum capacity.
if (maximum_size_scavenge) {
site->set_deopt_dependent_code(true);
site->set_pretenure_decision(AllocationSite::kTenure);
// Currently we just need to deopt when we make a state transition to
// tenure.
return true;
}
site->set_pretenure_decision(AllocationSite::kMaybeTenure);
} else {
site->set_pretenure_decision(AllocationSite::kDontTenure);
}
}
return false;
}
inline bool DigestPretenuringFeedback(Isolate* isolate, AllocationSite* site,
bool maximum_size_scavenge) {
bool deopt = false;
int create_count = site->memento_create_count();
int found_count = site->memento_found_count();
bool minimum_mementos_created =
create_count >= AllocationSite::kPretenureMinimumCreated;
double ratio = minimum_mementos_created || FLAG_trace_pretenuring_statistics
? static_cast<double>(found_count) / create_count
: 0.0;
AllocationSite::PretenureDecision current_decision =
site->pretenure_decision();
if (minimum_mementos_created) {
deopt = MakePretenureDecision(site, current_decision, ratio,
maximum_size_scavenge);
}
if (FLAG_trace_pretenuring_statistics) {
PrintIsolate(isolate,
"pretenuring: AllocationSite(%p): (created, found, ratio) "
"(%d, %d, %f) %s => %s\n",
static_cast<void*>(site), create_count, found_count, ratio,
site->PretenureDecisionName(current_decision),
site->PretenureDecisionName(site->pretenure_decision()));
}
// Clear feedback calculation fields until the next gc.
site->set_memento_found_count(0);
site->set_memento_create_count(0);
return deopt;
}
} // namespace
void Heap::ProcessPretenuringFeedback() {
bool trigger_deoptimization = false;
......@@ -580,7 +639,7 @@ void Heap::ProcessPretenuringFeedback() {
DCHECK(site->IsAllocationSite());
active_allocation_sites++;
allocation_mementos_found += found_count;
if (site->DigestPretenuringFeedback(maximum_size_scavenge)) {
if (DigestPretenuringFeedback(isolate_, site, maximum_size_scavenge)) {
trigger_deoptimization = true;
}
if (site->GetPretenureMode() == TENURED) {
......
......@@ -1251,64 +1251,6 @@ inline void AllocationSite::IncrementMementoCreateCount() {
}
inline bool AllocationSite::MakePretenureDecision(
PretenureDecision current_decision,
double ratio,
bool maximum_size_scavenge) {
// Here we just allow state transitions from undecided or maybe tenure
// to don't tenure, maybe tenure, or tenure.
if ((current_decision == kUndecided || current_decision == kMaybeTenure)) {
if (ratio >= kPretenureRatio) {
// We just transition into tenure state when the semi-space was at
// maximum capacity.
if (maximum_size_scavenge) {
set_deopt_dependent_code(true);
set_pretenure_decision(kTenure);
// Currently we just need to deopt when we make a state transition to
// tenure.
return true;
}
set_pretenure_decision(kMaybeTenure);
} else {
set_pretenure_decision(kDontTenure);
}
}
return false;
}
inline bool AllocationSite::DigestPretenuringFeedback(
bool maximum_size_scavenge) {
bool deopt = false;
int create_count = memento_create_count();
int found_count = memento_found_count();
bool minimum_mementos_created = create_count >= kPretenureMinimumCreated;
double ratio =
minimum_mementos_created || FLAG_trace_pretenuring_statistics ?
static_cast<double>(found_count) / create_count : 0.0;
PretenureDecision current_decision = pretenure_decision();
if (minimum_mementos_created) {
deopt = MakePretenureDecision(
current_decision, ratio, maximum_size_scavenge);
}
if (FLAG_trace_pretenuring_statistics) {
PrintIsolate(GetIsolate(),
"pretenuring: AllocationSite(%p): (created, found, ratio) "
"(%d, %d, %f) %s => %s\n",
static_cast<void*>(this), create_count, found_count, ratio,
PretenureDecisionName(current_decision),
PretenureDecisionName(pretenure_decision()));
}
// Clear feedback calculation fields until the next gc.
set_memento_found_count(0);
set_memento_create_count(0);
return deopt;
}
bool AllocationMemento::IsValid() {
return allocation_site()->IsAllocationSite() &&
!AllocationSite::cast(allocation_site())->IsZombie();
......
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