Commit 7e95f30e authored by QiuJi's avatar QiuJi Committed by V8 LUCI CQ

[riscv64][baseline] Port Sparkplug on heap compilation

1. Adds EmbeddedObjectMatches
   Port 6bf0b704
2. Fallback to handle references on heap compilation
   Port 642a4673
3. Remove initial relocation when compiling on heap
   Port 7ac3b55a
4. Retry compiling on-heap when growing buffer
   Port fb4f89ae
5. 208854bb
   Port 208854bb

Bug: v8:11872
Change-Id: I43118c3acea1d174d2b826e5ed2823ec5388569c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3081606Reviewed-by: 's avatarJi Qiu <qiuji@iscas.ac.cn>
Reviewed-by: 's avatarBrice Dobry <brice.dobry@futurewei.com>
Commit-Queue: Ji Qiu <qiuji@iscas.ac.cn>
Cr-Commit-Position: refs/heads/master@{#76185}
parent 996e0380
......@@ -2787,13 +2787,27 @@ void Assembler::RelocateRelativeReference(RelocInfo::Mode rmode, Address pc,
}
void Assembler::FixOnHeapReferences(bool update_embedded_objects) {
UNIMPLEMENTED();
if (!update_embedded_objects) return;
for (auto p : saved_handles_for_raw_object_ptr_) {
Address address = reinterpret_cast<Address>(buffer_->start() + p.first);
Handle<HeapObject> object(reinterpret_cast<Address*>(p.second));
set_target_value_at(address, object->ptr());
}
}
void Assembler::FixOnHeapReferencesToHandles() { UNIMPLEMENTED(); }
void Assembler::FixOnHeapReferencesToHandles() {
for (auto p : saved_handles_for_raw_object_ptr_) {
Address address = reinterpret_cast<Address>(buffer_->start() + p.first);
set_target_value_at(address, p.second);
}
saved_handles_for_raw_object_ptr_.clear();
}
void Assembler::GrowBuffer() {
DEBUG_PRINTF("GrowBuffer: %p -> ", buffer_start_);
bool previously_on_heap = buffer_->IsOnHeap();
int previous_on_heap_gc_count = OnHeapGCCount();
// Compute new buffer size.
int old_size = buffer_->size();
int new_size = std::min(2 * old_size, old_size + 1 * MB);
......@@ -2835,6 +2849,16 @@ void Assembler::GrowBuffer() {
RelocateInternalReference(rmode, it.rinfo()->pc(), pc_delta);
}
}
// Fix on-heap references.
if (previously_on_heap) {
if (buffer_->IsOnHeap()) {
FixOnHeapReferences(previous_on_heap_gc_count != OnHeapGCCount());
} else {
FixOnHeapReferencesToHandles();
}
}
DCHECK(!overflow());
}
......
......@@ -1028,6 +1028,14 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
}
}
#ifdef DEBUG
bool EmbeddedObjectMatches(int pc_offset, Handle<Object> object) {
return target_address_at(
reinterpret_cast<Address>(buffer_->start() + pc_offset)) ==
(IsOnHeap() ? object->ptr() : object.address());
}
#endif
private:
// Avoid overflows for displacements etc.
static const int kMaximalBufferSize = 512 * MB;
......
......@@ -1660,6 +1660,17 @@ void TurboAssembler::li(Register rd, Operand j, LiFlags mode) {
Li(rd, j.immediate());
}
}
} else if (IsOnHeap() && RelocInfo::IsEmbeddedObjectMode(j.rmode())) {
BlockGrowBufferScope block_growbuffer(this);
int offset = pc_offset();
Address address = j.immediate();
saved_handles_for_raw_object_ptr_.push_back(
std::make_pair(offset, address));
Handle<HeapObject> object(reinterpret_cast<Address*>(address));
int64_t immediate = object->ptr();
RecordRelocInfo(j.rmode(), immediate);
li_ptr(rd, immediate);
DCHECK(EmbeddedObjectMatches(offset, object));
} else if (MustUseReg(j.rmode())) {
int64_t immediate;
if (j.IsHeapObjectRequest()) {
......
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