Commit e58287a1 authored by whesse@chromium.org's avatar whesse@chromium.org

Use GetCodeFromTargetAddress everywhere, uniformly.

Review URL: http://codereview.chromium.org/193111

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2888 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 91ecc77e
...@@ -494,7 +494,7 @@ void RelocInfo::Verify() { ...@@ -494,7 +494,7 @@ void RelocInfo::Verify() {
Address addr = target_address(); Address addr = target_address();
ASSERT(addr != NULL); ASSERT(addr != NULL);
// Check that we can find the right code object. // Check that we can find the right code object.
HeapObject* code = HeapObject::FromAddress(addr - Code::kHeaderSize); Code* code = Code::GetCodeFromTargetAddress(addr);
Object* found = Heap::FindCodeObject(addr); Object* found = Heap::FindCodeObject(addr);
ASSERT(found->IsCode()); ASSERT(found->IsCode());
ASSERT(code->address() == HeapObject::cast(found)->address()); ASSERT(code->address() == HeapObject::cast(found)->address());
......
...@@ -279,7 +279,7 @@ class MarkingVisitor : public ObjectVisitor { ...@@ -279,7 +279,7 @@ class MarkingVisitor : public ObjectVisitor {
void VisitCodeTarget(RelocInfo* rinfo) { void VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Code* code = CodeFromDerivedPointer(rinfo->target_address()); Code* code = Code::GetCodeFromTargetAddress(rinfo->target_address());
if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) { if (FLAG_cleanup_ics_at_gc && code->is_inline_cache_stub()) {
IC::Clear(rinfo->pc()); IC::Clear(rinfo->pc());
// Please note targets for cleared inline cached do not have to be // Please note targets for cleared inline cached do not have to be
...@@ -289,7 +289,7 @@ class MarkingVisitor : public ObjectVisitor { ...@@ -289,7 +289,7 @@ class MarkingVisitor : public ObjectVisitor {
} }
if (IsCompacting()) { if (IsCompacting()) {
// When compacting we convert the target to a real object pointer. // When compacting we convert the target to a real object pointer.
code = CodeFromDerivedPointer(rinfo->target_address()); code = Code::GetCodeFromTargetAddress(rinfo->target_address());
rinfo->set_target_object(code); rinfo->set_target_object(code);
} }
} }
...@@ -297,7 +297,7 @@ class MarkingVisitor : public ObjectVisitor { ...@@ -297,7 +297,7 @@ class MarkingVisitor : public ObjectVisitor {
void VisitDebugTarget(RelocInfo* rinfo) { void VisitDebugTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) && ASSERT(RelocInfo::IsJSReturn(rinfo->rmode()) &&
rinfo->IsCallInstruction()); rinfo->IsCallInstruction());
HeapObject* code = CodeFromDerivedPointer(rinfo->call_address()); HeapObject* code = Code::GetCodeFromTargetAddress(rinfo->call_address());
MarkCompactCollector::MarkObject(code); MarkCompactCollector::MarkObject(code);
// When compacting we convert the call to a real object pointer. // When compacting we convert the call to a real object pointer.
if (IsCompacting()) rinfo->set_call_object(code); if (IsCompacting()) rinfo->set_call_object(code);
...@@ -314,13 +314,6 @@ class MarkingVisitor : public ObjectVisitor { ...@@ -314,13 +314,6 @@ class MarkingVisitor : public ObjectVisitor {
// Tells whether the mark sweep collection will perform compaction. // Tells whether the mark sweep collection will perform compaction.
bool IsCompacting() { return MarkCompactCollector::IsCompacting(); } bool IsCompacting() { return MarkCompactCollector::IsCompacting(); }
// Retrieves the Code pointer from derived code entry.
Code* CodeFromDerivedPointer(Address addr) {
ASSERT(addr != NULL);
return reinterpret_cast<Code*>(
HeapObject::FromAddress(addr - Code::kHeaderSize));
}
// Visit an unmarked object. // Visit an unmarked object.
void VisitUnmarkedObject(HeapObject* obj) { void VisitUnmarkedObject(HeapObject* obj) {
#ifdef DEBUG #ifdef DEBUG
......
...@@ -4967,7 +4967,7 @@ void Code::ConvertICTargetsFromAddressToObject() { ...@@ -4967,7 +4967,7 @@ void Code::ConvertICTargetsFromAddressToObject() {
!it.done(); it.next()) { !it.done(); it.next()) {
Address ic_addr = it.rinfo()->target_address(); Address ic_addr = it.rinfo()->target_address();
ASSERT(ic_addr != NULL); ASSERT(ic_addr != NULL);
HeapObject* code = HeapObject::FromAddress(ic_addr - Code::kHeaderSize); HeapObject* code = Code::GetCodeFromTargetAddress(ic_addr);
ASSERT(code->IsHeapObject()); ASSERT(code->IsHeapObject());
it.rinfo()->set_target_object(code); it.rinfo()->set_target_object(code);
} }
...@@ -4980,7 +4980,7 @@ void Code::ConvertICTargetsFromAddressToObject() { ...@@ -4980,7 +4980,7 @@ void Code::ConvertICTargetsFromAddressToObject() {
if (it.rinfo()->IsCallInstruction()) { if (it.rinfo()->IsCallInstruction()) {
Address addr = it.rinfo()->call_address(); Address addr = it.rinfo()->call_address();
ASSERT(addr != NULL); ASSERT(addr != NULL);
HeapObject* code = HeapObject::FromAddress(addr - Code::kHeaderSize); HeapObject* code = Code::GetCodeFromTargetAddress(addr);
ASSERT(code->IsHeapObject()); ASSERT(code->IsHeapObject());
it.rinfo()->set_call_object(code); it.rinfo()->set_call_object(code);
} }
......
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