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

Side by Side Diff: src/map-updater.cc

Issue 2624903003: [runtime] Use PropertyKind/PropertyLocation instead of PropertyType. (Closed)
Patch Set: Addressing comments 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/lookup.cc ('k') | src/objects.h » ('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 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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/map-updater.h" 5 #include "src/map-updater.h"
6 6
7 #include "src/field-type.h" 7 #include "src/field-type.h"
8 #include "src/handles.h" 8 #include "src/handles.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/objects-inl.h" 10 #include "src/objects-inl.h"
11 #include "src/objects.h" 11 #include "src/objects.h"
12 #include "src/transitions.h" 12 #include "src/transitions.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 namespace { 17 namespace {
18 18
19 inline bool EqualImmutableValues(Object* obj1, Object* obj2) { 19 inline bool EqualImmutableValues(Object* obj1, Object* obj2) {
20 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds. 20 if (obj1 == obj2) return true; // Valid for both kData and kAccessor kinds.
21 // TODO(ishell): compare AccessorPairs. 21 // TODO(ishell): compare AccessorPairs.
22 return false; 22 return false;
23 } 23 }
24 24
25 inline bool LocationFitsInto(PropertyLocation what, PropertyLocation where) {
26 return where == kField || what == kDescriptor;
27 }
28
25 } // namespace 29 } // namespace
26 30
27 Name* MapUpdater::GetKey(int descriptor) const { 31 Name* MapUpdater::GetKey(int descriptor) const {
28 return old_descriptors_->GetKey(descriptor); 32 return old_descriptors_->GetKey(descriptor);
29 } 33 }
30 34
31 PropertyDetails MapUpdater::GetDetails(int descriptor) const { 35 PropertyDetails MapUpdater::GetDetails(int descriptor) const {
32 DCHECK_LE(0, descriptor); 36 DCHECK_LE(0, descriptor);
33 if (descriptor == modified_descriptor_) { 37 if (descriptor == modified_descriptor_) {
34 return PropertyDetails(new_kind_, new_attributes_, new_location_, 38 return PropertyDetails(new_kind_, new_attributes_, new_location_,
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 // Check if target map is incompatible. 273 // Check if target map is incompatible.
270 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i); 274 PropertyDetails tmp_details = tmp_descriptors->GetDetails(i);
271 DCHECK_EQ(old_details.kind(), tmp_details.kind()); 275 DCHECK_EQ(old_details.kind(), tmp_details.kind());
272 DCHECK_EQ(old_details.attributes(), tmp_details.attributes()); 276 DCHECK_EQ(old_details.attributes(), tmp_details.attributes());
273 if (old_details.kind() == kAccessor && 277 if (old_details.kind() == kAccessor &&
274 !EqualImmutableValues(GetValue(i), tmp_descriptors->GetValue(i))) { 278 !EqualImmutableValues(GetValue(i), tmp_descriptors->GetValue(i))) {
275 // TODO(ishell): mutable accessors are not implemented yet. 279 // TODO(ishell): mutable accessors are not implemented yet.
276 return CopyGeneralizeAllRepresentations("GenAll_Incompatible"); 280 return CopyGeneralizeAllRepresentations("GenAll_Incompatible");
277 } 281 }
278 // Check if old location fits into tmp location. 282 // Check if old location fits into tmp location.
279 if (old_details.location() == kField && 283 if (!LocationFitsInto(old_details.location(), tmp_details.location())) {
280 tmp_details.location() == kDescriptor) {
281 break; 284 break;
282 } 285 }
283 286
284 // Check if old representation fits into tmp representation. 287 // Check if old representation fits into tmp representation.
285 Representation tmp_representation = tmp_details.representation(); 288 Representation tmp_representation = tmp_details.representation();
286 if (!old_details.representation().fits_into(tmp_representation)) { 289 if (!old_details.representation().fits_into(tmp_representation)) {
287 break; 290 break;
288 } 291 }
289 292
290 if (tmp_details.location() == kField) { 293 if (tmp_details.location() == kField) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 569
567 if (FLAG_trace_generalization && modified_descriptor_ >= 0) { 570 if (FLAG_trace_generalization && modified_descriptor_ >= 0) {
568 PropertyDetails old_details = 571 PropertyDetails old_details =
569 old_descriptors_->GetDetails(modified_descriptor_); 572 old_descriptors_->GetDetails(modified_descriptor_);
570 PropertyDetails new_details = 573 PropertyDetails new_details =
571 new_descriptors->GetDetails(modified_descriptor_); 574 new_descriptors->GetDetails(modified_descriptor_);
572 MaybeHandle<FieldType> old_field_type; 575 MaybeHandle<FieldType> old_field_type;
573 MaybeHandle<FieldType> new_field_type; 576 MaybeHandle<FieldType> new_field_type;
574 MaybeHandle<Object> old_value; 577 MaybeHandle<Object> old_value;
575 MaybeHandle<Object> new_value; 578 MaybeHandle<Object> new_value;
576 if (old_details.type() == DATA) { 579 if (old_details.location() == kField) {
577 old_field_type = handle( 580 old_field_type = handle(
578 old_descriptors_->GetFieldType(modified_descriptor_), isolate_); 581 old_descriptors_->GetFieldType(modified_descriptor_), isolate_);
579 } else { 582 } else {
580 old_value = 583 old_value =
581 handle(old_descriptors_->GetValue(modified_descriptor_), isolate_); 584 handle(old_descriptors_->GetValue(modified_descriptor_), isolate_);
582 } 585 }
583 if (new_details.type() == DATA) { 586 if (new_details.location() == kField) {
584 new_field_type = 587 new_field_type =
585 handle(new_descriptors->GetFieldType(modified_descriptor_), isolate_); 588 handle(new_descriptors->GetFieldType(modified_descriptor_), isolate_);
586 } else { 589 } else {
587 new_value = 590 new_value =
588 handle(new_descriptors->GetValue(modified_descriptor_), isolate_); 591 handle(new_descriptors->GetValue(modified_descriptor_), isolate_);
589 } 592 }
590 593
591 old_map_->PrintGeneralization( 594 old_map_->PrintGeneralization(
592 stdout, "", modified_descriptor_, split_nof, old_nof_, 595 stdout, "", modified_descriptor_, split_nof, old_nof_,
593 old_details.location() == kDescriptor && new_location_ == kField, 596 old_details.location() == kDescriptor && new_location_ == kField,
(...skipping 12 matching lines...) Expand all
606 // the new descriptors to maintain descriptors sharing invariant. 609 // the new descriptors to maintain descriptors sharing invariant.
607 split_map->ReplaceDescriptors(*new_descriptors, *new_layout_descriptor); 610 split_map->ReplaceDescriptors(*new_descriptors, *new_layout_descriptor);
608 611
609 result_map_ = new_map; 612 result_map_ = new_map;
610 state_ = kEnd; 613 state_ = kEnd;
611 return state_; // Done. 614 return state_; // Done.
612 } 615 }
613 616
614 } // namespace internal 617 } // namespace internal
615 } // namespace v8 618 } // namespace v8
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698