Commit 1eb87706 authored by Victor Gomes's avatar Victor Gomes Committed by V8 LUCI CQ

[baseline][arm64] Remove initial relocation when compiling on heap

Constant pool doc: shorturl.at/txS08

Bug: v8:11872
Change-Id: Idd36b4c1ef0dc634a7411f530cdfc50681d7e875
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3024146
Commit-Queue: Victor Gomes <victorgomes@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75708}
parent 7f58edd5
......@@ -4276,6 +4276,8 @@ bool Assembler::IsImmFP64(double imm) {
}
void Assembler::GrowBuffer() {
bool previously_on_heap = buffer_->IsOnHeap();
// Compute new buffer size.
int old_size = buffer_->size();
int new_size = std::min(2 * old_size, old_size + 1 * MB);
......@@ -4318,6 +4320,21 @@ void Assembler::GrowBuffer() {
WriteUnalignedValue<intptr_t>(address, internal_ref);
}
// Patch on-heap references to handles.
if (previously_on_heap && !buffer_->IsOnHeap()) {
Address base = reinterpret_cast<Address>(buffer_->start());
for (auto p : saved_handles_for_raw_object_ptr_) {
WriteUnalignedValue(base + p.first, p.second);
}
for (auto p : saved_offsets_for_runtime_entries_) {
Instruction* instr = reinterpret_cast<Instruction*>(base + p.first);
DCHECK(is_int26(p.second));
DCHECK(instr->IsBranchAndLink() || instr->IsUnconditionalBranch());
instr->SetInstructionBits(instr->Mask(UnconditionalBranchMask) |
p.second);
}
}
// Pending relocation entries are also relative, no need to relocate.
}
......
......@@ -1844,7 +1844,13 @@ int64_t TurboAssembler::CalculateTargetOffset(Address target,
void TurboAssembler::Jump(Address target, RelocInfo::Mode rmode,
Condition cond) {
JumpHelper(CalculateTargetOffset(target, rmode, pc_), rmode, cond);
int64_t offset = CalculateTargetOffset(target, rmode, pc_);
if (RelocInfo::IsRuntimeEntry(rmode) && IsOnHeap()) {
saved_offsets_for_runtime_entries_.push_back(
std::make_pair(pc_offset(), offset));
offset = CalculateTargetOffset(target, RelocInfo::NONE, pc_);
}
JumpHelper(offset, rmode, cond);
}
void TurboAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode,
......@@ -1886,9 +1892,13 @@ void TurboAssembler::Call(Register target) {
void TurboAssembler::Call(Address target, RelocInfo::Mode rmode) {
BlockPoolsScope scope(this);
if (CanUseNearCallOrJump(rmode)) {
int64_t offset = CalculateTargetOffset(target, rmode, pc_);
if (IsOnHeap() && RelocInfo::IsRuntimeEntry(rmode)) {
saved_offsets_for_runtime_entries_.push_back(
std::make_pair(pc_offset(), offset));
offset = CalculateTargetOffset(target, RelocInfo::NONE, pc_);
}
DCHECK(IsNearCallOffset(offset));
near_call(static_cast<int>(offset), rmode);
} else {
......
......@@ -353,7 +353,14 @@ void ConstantPool::Emit(const ConstantPoolKey& key) {
if (key.is_value32()) {
assm_->dd(key.value32());
} else {
assm_->dq(key.value64());
if (assm_->IsOnHeap() && RelocInfo::IsEmbeddedObjectMode(key.rmode())) {
assm_->saved_handles_for_raw_object_ptr_.push_back(
std::make_pair(assm_->pc_offset(), key.value64()));
Handle<Object> handle = assm_->GetEmbeddedObject(key.value64());
assm_->dq(handle->ptr());
} else {
assm_->dq(key.value64());
}
}
}
......
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