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

Side by Side Diff: src/objects.cc

Issue 1522413002: [field type tracking] Fix handling of cleared WeakCells. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Created 5 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 | « no previous file | src/objects-debug.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 "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 3028 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 details.representation().IsNone()); 3039 details.representation().IsNone());
3040 3040
3041 // Skip if already updated the shared descriptor. 3041 // Skip if already updated the shared descriptor.
3042 if (instance_descriptors()->GetValue(descriptor) == *new_wrapped_type) return; 3042 if (instance_descriptors()->GetValue(descriptor) == *new_wrapped_type) return;
3043 DataDescriptor d(name, instance_descriptors()->GetFieldIndex(descriptor), 3043 DataDescriptor d(name, instance_descriptors()->GetFieldIndex(descriptor),
3044 new_wrapped_type, details.attributes(), new_representation); 3044 new_wrapped_type, details.attributes(), new_representation);
3045 instance_descriptors()->Replace(descriptor, &d); 3045 instance_descriptors()->Replace(descriptor, &d);
3046 } 3046 }
3047 3047
3048 3048
3049 bool FieldTypeIsCleared(Representation rep, Handle<HeapType> type) { 3049 bool FieldTypeIsCleared(Representation rep, HeapType* type) {
3050 return type->Is(HeapType::None()) && rep.IsHeapObject(); 3050 return type->Is(HeapType::None()) && rep.IsHeapObject();
3051 } 3051 }
3052 3052
3053 3053
3054 // static 3054 // static
3055 Handle<HeapType> Map::GeneralizeFieldType(Representation rep1, 3055 Handle<HeapType> Map::GeneralizeFieldType(Representation rep1,
3056 Handle<HeapType> type1, 3056 Handle<HeapType> type1,
3057 Representation rep2, 3057 Representation rep2,
3058 Handle<HeapType> type2, 3058 Handle<HeapType> type2,
3059 Isolate* isolate) { 3059 Isolate* isolate) {
3060 // Cleared field types need special treatment. They represent lost knowledge, 3060 // Cleared field types need special treatment. They represent lost knowledge,
3061 // so we must be conservative, so their generalization with any other type 3061 // so we must be conservative, so their generalization with any other type
3062 // is "Any". 3062 // is "Any".
3063 if (FieldTypeIsCleared(rep1, type1) || FieldTypeIsCleared(rep2, type2)) { 3063 if (FieldTypeIsCleared(rep1, *type1) || FieldTypeIsCleared(rep2, *type2)) {
3064 return HeapType::Any(isolate); 3064 return HeapType::Any(isolate);
3065 } 3065 }
3066 if (type1->NowIs(type2)) return type2; 3066 if (type1->NowIs(type2)) return type2;
3067 if (type2->NowIs(type1)) return type1; 3067 if (type2->NowIs(type1)) return type1;
3068 return HeapType::Any(isolate); 3068 return HeapType::Any(isolate);
3069 } 3069 }
3070 3070
3071 3071
3072 // static 3072 // static
3073 void Map::GeneralizeFieldType(Handle<Map> map, int modify_index, 3073 void Map::GeneralizeFieldType(Handle<Map> map, int modify_index,
3074 Representation new_representation, 3074 Representation new_representation,
3075 Handle<HeapType> new_field_type) { 3075 Handle<HeapType> new_field_type) {
3076 Isolate* isolate = map->GetIsolate(); 3076 Isolate* isolate = map->GetIsolate();
3077 3077
3078 // Check if we actually need to generalize the field type at all. 3078 // Check if we actually need to generalize the field type at all.
3079 Handle<DescriptorArray> old_descriptors(map->instance_descriptors(), isolate); 3079 Handle<DescriptorArray> old_descriptors(map->instance_descriptors(), isolate);
3080 Representation old_representation = 3080 Representation old_representation =
3081 old_descriptors->GetDetails(modify_index).representation(); 3081 old_descriptors->GetDetails(modify_index).representation();
3082 Handle<HeapType> old_field_type(old_descriptors->GetFieldType(modify_index), 3082 Handle<HeapType> old_field_type(old_descriptors->GetFieldType(modify_index),
3083 isolate); 3083 isolate);
3084 3084
3085 if (old_representation.Equals(new_representation) && 3085 if (old_representation.Equals(new_representation) &&
3086 !FieldTypeIsCleared(new_representation, new_field_type) && 3086 !FieldTypeIsCleared(new_representation, *new_field_type) &&
3087 // Checking old_field_type for being cleared is not necessary because 3087 // Checking old_field_type for being cleared is not necessary because
3088 // the NowIs check below would fail anyway in that case. 3088 // the NowIs check below would fail anyway in that case.
3089 new_field_type->NowIs(old_field_type)) { 3089 new_field_type->NowIs(old_field_type)) {
3090 DCHECK(Map::GeneralizeFieldType(old_representation, old_field_type, 3090 DCHECK(Map::GeneralizeFieldType(old_representation, old_field_type,
3091 new_representation, new_field_type, isolate) 3091 new_representation, new_field_type, isolate)
3092 ->NowIs(old_field_type)); 3092 ->NowIs(old_field_type));
3093 return; 3093 return;
3094 } 3094 }
3095 3095
3096 // Determine the field owner. 3096 // Determine the field owner.
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3728 3728
3729 PropertyDetails new_details = new_descriptors->GetDetails(i); 3729 PropertyDetails new_details = new_descriptors->GetDetails(i);
3730 DCHECK_EQ(old_details.kind(), new_details.kind()); 3730 DCHECK_EQ(old_details.kind(), new_details.kind());
3731 DCHECK_EQ(old_details.attributes(), new_details.attributes()); 3731 DCHECK_EQ(old_details.attributes(), new_details.attributes());
3732 if (!old_details.representation().fits_into(new_details.representation())) { 3732 if (!old_details.representation().fits_into(new_details.representation())) {
3733 return MaybeHandle<Map>(); 3733 return MaybeHandle<Map>();
3734 } 3734 }
3735 switch (new_details.type()) { 3735 switch (new_details.type()) {
3736 case DATA: { 3736 case DATA: {
3737 HeapType* new_type = new_descriptors->GetFieldType(i); 3737 HeapType* new_type = new_descriptors->GetFieldType(i);
3738 // Cleared field types need special treatment. They represent lost
3739 // knowledge, so we must first generalize the old_type to "Any".
3740 if (!FieldTypeIsCleared(new_details.representation(), new_type)) {
3741 return MaybeHandle<Map>();
3742 }
3738 PropertyType old_property_type = old_details.type(); 3743 PropertyType old_property_type = old_details.type();
3739 if (old_property_type == DATA) { 3744 if (old_property_type == DATA) {
3740 HeapType* old_type = old_descriptors->GetFieldType(i); 3745 HeapType* old_type = old_descriptors->GetFieldType(i);
3741 if (!old_type->NowIs(new_type)) { 3746 if (FieldTypeIsCleared(old_details.representation(), old_type) ||
3747 !old_type->NowIs(new_type)) {
3742 return MaybeHandle<Map>(); 3748 return MaybeHandle<Map>();
3743 } 3749 }
3744 } else { 3750 } else {
3745 DCHECK(old_property_type == DATA_CONSTANT); 3751 DCHECK(old_property_type == DATA_CONSTANT);
3746 Object* old_value = old_descriptors->GetValue(i); 3752 Object* old_value = old_descriptors->GetValue(i);
3747 if (!new_type->NowContains(old_value)) { 3753 if (!new_type->NowContains(old_value)) {
3748 return MaybeHandle<Map>(); 3754 return MaybeHandle<Map>();
3749 } 3755 }
3750 } 3756 }
3751 break; 3757 break;
(...skipping 15560 matching lines...) Expand 10 before | Expand all | Expand 10 after
19312 if (cell->value() != *new_value) { 19318 if (cell->value() != *new_value) {
19313 cell->set_value(*new_value); 19319 cell->set_value(*new_value);
19314 Isolate* isolate = cell->GetIsolate(); 19320 Isolate* isolate = cell->GetIsolate();
19315 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19321 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19316 isolate, DependentCode::kPropertyCellChangedGroup); 19322 isolate, DependentCode::kPropertyCellChangedGroup);
19317 } 19323 }
19318 } 19324 }
19319 19325
19320 } // namespace internal 19326 } // namespace internal
19321 } // namespace v8 19327 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698