Commit 14c68d4c authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[arm] Do not dedupe constants with incompatible reloc mode

Keep track of RelocInfo::Mode for ConstantPoolEntries in the assembler,
so that ARM's constant pool de-duping does not accidentally dedupe
constants with the same value but different reloc modes (e.g. the first
Code object in the builtins table as a CODE_TARGET vs. the builtin table
itself as an EXTERNAL_REFERENCE).

Change-Id: I15fad5b83bb99688726e66e0e290149025c6c059
Reviewed-on: https://chromium-review.googlesource.com/958864Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51900}
parent c04e9e0c
......@@ -5175,7 +5175,8 @@ void Assembler::ConstantPoolAddEntry(int position, RelocInfo::Mode rmode,
}
ConstantPoolEntry entry(position, value,
sharing_ok || (rmode == RelocInfo::CODE_TARGET &&
IsCodeTargetSharingAllowed()));
IsCodeTargetSharingAllowed()),
rmode);
bool shared = false;
if (sharing_ok) {
......@@ -5183,7 +5184,8 @@ void Assembler::ConstantPoolAddEntry(int position, RelocInfo::Mode rmode,
for (size_t i = 0; i < pending_32_bit_constants_.size(); i++) {
ConstantPoolEntry& current_entry = pending_32_bit_constants_[i];
if (!current_entry.sharing_ok()) continue;
if (entry.value() == current_entry.value()) {
if (entry.value() == current_entry.value() &&
entry.rmode() == current_entry.rmode()) {
entry.set_merged_index(i);
shared = true;
break;
......
......@@ -746,14 +746,18 @@ double power_double_double(double x, double y);
class ConstantPoolEntry {
public:
ConstantPoolEntry() {}
ConstantPoolEntry(int position, intptr_t value, bool sharing_ok)
ConstantPoolEntry(int position, intptr_t value, bool sharing_ok,
RelocInfo::Mode rmode = RelocInfo::NONE)
: position_(position),
merged_index_(sharing_ok ? SHARING_ALLOWED : SHARING_PROHIBITED),
value_(value) {}
ConstantPoolEntry(int position, Double value)
value_(value),
rmode_(rmode) {}
ConstantPoolEntry(int position, Double value,
RelocInfo::Mode rmode = RelocInfo::NONE)
: position_(position),
merged_index_(SHARING_ALLOWED),
value64_(value.AsUint64()) {}
value64_(value.AsUint64()),
rmode_(rmode) {}
int position() const { return position_; }
bool sharing_ok() const { return merged_index_ != SHARING_PROHIBITED; }
......@@ -777,6 +781,7 @@ class ConstantPoolEntry {
}
intptr_t value() const { return value_; }
uint64_t value64() const { return value64_; }
RelocInfo::Mode rmode() const { return rmode_; }
enum Type { INTPTR, DOUBLE, NUMBER_OF_TYPES };
......@@ -793,6 +798,9 @@ class ConstantPoolEntry {
intptr_t value_;
uint64_t value64_;
};
// TODO(leszeks): The way we use this, it could probably be packed into
// merged_index_ if size is a concern.
RelocInfo::Mode rmode_;
enum { SHARING_PROHIBITED = -2, SHARING_ALLOWED = -1 };
};
......
......@@ -135,6 +135,8 @@ static void PrintRelocInfo(StringBuilder* out, Isolate* isolate,
out->AddFormatted(" %s, %s, ", Code::Kind2String(kind),
CodeStub::MajorName(major_key));
out->AddFormatted("minor: %d", minor_key);
} else if (code->is_builtin()) {
out->AddFormatted(" Builtin::%s", Builtins::name(code->builtin_index()));
} else {
out->AddFormatted(" %s", Code::Kind2String(kind));
}
......
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