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

Side by Side Diff: src/objects.cc

Issue 2639583002: [runtime] Remove redundant StoreMode enum. (Closed)
Patch Set: Created 3 years, 11 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') | test/cctest/test-field-type-tracking.cc » ('j') | 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 <memory> 9 #include <memory>
10 #include <sstream> 10 #include <sstream>
(...skipping 3889 matching lines...) Expand 10 before | Expand all | Expand 10 after
3900 if (details.location() == kField) { 3900 if (details.location() == kField) {
3901 DCHECK_EQ(kData, details.kind()); 3901 DCHECK_EQ(kData, details.kind());
3902 SetValue(i, FieldType::Any()); 3902 SetValue(i, FieldType::Any());
3903 } 3903 }
3904 set(ToDetailsIndex(i), details.AsSmi()); 3904 set(ToDetailsIndex(i), details.AsSmi());
3905 } 3905 }
3906 } 3906 }
3907 3907
3908 Handle<Map> Map::CopyGeneralizeAllFields(Handle<Map> map, 3908 Handle<Map> Map::CopyGeneralizeAllFields(Handle<Map> map,
3909 ElementsKind elements_kind, 3909 ElementsKind elements_kind,
3910 int modify_index, StoreMode store_mode, 3910 int modify_index, PropertyKind kind,
3911 PropertyKind kind,
3912 PropertyAttributes attributes, 3911 PropertyAttributes attributes,
3913 const char* reason) { 3912 const char* reason) {
3914 Isolate* isolate = map->GetIsolate(); 3913 Isolate* isolate = map->GetIsolate();
3915 Handle<DescriptorArray> old_descriptors(map->instance_descriptors(), isolate); 3914 Handle<DescriptorArray> old_descriptors(map->instance_descriptors(), isolate);
3916 int number_of_own_descriptors = map->NumberOfOwnDescriptors(); 3915 int number_of_own_descriptors = map->NumberOfOwnDescriptors();
3917 Handle<DescriptorArray> descriptors = 3916 Handle<DescriptorArray> descriptors =
3918 DescriptorArray::CopyUpTo(old_descriptors, number_of_own_descriptors); 3917 DescriptorArray::CopyUpTo(old_descriptors, number_of_own_descriptors);
3919 descriptors->GeneralizeAllFields(); 3918 descriptors->GeneralizeAllFields();
3920 3919
3921 Handle<LayoutDescriptor> new_layout_descriptor( 3920 Handle<LayoutDescriptor> new_layout_descriptor(
3922 LayoutDescriptor::FastPointerLayout(), isolate); 3921 LayoutDescriptor::FastPointerLayout(), isolate);
3923 Handle<Map> new_map = CopyReplaceDescriptors( 3922 Handle<Map> new_map = CopyReplaceDescriptors(
3924 map, descriptors, new_layout_descriptor, OMIT_TRANSITION, 3923 map, descriptors, new_layout_descriptor, OMIT_TRANSITION,
3925 MaybeHandle<Name>(), reason, SPECIAL_TRANSITION); 3924 MaybeHandle<Name>(), reason, SPECIAL_TRANSITION);
3926 3925
3927 // Unless the instance is being migrated, ensure that modify_index is a field. 3926 // Unless the instance is being migrated, ensure that modify_index is a field.
3928 if (modify_index >= 0) { 3927 if (modify_index >= 0) {
3929 PropertyDetails details = descriptors->GetDetails(modify_index); 3928 PropertyDetails details = descriptors->GetDetails(modify_index);
3930 if (store_mode == FORCE_FIELD && 3929 if (details.location() != kField || details.attributes() != attributes) {
3931 (details.location() != kField || details.attributes() != attributes)) {
3932 int field_index = details.location() == kField 3930 int field_index = details.location() == kField
3933 ? details.field_index() 3931 ? details.field_index()
3934 : new_map->NumberOfFields(); 3932 : new_map->NumberOfFields();
3935 Descriptor d = Descriptor::DataField( 3933 Descriptor d = Descriptor::DataField(
3936 handle(descriptors->GetKey(modify_index), isolate), field_index, 3934 handle(descriptors->GetKey(modify_index), isolate), field_index,
3937 attributes, Representation::Tagged()); 3935 attributes, Representation::Tagged());
3938 descriptors->Replace(modify_index, &d); 3936 descriptors->Replace(modify_index, &d);
3939 if (details.location() != kField) { 3937 if (details.location() != kField) {
3940 int unused_property_fields = new_map->unused_property_fields() - 1; 3938 int unused_property_fields = new_map->unused_property_fields() - 1;
3941 if (unused_property_fields < 0) { 3939 if (unused_property_fields < 0) {
3942 unused_property_fields += JSObject::kFieldsAdded; 3940 unused_property_fields += JSObject::kFieldsAdded;
3943 } 3941 }
3944 new_map->set_unused_property_fields(unused_property_fields); 3942 new_map->set_unused_property_fields(unused_property_fields);
3945 } 3943 }
3946 } else { 3944 } else {
3947 DCHECK(details.attributes() == attributes); 3945 DCHECK(details.attributes() == attributes);
3948 } 3946 }
3949 3947
3950 if (FLAG_trace_generalization) { 3948 if (FLAG_trace_generalization) {
3951 MaybeHandle<FieldType> field_type = FieldType::None(isolate); 3949 MaybeHandle<FieldType> field_type = FieldType::None(isolate);
3952 if (details.location() == kField) { 3950 if (details.location() == kField) {
3953 field_type = handle( 3951 field_type = handle(
3954 map->instance_descriptors()->GetFieldType(modify_index), isolate); 3952 map->instance_descriptors()->GetFieldType(modify_index), isolate);
3955 } 3953 }
3956 map->PrintGeneralization( 3954 map->PrintGeneralization(
3957 stdout, reason, modify_index, new_map->NumberOfOwnDescriptors(), 3955 stdout, reason, modify_index, new_map->NumberOfOwnDescriptors(),
3958 new_map->NumberOfOwnDescriptors(), 3956 new_map->NumberOfOwnDescriptors(), details.location() == kDescriptor,
3959 details.location() == kDescriptor && store_mode == FORCE_FIELD,
3960 details.representation(), Representation::Tagged(), field_type, 3957 details.representation(), Representation::Tagged(), field_type,
3961 MaybeHandle<Object>(), FieldType::Any(isolate), 3958 MaybeHandle<Object>(), FieldType::Any(isolate),
3962 MaybeHandle<Object>()); 3959 MaybeHandle<Object>());
3963 } 3960 }
3964 } 3961 }
3965 new_map->set_elements_kind(elements_kind); 3962 new_map->set_elements_kind(elements_kind);
3966 return new_map; 3963 return new_map;
3967 } 3964 }
3968 3965
3969 3966
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 MaybeHandle<Object>(), new_field_type, MaybeHandle<Object>()); 4151 MaybeHandle<Object>(), new_field_type, MaybeHandle<Object>());
4155 } 4152 }
4156 } 4153 }
4157 4154
4158 // TODO(ishell): remove. 4155 // TODO(ishell): remove.
4159 // static 4156 // static
4160 Handle<Map> Map::ReconfigureProperty(Handle<Map> map, int modify_index, 4157 Handle<Map> Map::ReconfigureProperty(Handle<Map> map, int modify_index,
4161 PropertyKind new_kind, 4158 PropertyKind new_kind,
4162 PropertyAttributes new_attributes, 4159 PropertyAttributes new_attributes,
4163 Representation new_representation, 4160 Representation new_representation,
4164 Handle<FieldType> new_field_type, 4161 Handle<FieldType> new_field_type) {
4165 StoreMode store_mode) {
4166 DCHECK_EQ(kData, new_kind); // Only kData case is supported. 4162 DCHECK_EQ(kData, new_kind); // Only kData case is supported.
4167 MapUpdater mu(map->GetIsolate(), map); 4163 MapUpdater mu(map->GetIsolate(), map);
4168 return mu.ReconfigureToDataField(modify_index, new_attributes, 4164 return mu.ReconfigureToDataField(modify_index, new_attributes,
4169 new_representation, new_field_type); 4165 new_representation, new_field_type);
4170 } 4166 }
4171 4167
4172 // TODO(ishell): remove. 4168 // TODO(ishell): remove.
4173 // static 4169 // static
4174 Handle<Map> Map::ReconfigureElementsKind(Handle<Map> map, 4170 Handle<Map> Map::ReconfigureElementsKind(Handle<Map> map,
4175 ElementsKind new_elements_kind) { 4171 ElementsKind new_elements_kind) {
(...skipping 5075 matching lines...) Expand 10 before | Expand all | Expand 10 after
9251 9247
9252 Handle<Map> Map::ReconfigureExistingProperty(Handle<Map> map, int descriptor, 9248 Handle<Map> Map::ReconfigureExistingProperty(Handle<Map> map, int descriptor,
9253 PropertyKind kind, 9249 PropertyKind kind,
9254 PropertyAttributes attributes) { 9250 PropertyAttributes attributes) {
9255 // Dictionaries have to be reconfigured in-place. 9251 // Dictionaries have to be reconfigured in-place.
9256 DCHECK(!map->is_dictionary_map()); 9252 DCHECK(!map->is_dictionary_map());
9257 9253
9258 if (!map->GetBackPointer()->IsMap()) { 9254 if (!map->GetBackPointer()->IsMap()) {
9259 // There is no benefit from reconstructing transition tree for maps without 9255 // There is no benefit from reconstructing transition tree for maps without
9260 // back pointers. 9256 // back pointers.
9261 return CopyGeneralizeAllFields(map, map->elements_kind(), descriptor, 9257 return CopyGeneralizeAllFields(map, map->elements_kind(), descriptor, kind,
9262 FORCE_FIELD, kind, attributes, 9258 attributes,
9263 "GenAll_AttributesMismatchProtoMap"); 9259 "GenAll_AttributesMismatchProtoMap");
9264 } 9260 }
9265 9261
9266 if (FLAG_trace_generalization) { 9262 if (FLAG_trace_generalization) {
9267 map->PrintReconfiguration(stdout, descriptor, kind, attributes); 9263 map->PrintReconfiguration(stdout, descriptor, kind, attributes);
9268 } 9264 }
9269 9265
9270 Isolate* isolate = map->GetIsolate(); 9266 Isolate* isolate = map->GetIsolate();
9271 9267
9272 MapUpdater mu(isolate, map); 9268 MapUpdater mu(isolate, map);
(...skipping 10628 matching lines...) Expand 10 before | Expand all | Expand 10 after
19901 // depend on this. 19897 // depend on this.
19902 return DICTIONARY_ELEMENTS; 19898 return DICTIONARY_ELEMENTS;
19903 } 19899 }
19904 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 19900 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
19905 return kind; 19901 return kind;
19906 } 19902 }
19907 } 19903 }
19908 19904
19909 } // namespace internal 19905 } // namespace internal
19910 } // namespace v8 19906 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/cctest/test-field-type-tracking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698