Commit 94aac004 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

PPC/s390: [wasm] Make stack check independent of the Isolate.

Port c96ac82c

Original Commit Message:

    This makes stack checks in WasmCode independent of the underlying
    Isolate by loading the limit address from the WasmInstanceObject instead
    of embedding it into the instruction stream. It hence removes the last
    use of the Isolate field from WasmGraphBuilder.

    Additionally this introduces the notion of a "runtime stub" which
    represents stub code global to the NativeModule that can be directly
    called from each WasmCode in the same module. These stubs can act as
    trampolines via which Isolate-independent WasmCode can enter other V8
    builtins or runtime functions that remain Isolate-dependent. They will
    eventually replace the current "trampoline" in a NativeModule.

R=mstarzinger@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:7424
LOG=N

Change-Id: I5745a20133c930aecb80119e71ac1d8717e267bf
Reviewed-on: https://chromium-review.googlesource.com/1085276Reviewed-by: 's avatarJoran Siu <joransiu@ca.ibm.com>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#53503}
parent aaa700bd
......@@ -927,20 +927,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchCallWasmFunction: {
// We must not share code targets for calls to builtins for wasm code, as
// they might need to be patched individually.
RelocInfo::Mode rmode = RelocInfo::JS_TO_WASM_CALL;
if (info()->IsWasm()) {
rmode = RelocInfo::WASM_CALL;
}
if (instr->InputAt(0)->IsImmediate()) {
Constant constant = i.ToConstant(instr->InputAt(0));
#ifdef V8_TARGET_ARCH_PPC64
Address wasm_code =
static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt64());
Address wasm_code = static_cast<Address>(constant.ToInt64());
#else
Address wasm_code =
static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt32());
Address wasm_code = static_cast<Address>(constant.ToInt32());
#endif
__ Call(wasm_code, rmode);
__ Call(wasm_code, constant.rmode());
} else {
__ Call(i.InputRegister(0));
}
......@@ -974,15 +968,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTailCallWasm: {
// We must not share code targets for calls to builtins for wasm code, as
// they might need to be patched individually.
RelocInfo::Mode rmode = RelocInfo::JS_TO_WASM_CALL;
if (info()->IsWasm()) {
rmode = RelocInfo::WASM_CALL;
}
if (instr->InputAt(0)->IsImmediate()) {
Address wasm_code =
static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt32());
__ Jump(wasm_code, rmode);
Constant constant = i.ToConstant(instr->InputAt(0));
#ifdef V8_TARGET_ARCH_S390X
Address wasm_code = static_cast<Address>(constant.ToInt64());
#else
Address wasm_code = static_cast<Address>(constant.ToInt32());
#endif
__ Jump(wasm_code, constant.rmode());
} else {
__ Jump(i.InputRegister(0));
}
......
......@@ -1367,20 +1367,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchCallWasmFunction: {
// We must not share code targets for calls to builtins for wasm code, as
// they might need to be patched individually.
RelocInfo::Mode rmode = RelocInfo::JS_TO_WASM_CALL;
if (info()->IsWasm()) {
rmode = RelocInfo::WASM_CALL;
}
if (instr->InputAt(0)->IsImmediate()) {
Constant constant = i.ToConstant(instr->InputAt(0));
#ifdef V8_TARGET_ARCH_S390X
Address wasm_code =
static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt64());
Address wasm_code = static_cast<Address>(constant.ToInt64());
#else
Address wasm_code =
static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt32());
Address wasm_code = static_cast<Address>(constant.ToInt32());
#endif
__ Call(wasm_code, rmode);
__ Call(wasm_code, constant.rmode());
} else {
__ Call(i.InputRegister(0));
}
......@@ -1412,15 +1406,14 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTailCallWasm: {
// We must not share code targets for calls to builtins for wasm code, as
// they might need to be patched individually.
RelocInfo::Mode rmode = RelocInfo::JS_TO_WASM_CALL;
if (info()->IsWasm()) {
rmode = RelocInfo::WASM_CALL;
}
if (instr->InputAt(0)->IsImmediate()) {
Address wasm_code =
static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt32());
__ Jump(wasm_code, rmode);
Constant constant = i.ToConstant(instr->InputAt(0));
#ifdef V8_TARGET_ARCH_S390X
Address wasm_code = static_cast<Address>(constant.ToInt64());
#else
Address wasm_code = static_cast<Address>(constant.ToInt32());
#endif
__ Jump(wasm_code, constant.rmode());
} else {
__ Jump(i.InputRegister(0));
}
......
......@@ -161,16 +161,6 @@ bool RelocInfo::IsInConstantPool() {
return false;
}
uint32_t RelocInfo::embedded_size() const {
return static_cast<uint32_t>(
Assembler::target_address_at(pc_, constant_pool_));
}
void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) {
Assembler::set_target_address_at(pc_, constant_pool_,
static_cast<Address>(size), flush_mode);
}
void RelocInfo::set_js_to_wasm_address(Address address,
ICacheFlushMode icache_flush_mode) {
DCHECK_EQ(rmode_, JS_TO_WASM_CALL);
......@@ -183,6 +173,12 @@ Address RelocInfo::js_to_wasm_address() const {
return Assembler::target_address_at(pc_, constant_pool_);
}
uint32_t RelocInfo::wasm_stub_call_tag() const {
DCHECK_EQ(rmode_, WASM_STUB_CALL);
return static_cast<uint32_t>(
Assembler::target_address_at(pc_, constant_pool_));
}
// -----------------------------------------------------------------------------
// Implementation of Operand and MemOperand
// See assembler-ppc-inl.h for inlined constructors
......
......@@ -270,16 +270,6 @@ bool RelocInfo::IsCodedSpecially() {
bool RelocInfo::IsInConstantPool() { return false; }
uint32_t RelocInfo::embedded_size() const {
return static_cast<uint32_t>(
Assembler::target_address_at(pc_, constant_pool_));
}
void RelocInfo::set_embedded_size(uint32_t size, ICacheFlushMode flush_mode) {
Assembler::set_target_address_at(pc_, constant_pool_,
static_cast<Address>(size), flush_mode);
}
void RelocInfo::set_js_to_wasm_address(Address address,
ICacheFlushMode icache_flush_mode) {
DCHECK_EQ(rmode_, JS_TO_WASM_CALL);
......@@ -292,6 +282,12 @@ Address RelocInfo::js_to_wasm_address() const {
return Assembler::target_address_at(pc_, constant_pool_);
}
uint32_t RelocInfo::wasm_stub_call_tag() const {
DCHECK_EQ(rmode_, WASM_STUB_CALL);
return static_cast<uint32_t>(
Assembler::target_address_at(pc_, constant_pool_));
}
// -----------------------------------------------------------------------------
// Implementation of Operand and MemOperand
// 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