Commit c5be7ab8 authored by jgruber's avatar jgruber Committed by Commit Bot

[builtins] Support specially-coded off-heap addresses

On {mips,mips64,ppc,s390}, target addresses are specially coded into
the instruction stream, i.e. split between a series of instructions.
This adds support for that case, similar to what happens with runtime
external references.

Bug: v8:6666,v8:7571
Change-Id: Ie6f62bc0ca3183f005d8380f6f8b908fa12ea62b
Reviewed-on: https://chromium-review.googlesource.com/970824
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52091}
parent 8452c146
......@@ -66,13 +66,8 @@ declare_args() {
v8_enable_fast_mksnapshot = false
# Enable embedded builtins.
# TODO(jgruber,v8:6666): Support mips, mips64, ia32 and maybe MSVC.
v8_enable_embedded_builtins =
v8_current_cpu != "x86" && v8_current_cpu != "mips" &&
v8_current_cpu != "mipsel" && v8_current_cpu != "mips64" &&
v8_current_cpu != "mips64el" && v8_current_cpu != "ppc" &&
v8_current_cpu != "ppc64" && v8_current_cpu != "s390" &&
v8_current_cpu != "s390x" && (!is_win || is_clang)
# TODO(jgruber,v8:6666): Support ia32 and maybe MSVC.
v8_enable_embedded_builtins = v8_current_cpu != "x86" && (!is_win || is_clang)
# Enable code-generation-time checking of types in the CodeStubAssembler.
v8_enable_verify_csa = false
......
......@@ -202,6 +202,17 @@ const int kLastChunkTagBits = 1;
const int kLastChunkTagMask = 1;
const int kLastChunkTag = 1;
// static
bool RelocInfo::OffHeapTargetIsCodedSpecially() {
#if defined(V8_TARGET_ARCH_ARM) || defined(V8_TARGET_ARCH_ARM64) || \
defined(V8_TARGET_ARCH_X64) || defined(V8_TARGET_ARCH_IA32)
return false;
#elif defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64) || \
defined(V8_TARGET_ARCH_PPC) || defined(V8_TARGET_ARCH_S390)
return true;
#endif
}
void RelocInfo::set_wasm_context_reference(Address address,
ICacheFlushMode icache_flush_mode) {
DCHECK(IsWasmContextReference(rmode_));
......
......@@ -497,6 +497,10 @@ class RelocInfo {
// instructions).
bool IsCodedSpecially();
// The static pendant to IsCodedSpecially, just for off-heap targets. Used
// during deserialization, when we don't actually have a RelocInfo handy.
static bool OffHeapTargetIsCodedSpecially();
// If true, the pointer this relocation info refers to is an entry in the
// constant pool, otherwise the pointer is embedded in the instruction stream.
bool IsInConstantPool();
......
......@@ -526,12 +526,22 @@ bool Deserializer<AllocatorT>::ReadData(MaybeObject** current,
EmbeddedData d = EmbeddedData::FromBlob(isolate->embedded_blob(),
isolate->embedded_blob_size());
const uint8_t* address = d.InstructionStartOfBuiltin(builtin_index);
MaybeObject* o =
reinterpret_cast<MaybeObject*>(const_cast<uint8_t*>(address));
UnalignedCopy(current, &o);
CHECK_NOT_NULL(o);
current++;
CHECK_NOT_NULL(address);
if (RelocInfo::OffHeapTargetIsCodedSpecially()) {
Address location_of_branch_data = reinterpret_cast<Address>(current);
Assembler::deserialization_set_special_target_at(
location_of_branch_data,
Code::cast(HeapObject::FromAddress(current_object_address)),
const_cast<Address>(address));
location_of_branch_data += Assembler::kSpecialTargetSize;
current = reinterpret_cast<MaybeObject**>(location_of_branch_data);
} else {
MaybeObject* o =
reinterpret_cast<MaybeObject*>(const_cast<uint8_t*>(address));
UnalignedCopy(current, &o);
current++;
}
#else
UNREACHABLE();
#endif
......
......@@ -843,7 +843,7 @@ void Serializer<AllocatorT>::ObjectSerializer::VisitOffHeapTarget(
sink_->Put(kOffHeapTarget, "OffHeapTarget");
sink_->PutInt(skip, "SkipB4OffHeapTarget");
sink_->PutInt(host->builtin_index(), "builtin index");
bytes_processed_so_far_ += kPointerSize;
bytes_processed_so_far_ += rinfo->target_address_size();
#else
UNREACHABLE();
#endif
......
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