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

Side by Side Diff: src/objects.cc

Issue 1681533003: Tenure long-living descriptor arrays. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/objects.h ('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 5692 matching lines...) Expand 10 before | Expand all | Expand 10 after
5703 new_map->set_unused_property_fields(inobject_props); 5703 new_map->set_unused_property_fields(inobject_props);
5704 object->synchronized_set_map(*new_map); 5704 object->synchronized_set_map(*new_map);
5705 object->set_properties(isolate->heap()->empty_fixed_array()); 5705 object->set_properties(isolate->heap()->empty_fixed_array());
5706 // Check that it really works. 5706 // Check that it really works.
5707 DCHECK(object->HasFastProperties()); 5707 DCHECK(object->HasFastProperties());
5708 return; 5708 return;
5709 } 5709 }
5710 5710
5711 // Allocate the instance descriptor. 5711 // Allocate the instance descriptor.
5712 Handle<DescriptorArray> descriptors = DescriptorArray::Allocate( 5712 Handle<DescriptorArray> descriptors = DescriptorArray::Allocate(
5713 isolate, instance_descriptor_length); 5713 isolate, instance_descriptor_length, 0, TENURED);
5714 5714
5715 int number_of_allocated_fields = 5715 int number_of_allocated_fields =
5716 number_of_fields + unused_property_fields - inobject_props; 5716 number_of_fields + unused_property_fields - inobject_props;
5717 if (number_of_allocated_fields < 0) { 5717 if (number_of_allocated_fields < 0) {
5718 // There is enough inobject space for all fields (including unused). 5718 // There is enough inobject space for all fields (including unused).
5719 number_of_allocated_fields = 0; 5719 number_of_allocated_fields = 0;
5720 unused_property_fields = inobject_props - number_of_fields; 5720 unused_property_fields = inobject_props - number_of_fields;
5721 } 5721 }
5722 5722
5723 // Allocate the fixed array for the fields. 5723 // Allocate the fixed array for the fields.
(...skipping 5183 matching lines...) Expand 10 before | Expand all | Expand 10 after
10907 int new_capacity = kFirstIndex + length; 10907 int new_capacity = kFirstIndex + length;
10908 new_capacity = new_capacity + Max(new_capacity / 2, 2); 10908 new_capacity = new_capacity + Max(new_capacity / 2, 2);
10909 int grow_by = new_capacity - capacity; 10909 int grow_by = new_capacity - capacity;
10910 array = Handle<ArrayList>::cast( 10910 array = Handle<ArrayList>::cast(
10911 isolate->factory()->CopyFixedArrayAndGrow(array, grow_by)); 10911 isolate->factory()->CopyFixedArrayAndGrow(array, grow_by));
10912 if (empty) array->SetLength(0); 10912 if (empty) array->SetLength(0);
10913 } 10913 }
10914 return array; 10914 return array;
10915 } 10915 }
10916 10916
10917
10918 Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate, 10917 Handle<DescriptorArray> DescriptorArray::Allocate(Isolate* isolate,
10919 int number_of_descriptors, 10918 int number_of_descriptors,
10920 int slack) { 10919 int slack,
10920 PretenureFlag pretenure) {
10921 DCHECK(0 <= number_of_descriptors); 10921 DCHECK(0 <= number_of_descriptors);
10922 Factory* factory = isolate->factory(); 10922 Factory* factory = isolate->factory();
10923 // Do not use DescriptorArray::cast on incomplete object. 10923 // Do not use DescriptorArray::cast on incomplete object.
10924 int size = number_of_descriptors + slack; 10924 int size = number_of_descriptors + slack;
10925 if (size == 0) return factory->empty_descriptor_array(); 10925 if (size == 0) return factory->empty_descriptor_array();
10926 // Allocate the array of keys. 10926 // Allocate the array of keys.
10927 Handle<FixedArray> result = factory->NewFixedArray(LengthFor(size)); 10927 Handle<FixedArray> result =
10928 factory->NewFixedArray(LengthFor(size), pretenure);
10928 10929
10929 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors)); 10930 result->set(kDescriptorLengthIndex, Smi::FromInt(number_of_descriptors));
10930 result->set(kEnumCacheIndex, Smi::FromInt(0)); 10931 result->set(kEnumCacheIndex, Smi::FromInt(0));
10931 return Handle<DescriptorArray>::cast(result); 10932 return Handle<DescriptorArray>::cast(result);
10932 } 10933 }
10933 10934
10934 10935
10935 void DescriptorArray::ClearEnumCache() { 10936 void DescriptorArray::ClearEnumCache() {
10936 set(kEnumCacheIndex, Smi::FromInt(0)); 10937 set(kEnumCacheIndex, Smi::FromInt(0));
10937 } 10938 }
(...skipping 8985 matching lines...) Expand 10 before | Expand all | Expand 10 after
19923 if (cell->value() != *new_value) { 19924 if (cell->value() != *new_value) {
19924 cell->set_value(*new_value); 19925 cell->set_value(*new_value);
19925 Isolate* isolate = cell->GetIsolate(); 19926 Isolate* isolate = cell->GetIsolate();
19926 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19927 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19927 isolate, DependentCode::kPropertyCellChangedGroup); 19928 isolate, DependentCode::kPropertyCellChangedGroup);
19928 } 19929 }
19929 } 19930 }
19930 19931
19931 } // namespace internal 19932 } // namespace internal
19932 } // namespace v8 19933 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698