Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: src/objects.cc

Issue 1873173002: [compiler] Set expect property count right after parsing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 13387 matching lines...) Expand 10 before | Expand all | Expand 10 after
13398 abstract_code()->kind() == AbstractCode::INTERPRETED_FUNCTION || 13398 abstract_code()->kind() == AbstractCode::INTERPRETED_FUNCTION ||
13399 abstract_code()->kind() == AbstractCode::BUILTIN); 13399 abstract_code()->kind() == AbstractCode::BUILTIN);
13400 PROFILE(GetIsolate(), CodeDisableOptEvent(abstract_code(), this)); 13400 PROFILE(GetIsolate(), CodeDisableOptEvent(abstract_code(), this));
13401 if (FLAG_trace_opt) { 13401 if (FLAG_trace_opt) {
13402 PrintF("[disabled optimization for "); 13402 PrintF("[disabled optimization for ");
13403 ShortPrint(); 13403 ShortPrint();
13404 PrintF(", reason: %s]\n", GetBailoutReason(reason)); 13404 PrintF(", reason: %s]\n", GetBailoutReason(reason));
13405 } 13405 }
13406 } 13406 }
13407 13407
13408 namespace {
13409
13410 // Sets the expected number of properties based on estimate from parser.
13411 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
13412 FunctionLiteral* literal) {
13413 int estimate = literal->expected_property_count();
13414
13415 // If no properties are added in the constructor, they are more likely
13416 // to be added later.
13417 if (estimate == 0) estimate = 2;
13418
13419 // TODO(yangguo): check whether those heuristics are still up-to-date.
13420 // We do not shrink objects that go into a snapshot (yet), so we adjust
13421 // the estimate conservatively.
13422 if (shared->GetIsolate()->serializer_enabled()) {
13423 estimate += 2;
13424 } else {
13425 // Inobject slack tracking will reclaim redundant inobject space later,
13426 // so we can afford to adjust the estimate generously.
13427 estimate += 8;
13428 }
13429
13430 shared->set_expected_nof_properties(estimate);
13431 }
13432
13433 } // namespace
13408 13434
13409 void SharedFunctionInfo::InitFromFunctionLiteral( 13435 void SharedFunctionInfo::InitFromFunctionLiteral(
13410 Handle<SharedFunctionInfo> shared_info, FunctionLiteral* lit) { 13436 Handle<SharedFunctionInfo> shared_info, FunctionLiteral* lit) {
13411 shared_info->set_length(lit->scope()->default_function_length()); 13437 shared_info->set_length(lit->scope()->default_function_length());
13412 shared_info->set_internal_formal_parameter_count(lit->parameter_count()); 13438 shared_info->set_internal_formal_parameter_count(lit->parameter_count());
13413 shared_info->set_function_token_position(lit->function_token_position()); 13439 shared_info->set_function_token_position(lit->function_token_position());
13414 shared_info->set_start_position(lit->start_position()); 13440 shared_info->set_start_position(lit->start_position());
13415 shared_info->set_end_position(lit->end_position()); 13441 shared_info->set_end_position(lit->end_position());
13416 shared_info->set_is_declaration(lit->is_declaration()); 13442 shared_info->set_is_declaration(lit->is_declaration());
13417 shared_info->set_is_named_expression(lit->is_named_expression()); 13443 shared_info->set_is_named_expression(lit->is_named_expression());
(...skipping 12 matching lines...) Expand all
13430 } 13456 }
13431 shared_info->set_dont_crankshaft(lit->flags() & 13457 shared_info->set_dont_crankshaft(lit->flags() &
13432 AstProperties::kDontCrankshaft); 13458 AstProperties::kDontCrankshaft);
13433 shared_info->set_kind(lit->kind()); 13459 shared_info->set_kind(lit->kind());
13434 if (!IsConstructable(lit->kind(), lit->language_mode())) { 13460 if (!IsConstructable(lit->kind(), lit->language_mode())) {
13435 shared_info->set_construct_stub( 13461 shared_info->set_construct_stub(
13436 *shared_info->GetIsolate()->builtins()->ConstructedNonConstructable()); 13462 *shared_info->GetIsolate()->builtins()->ConstructedNonConstructable());
13437 } 13463 }
13438 shared_info->set_needs_home_object(lit->scope()->NeedsHomeObject()); 13464 shared_info->set_needs_home_object(lit->scope()->NeedsHomeObject());
13439 shared_info->set_asm_function(lit->scope()->asm_function()); 13465 shared_info->set_asm_function(lit->scope()->asm_function());
13466 SetExpectedNofPropertiesFromEstimate(shared_info, lit);
13440 } 13467 }
13441 13468
13442 13469
13443 bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) { 13470 bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) {
13444 DCHECK(!id.IsNone()); 13471 DCHECK(!id.IsNone());
13445 Code* unoptimized = code(); 13472 Code* unoptimized = code();
13446 DeoptimizationOutputData* data = 13473 DeoptimizationOutputData* data =
13447 DeoptimizationOutputData::cast(unoptimized->deoptimization_data()); 13474 DeoptimizationOutputData::cast(unoptimized->deoptimization_data());
13448 unsigned ignore = Deoptimizer::GetOutputInfo(data, id, this); 13475 unsigned ignore = Deoptimizer::GetOutputInfo(data, id, this);
13449 USE(ignore); 13476 USE(ignore);
(...skipping 5866 matching lines...) Expand 10 before | Expand all | Expand 10 after
19316 if (cell->value() != *new_value) { 19343 if (cell->value() != *new_value) {
19317 cell->set_value(*new_value); 19344 cell->set_value(*new_value);
19318 Isolate* isolate = cell->GetIsolate(); 19345 Isolate* isolate = cell->GetIsolate();
19319 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19346 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19320 isolate, DependentCode::kPropertyCellChangedGroup); 19347 isolate, DependentCode::kPropertyCellChangedGroup);
19321 } 19348 }
19322 } 19349 }
19323 19350
19324 } // namespace internal 19351 } // namespace internal
19325 } // namespace v8 19352 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698