Commit 79c350b3 authored by jyan's avatar jyan Committed by Commit bot

S390: Add new relocation type WASM_MEMORY_SIZE_REFERENCE, use relocatable...

S390: Add new relocation type WASM_MEMORY_SIZE_REFERENCE, use relocatable pointers to update wasm memory size references in generated code.

port 117a56b7

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, mbrandy@us.ibm.com, bjaideep@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review-Url: https://codereview.chromium.org/1955593003
Cr-Commit-Position: refs/heads/master@{#36056}
parent c6405c4a
...@@ -1937,21 +1937,23 @@ void CodeGenerator::AssembleMove(InstructionOperand* source, ...@@ -1937,21 +1937,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_S390X #if V8_TARGET_ARCH_S390X
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 {
__ mov(dst, Operand(src.ToInt32())); __ mov(dst, Operand(src.ToInt32()));
} }
#else
__ mov(dst, Operand(src.ToInt32()));
#endif // V8_TARGET_ARCH_S390X
break; break;
case Constant::kInt64: case Constant::kInt64:
#if V8_TARGET_ARCH_S390X #if V8_TARGET_ARCH_S390X
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);
__ mov(dst, Operand(src.ToInt64())); __ mov(dst, Operand(src.ToInt64()));
} }
#else #else
......
...@@ -93,11 +93,6 @@ Address RelocInfo::target_address() { ...@@ -93,11 +93,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);
...@@ -156,19 +151,6 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc) { ...@@ -156,19 +151,6 @@ Handle<Object> Assembler::code_target_object_handle_at(Address pc) {
return code_targets_[index]; return code_targets_[index];
} }
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_));
......
...@@ -217,6 +217,44 @@ bool RelocInfo::IsCodedSpecially() { ...@@ -217,6 +217,44 @@ bool RelocInfo::IsCodedSpecially() {
bool RelocInfo::IsInConstantPool() { return false; } bool RelocInfo::IsInConstantPool() { 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
// See assembler-s390-inl.h for inlined constructors // See assembler-s390-inl.h for inlined constructors
......
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