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

Side by Side Diff: src/objects.cc

Issue 805453002: Introduced PropertyType ACCESSOR_FIELD. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 6 years 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/lookup-inl.h ('k') | src/objects-printer.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after
2859 for (int i = root_nof; i < old_nof; ++i) { 2859 for (int i = root_nof; i < old_nof; ++i) {
2860 PropertyDetails old_details = old_descriptors->GetDetails(i); 2860 PropertyDetails old_details = old_descriptors->GetDetails(i);
2861 int j = new_map->SearchTransition(old_details.kind(), 2861 int j = new_map->SearchTransition(old_details.kind(),
2862 old_descriptors->GetKey(i), 2862 old_descriptors->GetKey(i),
2863 old_details.attributes()); 2863 old_details.attributes());
2864 if (j == TransitionArray::kNotFound) return MaybeHandle<Map>(); 2864 if (j == TransitionArray::kNotFound) return MaybeHandle<Map>();
2865 new_map = new_map->GetTransition(j); 2865 new_map = new_map->GetTransition(j);
2866 DescriptorArray* new_descriptors = new_map->instance_descriptors(); 2866 DescriptorArray* new_descriptors = new_map->instance_descriptors();
2867 2867
2868 PropertyDetails new_details = new_descriptors->GetDetails(i); 2868 PropertyDetails new_details = new_descriptors->GetDetails(i);
2869 if (old_details.attributes() != new_details.attributes() || 2869 DCHECK_EQ(old_details.kind(), new_details.kind());
2870 !old_details.representation().fits_into(new_details.representation())) { 2870 DCHECK_EQ(old_details.attributes(), new_details.attributes());
2871 if (!old_details.representation().fits_into(new_details.representation())) {
2871 return MaybeHandle<Map>(); 2872 return MaybeHandle<Map>();
2872 } 2873 }
2873 PropertyType new_type = new_details.type();
2874 PropertyType old_type = old_details.type();
2875 Object* new_value = new_descriptors->GetValue(i); 2874 Object* new_value = new_descriptors->GetValue(i);
2876 Object* old_value = old_descriptors->GetValue(i); 2875 Object* old_value = old_descriptors->GetValue(i);
2877 switch (new_type) { 2876 switch (new_details.type()) {
2878 case FIELD: 2877 case FIELD: {
2879 if ((old_type == FIELD && 2878 PropertyType old_type = old_details.type();
2880 !HeapType::cast(old_value)->NowIs(HeapType::cast(new_value))) || 2879 if (old_type == FIELD) {
2881 (old_type == CONSTANT && 2880 if (!HeapType::cast(old_value)->NowIs(HeapType::cast(new_value))) {
2882 !HeapType::cast(new_value)->NowContains(old_value)) || 2881 return MaybeHandle<Map>();
2883 (old_type == CALLBACKS && 2882 }
2884 !HeapType::Any()->Is(HeapType::cast(new_value)))) { 2883 } else {
2885 return MaybeHandle<Map>(); 2884 DCHECK(old_type == CONSTANT);
2885 if (!HeapType::cast(new_value)->NowContains(old_value)) {
2886 return MaybeHandle<Map>();
2887 }
2886 } 2888 }
2887 break; 2889 break;
2890 }
2891 case ACCESSOR_FIELD:
2892 DCHECK(HeapType::Any()->Is(HeapType::cast(new_value)));
2893 break;
2888 2894
2889 case CONSTANT: 2895 case CONSTANT:
2890 case CALLBACKS: 2896 case CALLBACKS:
2891 if (old_type != new_type || old_value != new_value) { 2897 if (old_details.location() == IN_OBJECT || old_value != new_value) {
2892 return MaybeHandle<Map>(); 2898 return MaybeHandle<Map>();
2893 } 2899 }
2894 break; 2900 break;
2895 } 2901 }
2896 } 2902 }
2897 if (new_map->NumberOfOwnDescriptors() != old_nof) return MaybeHandle<Map>(); 2903 if (new_map->NumberOfOwnDescriptors() != old_nof) return MaybeHandle<Map>();
2898 return handle(new_map); 2904 return handle(new_map);
2899 } 2905 }
2900 2906
2901 2907
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
4358 property_count += expected_additional_properties; 4364 property_count += expected_additional_properties;
4359 } else { 4365 } else {
4360 property_count += 2; // Make space for two more properties. 4366 property_count += 2; // Make space for two more properties.
4361 } 4367 }
4362 Handle<NameDictionary> dictionary = 4368 Handle<NameDictionary> dictionary =
4363 NameDictionary::New(isolate, property_count); 4369 NameDictionary::New(isolate, property_count);
4364 4370
4365 Handle<DescriptorArray> descs(map->instance_descriptors()); 4371 Handle<DescriptorArray> descs(map->instance_descriptors());
4366 for (int i = 0; i < real_size; i++) { 4372 for (int i = 0; i < real_size; i++) {
4367 PropertyDetails details = descs->GetDetails(i); 4373 PropertyDetails details = descs->GetDetails(i);
4374 Handle<Name> key(descs->GetKey(i));
4368 switch (details.type()) { 4375 switch (details.type()) {
4369 case CONSTANT: { 4376 case CONSTANT: {
4370 Handle<Name> key(descs->GetKey(i));
4371 Handle<Object> value(descs->GetConstant(i), isolate); 4377 Handle<Object> value(descs->GetConstant(i), isolate);
4372 PropertyDetails d(details.attributes(), FIELD, i + 1); 4378 PropertyDetails d(details.attributes(), FIELD, i + 1);
4373 dictionary = NameDictionary::Add(dictionary, key, value, d); 4379 dictionary = NameDictionary::Add(dictionary, key, value, d);
4374 break; 4380 break;
4375 } 4381 }
4376 case FIELD: { 4382 case FIELD: {
4377 Handle<Name> key(descs->GetKey(i));
4378 FieldIndex index = FieldIndex::ForDescriptor(*map, i); 4383 FieldIndex index = FieldIndex::ForDescriptor(*map, i);
4379 Handle<Object> value; 4384 Handle<Object> value;
4380 if (object->IsUnboxedDoubleField(index)) { 4385 if (object->IsUnboxedDoubleField(index)) {
4381 double old_value = object->RawFastDoublePropertyAt(index); 4386 double old_value = object->RawFastDoublePropertyAt(index);
4382 value = isolate->factory()->NewHeapNumber(old_value); 4387 value = isolate->factory()->NewHeapNumber(old_value);
4383 } else { 4388 } else {
4384 value = handle(object->RawFastPropertyAt(index), isolate); 4389 value = handle(object->RawFastPropertyAt(index), isolate);
4385 if (details.representation().IsDouble()) { 4390 if (details.representation().IsDouble()) {
4386 DCHECK(value->IsMutableHeapNumber()); 4391 DCHECK(value->IsMutableHeapNumber());
4387 Handle<HeapNumber> old = Handle<HeapNumber>::cast(value); 4392 Handle<HeapNumber> old = Handle<HeapNumber>::cast(value);
4388 value = isolate->factory()->NewHeapNumber(old->value()); 4393 value = isolate->factory()->NewHeapNumber(old->value());
4389 } 4394 }
4390 } 4395 }
4391 PropertyDetails d(details.attributes(), FIELD, i + 1); 4396 PropertyDetails d(details.attributes(), FIELD, i + 1);
4392 dictionary = NameDictionary::Add(dictionary, key, value, d); 4397 dictionary = NameDictionary::Add(dictionary, key, value, d);
4393 break; 4398 break;
4394 } 4399 }
4400 case ACCESSOR_FIELD: {
4401 FieldIndex index = FieldIndex::ForDescriptor(*map, i);
4402 Handle<Object> value(object->RawFastPropertyAt(index), isolate);
4403 PropertyDetails d(details.attributes(), CALLBACKS, i + 1);
4404 dictionary = NameDictionary::Add(dictionary, key, value, d);
4405 break;
4406 }
4395 case CALLBACKS: { 4407 case CALLBACKS: {
4396 Handle<Name> key(descs->GetKey(i));
4397 Handle<Object> value(descs->GetCallbacksObject(i), isolate); 4408 Handle<Object> value(descs->GetCallbacksObject(i), isolate);
4398 PropertyDetails d(details.attributes(), CALLBACKS, i + 1); 4409 PropertyDetails d(details.attributes(), CALLBACKS, i + 1);
4399 dictionary = NameDictionary::Add(dictionary, key, value, d); 4410 dictionary = NameDictionary::Add(dictionary, key, value, d);
4400 break; 4411 break;
4401 } 4412 }
4402 } 4413 }
4403 } 4414 }
4404 4415
4405 // Copy the next enumeration index from instance descriptor. 4416 // Copy the next enumeration index from instance descriptor.
4406 dictionary->SetNextEnumerationIndex(real_size + 1); 4417 dictionary->SetNextEnumerationIndex(real_size + 1);
(...skipping 2650 matching lines...) Expand 10 before | Expand all | Expand 10 after
7057 switch (details.type()) { 7068 switch (details.type()) {
7058 case FIELD: 7069 case FIELD:
7059 return value->FitsRepresentation(details.representation()) && 7070 return value->FitsRepresentation(details.representation()) &&
7060 GetFieldType(descriptor)->NowContains(value); 7071 GetFieldType(descriptor)->NowContains(value);
7061 7072
7062 case CONSTANT: 7073 case CONSTANT:
7063 DCHECK(GetConstant(descriptor) != value || 7074 DCHECK(GetConstant(descriptor) != value ||
7064 value->FitsRepresentation(details.representation())); 7075 value->FitsRepresentation(details.representation()));
7065 return GetConstant(descriptor) == value; 7076 return GetConstant(descriptor) == value;
7066 7077
7078 case ACCESSOR_FIELD:
7067 case CALLBACKS: 7079 case CALLBACKS:
7068 return false; 7080 return false;
7069 } 7081 }
7070 7082
7071 UNREACHABLE(); 7083 UNREACHABLE();
7072 return false; 7084 return false;
7073 } 7085 }
7074 7086
7075 7087
7076 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor, 7088 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
7182 ? KEEP_INOBJECT_PROPERTIES 7194 ? KEEP_INOBJECT_PROPERTIES
7183 : CLEAR_INOBJECT_PROPERTIES; 7195 : CLEAR_INOBJECT_PROPERTIES;
7184 7196
7185 int index = map->SearchTransition(ACCESSOR, *name, attributes); 7197 int index = map->SearchTransition(ACCESSOR, *name, attributes);
7186 if (index != TransitionArray::kNotFound) { 7198 if (index != TransitionArray::kNotFound) {
7187 Handle<Map> transition(map->GetTransition(index)); 7199 Handle<Map> transition(map->GetTransition(index));
7188 DescriptorArray* descriptors = transition->instance_descriptors(); 7200 DescriptorArray* descriptors = transition->instance_descriptors();
7189 int descriptor = transition->LastAdded(); 7201 int descriptor = transition->LastAdded();
7190 DCHECK(descriptors->GetKey(descriptor)->Equals(*name)); 7202 DCHECK(descriptors->GetKey(descriptor)->Equals(*name));
7191 7203
7192 DCHECK_EQ(CALLBACKS, descriptors->GetDetails(descriptor).type()); 7204 DCHECK_EQ(ACCESSOR, descriptors->GetDetails(descriptor).kind());
7193 DCHECK_EQ(attributes, descriptors->GetDetails(descriptor).attributes()); 7205 DCHECK_EQ(attributes, descriptors->GetDetails(descriptor).attributes());
7194 7206
7195 Handle<Object> maybe_pair(descriptors->GetValue(descriptor), isolate); 7207 Handle<Object> maybe_pair(descriptors->GetValue(descriptor), isolate);
7196 if (!maybe_pair->IsAccessorPair()) { 7208 if (!maybe_pair->IsAccessorPair()) {
7197 return Map::Normalize(map, mode, "TransitionToAccessorFromNonPair"); 7209 return Map::Normalize(map, mode, "TransitionToAccessorFromNonPair");
7198 } 7210 }
7199 7211
7200 Handle<AccessorPair> pair = Handle<AccessorPair>::cast(maybe_pair); 7212 Handle<AccessorPair> pair = Handle<AccessorPair>::cast(maybe_pair);
7201 if (pair->get(component) != *accessor) { 7213 if (pair->get(component) != *accessor) {
7202 return Map::Normalize(map, mode, "TransitionToDifferentAccessor"); 7214 return Map::Normalize(map, mode, "TransitionToDifferentAccessor");
(...skipping 9700 matching lines...) Expand 10 before | Expand all | Expand 10 after
16903 Handle<DependentCode> codes = 16915 Handle<DependentCode> codes =
16904 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16916 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16905 DependentCode::kPropertyCellChangedGroup, 16917 DependentCode::kPropertyCellChangedGroup,
16906 info->object_wrapper()); 16918 info->object_wrapper());
16907 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16919 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16908 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16920 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16909 cell, info->zone()); 16921 cell, info->zone());
16910 } 16922 }
16911 16923
16912 } } // namespace v8::internal 16924 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lookup-inl.h ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698