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 <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 3263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3274 result = parent; | 3274 result = parent; |
3275 } | 3275 } |
3276 return result; | 3276 return result; |
3277 } | 3277 } |
3278 | 3278 |
3279 | 3279 |
3280 void Map::UpdateFieldType(int descriptor, Handle<Name> name, | 3280 void Map::UpdateFieldType(int descriptor, Handle<Name> name, |
3281 Representation new_representation, | 3281 Representation new_representation, |
3282 Handle<Object> new_wrapped_type) { | 3282 Handle<Object> new_wrapped_type) { |
3283 DCHECK(new_wrapped_type->IsSmi() || new_wrapped_type->IsWeakCell()); | 3283 DCHECK(new_wrapped_type->IsSmi() || new_wrapped_type->IsWeakCell()); |
| 3284 // We store raw pointers in the queue, so no allocations are allowed. |
3284 DisallowHeapAllocation no_allocation; | 3285 DisallowHeapAllocation no_allocation; |
3285 PropertyDetails details = instance_descriptors()->GetDetails(descriptor); | 3286 PropertyDetails details = instance_descriptors()->GetDetails(descriptor); |
3286 if (details.type() != DATA) return; | 3287 if (details.type() != DATA) return; |
3287 Object* transitions = raw_transitions(); | 3288 |
3288 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 3289 Zone zone(GetIsolate()->allocator()); |
3289 for (int i = 0; i < num_transitions; ++i) { | 3290 ZoneQueue<Map*> backlog(&zone); |
3290 Map* target = TransitionArray::GetTarget(transitions, i); | 3291 backlog.push(this); |
3291 target->UpdateFieldType(descriptor, name, new_representation, | 3292 |
3292 new_wrapped_type); | 3293 while (!backlog.empty()) { |
| 3294 Map* current = backlog.front(); |
| 3295 backlog.pop(); |
| 3296 |
| 3297 Object* transitions = current->raw_transitions(); |
| 3298 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
| 3299 for (int i = 0; i < num_transitions; ++i) { |
| 3300 Map* target = TransitionArray::GetTarget(transitions, i); |
| 3301 backlog.push(target); |
| 3302 } |
| 3303 DescriptorArray* descriptors = current->instance_descriptors(); |
| 3304 PropertyDetails details = descriptors->GetDetails(descriptor); |
| 3305 |
| 3306 // It is allowed to change representation here only from None to something. |
| 3307 DCHECK(details.representation().Equals(new_representation) || |
| 3308 details.representation().IsNone()); |
| 3309 |
| 3310 // Skip if already updated the shared descriptor. |
| 3311 if (descriptors->GetValue(descriptor) != *new_wrapped_type) { |
| 3312 DataDescriptor d(name, descriptors->GetFieldIndex(descriptor), |
| 3313 new_wrapped_type, details.attributes(), |
| 3314 new_representation); |
| 3315 descriptors->Replace(descriptor, &d); |
| 3316 } |
3293 } | 3317 } |
3294 // It is allowed to change representation here only from None to something. | |
3295 DCHECK(details.representation().Equals(new_representation) || | |
3296 details.representation().IsNone()); | |
3297 | |
3298 // Skip if already updated the shared descriptor. | |
3299 if (instance_descriptors()->GetValue(descriptor) == *new_wrapped_type) return; | |
3300 DataDescriptor d(name, instance_descriptors()->GetFieldIndex(descriptor), | |
3301 new_wrapped_type, details.attributes(), new_representation); | |
3302 instance_descriptors()->Replace(descriptor, &d); | |
3303 } | 3318 } |
3304 | 3319 |
3305 bool FieldTypeIsCleared(Representation rep, FieldType* type) { | 3320 bool FieldTypeIsCleared(Representation rep, FieldType* type) { |
3306 return type->IsNone() && rep.IsHeapObject(); | 3321 return type->IsNone() && rep.IsHeapObject(); |
3307 } | 3322 } |
3308 | 3323 |
3309 | 3324 |
3310 // static | 3325 // static |
3311 Handle<FieldType> Map::GeneralizeFieldType(Representation rep1, | 3326 Handle<FieldType> Map::GeneralizeFieldType(Representation rep1, |
3312 Handle<FieldType> type1, | 3327 Handle<FieldType> type1, |
(...skipping 16048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
19361 if (cell->value() != *new_value) { | 19376 if (cell->value() != *new_value) { |
19362 cell->set_value(*new_value); | 19377 cell->set_value(*new_value); |
19363 Isolate* isolate = cell->GetIsolate(); | 19378 Isolate* isolate = cell->GetIsolate(); |
19364 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19379 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19365 isolate, DependentCode::kPropertyCellChangedGroup); | 19380 isolate, DependentCode::kPropertyCellChangedGroup); |
19366 } | 19381 } |
19367 } | 19382 } |
19368 | 19383 |
19369 } // namespace internal | 19384 } // namespace internal |
19370 } // namespace v8 | 19385 } // namespace v8 |
OLD | NEW |