Commit bda4096b authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[in-place weak refs] Merge MaybeObjectBrief and Brief

BUG=v8:7308

Change-Id: I36dda6606aecb9e8e2e9604c49e62ec70e3aee29
Reviewed-on: https://chromium-review.googlesource.com/1174447
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55169}
parent bcb8d5ad
......@@ -907,7 +907,7 @@ void PrintWeakArrayElements(std::ostream& os, T* array) {
if (previous_index != i - 1) {
ss << '-' << (i - 1);
}
os << std::setw(12) << ss.str() << ": " << MaybeObjectBrief(previous_value);
os << std::setw(12) << ss.str() << ": " << Brief(previous_value);
previous_index = i;
previous_value = value;
}
......@@ -1056,7 +1056,7 @@ void FeedbackVector::FeedbackVectorPrint(std::ostream& os) { // NOLINT
if (entry_size > 0) os << " {";
for (int i = 0; i < entry_size; i++) {
int index = GetIndex(slot) + i;
os << "\n [" << index << "]: " << MaybeObjectBrief(get(index));
os << "\n [" << index << "]: " << Brief(get(index));
}
if (entry_size > 0) os << "\n }";
}
......@@ -1671,7 +1671,7 @@ void PrototypeInfo::PrototypeInfoPrint(std::ostream& os) { // NOLINT
os << "\n - module namespace: " << Brief(module_namespace());
os << "\n - prototype users: " << Brief(prototype_users());
os << "\n - registry slot: " << registry_slot();
os << "\n - object create map: " << MaybeObjectBrief(object_create_map());
os << "\n - object create map: " << Brief(object_create_map());
os << "\n - should_be_fast_map: " << should_be_fast_map();
os << "\n";
}
......@@ -1782,13 +1782,13 @@ void LoadHandler::LoadHandlerPrint(std::ostream& os) { // NOLINT
os << "\n - validity_cell: " << Brief(validity_cell());
int data_count = data_field_count();
if (data_count >= 1) {
os << "\n - data1: " << MaybeObjectBrief(data1());
os << "\n - data1: " << Brief(data1());
}
if (data_count >= 2) {
os << "\n - data2: " << MaybeObjectBrief(data2());
os << "\n - data2: " << Brief(data2());
}
if (data_count >= 3) {
os << "\n - data3: " << MaybeObjectBrief(data3());
os << "\n - data3: " << Brief(data3());
}
os << "\n";
}
......@@ -1800,13 +1800,13 @@ void StoreHandler::StoreHandlerPrint(std::ostream& os) { // NOLINT
os << "\n - validity_cell: " << Brief(validity_cell());
int data_count = data_field_count();
if (data_count >= 1) {
os << "\n - data1: " << MaybeObjectBrief(data1());
os << "\n - data1: " << Brief(data1());
}
if (data_count >= 2) {
os << "\n - data2: " << MaybeObjectBrief(data2());
os << "\n - data2: " << Brief(data2());
}
if (data_count >= 3) {
os << "\n - data3: " << MaybeObjectBrief(data3());
os << "\n - data3: " << Brief(data3());
}
os << "\n";
}
......
......@@ -2493,30 +2493,22 @@ void Object::ShortPrint(std::ostream& os) { os << Brief(this); }
void MaybeObject::ShortPrint(FILE* out) {
OFStream os(out);
os << MaybeObjectBrief(this);
os << Brief(this);
}
void MaybeObject::ShortPrint(StringStream* accumulator) {
std::ostringstream os;
os << MaybeObjectBrief(this);
os << Brief(this);
accumulator->Add(os.str().c_str());
}
void MaybeObject::ShortPrint(std::ostream& os) { os << MaybeObjectBrief(this); }
void MaybeObject::ShortPrint(std::ostream& os) { os << Brief(this); }
std::ostream& operator<<(std::ostream& os, const Brief& v) {
if (v.value->IsSmi()) {
Smi::cast(v.value)->SmiPrint(os);
} else {
// TODO(svenpanne) Const-correct HeapObjectShortPrint!
HeapObject* obj = const_cast<HeapObject*>(HeapObject::cast(v.value));
obj->HeapObjectShortPrint(os);
}
return os;
}
Brief::Brief(const Object* v)
: value(MaybeObject::FromObject(const_cast<Object*>(v))) {}
std::ostream& operator<<(std::ostream& os, const MaybeObjectBrief& v) {
// TODO(marja): const-correct this the same way as the Object* version.
std::ostream& operator<<(std::ostream& os, const Brief& v) {
// TODO(marja): const-correct HeapObjectShortPrint.
MaybeObject* maybe_object = const_cast<MaybeObject*>(v.value);
Smi* smi;
HeapObject* heap_object;
......
......@@ -1518,18 +1518,12 @@ bool Object::IsHeapObject() const {
}
struct Brief {
explicit Brief(const Object* const v) : value(v) {}
const Object* value;
};
struct MaybeObjectBrief {
explicit MaybeObjectBrief(const MaybeObject* const v) : value(v) {}
V8_EXPORT_PRIVATE explicit Brief(const Object* v);
explicit Brief(const MaybeObject* v) : value(v) {}
const MaybeObject* value;
};
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const Brief& v);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
const MaybeObjectBrief& v);
// Smi represents integer Numbers that can be stored in 31 bits.
// Smis are immediate which means they are NOT allocated in the heap.
......
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