Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(795)

Unified Diff: src/objects.cc

Issue 1989973002: Refactor ObjectVisitor functions to not mutate the slot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 6f24eee0afeaab064e0051b737894db1ffe414bd..ea137f9157a5ae136273c630b7fb78589e5bd18e 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -12978,63 +12978,66 @@ const char* const VisitorSynchronization::kTagNames[
void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode()));
- Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
- Object* old_target = target;
- VisitPointer(&target);
- CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
+ Object* old_pointer = Code::GetCodeFromTargetAddress(rinfo->target_address());
+ Object* new_pointer = old_pointer;
+ VisitPointer(&new_pointer);
+ DCHECK_EQ(old_pointer, new_pointer);
}
void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) {
DCHECK(RelocInfo::IsCodeAgeSequence(rinfo->rmode()));
- Object* stub = rinfo->code_age_stub();
- if (stub) {
- VisitPointer(&stub);
+ Object* old_pointer = rinfo->code_age_stub();
+ Object* new_pointer = old_pointer;
+ if (old_pointer != nullptr) {
+ VisitPointer(&new_pointer);
+ DCHECK_EQ(old_pointer, new_pointer);
}
}
void ObjectVisitor::VisitCodeEntry(Address entry_address) {
- Object* code = Code::GetObjectFromEntryAddress(entry_address);
- Object* old_code = code;
- VisitPointer(&code);
- if (code != old_code) {
- Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry();
- }
+ Object* old_pointer = Code::GetObjectFromEntryAddress(entry_address);
+ Object* new_pointer = old_pointer;
+ VisitPointer(&new_pointer);
+ DCHECK_EQ(old_pointer, new_pointer);
}
void ObjectVisitor::VisitCell(RelocInfo* rinfo) {
DCHECK(rinfo->rmode() == RelocInfo::CELL);
- Object* cell = rinfo->target_cell();
- Object* old_cell = cell;
- VisitPointer(&cell);
- if (cell != old_cell) {
- rinfo->set_target_cell(reinterpret_cast<Cell*>(cell));
- }
+ Object* old_pointer = rinfo->target_cell();
+ Object* new_pointer = old_pointer;
+ VisitPointer(&new_pointer);
+ DCHECK_EQ(old_pointer, new_pointer);
}
void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) {
DCHECK(RelocInfo::IsDebugBreakSlot(rinfo->rmode()) &&
rinfo->IsPatchedDebugBreakSlotSequence());
- Object* target = Code::GetCodeFromTargetAddress(rinfo->debug_call_address());
- Object* old_target = target;
- VisitPointer(&target);
- CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
+ Object* old_pointer =
+ Code::GetCodeFromTargetAddress(rinfo->debug_call_address());
+ Object* new_pointer = old_pointer;
+ VisitPointer(&new_pointer);
+ DCHECK_EQ(old_pointer, new_pointer);
}
void ObjectVisitor::VisitEmbeddedPointer(RelocInfo* rinfo) {
DCHECK(rinfo->rmode() == RelocInfo::EMBEDDED_OBJECT);
- Object* p = rinfo->target_object();
- VisitPointer(&p);
+ Object* old_pointer = rinfo->target_object();
+ Object* new_pointer = old_pointer;
+ VisitPointer(&new_pointer);
+ DCHECK_EQ(old_pointer, new_pointer);
}
void ObjectVisitor::VisitExternalReference(RelocInfo* rinfo) {
- Address p = rinfo->target_external_reference();
- VisitExternalReference(&p);
+ Address old_reference = rinfo->target_external_reference();
+ Address new_reference = old_reference;
+ VisitExternalReference(&new_reference);
+ DCHECK_EQ(old_reference, new_reference);
}
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698