diff --git a/src/handles.h b/src/handles.h index 0b84b798d1..5067e28f4a 100644 --- a/src/handles.h +++ b/src/handles.h @@ -162,12 +162,15 @@ class Handle final : public HandleBase { std::is_same::value || std::is_same::value || std::is_same::value || + std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || - std::is_same::value || std::is_same::value || + std::is_same::value || + std::is_same::value || + std::is_same::value || std::is_same::value || std::is_same::value || std::is_same::value || diff --git a/src/objects-inl.h b/src/objects-inl.h index 38548059f1..c260a10630 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -408,7 +408,7 @@ STRUCT_LIST(MAKE_STRUCT_PREDICATE) double Object::Number() const { DCHECK(IsNumber()); return IsSmi() ? static_cast(Smi(this->ptr())->value()) - : reinterpret_cast(this)->value(); + : HeapNumber::unchecked_cast(this)->value(); } bool Object::IsNaN() const { diff --git a/src/objects.cc b/src/objects.cc index 4e94731a1a..cdf81e64d4 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -18720,7 +18720,7 @@ Handle JSDate::SetValue(Handle date, double v) { void JSDate::SetValue(Object* value, bool is_value_nan) { set_value(value); if (is_value_nan) { - HeapNumber* nan = GetReadOnlyRoots().nan_value(); + HeapNumber nan = GetReadOnlyRoots().nan_value(); set_cache_stamp(nan, SKIP_WRITE_BARRIER); set_year(nan, SKIP_WRITE_BARRIER); set_month(nan, SKIP_WRITE_BARRIER); diff --git a/src/objects/heap-number-inl.h b/src/objects/heap-number-inl.h index b72b22dad0..86da7cca5f 100644 --- a/src/objects/heap-number-inl.h +++ b/src/objects/heap-number-inl.h @@ -15,8 +15,12 @@ namespace v8 { namespace internal { -CAST_ACCESSOR(HeapNumber) -CAST_ACCESSOR(MutableHeapNumber) +OBJECT_CONSTRUCTORS_IMPL(HeapNumberBase, HeapObjectPtr) +OBJECT_CONSTRUCTORS_IMPL(HeapNumber, HeapNumberBase) +OBJECT_CONSTRUCTORS_IMPL(MutableHeapNumber, HeapNumberBase) + +CAST_ACCESSOR2(HeapNumber) +CAST_ACCESSOR2(MutableHeapNumber) double HeapNumberBase::value() const { return READ_DOUBLE_FIELD(this, kValueOffset); diff --git a/src/objects/heap-number.h b/src/objects/heap-number.h index de1937d809..42fc8cb70d 100644 --- a/src/objects/heap-number.h +++ b/src/objects/heap-number.h @@ -5,7 +5,7 @@ #ifndef V8_OBJECTS_HEAP_NUMBER_H_ #define V8_OBJECTS_HEAP_NUMBER_H_ -#include "src/objects.h" +#include "src/objects/heap-object.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -17,7 +17,7 @@ namespace internal { // represented in a Smi (small integer). MutableHeapNumber is the same, but its // number value can change over time (it is used only as property storage). // HeapNumberBase merely exists to avoid code duplication. -class HeapNumberBase : public HeapObject { +class HeapNumberBase : public HeapObjectPtr { public: // [value]: number value. inline double value() const; @@ -58,26 +58,27 @@ class HeapNumberBase : public HeapObject { static const int kMantissaBitsInTopWord = 20; static const int kNonMantissaBitsInTopWord = 12; - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumberBase); + // Just to make the macro-generated constructor happy. Subclasses should + // perform their own proper type checking. + inline bool IsHeapNumberBase() const { return true; } + + OBJECT_CONSTRUCTORS(HeapNumberBase, HeapObjectPtr); }; class HeapNumber : public HeapNumberBase { public: - DECL_CAST(HeapNumber) + DECL_CAST2(HeapNumber) V8_EXPORT_PRIVATE void HeapNumberPrint(std::ostream& os); - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); + OBJECT_CONSTRUCTORS(HeapNumber, HeapNumberBase); }; class MutableHeapNumber : public HeapNumberBase { public: - DECL_CAST(MutableHeapNumber) + DECL_CAST2(MutableHeapNumber) V8_EXPORT_PRIVATE void MutableHeapNumberPrint(std::ostream& os); - private: - DISALLOW_IMPLICIT_CONSTRUCTORS(MutableHeapNumber); + OBJECT_CONSTRUCTORS(MutableHeapNumber, HeapNumberBase); }; } // namespace internal diff --git a/src/roots.h b/src/roots.h index 45b0592c71..72ee53c33b 100644 --- a/src/roots.h +++ b/src/roots.h @@ -210,11 +210,11 @@ class RootVisitor; V(WeakFixedArray, empty_weak_fixed_array, EmptyWeakFixedArray) \ V(WeakArrayList, empty_weak_array_list, EmptyWeakArrayList) \ /* Special numbers */ \ - V(HeapNumber*, nan_value, NanValue) \ - V(HeapNumber*, hole_nan_value, HoleNanValue) \ - V(HeapNumber*, infinity_value, InfinityValue) \ - V(HeapNumber*, minus_zero_value, MinusZeroValue) \ - V(HeapNumber*, minus_infinity_value, MinusInfinityValue) \ + V(HeapNumber, nan_value, NanValue) \ + V(HeapNumber, hole_nan_value, HoleNanValue) \ + V(HeapNumber, infinity_value, InfinityValue) \ + V(HeapNumber, minus_zero_value, MinusZeroValue) \ + V(HeapNumber, minus_infinity_value, MinusInfinityValue) \ /* Marker for self-references during code-generation */ \ V(HeapObject*, self_reference_marker, SelfReferenceMarker) \ /* Canonical trampoline RelocInfo */ \ diff --git a/src/value-serializer.cc b/src/value-serializer.cc index fedf43a18c..81ca2ff7e6 100644 --- a/src/value-serializer.cc +++ b/src/value-serializer.cc @@ -426,12 +426,12 @@ void ValueSerializer::WriteSmi(Smi smi) { WriteZigZag(smi->value()); } -void ValueSerializer::WriteHeapNumber(HeapNumber* number) { +void ValueSerializer::WriteHeapNumber(HeapNumber number) { WriteTag(SerializationTag::kDouble); WriteDouble(number->value()); } -void ValueSerializer::WriteMutableHeapNumber(MutableHeapNumber* number) { +void ValueSerializer::WriteMutableHeapNumber(MutableHeapNumber number) { WriteTag(SerializationTag::kDouble); WriteDouble(number->value()); } diff --git a/src/value-serializer.h b/src/value-serializer.h index 3933b6f1c0..97cd64a07b 100644 --- a/src/value-serializer.h +++ b/src/value-serializer.h @@ -110,8 +110,8 @@ class ValueSerializer { // Writing V8 objects of various kinds. void WriteOddball(Oddball* oddball); void WriteSmi(Smi smi); - void WriteHeapNumber(HeapNumber* number); - void WriteMutableHeapNumber(MutableHeapNumber* number); + void WriteHeapNumber(HeapNumber number); + void WriteMutableHeapNumber(MutableHeapNumber number); void WriteBigInt(BigInt bigint); void WriteString(Handle string); Maybe WriteJSReceiver(Handle receiver) diff --git a/src/wasm/wasm-objects-inl.h b/src/wasm/wasm-objects-inl.h index 2bd2bdf7f1..d4125bd762 100644 --- a/src/wasm/wasm-objects-inl.h +++ b/src/wasm/wasm-objects-inl.h @@ -291,7 +291,7 @@ ACCESSORS2(AsmWasmData, managed_native_module, Managed, kManagedNativeModuleOffset) ACCESSORS2(AsmWasmData, export_wrappers, FixedArray, kExportWrappersOffset) ACCESSORS2(AsmWasmData, asm_js_offset_table, ByteArray, kAsmJsOffsetTableOffset) -ACCESSORS(AsmWasmData, uses_bitset, HeapNumber, kUsesBitsetOffset) +ACCESSORS2(AsmWasmData, uses_bitset, HeapNumber, kUsesBitsetOffset) #include "src/objects/object-macros-undef.h" diff --git a/src/wasm/wasm-objects.h b/src/wasm/wasm-objects.h index 923a3b6fde..d4b89ab4b4 100644 --- a/src/wasm/wasm-objects.h +++ b/src/wasm/wasm-objects.h @@ -715,7 +715,7 @@ class AsmWasmData : public Struct { DECL_ACCESSORS2(managed_native_module, Managed) DECL_ACCESSORS2(export_wrappers, FixedArray) DECL_ACCESSORS2(asm_js_offset_table, ByteArray) - DECL_ACCESSORS(uses_bitset, HeapNumber) + DECL_ACCESSORS2(uses_bitset, HeapNumber) DECL_CAST2(AsmWasmData) DECL_PRINTER(AsmWasmData)