Commit 00d6c667 authored by Jakob Kummerow's avatar Jakob Kummerow Committed by Commit Bot

[ubsan] Temporarily duplicate Struct and Tuple2

in preparation for incrementally transitioning their subclasses.

Bug: v8:3770
Change-Id: I5ed6adb1969bc1ec7125571fea443834ca255c22
Reviewed-on: https://chromium-review.googlesource.com/c/1377453
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58252}
parent 19da9f24
......@@ -1762,6 +1762,10 @@ void Tuple2::Tuple2Verify(Isolate* isolate) {
}
}
void Tuple2Ptr::Tuple2Verify(Isolate* isolate) {
reinterpret_cast<Tuple2*>(ptr())->Tuple2Verify(isolate);
}
void Tuple3::Tuple3Verify(Isolate* isolate) {
CHECK(IsTuple3());
VerifyObjectField(isolate, kValue1Offset);
......
......@@ -1725,6 +1725,10 @@ void Tuple2::Tuple2Print(std::ostream& os) { // NOLINT
os << "\n";
}
void Tuple2Ptr::Tuple2Print(std::ostream& os) { // NOLINT
reinterpret_cast<Tuple2*>(ptr())->Tuple2Print(os);
}
void Tuple3::Tuple3Print(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "Tuple3");
os << "\n - value1: " << Brief(value1());
......
......@@ -3762,10 +3762,16 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
void Struct::BriefPrintDetails(std::ostream& os) {}
void StructPtr::BriefPrintDetails(std::ostream& os) {}
void Tuple2::BriefPrintDetails(std::ostream& os) {
os << " " << Brief(value1()) << ", " << Brief(value2());
}
void Tuple2Ptr::BriefPrintDetails(std::ostream& os) {
os << " " << Brief(value1()) << ", " << Brief(value2());
}
void Tuple3::BriefPrintDetails(std::ostream& os) {
os << " " << Brief(value1()) << ", " << Brief(value2()) << ", "
<< Brief(value3());
......
......@@ -15,9 +15,21 @@
namespace v8 {
namespace internal {
bool StructPtr::IsStructPtr() const {
return reinterpret_cast<Struct*>(ptr())->IsStruct();
}
bool Tuple2Ptr::IsTuple2Ptr() const {
return reinterpret_cast<Tuple2*>(ptr())->IsTuple2();
}
OBJECT_CONSTRUCTORS_IMPL(StructPtr, HeapObjectPtr)
OBJECT_CONSTRUCTORS_IMPL(Tuple2Ptr, StructPtr)
CAST_ACCESSOR(AccessorPair)
CAST_ACCESSOR(Struct)
CAST_ACCESSOR2(StructPtr)
CAST_ACCESSOR(Tuple2)
CAST_ACCESSOR2(Tuple2Ptr)
CAST_ACCESSOR(Tuple3)
void Struct::InitializeBody(int object_size) {
......@@ -27,8 +39,17 @@ void Struct::InitializeBody(int object_size) {
}
}
void StructPtr::InitializeBody(int object_size) {
Object* value = GetReadOnlyRoots().undefined_value();
for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
WRITE_FIELD(this, offset, value);
}
}
ACCESSORS(Tuple2, value1, Object, kValue1Offset)
ACCESSORS(Tuple2Ptr, value1, Object, kValue1Offset)
ACCESSORS(Tuple2, value2, Object, kValue2Offset)
ACCESSORS(Tuple2Ptr, value2, Object, kValue2Offset)
ACCESSORS(Tuple3, value3, Object, kValue3Offset)
ACCESSORS(AccessorPair, getter, Object, kGetterOffset)
......
......@@ -24,6 +24,20 @@ class Struct : public HeapObject {
void BriefPrintDetails(std::ostream& os);
};
// Replacement for the above, temporarily separate for incremental transition
// of subclasses.
class StructPtr : public HeapObjectPtr {
public:
inline void InitializeBody(int object_size);
DECL_CAST2(StructPtr)
void BriefPrintDetails(std::ostream& os);
// TODO(3770): Temporary.
inline bool IsStructPtr() const;
OBJECT_CONSTRUCTORS(StructPtr, HeapObjectPtr);
};
class Tuple2 : public Struct {
public:
DECL_ACCESSORS(value1, Object)
......@@ -44,6 +58,30 @@ class Tuple2 : public Struct {
DISALLOW_IMPLICIT_CONSTRUCTORS(Tuple2);
};
// Replacement for the above, temporarily separate for incremental transition
// of subclasses.
class Tuple2Ptr : public StructPtr {
public:
DECL_ACCESSORS(value1, Object)
DECL_ACCESSORS(value2, Object)
DECL_CAST2(Tuple2Ptr)
// Dispatched behavior.
DECL_PRINTER(Tuple2)
DECL_VERIFIER(Tuple2)
void BriefPrintDetails(std::ostream& os);
// TODO(3770): Temporary.
inline bool IsTuple2Ptr() const;
static const int kValue1Offset = HeapObject::kHeaderSize;
static const int kValue2Offset = kValue1Offset + kPointerSize;
static const int kSize = kValue2Offset + kPointerSize;
OBJECT_CONSTRUCTORS(Tuple2Ptr, StructPtr);
};
class Tuple3 : public Tuple2 {
public:
DECL_ACCESSORS(value3, Object)
......
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