Skip to content

Commit 043fb91

Browse files
ngzhianV8 LUCI CQ
authored andcommitted
[cleanup] Make PropertyLocation a scoped enum
Bug: v8:12244 Change-Id: I7ea68dd74a376221631d7f56b4a012207f68a1ec Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3182899 Reviewed-by: Hannes Payer <hpayer@chromium.org> Commit-Queue: Zhi An Ng <zhin@chromium.org> Cr-Commit-Position: refs/heads/main@{#77129}
1 parent d68e518 commit 043fb91

37 files changed

Lines changed: 169 additions & 147 deletions

src/codegen/code-stub-assembler.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9347,8 +9347,9 @@ void CodeStubAssembler::LoadPropertyFromFastObject(
93479347
DecodeWord32<PropertyDetails::LocationField>(details);
93489348

93499349
Label if_in_field(this), if_in_descriptor(this), done(this);
9350-
Branch(Word32Equal(location, Int32Constant(kField)), &if_in_field,
9351-
&if_in_descriptor);
9350+
Branch(Word32Equal(location, Int32Constant(static_cast<int32_t>(
9351+
PropertyLocation::kField))),
9352+
&if_in_field, &if_in_descriptor);
93529353
BIND(&if_in_field);
93539354
{
93549355
TNode<IntPtrT> field_index =

src/compiler/access-info.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ PropertyAccessInfo AccessInfoFactory::ComputePropertyAccessInfo(
836836
// occuring before a fast mode holder on the chain.
837837
return Invalid();
838838
}
839-
if (details.location() == kField) {
839+
if (details.location() == PropertyLocation::kField) {
840840
if (details.kind() == kData) {
841841
return ComputeDataFieldAccessInfo(receiver_map, map, holder, index,
842842
access_mode);
@@ -846,7 +846,7 @@ PropertyAccessInfo AccessInfoFactory::ComputePropertyAccessInfo(
846846
return Invalid();
847847
}
848848
} else {
849-
DCHECK_EQ(kDescriptor, details.location());
849+
DCHECK_EQ(PropertyLocation::kDescriptor, details.location());
850850
DCHECK_EQ(kAccessor, details.kind());
851851
return ComputeAccessorDescriptorAccessInfo(receiver_map, name, map,
852852
holder, index, access_mode);
@@ -1130,7 +1130,7 @@ PropertyAccessInfo AccessInfoFactory::LookupTransition(
11301130
if (details.IsReadOnly()) return Invalid();
11311131

11321132
// TODO(bmeurer): Handle transition to data constant?
1133-
if (details.location() != kField) return Invalid();
1133+
if (details.location() != PropertyLocation::kField) return Invalid();
11341134

11351135
int const index = details.field_index();
11361136
Representation details_representation = details.representation();

src/compiler/heap-refs.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ bool JSObjectData::SerializeAsBoilerplateRecursive(JSHeapBroker* broker,
12721272
boilerplate->map().instance_descriptors(isolate), isolate);
12731273
for (InternalIndex i : boilerplate->map().IterateOwnDescriptors()) {
12741274
PropertyDetails details = descriptors->GetDetails(i);
1275-
if (details.location() != kField) continue;
1275+
if (details.location() != PropertyLocation::kField) continue;
12761276
DCHECK_EQ(kData, details.kind());
12771277

12781278
FieldIndex field_index = FieldIndex::ForDescriptor(boilerplate->map(), i);

src/compiler/js-create-lowering.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ base::Optional<Node*> JSCreateLowering::TryAllocateFastLiteral(
17111711
for (InternalIndex i : InternalIndex::Range(boilerplate_nof)) {
17121712
PropertyDetails const property_details =
17131713
boilerplate_map.GetPropertyDetails(i);
1714-
if (property_details.location() != kField) continue;
1714+
if (property_details.location() != PropertyLocation::kField) continue;
17151715
DCHECK_EQ(kData, property_details.kind());
17161716
if ((*max_properties)-- == 0) return {};
17171717

src/diagnostics/objects-debug.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ void JSObject::JSObjectVerify(Isolate* isolate) {
417417

418418
for (InternalIndex i : map().IterateOwnDescriptors()) {
419419
PropertyDetails details = descriptors.GetDetails(i);
420-
if (details.location() == kField) {
420+
if (details.location() == PropertyLocation::kField) {
421421
DCHECK_EQ(kData, details.kind());
422422
Representation r = details.representation();
423423
FieldIndex index = FieldIndex::ForDescriptor(map(), i);
@@ -652,7 +652,7 @@ void DescriptorArray::DescriptorArrayVerify(Isolate* isolate) {
652652
}
653653
MaybeObject value = GetValue(descriptor);
654654
HeapObject heap_object;
655-
if (details.location() == kField) {
655+
if (details.location() == PropertyLocation::kField) {
656656
CHECK_EQ(details.field_index(), expected_field_index);
657657
CHECK(
658658
value == MaybeObject::FromObject(FieldType::None()) ||

src/diagnostics/objects-printer.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,18 +295,18 @@ bool JSObject::PrintProperties(std::ostream& os) {
295295
os << ": ";
296296
PropertyDetails details = descs.GetDetails(i);
297297
switch (details.location()) {
298-
case kField: {
298+
case PropertyLocation::kField: {
299299
FieldIndex field_index = FieldIndex::ForDescriptor(map(), i);
300300
os << Brief(RawFastPropertyAt(field_index));
301301
break;
302302
}
303-
case kDescriptor:
303+
case PropertyLocation::kDescriptor:
304304
os << Brief(descs.GetStrongValue(i));
305305
break;
306306
}
307307
os << " ";
308308
details.PrintAsFastTo(os, PropertyDetails::kForProperties);
309-
if (details.location() == kField) {
309+
if (details.location() == PropertyLocation::kField) {
310310
int field_index = details.field_index();
311311
if (field_index < nof_inobject_properties) {
312312
os << ", location: in-object";
@@ -2665,12 +2665,12 @@ void DescriptorArray::PrintDescriptorDetails(std::ostream& os,
26652665
details.PrintAsFastTo(os, mode);
26662666
os << " @ ";
26672667
switch (details.location()) {
2668-
case kField: {
2668+
case PropertyLocation::kField: {
26692669
FieldType field_type = GetFieldType(descriptor);
26702670
field_type.PrintTo(os);
26712671
break;
26722672
}
2673-
case kDescriptor:
2673+
case PropertyLocation::kDescriptor:
26742674
Object value = GetStrongValue(descriptor);
26752675
os << Brief(value);
26762676
if (value.IsAccessorPair()) {

src/heap/object-stats.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ FieldStatsCollector::GetInobjectFieldStats(Map map) {
145145
DescriptorArray descriptors = map.instance_descriptors();
146146
for (InternalIndex descriptor : map.IterateOwnDescriptors()) {
147147
PropertyDetails details = descriptors.GetDetails(descriptor);
148-
if (details.location() == kField) {
148+
if (details.location() == PropertyLocation::kField) {
149149
FieldIndex index = FieldIndex::ForDescriptor(map, descriptor);
150150
// Stop on first out-of-object field.
151151
if (!index.is_inobject()) break;

src/ic/accessor-assembler.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,8 +1481,9 @@ void AccessorAssembler::OverwriteExistingFastDataProperty(
14811481
Word32Equal(DecodeWord32<PropertyDetails::KindField>(details),
14821482
Int32Constant(kData)));
14831483

1484-
Branch(Word32Equal(DecodeWord32<PropertyDetails::LocationField>(details),
1485-
Int32Constant(kField)),
1484+
Branch(Word32Equal(
1485+
DecodeWord32<PropertyDetails::LocationField>(details),
1486+
Int32Constant(static_cast<int32_t>(PropertyLocation::kField))),
14861487
&if_field, &if_descriptor);
14871488

14881489
BIND(&if_field);

src/ic/ic.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,8 @@ Handle<Object> LoadIC::ComputeHandler(LookupIterator* lookup) {
11341134
TRACE_HANDLER_STATS(isolate(), LoadIC_SlowStub);
11351135
return LoadHandler::LoadSlow(isolate());
11361136
} else {
1137-
DCHECK_EQ(kField, lookup->property_details().location());
1137+
DCHECK_EQ(PropertyLocation::kField,
1138+
lookup->property_details().location());
11381139
#if V8_ENABLE_WEBASSEMBLY
11391140
if (V8_UNLIKELY(holder->IsWasmObject(isolate()))) {
11401141
smi_handler =
@@ -1993,7 +1994,7 @@ MaybeObjectHandle StoreIC::ComputeHandler(LookupIterator* lookup) {
19931994
}
19941995

19951996
// -------------- Fields --------------
1996-
if (lookup->property_details().location() == kField) {
1997+
if (lookup->property_details().location() == PropertyLocation::kField) {
19971998
TRACE_HANDLER_STATS(isolate(), StoreIC_StoreFieldDH);
19981999
int descriptor = lookup->GetFieldDescriptorIndex();
19992000
FieldIndex index = lookup->GetFieldIndex();
@@ -2010,7 +2011,8 @@ MaybeObjectHandle StoreIC::ComputeHandler(LookupIterator* lookup) {
20102011
}
20112012

20122013
// -------------- Constant properties --------------
2013-
DCHECK_EQ(kDescriptor, lookup->property_details().location());
2014+
DCHECK_EQ(PropertyLocation::kDescriptor,
2015+
lookup->property_details().location());
20142016
set_slow_stub_reason("constant property");
20152017
TRACE_HANDLER_STATS(isolate(), StoreIC_SlowStub);
20162018
return MaybeObjectHandle(StoreHandler::StoreSlow(isolate()));

src/init/bootstrapper.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5238,7 +5238,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
52385238
from->map().instance_descriptors(isolate()), isolate());
52395239
for (InternalIndex i : from->map().IterateOwnDescriptors()) {
52405240
PropertyDetails details = descs->GetDetails(i);
5241-
if (details.location() == kField) {
5241+
if (details.location() == PropertyLocation::kField) {
52425242
if (details.kind() == kData) {
52435243
HandleScope inner(isolate());
52445244
Handle<Name> key = Handle<Name>(descs->GetKey(i), isolate());
@@ -5255,7 +5255,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
52555255
}
52565256

52575257
} else {
5258-
DCHECK_EQ(kDescriptor, details.location());
5258+
DCHECK_EQ(PropertyLocation::kDescriptor, details.location());
52595259
DCHECK_EQ(kAccessor, details.kind());
52605260
Handle<Name> key(descs->GetKey(i), isolate());
52615261
// If the property is already there we skip it.

0 commit comments

Comments
 (0)