OLD | NEW |
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 <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 13559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13570 | 13570 |
13571 // Sets the expected number of properties based on estimate from parser. | 13571 // Sets the expected number of properties based on estimate from parser. |
13572 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, | 13572 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, |
13573 FunctionLiteral* literal) { | 13573 FunctionLiteral* literal) { |
13574 int estimate = literal->expected_property_count(); | 13574 int estimate = literal->expected_property_count(); |
13575 | 13575 |
13576 // If no properties are added in the constructor, they are more likely | 13576 // If no properties are added in the constructor, they are more likely |
13577 // to be added later. | 13577 // to be added later. |
13578 if (estimate == 0) estimate = 2; | 13578 if (estimate == 0) estimate = 2; |
13579 | 13579 |
13580 // TODO(yangguo): check whether those heuristics are still up-to-date. | 13580 // Inobject slack tracking will reclaim redundant inobject space later, |
13581 // We do not shrink objects that go into a snapshot (yet), so we adjust | 13581 // so we can afford to adjust the estimate generously. |
13582 // the estimate conservatively. | 13582 estimate += 8; |
13583 if (shared->GetIsolate()->serializer_enabled()) { | |
13584 estimate += 2; | |
13585 } else { | |
13586 // Inobject slack tracking will reclaim redundant inobject space later, | |
13587 // so we can afford to adjust the estimate generously. | |
13588 estimate += 8; | |
13589 } | |
13590 | 13583 |
13591 shared->set_expected_nof_properties(estimate); | 13584 shared->set_expected_nof_properties(estimate); |
13592 } | 13585 } |
13593 | 13586 |
13594 } // namespace | 13587 } // namespace |
13595 | 13588 |
13596 void SharedFunctionInfo::InitFromFunctionLiteral( | 13589 void SharedFunctionInfo::InitFromFunctionLiteral( |
13597 Handle<SharedFunctionInfo> shared_info, FunctionLiteral* lit) { | 13590 Handle<SharedFunctionInfo> shared_info, FunctionLiteral* lit) { |
13598 // When adding fields here, make sure DeclarationScope::AnalyzePartially is | 13591 // When adding fields here, make sure DeclarationScope::AnalyzePartially is |
13599 // updated accordingly. | 13592 // updated accordingly. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13632 return true; // Return true if there was no DCHECK. | 13625 return true; // Return true if there was no DCHECK. |
13633 } | 13626 } |
13634 | 13627 |
13635 void SharedFunctionInfo::SetConstructStub(Code* code) { | 13628 void SharedFunctionInfo::SetConstructStub(Code* code) { |
13636 if (code->kind() == Code::BUILTIN) code->set_is_construct_stub(true); | 13629 if (code->kind() == Code::BUILTIN) code->set_is_construct_stub(true); |
13637 set_construct_stub(code); | 13630 set_construct_stub(code); |
13638 } | 13631 } |
13639 | 13632 |
13640 void Map::StartInobjectSlackTracking() { | 13633 void Map::StartInobjectSlackTracking() { |
13641 DCHECK(!IsInobjectSlackTrackingInProgress()); | 13634 DCHECK(!IsInobjectSlackTrackingInProgress()); |
13642 | |
13643 // No tracking during the snapshot construction phase. | |
13644 Isolate* isolate = GetIsolate(); | |
13645 if (isolate->serializer_enabled()) return; | |
13646 | |
13647 if (unused_property_fields() == 0) return; | 13635 if (unused_property_fields() == 0) return; |
13648 | |
13649 set_construction_counter(Map::kSlackTrackingCounterStart); | 13636 set_construction_counter(Map::kSlackTrackingCounterStart); |
13650 } | 13637 } |
13651 | 13638 |
13652 | 13639 |
13653 void SharedFunctionInfo::ResetForNewContext(int new_ic_age) { | 13640 void SharedFunctionInfo::ResetForNewContext(int new_ic_age) { |
13654 code()->ClearInlineCaches(); | 13641 code()->ClearInlineCaches(); |
13655 set_ic_age(new_ic_age); | 13642 set_ic_age(new_ic_age); |
13656 if (code()->kind() == Code::FUNCTION) { | 13643 if (code()->kind() == Code::FUNCTION) { |
13657 code()->set_profiler_ticks(0); | 13644 code()->set_profiler_ticks(0); |
13658 if (optimization_disabled() && opt_count() >= FLAG_max_opt_count) { | 13645 if (optimization_disabled() && opt_count() >= FLAG_max_opt_count) { |
(...skipping 6576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20235 // depend on this. | 20222 // depend on this. |
20236 return DICTIONARY_ELEMENTS; | 20223 return DICTIONARY_ELEMENTS; |
20237 } | 20224 } |
20238 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20225 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20239 return kind; | 20226 return kind; |
20240 } | 20227 } |
20241 } | 20228 } |
20242 | 20229 |
20243 } // namespace internal | 20230 } // namespace internal |
20244 } // namespace v8 | 20231 } // namespace v8 |
OLD | NEW |