Commit cb222018 authored by Peter Kasting's avatar Peter Kasting Committed by V8 LUCI CQ

Avoid math with disparate enums.

This is deprecated in C++20.  Use constexprs and explicit casts to work
around.

Bug: chromium:1284275
Change-Id: I6a3974f3c678cb797081938622036a12a99c5d1b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3630349
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80392}
parent 08348dba
...@@ -6996,13 +6996,13 @@ Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) { ...@@ -6996,13 +6996,13 @@ Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) {
jsgraph()->Constant(native_context().promise_function()); jsgraph()->Constant(native_context().promise_function());
// Allocate shared context for the closures below. // Allocate shared context for the closures below.
context = etrue = context = etrue = graph()->NewNode(
graph()->NewNode(javascript()->CreateFunctionContext( javascript()->CreateFunctionContext(
native_context().scope_info(), native_context().scope_info(),
PromiseBuiltins::kPromiseFinallyContextLength - int{PromiseBuiltins::kPromiseFinallyContextLength} -
Context::MIN_CONTEXT_SLOTS, Context::MIN_CONTEXT_SLOTS,
FUNCTION_SCOPE), FUNCTION_SCOPE),
context, etrue, if_true); context, etrue, if_true);
etrue = graph()->NewNode( etrue = graph()->NewNode(
simplified()->StoreField( simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kOnFinallySlot)), AccessBuilder::ForContextSlot(PromiseBuiltins::kOnFinallySlot)),
......
...@@ -107,10 +107,9 @@ class ObjectStats { ...@@ -107,10 +107,9 @@ class ObjectStats {
// ObjectStats are kept in two arrays, counts and sizes. Related stats are // ObjectStats are kept in two arrays, counts and sizes. Related stats are
// stored in a contiguous linear buffer. Stats groups are stored one after // stored in a contiguous linear buffer. Stats groups are stored one after
// another. // another.
enum { static constexpr int FIRST_VIRTUAL_TYPE = LAST_TYPE + 1;
FIRST_VIRTUAL_TYPE = LAST_TYPE + 1, static constexpr int OBJECT_STATS_COUNT =
OBJECT_STATS_COUNT = FIRST_VIRTUAL_TYPE + LAST_VIRTUAL_TYPE + 1, FIRST_VIRTUAL_TYPE + LAST_VIRTUAL_TYPE + 1;
};
void ClearObjectStats(bool clear_last_time_stats = false); void ClearObjectStats(bool clear_last_time_stats = false);
......
...@@ -676,7 +676,7 @@ class Context : public TorqueGeneratedContext<Context, HeapObject> { ...@@ -676,7 +676,7 @@ class Context : public TorqueGeneratedContext<Context, HeapObject> {
static int ArrayMapIndex(ElementsKind elements_kind) { static int ArrayMapIndex(ElementsKind elements_kind) {
DCHECK(IsFastElementsKind(elements_kind)); DCHECK(IsFastElementsKind(elements_kind));
return elements_kind + FIRST_JS_ARRAY_MAP_SLOT; return int{elements_kind} + FIRST_JS_ARRAY_MAP_SLOT;
} }
inline Map GetInitialJSArrayMap(ElementsKind kind) const; inline Map GetInitialJSArrayMap(ElementsKind kind) const;
......
...@@ -1571,7 +1571,7 @@ class DictionaryElementsAccessor ...@@ -1571,7 +1571,7 @@ class DictionaryElementsAccessor
if (filter != ALL_PROPERTIES) { if (filter != ALL_PROPERTIES) {
PropertyDetails details = dictionary.DetailsAt(entry); PropertyDetails details = dictionary.DetailsAt(entry);
PropertyAttributes attr = details.attributes(); PropertyAttributes attr = details.attributes();
if ((attr & filter) != 0) return InternalIndex::NotFound(); if ((int{attr} & filter) != 0) return InternalIndex::NotFound();
} }
return entry; return entry;
} }
...@@ -1592,7 +1592,7 @@ class DictionaryElementsAccessor ...@@ -1592,7 +1592,7 @@ class DictionaryElementsAccessor
DCHECK_LE(raw_key.Number(), kMaxUInt32); DCHECK_LE(raw_key.Number(), kMaxUInt32);
PropertyDetails details = dictionary->DetailsAt(entry); PropertyDetails details = dictionary->DetailsAt(entry);
PropertyAttributes attr = details.attributes(); PropertyAttributes attr = details.attributes();
if ((attr & filter) != 0) return kMaxUInt32; if ((int{attr} & filter) != 0) return kMaxUInt32;
return static_cast<uint32_t>(raw_key.Number()); return static_cast<uint32_t>(raw_key.Number());
} }
......
...@@ -758,7 +758,7 @@ base::Optional<int> CollectOwnPropertyNamesInternal( ...@@ -758,7 +758,7 @@ base::Optional<int> CollectOwnPropertyNamesInternal(
bool is_shadowing_key = false; bool is_shadowing_key = false;
PropertyDetails details = descs->GetDetails(i); PropertyDetails details = descs->GetDetails(i);
if ((details.attributes() & filter) != 0) { if ((int{details.attributes()} & filter) != 0) {
if (mode == KeyCollectionMode::kIncludePrototypes) { if (mode == KeyCollectionMode::kIncludePrototypes) {
is_shadowing_key = true; is_shadowing_key = true;
} else { } else {
...@@ -918,7 +918,7 @@ ExceptionStatus CollectKeysFromDictionary(Handle<Dictionary> dictionary, ...@@ -918,7 +918,7 @@ ExceptionStatus CollectKeysFromDictionary(Handle<Dictionary> dictionary,
if (!raw_dictionary.ToKey(roots, i, &key)) continue; if (!raw_dictionary.ToKey(roots, i, &key)) continue;
if (key.FilterKey(filter)) continue; if (key.FilterKey(filter)) continue;
PropertyDetails details = raw_dictionary.DetailsAt(i); PropertyDetails details = raw_dictionary.DetailsAt(i);
if ((details.attributes() & filter) != 0) { if ((int{details.attributes()} & filter) != 0) {
AllowGarbageCollection gc; AllowGarbageCollection gc;
// This might allocate, but {key} is not used afterwards. // This might allocate, but {key} is not used afterwards.
keys->AddShadowingKey(key, &gc); keys->AddShadowingKey(key, &gc);
......
...@@ -1083,7 +1083,7 @@ int Map::NumberOfEnumerableProperties() const { ...@@ -1083,7 +1083,7 @@ int Map::NumberOfEnumerableProperties() const {
int result = 0; int result = 0;
DescriptorArray descs = instance_descriptors(kRelaxedLoad); DescriptorArray descs = instance_descriptors(kRelaxedLoad);
for (InternalIndex i : IterateOwnDescriptors()) { for (InternalIndex i : IterateOwnDescriptors()) {
if ((descs.GetDetails(i).attributes() & ONLY_ENUMERABLE) == 0 && if ((int{descs.GetDetails(i).attributes()} & ONLY_ENUMERABLE) == 0 &&
!descs.GetKey(i).FilterKey(ENUMERABLE_STRINGS)) { !descs.GetKey(i).FilterKey(ENUMERABLE_STRINGS)) {
result++; result++;
} }
......
...@@ -6256,7 +6256,7 @@ int Dictionary<Derived, Shape>::NumberOfEnumerableProperties() { ...@@ -6256,7 +6256,7 @@ int Dictionary<Derived, Shape>::NumberOfEnumerableProperties() {
if (k.FilterKey(ENUMERABLE_STRINGS)) continue; if (k.FilterKey(ENUMERABLE_STRINGS)) continue;
PropertyDetails details = this->DetailsAt(i); PropertyDetails details = this->DetailsAt(i);
PropertyAttributes attr = details.attributes(); PropertyAttributes attr = details.attributes();
if ((attr & ONLY_ENUMERABLE) == 0) result++; if ((int{attr} & ONLY_ENUMERABLE) == 0) result++;
} }
return result; return result;
} }
......
...@@ -260,7 +260,7 @@ int SwissNameDictionary::NumberOfEnumerableProperties() { ...@@ -260,7 +260,7 @@ int SwissNameDictionary::NumberOfEnumerableProperties() {
if (k.FilterKey(ENUMERABLE_STRINGS)) continue; if (k.FilterKey(ENUMERABLE_STRINGS)) continue;
PropertyDetails details = this->DetailsAt(i); PropertyDetails details = this->DetailsAt(i);
PropertyAttributes attr = details.attributes(); PropertyAttributes attr = details.attributes();
if ((attr & ONLY_ENUMERABLE) == 0) result++; if ((int{attr} & ONLY_ENUMERABLE) == 0) result++;
} }
return result; return result;
} }
......
...@@ -1147,7 +1147,7 @@ int Deserializer<IsolateT>::ReadSingleBytecodeData(byte data, ...@@ -1147,7 +1147,7 @@ int Deserializer<IsolateT>::ReadSingleBytecodeData(byte data,
} }
// Advance to the end of the code object. // Advance to the end of the code object.
return (Code::kDataStart - HeapObject::kHeaderSize) / kTaggedSize + return (int{Code::kDataStart} - HeapObject::kHeaderSize) / kTaggedSize +
size_in_tagged; size_in_tagged;
} }
......
...@@ -1079,9 +1079,11 @@ class CodeGeneratorTester { ...@@ -1079,9 +1079,11 @@ class CodeGeneratorTester {
#if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_S390) || \ #if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_S390) || \
defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64) defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)
// Only folding register pushes is supported on ARM. // Only folding register pushes is supported on ARM.
bool supported = ((push_type & CodeGenerator::kRegisterPush) == push_type); bool supported =
((int{push_type} & CodeGenerator::kRegisterPush) == push_type);
#elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_IA32) #elif defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_IA32)
bool supported = ((push_type & CodeGenerator::kScalarPush) == push_type); bool supported =
((int{push_type} & CodeGenerator::kScalarPush) == push_type);
#else #else
bool supported = false; bool supported = false;
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment