Don't convert jump and call targets to code object pointers when (de)serializing.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2932 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
whesse@chromium.org 2009-09-18 10:50:08 +00:00
parent 425cd77c40
commit 4ac11e3b15
2 changed files with 34 additions and 13 deletions

View File

@ -935,6 +935,19 @@ class ReferenceUpdater: public ObjectVisitor {
}
}
// Do not assert that code targets have been converted to object pointers.
virtual void BeginCodeIteration(Code* code) {
}
virtual void VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
Address encoded_target = serializer_->GetSavedAddress(target);
offsets_.Add(rinfo->target_address_address() - obj_address_);
addresses_.Add(encoded_target);
}
virtual void VisitExternalReferences(Address* start, Address* end) {
for (Address* p = start; p < end; ++p) {
uint32_t code = reference_encoder_->Encode(*p);
@ -1093,6 +1106,14 @@ void Serializer::VisitPointers(Object** start, Object** end) {
}
void Serializer::VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
bool serialized;
Encode(target, &serialized);
}
class GlobalHandlesRetriever: public ObjectVisitor {
public:
explicit GlobalHandlesRetriever(List<Object**>* handles)
@ -1255,10 +1276,7 @@ Address Serializer::PutObject(HeapObject* obj) {
SaveAddress(obj, addr);
if (type == CODE_TYPE) {
Code* code = Code::cast(obj);
// Ensure Code objects contain Object pointers, not Addresses.
code->ConvertICTargetsFromAddressToObject();
LOG(CodeMoveEvent(code->address(), addr));
LOG(CodeMoveEvent(obj->address(), addr));
}
// Write out the object prologue: type, size, and simulated address of obj.
@ -1290,12 +1308,6 @@ Address Serializer::PutObject(HeapObject* obj) {
}
#endif
if (type == CODE_TYPE) {
Code* code = Code::cast(obj);
// Convert relocations from Object* to Address in Code objects
code->ConvertICTargetsFromObjectToAddress();
}
objects_++;
return addr;
}
@ -1422,6 +1434,14 @@ void Deserializer::VisitPointers(Object** start, Object** end) {
}
void Deserializer::VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Address encoded_address = reinterpret_cast<Address>(rinfo->target_object());
Code* target_object = reinterpret_cast<Code*>(Resolve(encoded_address));
rinfo->set_target_address(target_object->instruction_start());
}
void Deserializer::VisitExternalReferences(Address* start, Address* end) {
for (Address* p = start; p < end; ++p) {
uint32_t code = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(*p));
@ -1617,8 +1637,6 @@ Object* Deserializer::GetObject() {
if (type == CODE_TYPE) {
Code* code = Code::cast(obj);
// Convert relocations from Object* to Address in Code objects
code->ConvertICTargetsFromObjectToAddress();
LOG(CodeMoveEvent(a, code->address()));
}
objects_++;

View File

@ -154,8 +154,9 @@ class Serializer: public ObjectVisitor {
private:
friend class ReferenceUpdater;
virtual void BeginCodeIteration(Code* code) { }
virtual void VisitPointers(Object** start, Object** end);
virtual void VisitCodeTarget(RelocInfo* rinfo);
bool IsVisited(HeapObject* obj);
Address GetSavedAddress(HeapObject* obj);
@ -289,6 +290,8 @@ class Deserializer: public ObjectVisitor {
private:
virtual void VisitPointers(Object** start, Object** end);
virtual void BeginCodeIteration(Code* code) { }
virtual void VisitCodeTarget(RelocInfo* rinfo);
virtual void VisitExternalReferences(Address* start, Address* end);
virtual void VisitRuntimeEntry(RelocInfo* rinfo);