Chromium Code Reviews| Index: src/compiler.cc |
| diff --git a/src/compiler.cc b/src/compiler.cc |
| index e2f016114afd23f363788013966acf6433739336..94d135c63e902852d1e01e79f3ecc11ae85a86b8 100644 |
| --- a/src/compiler.cc |
| +++ b/src/compiler.cc |
| @@ -488,27 +488,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) { |
| @@ -663,7 +642,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. |
| @@ -1005,6 +983,29 @@ inline bool IsEvalToplevel(Handle<SharedFunctionInfo> shared) { |
| Script::COMPILATION_TYPE_EVAL; |
| } |
| +// 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); |
| +} |
| + |
| Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral( |
| Isolate* isolate, FunctionLiteral* literal, Handle<Script> script) { |
| Handle<Code> code = isolate->builtins()->CompileLazy(); |
| @@ -1014,6 +1015,7 @@ Handle<SharedFunctionInfo> NewSharedFunctionInfoForLiteral( |
| code, scope_info); |
| SharedFunctionInfo::InitFromFunctionLiteral(result, literal); |
| SharedFunctionInfo::SetScript(result, script); |
| + SetExpectedNofPropertiesFromEstimate(result, literal); |
|
Michael Starzinger
2016/04/11 13:32:42
This could even be moved out of "compiler.cc" enti
Toon Verwaest
2016/04/11 13:43:32
That sounds good. The helper function used to be i
Michael Starzinger
2016/04/11 14:17:31
Done.
|
| return result; |
| } |
| @@ -1120,12 +1122,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); |
| @@ -1608,10 +1604,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()); |
| } |