Commit 8ce0a943 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Set expect property count right after parsing.

This moves the computation of the {expected_nof_properties} for a shared
function to where the object is actually being allocated. This is done
after parsing when the literal has been populated already. The expected
number of properties is not mutated after parsing.

R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/1873173002

Cr-Commit-Position: refs/heads/master@{#35391}
parent 1c4b80b1
......@@ -483,27 +483,6 @@ void OptimizedCompileJob::RecordOptimizationStats() {
namespace {
// Sets the expected number of properties based on estimate from compiler.
void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
int estimate) {
// If no properties are added in the constructor, they are more likely
// to be added later.
if (estimate == 0) estimate = 2;
// TODO(yangguo): check whether those heuristics are still up-to-date.
// We do not shrink objects that go into a snapshot (yet), so we adjust
// the estimate conservatively.
if (shared->GetIsolate()->serializer_enabled()) {
estimate += 2;
} else {
// Inobject slack tracking will reclaim redundant inobject space later,
// so we can afford to adjust the estimate generously.
estimate += 8;
}
shared->set_expected_nof_properties(estimate);
}
void MaybeDisableOptimization(Handle<SharedFunctionInfo> shared_info,
BailoutReason bailout_reason) {
if (bailout_reason != kNoReason) {
......@@ -658,7 +637,6 @@ MUST_USE_RESULT MaybeHandle<Code> GetUnoptimizedCode(CompilationInfo* info) {
Handle<SharedFunctionInfo> shared = info->shared_info();
FunctionLiteral* lit = info->literal();
DCHECK_EQ(shared->language_mode(), lit->language_mode());
SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
MaybeDisableOptimization(shared, lit->dont_optimize_reason());
// Compile either unoptimized code or bytecode for the interpreter.
......@@ -1115,12 +1093,6 @@ Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
PROFILE(isolate, CodeCreateEvent(log_tag, *info->abstract_code(), *result,
info, *script_name));
// Hint to the runtime system used when allocating space for initial
// property space by setting the expected number of properties for
// the instances of the function.
SetExpectedNofPropertiesFromEstimate(result,
lit->expected_property_count());
if (!script.is_null())
script->set_compilation_state(Script::COMPILATION_STATE_COMPILED);
......@@ -1603,10 +1575,6 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
result->set_allows_lazy_compilation(literal->AllowsLazyCompilation());
result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
// Set the expected number of properties for instances and return
// the resulting function.
SetExpectedNofPropertiesFromEstimate(result,
literal->expected_property_count());
live_edit_tracker.RecordFunctionInfo(result, literal, info.zone());
}
......
......@@ -13405,6 +13405,32 @@ void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
}
}
namespace {
// Sets the expected number of properties based on estimate from parser.
void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
FunctionLiteral* literal) {
int estimate = literal->expected_property_count();
// If no properties are added in the constructor, they are more likely
// to be added later.
if (estimate == 0) estimate = 2;
// TODO(yangguo): check whether those heuristics are still up-to-date.
// We do not shrink objects that go into a snapshot (yet), so we adjust
// the estimate conservatively.
if (shared->GetIsolate()->serializer_enabled()) {
estimate += 2;
} else {
// Inobject slack tracking will reclaim redundant inobject space later,
// so we can afford to adjust the estimate generously.
estimate += 8;
}
shared->set_expected_nof_properties(estimate);
}
} // namespace
void SharedFunctionInfo::InitFromFunctionLiteral(
Handle<SharedFunctionInfo> shared_info, FunctionLiteral* lit) {
......@@ -13437,6 +13463,7 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
}
shared_info->set_needs_home_object(lit->scope()->NeedsHomeObject());
shared_info->set_asm_function(lit->scope()->asm_function());
SetExpectedNofPropertiesFromEstimate(shared_info, lit);
}
......
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