Commit 0b94bed7 authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

PPC/s390: [Turboprop] Support HeapObject immediate deopt args.

Port bbb1b345

Original Commit Message:

    Adds support for emitting data with a reloc info to enable support
    for HeapObjects for immediate deopt args, required by dynamic check maps.

    In order to do this, a new DATA_EMBEDDED_OBJECT relocinfo type is added.
    This represents a raw object inserted into the instruction stream. For
    x64/ia32 it is treated the same as FULL_EMBEDDED_OBJECT, but on
    Arm/Arm64 this behaves differently since it points directly to the
    embedded object pointer rather than to an instruction that loads it.

R=rmcilroy@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=v8:10582
LOG=N

Change-Id: I949acb69ca6f6a377102eb0ac5f44919d4f7d25b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2612930Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#71931}
parent 90996698
...@@ -149,7 +149,9 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc, ...@@ -149,7 +149,9 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc,
HeapObject RelocInfo::target_object() { HeapObject RelocInfo::target_object() {
DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_));
if (IsCompressedEmbeddedObject(rmode_)) { if (IsDataEmbeddedObject(rmode_)) {
return HeapObject::cast(Object(ReadUnalignedValue<Address>(pc_)));
} else if (IsCompressedEmbeddedObject(rmode_)) {
return HeapObject::cast(Object(DecompressTaggedAny( return HeapObject::cast(Object(DecompressTaggedAny(
host_.address(), host_.address(),
Assembler::target_compressed_address_at(pc_, constant_pool_)))); Assembler::target_compressed_address_at(pc_, constant_pool_))));
...@@ -176,7 +178,9 @@ Handle<HeapObject> Assembler::compressed_embedded_object_handle_at( ...@@ -176,7 +178,9 @@ Handle<HeapObject> Assembler::compressed_embedded_object_handle_at(
Handle<HeapObject> RelocInfo::target_object_handle(Assembler* origin) { Handle<HeapObject> RelocInfo::target_object_handle(Assembler* origin) {
DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_));
if (IsCodeTarget(rmode_)) { if (IsDataEmbeddedObject(rmode_)) {
return Handle<HeapObject>::cast(ReadUnalignedValue<Handle<Object>>(pc_));
} else if (IsCodeTarget(rmode_)) {
return Handle<HeapObject>::cast( return Handle<HeapObject>::cast(
origin->code_target_object_handle_at(pc_, constant_pool_)); origin->code_target_object_handle_at(pc_, constant_pool_));
} else { } else {
...@@ -192,7 +196,10 @@ void RelocInfo::set_target_object(Heap* heap, HeapObject target, ...@@ -192,7 +196,10 @@ void RelocInfo::set_target_object(Heap* heap, HeapObject target,
WriteBarrierMode write_barrier_mode, WriteBarrierMode write_barrier_mode,
ICacheFlushMode icache_flush_mode) { ICacheFlushMode icache_flush_mode) {
DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_));
if (IsCompressedEmbeddedObject(rmode_)) { if (IsDataEmbeddedObject(rmode_)) {
WriteUnalignedValue(pc_, target.ptr());
// No need to flush icache since no instructions were changed.
} else if (IsCompressedEmbeddedObject(rmode_)) {
Assembler::set_target_compressed_address_at( Assembler::set_target_compressed_address_at(
pc_, constant_pool_, CompressTagged(target.ptr()), icache_flush_mode); pc_, constant_pool_, CompressTagged(target.ptr()), icache_flush_mode);
} else { } else {
......
...@@ -1948,20 +1948,32 @@ void Assembler::db(uint8_t data) { ...@@ -1948,20 +1948,32 @@ void Assembler::db(uint8_t data) {
pc_ += sizeof(uint8_t); pc_ += sizeof(uint8_t);
} }
void Assembler::dd(uint32_t data) { void Assembler::dd(uint32_t data, RelocInfo::Mode rmode) {
CheckBuffer(); CheckBuffer();
if (!RelocInfo::IsNone(rmode)) {
DCHECK(RelocInfo::IsDataEmbeddedObject(rmode));
RecordRelocInfo(rmode);
}
*reinterpret_cast<uint32_t*>(pc_) = data; *reinterpret_cast<uint32_t*>(pc_) = data;
pc_ += sizeof(uint32_t); pc_ += sizeof(uint32_t);
} }
void Assembler::dq(uint64_t value) { void Assembler::dq(uint64_t value, RelocInfo::Mode rmode) {
CheckBuffer(); CheckBuffer();
if (!RelocInfo::IsNone(rmode)) {
DCHECK(RelocInfo::IsDataEmbeddedObject(rmode));
RecordRelocInfo(rmode);
}
*reinterpret_cast<uint64_t*>(pc_) = value; *reinterpret_cast<uint64_t*>(pc_) = value;
pc_ += sizeof(uint64_t); pc_ += sizeof(uint64_t);
} }
void Assembler::dp(uintptr_t data) { void Assembler::dp(uintptr_t data, RelocInfo::Mode rmode) {
CheckBuffer(); CheckBuffer();
if (!RelocInfo::IsNone(rmode)) {
DCHECK(RelocInfo::IsDataEmbeddedObject(rmode));
RecordRelocInfo(rmode);
}
*reinterpret_cast<uintptr_t*>(pc_) = data; *reinterpret_cast<uintptr_t*>(pc_) = data;
pc_ += sizeof(uintptr_t); pc_ += sizeof(uintptr_t);
} }
......
...@@ -1123,9 +1123,9 @@ class Assembler : public AssemblerBase { ...@@ -1123,9 +1123,9 @@ class Assembler : public AssemblerBase {
// Writes a single byte or word of data in the code stream. Used // Writes a single byte or word of data in the code stream. Used
// for inline tables, e.g., jump-tables. // for inline tables, e.g., jump-tables.
void db(uint8_t data); void db(uint8_t data);
void dd(uint32_t data); void dd(uint32_t data, RelocInfo::Mode rmode = RelocInfo::NONE);
void dq(uint64_t data); void dq(uint64_t data, RelocInfo::Mode rmode = RelocInfo::NONE);
void dp(uintptr_t data); void dp(uintptr_t data, RelocInfo::Mode rmode = RelocInfo::NONE);
// Read/patch instructions // Read/patch instructions
Instr instr_at(int pos) { Instr instr_at(int pos) {
......
...@@ -145,7 +145,9 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc) { ...@@ -145,7 +145,9 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc) {
HeapObject RelocInfo::target_object() { HeapObject RelocInfo::target_object() {
DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_));
if (IsCompressedEmbeddedObject(rmode_)) { if (IsDataEmbeddedObject(rmode_)) {
return HeapObject::cast(Object(ReadUnalignedValue<Address>(pc_)));
} else if (IsCompressedEmbeddedObject(rmode_)) {
return HeapObject::cast(Object(DecompressTaggedAny( return HeapObject::cast(Object(DecompressTaggedAny(
host_.address(), host_.address(),
Assembler::target_compressed_address_at(pc_, constant_pool_)))); Assembler::target_compressed_address_at(pc_, constant_pool_))));
...@@ -173,7 +175,9 @@ Handle<HeapObject> Assembler::compressed_embedded_object_handle_at( ...@@ -173,7 +175,9 @@ Handle<HeapObject> Assembler::compressed_embedded_object_handle_at(
Handle<HeapObject> RelocInfo::target_object_handle(Assembler* origin) { Handle<HeapObject> RelocInfo::target_object_handle(Assembler* origin) {
DCHECK(IsRelativeCodeTarget(rmode_) || IsCodeTarget(rmode_) || DCHECK(IsRelativeCodeTarget(rmode_) || IsCodeTarget(rmode_) ||
IsEmbeddedObjectMode(rmode_)); IsEmbeddedObjectMode(rmode_));
if (IsCodeTarget(rmode_) || IsRelativeCodeTarget(rmode_)) { if (IsDataEmbeddedObject(rmode_)) {
return Handle<HeapObject>::cast(ReadUnalignedValue<Handle<Object>>(pc_));
} else if (IsCodeTarget(rmode_) || IsRelativeCodeTarget(rmode_)) {
return Handle<HeapObject>::cast(origin->code_target_object_handle_at(pc_)); return Handle<HeapObject>::cast(origin->code_target_object_handle_at(pc_));
} else { } else {
if (IsCompressedEmbeddedObject(rmode_)) { if (IsCompressedEmbeddedObject(rmode_)) {
...@@ -188,7 +192,10 @@ void RelocInfo::set_target_object(Heap* heap, HeapObject target, ...@@ -188,7 +192,10 @@ void RelocInfo::set_target_object(Heap* heap, HeapObject target,
WriteBarrierMode write_barrier_mode, WriteBarrierMode write_barrier_mode,
ICacheFlushMode icache_flush_mode) { ICacheFlushMode icache_flush_mode) {
DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsEmbeddedObjectMode(rmode_));
if (IsCompressedEmbeddedObject(rmode_)) { if (IsDataEmbeddedObject(rmode_)) {
WriteUnalignedValue(pc_, target.ptr());
// No need to flush icache since no instructions were changed.
} else if (IsCompressedEmbeddedObject(rmode_)) {
Assembler::set_target_compressed_address_at( Assembler::set_target_compressed_address_at(
pc_, constant_pool_, CompressTagged(target.ptr()), icache_flush_mode); pc_, constant_pool_, CompressTagged(target.ptr()), icache_flush_mode);
} else { } else {
......
...@@ -781,20 +781,32 @@ void Assembler::db(uint8_t data) { ...@@ -781,20 +781,32 @@ void Assembler::db(uint8_t data) {
pc_ += sizeof(uint8_t); pc_ += sizeof(uint8_t);
} }
void Assembler::dd(uint32_t data) { void Assembler::dd(uint32_t data, RelocInfo::Mode rmode) {
CheckBuffer(); CheckBuffer();
if (!RelocInfo::IsNone(rmode)) {
DCHECK(RelocInfo::IsDataEmbeddedObject(rmode));
RecordRelocInfo(rmode);
}
*reinterpret_cast<uint32_t*>(pc_) = data; *reinterpret_cast<uint32_t*>(pc_) = data;
pc_ += sizeof(uint32_t); pc_ += sizeof(uint32_t);
} }
void Assembler::dq(uint64_t value) { void Assembler::dq(uint64_t value, RelocInfo::Mode rmode) {
CheckBuffer(); CheckBuffer();
if (!RelocInfo::IsNone(rmode)) {
DCHECK(RelocInfo::IsDataEmbeddedObject(rmode));
RecordRelocInfo(rmode);
}
*reinterpret_cast<uint64_t*>(pc_) = value; *reinterpret_cast<uint64_t*>(pc_) = value;
pc_ += sizeof(uint64_t); pc_ += sizeof(uint64_t);
} }
void Assembler::dp(uintptr_t data) { void Assembler::dp(uintptr_t data, RelocInfo::Mode rmode) {
CheckBuffer(); CheckBuffer();
if (!RelocInfo::IsNone(rmode)) {
DCHECK(RelocInfo::IsDataEmbeddedObject(rmode));
RecordRelocInfo(rmode);
}
*reinterpret_cast<uintptr_t*>(pc_) = data; *reinterpret_cast<uintptr_t*>(pc_) = data;
pc_ += sizeof(uintptr_t); pc_ += sizeof(uintptr_t);
} }
......
...@@ -1310,9 +1310,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { ...@@ -1310,9 +1310,9 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
// Writes a single byte or word of data in the code stream. Used // Writes a single byte or word of data in the code stream. Used
// for inline tables, e.g., jump-tables. // for inline tables, e.g., jump-tables.
void db(uint8_t data); void db(uint8_t data);
void dd(uint32_t data); void dd(uint32_t data, RelocInfo::Mode rmode = RelocInfo::NONE);
void dq(uint64_t data); void dq(uint64_t data, RelocInfo::Mode rmode = RelocInfo::NONE);
void dp(uintptr_t data); void dp(uintptr_t data, RelocInfo::Mode rmode = RelocInfo::NONE);
// Read/patch instructions // Read/patch instructions
SixByteInstr instr_at(int pos) { SixByteInstr instr_at(int pos) {
......
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