diff --git a/runtime/vm/object.h b/runtime/vm/object.h index ce4581559c6..b77f399219e 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -291,6 +291,11 @@ class Object { using UntaggedObjectType = UntaggedObject; using ObjectPtrType = ObjectPtr; + // We use 30 bits for the hash code so hashes in a snapshot taken on a + // 64-bit architecture stay in Smi range when loaded on a 32-bit + // architecture. + static const intptr_t kHashBits = 30; + static ObjectPtr RawCast(ObjectPtr obj) { return obj; } virtual ~Object() {} @@ -5808,8 +5813,6 @@ class CodeSourceMap : public Object { class CompressedStackMaps : public Object { public: - static const intptr_t kHashBits = 30; - uintptr_t payload_size() const { return PayloadSizeOf(ptr()); } static uintptr_t PayloadSizeOf(const CompressedStackMapsPtr raw) { return UntaggedCompressedStackMaps::SizeField::decode( @@ -7623,11 +7626,6 @@ class TypeParameters : public Object { // A TypeArguments is an array of AbstractType. class TypeArguments : public Instance { public: - // We use 30 bits for the hash code so hashes in a snapshot taken on a - // 64-bit architecture stay in Smi range when loaded on a 32-bit - // architecture. - static const intptr_t kHashBits = 30; - // Hash value for a type argument vector consisting solely of dynamic types. static const intptr_t kAllDynamicHash = 1; @@ -7898,11 +7896,6 @@ class TypeArguments : public Instance { // Subclasses of AbstractType are Type and TypeParameter. class AbstractType : public Instance { public: - // We use 30 bits for the hash code so hashes in a snapshot taken on a - // 64-bit architecture stay in Smi range when loaded on a 32-bit - // architecture. - static const intptr_t kHashBits = 30; - virtual bool IsFinalized() const; virtual void SetIsFinalized() const; virtual bool IsBeingFinalized() const; @@ -9136,11 +9129,6 @@ class Symbol : public AllStatic { // String may not be '\0' terminated. class String : public Instance { public: - // We use 30 bits for the hash code so hashes in a snapshot taken on a - // 64-bit architecture stay in Smi range when loaded on a 32-bit - // architecture. - static const intptr_t kHashBits = 30; - static const intptr_t kOneByteChar = 1; static const intptr_t kTwoByteChar = 2; @@ -9990,11 +9978,6 @@ class Bool : public Instance { class Array : public Instance { public: - // We use 30 bits for the hash code so hashes in a snapshot taken on a - // 64-bit architecture stay in Smi range when loaded on a 32-bit - // architecture. - static const intptr_t kHashBits = 30; - // Returns `true` if we use card marking for arrays of length [array_length]. static bool UseCardMarkingForAllocation(const intptr_t array_length) { return Array::InstanceSize(array_length) > Heap::kNewAllocatableSize; @@ -10544,11 +10527,6 @@ class TypedDataBase : public PointerBase { class TypedData : public TypedDataBase { public: - // We use 30 bits for the hash code so hashes in a snapshot taken on a - // 64-bit architecture stay in Smi range when loaded on a 32-bit - // architecture. - static const intptr_t kHashBits = 30; - virtual bool CanonicalizeEquals(const Instance& other) const; virtual uint32_t CanonicalizeHash() const; diff --git a/runtime/vm/program_visitor.cc b/runtime/vm/program_visitor.cc index 6eb0c25cece..34022ebdc28 100644 --- a/runtime/vm/program_visitor.cc +++ b/runtime/vm/program_visitor.cc @@ -467,7 +467,7 @@ class StackMapEntry : public ZoneAllocated { ASSERT(it.current_spill_slot_bit_count_ >= 0); } - static const intptr_t kHashBits = 30; + static constexpr intptr_t kHashBits = Object::kHashBits; uword Hash() { if (hash_ != 0) return hash_; @@ -754,8 +754,7 @@ void ProgramVisitor::DedupPcDescriptors(Zone* zone, public Dedupper { public: explicit DedupPcDescriptorsVisitor(Zone* zone) - : Dedupper(zone), - pc_descriptor_(PcDescriptors::Handle(zone)) { + : Dedupper(zone), pc_descriptor_(PcDescriptors::Handle(zone)) { if (Snapshot::IncludesCode(Dart::vm_snapshot_kind())) { // Prefer existing objects in the VM isolate. AddVMBaseObjects();