PPC: Add new relocation type WASM_MEMORY_SIZE_REFERENCE, use relocatable pointers to update wasm memory size references in generated code.
Port 117a56b7c2
Original commit message:
- Add new RelocInfo mode WASM_MEMORY_SIZE_REFERENCE in the assembler and add relocation information to immediates in compare instructions.
- Use relocatable constants for MemSize/BoundsCheck in the wasm compiler
R=gdeepti@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com
BUG=
LOG=N
Review-Url: https://codereview.chromium.org/1948263003
Cr-Commit-Position: refs/heads/master@{#36054}
This commit is contained in:
parent
e11eb9a7d7
commit
a870cf3abd
@ -1924,21 +1924,23 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
|
|||||||
destination->IsRegister() ? g.ToRegister(destination) : kScratchReg;
|
destination->IsRegister() ? g.ToRegister(destination) : kScratchReg;
|
||||||
switch (src.type()) {
|
switch (src.type()) {
|
||||||
case Constant::kInt32:
|
case Constant::kInt32:
|
||||||
#if !V8_TARGET_ARCH_PPC64
|
#if V8_TARGET_ARCH_PPC64
|
||||||
if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE) {
|
if (src.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE) {
|
||||||
|
#else
|
||||||
|
if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE ||
|
||||||
|
src.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE) {
|
||||||
|
#endif
|
||||||
__ mov(dst, Operand(src.ToInt32(), src.rmode()));
|
__ mov(dst, Operand(src.ToInt32(), src.rmode()));
|
||||||
} else {
|
} else {
|
||||||
#endif
|
|
||||||
__ mov(dst, Operand(src.ToInt32()));
|
__ mov(dst, Operand(src.ToInt32()));
|
||||||
#if !V8_TARGET_ARCH_PPC64
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case Constant::kInt64:
|
case Constant::kInt64:
|
||||||
#if V8_TARGET_ARCH_PPC64
|
#if V8_TARGET_ARCH_PPC64
|
||||||
if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE) {
|
if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE) {
|
||||||
__ mov(dst, Operand(src.ToInt64(), src.rmode()));
|
__ mov(dst, Operand(src.ToInt64(), src.rmode()));
|
||||||
} else {
|
} else {
|
||||||
|
DCHECK(src.rmode() != RelocInfo::WASM_MEMORY_SIZE_REFERENCE);
|
||||||
#endif
|
#endif
|
||||||
__ mov(dst, Operand(src.ToInt64()));
|
__ mov(dst, Operand(src.ToInt64()));
|
||||||
#if V8_TARGET_ARCH_PPC64
|
#if V8_TARGET_ARCH_PPC64
|
||||||
|
@ -89,11 +89,6 @@ Address RelocInfo::target_address() {
|
|||||||
return Assembler::target_address_at(pc_, host_);
|
return Assembler::target_address_at(pc_, host_);
|
||||||
}
|
}
|
||||||
|
|
||||||
Address RelocInfo::wasm_memory_reference() {
|
|
||||||
DCHECK(IsWasmMemoryReference(rmode_));
|
|
||||||
return Assembler::target_address_at(pc_, host_);
|
|
||||||
}
|
|
||||||
|
|
||||||
Address RelocInfo::target_address_address() {
|
Address RelocInfo::target_address_address() {
|
||||||
DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) ||
|
DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) ||
|
||||||
rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE);
|
rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE);
|
||||||
@ -183,19 +178,6 @@ Address Assembler::return_address_from_call_start(Address pc) {
|
|||||||
return pc + (len + 2) * kInstrSize;
|
return pc + (len + 2) * kInstrSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelocInfo::update_wasm_memory_reference(
|
|
||||||
Address old_base, Address new_base, size_t old_size, size_t new_size,
|
|
||||||
ICacheFlushMode icache_flush_mode) {
|
|
||||||
DCHECK(IsWasmMemoryReference(rmode_));
|
|
||||||
DCHECK(old_base <= wasm_memory_reference() &&
|
|
||||||
wasm_memory_reference() < old_base + old_size);
|
|
||||||
Address updated_reference = new_base + (wasm_memory_reference() - old_base);
|
|
||||||
DCHECK(new_base <= updated_reference &&
|
|
||||||
updated_reference < new_base + new_size);
|
|
||||||
Assembler::set_target_address_at(isolate_, pc_, host_, updated_reference,
|
|
||||||
icache_flush_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
Object* RelocInfo::target_object() {
|
Object* RelocInfo::target_object() {
|
||||||
DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
|
DCHECK(IsCodeTarget(rmode_) || rmode_ == EMBEDDED_OBJECT);
|
||||||
return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_));
|
return reinterpret_cast<Object*>(Assembler::target_address_at(pc_, host_));
|
||||||
|
@ -155,6 +155,43 @@ bool RelocInfo::IsInConstantPool() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Address RelocInfo::wasm_memory_reference() {
|
||||||
|
DCHECK(IsWasmMemoryReference(rmode_));
|
||||||
|
return Assembler::target_address_at(pc_, host_);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t RelocInfo::wasm_memory_size_reference() {
|
||||||
|
DCHECK(IsWasmMemorySizeReference(rmode_));
|
||||||
|
return static_cast<uint32_t>(
|
||||||
|
reinterpret_cast<intptr_t>(Assembler::target_address_at(pc_, host_)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void RelocInfo::update_wasm_memory_reference(
|
||||||
|
Address old_base, Address new_base, uint32_t old_size, uint32_t new_size,
|
||||||
|
ICacheFlushMode icache_flush_mode) {
|
||||||
|
DCHECK(IsWasmMemoryReference(rmode_) || IsWasmMemorySizeReference(rmode_));
|
||||||
|
if (IsWasmMemoryReference(rmode_)) {
|
||||||
|
Address updated_memory_reference;
|
||||||
|
DCHECK(old_base <= wasm_memory_reference() &&
|
||||||
|
wasm_memory_reference() < old_base + old_size);
|
||||||
|
updated_memory_reference = new_base + (wasm_memory_reference() - old_base);
|
||||||
|
DCHECK(new_base <= updated_memory_reference &&
|
||||||
|
updated_memory_reference < new_base + new_size);
|
||||||
|
Assembler::set_target_address_at(
|
||||||
|
isolate_, pc_, host_, updated_memory_reference, icache_flush_mode);
|
||||||
|
} else if (IsWasmMemorySizeReference(rmode_)) {
|
||||||
|
uint32_t updated_size_reference;
|
||||||
|
DCHECK(wasm_memory_size_reference() <= old_size);
|
||||||
|
updated_size_reference =
|
||||||
|
new_size + (wasm_memory_size_reference() - old_size);
|
||||||
|
DCHECK(updated_size_reference <= new_size);
|
||||||
|
Assembler::set_target_address_at(
|
||||||
|
isolate_, pc_, host_, reinterpret_cast<Address>(updated_size_reference),
|
||||||
|
icache_flush_mode);
|
||||||
|
} else {
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// Implementation of Operand and MemOperand
|
// Implementation of Operand and MemOperand
|
||||||
|
Loading…
Reference in New Issue
Block a user