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) {
jsgraph()->Constant(native_context().promise_function());
// Allocate shared context for the closures below.
context = etrue =
graph()->NewNode(javascript()->CreateFunctionContext(
native_context().scope_info(),
PromiseBuiltins::kPromiseFinallyContextLength -
Context::MIN_CONTEXT_SLOTS,
FUNCTION_SCOPE),
context, etrue, if_true);
context = etrue = graph()->NewNode(
javascript()->CreateFunctionContext(
native_context().scope_info(),
int{PromiseBuiltins::kPromiseFinallyContextLength} -
Context::MIN_CONTEXT_SLOTS,
FUNCTION_SCOPE),
context, etrue, if_true);
etrue = graph()->NewNode(
simplified()->StoreField(
AccessBuilder::ForContextSlot(PromiseBuiltins::kOnFinallySlot)),
......
......@@ -107,10 +107,9 @@ class ObjectStats {
// ObjectStats are kept in two arrays, counts and sizes. Related stats are
// stored in a contiguous linear buffer. Stats groups are stored one after
// another.
enum {
FIRST_VIRTUAL_TYPE = LAST_TYPE + 1,
OBJECT_STATS_COUNT = FIRST_VIRTUAL_TYPE + LAST_VIRTUAL_TYPE + 1,
};
static constexpr int FIRST_VIRTUAL_TYPE = LAST_TYPE + 1;
static constexpr int OBJECT_STATS_COUNT =
FIRST_VIRTUAL_TYPE + LAST_VIRTUAL_TYPE + 1;
void ClearObjectStats(bool clear_last_time_stats = false);
......
......@@ -676,7 +676,7 @@ class Context : public TorqueGeneratedContext<Context, HeapObject> {
static int ArrayMapIndex(ElementsKind 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;
......
......@@ -1571,7 +1571,7 @@ class DictionaryElementsAccessor
if (filter != ALL_PROPERTIES) {
PropertyDetails details = dictionary.DetailsAt(entry);
PropertyAttributes attr = details.attributes();
if ((attr & filter) != 0) return InternalIndex::NotFound();
if ((int{attr} & filter) != 0) return InternalIndex::NotFound();
}
return entry;
}
......@@ -1592,7 +1592,7 @@ class DictionaryElementsAccessor
DCHECK_LE(raw_key.Number(), kMaxUInt32);
PropertyDetails details = dictionary->DetailsAt(entry);
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());
}
......
......@@ -758,7 +758,7 @@ base::Optional<int> CollectOwnPropertyNamesInternal(
bool is_shadowing_key = false;
PropertyDetails details = descs->GetDetails(i);
if ((details.attributes() & filter) != 0) {
if ((int{details.attributes()} & filter) != 0) {
if (mode == KeyCollectionMode::kIncludePrototypes) {
is_shadowing_key = true;
} else {
......@@ -918,7 +918,7 @@ ExceptionStatus CollectKeysFromDictionary(Handle<Dictionary> dictionary,
if (!raw_dictionary.ToKey(roots, i, &key)) continue;
if (key.FilterKey(filter)) continue;
PropertyDetails details = raw_dictionary.DetailsAt(i);
if ((details.attributes() & filter) != 0) {
if ((int{details.attributes()} & filter) != 0) {
AllowGarbageCollection gc;
// This might allocate, but {key} is not used afterwards.
keys->AddShadowingKey(key, &gc);
......
......@@ -1083,7 +1083,7 @@ int Map::NumberOfEnumerableProperties() const {
int result = 0;
DescriptorArray descs = instance_descriptors(kRelaxedLoad);
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)) {
result++;
}
......
......@@ -6256,7 +6256,7 @@ int Dictionary<Derived, Shape>::NumberOfEnumerableProperties() {
if (k.FilterKey(ENUMERABLE_STRINGS)) continue;
PropertyDetails details = this->DetailsAt(i);
PropertyAttributes attr = details.attributes();
if ((attr & ONLY_ENUMERABLE) == 0) result++;
if ((int{attr} & ONLY_ENUMERABLE) == 0) result++;
}
return result;
}
......
......@@ -260,7 +260,7 @@ int SwissNameDictionary::NumberOfEnumerableProperties() {
if (k.FilterKey(ENUMERABLE_STRINGS)) continue;
PropertyDetails details = this->DetailsAt(i);
PropertyAttributes attr = details.attributes();
if ((attr & ONLY_ENUMERABLE) == 0) result++;
if ((int{attr} & ONLY_ENUMERABLE) == 0) result++;
}
return result;
}
......
......@@ -1147,7 +1147,7 @@ int Deserializer<IsolateT>::ReadSingleBytecodeData(byte data,
}
// Advance to the end of the code object.
return (Code::kDataStart - HeapObject::kHeaderSize) / kTaggedSize +
return (int{Code::kDataStart} - HeapObject::kHeaderSize) / kTaggedSize +
size_in_tagged;
}
......
......@@ -1079,9 +1079,11 @@ class CodeGeneratorTester {
#if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_S390) || \
defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_PPC64)
// 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)
bool supported = ((push_type & CodeGenerator::kScalarPush) == push_type);
bool supported =
((int{push_type} & CodeGenerator::kScalarPush) == push_type);
#else
bool supported = false;
#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