Serializer: prepare support for INTERNAL_REFERENCE_ENCODED.

Platform ports that use this RelocInfo kind need to implement
set_target_internal_reference accordingly to distinguish between
INTERNAL_REFERENCE and INTERNAL_REFERENCE_ENCODED.

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/1000373003

Cr-Commit-Position: refs/heads/master@{#27177}
This commit is contained in:
yangguo 2015-03-13 03:07:54 -07:00 committed by Commit bot
parent 0c56d7e809
commit a873c9f336
3 changed files with 13 additions and 7 deletions

View File

@ -832,6 +832,8 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
return "external reference";
case RelocInfo::INTERNAL_REFERENCE:
return "internal reference";
case RelocInfo::INTERNAL_REFERENCE_ENCODED:
return "encoded internal reference";
case RelocInfo::DEOPT_REASON:
return "deopt reason";
case RelocInfo::CONST_POOL:
@ -919,6 +921,7 @@ void RelocInfo::Verify(Isolate* isolate) {
case STATEMENT_POSITION:
case EXTERNAL_REFERENCE:
case INTERNAL_REFERENCE:
case INTERNAL_REFERENCE_ENCODED:
case DEOPT_REASON:
case CONST_POOL:
case VENEER_POOL:

View File

@ -379,6 +379,9 @@ class RelocInfo {
EXTERNAL_REFERENCE, // The address of an external C++ function.
INTERNAL_REFERENCE, // An address inside the same function.
// Encoded internal reference, used only on MIPS, MIPS64 and PPC.
INTERNAL_REFERENCE_ENCODED,
// Marks constant and veneer pools. Only used on ARM and ARM64.
// They use a custom noncompact encoding.
CONST_POOL,
@ -394,10 +397,6 @@ class RelocInfo {
CODE_AGE_SEQUENCE, // Not stored in RelocInfo array, used explictly by
// code aging.
// Encoded internal reference, used only on MIPS and MIPS64.
// Re-uses previous ARM-only encoding, to fit in RealRelocMode space.
INTERNAL_REFERENCE_ENCODED = CONST_POOL,
FIRST_REAL_RELOC_MODE = CODE_TARGET,
LAST_REAL_RELOC_MODE = VENEER_POOL,
FIRST_PSEUDO_RELOC_MODE = CODE_AGE_SEQUENCE,

View File

@ -799,7 +799,8 @@ void Deserializer::ReadObject(int space_number, Object** write_back) {
// Turn internal references encoded as offsets back to absolute addresses.
Code* code = Code::cast(obj);
Address entry = code->entry();
int mode_mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE);
int mode_mask = RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED);
for (RelocIterator it(code, mode_mask); !it.done(); it.next()) {
RelocInfo* rinfo = it.rinfo();
intptr_t offset =
@ -1953,10 +1954,13 @@ Address Serializer::ObjectSerializer::PrepareCode() {
RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) |
RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) |
RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE);
RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) |
RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED);
for (RelocIterator it(code, mode_mask); !it.done(); it.next()) {
RelocInfo* rinfo = it.rinfo();
if (RelocInfo::IsInternalReference(rinfo->rmode())) {
RelocInfo::Mode rmode = rinfo->rmode();
if (RelocInfo::IsInternalReference(rmode) ||
RelocInfo::IsInternalReferenceEncoded(rmode)) {
// Convert internal references to relative offsets.
Address target = rinfo->target_internal_reference();
intptr_t offset = target - entry;