diff --git a/src/compiler/ppc/code-generator-ppc.cc b/src/compiler/ppc/code-generator-ppc.cc index 34282d26c2..11fde27fc9 100644 --- a/src/compiler/ppc/code-generator-ppc.cc +++ b/src/compiler/ppc/code-generator-ppc.cc @@ -994,6 +994,26 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( frame_access_state()->ClearSPDelta(); break; } + 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()) { + Address wasm_code = reinterpret_cast
( + i.ToConstant(instr->InputAt(0)).ToInt32()); + __ Call(wasm_code, rmode); + } else { + __ Call(i.InputRegister(0)); + } + RecordCallPosition(instr); + DCHECK_EQ(LeaveRC, i.OutputRCBit()); + frame_access_state()->ClearSPDelta(); + break; + } case kArchTailCallCodeObjectFromJSFunction: case kArchTailCallCodeObject: { if (opcode == kArchTailCallCodeObjectFromJSFunction) { @@ -1016,6 +1036,26 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( frame_access_state()->SetFrameAccessToDefault(); break; } + 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 = reinterpret_cast( + i.ToConstant(instr->InputAt(0)).ToInt32()); + __ Jump(wasm_code, rmode); + } else { + __ Jump(i.InputRegister(0)); + } + DCHECK_EQ(LeaveRC, i.OutputRCBit()); + frame_access_state()->ClearSPDelta(); + frame_access_state()->SetFrameAccessToDefault(); + break; + } case kArchTailCallAddress: { CHECK(!instr->InputAt(0)->IsImmediate()); __ Jump(i.InputRegister(0)); diff --git a/src/compiler/s390/code-generator-s390.cc b/src/compiler/s390/code-generator-s390.cc index 334fdc3ba2..f49a8e540c 100644 --- a/src/compiler/s390/code-generator-s390.cc +++ b/src/compiler/s390/code-generator-s390.cc @@ -1210,6 +1210,25 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( frame_access_state()->ClearSPDelta(); break; } + 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()) { + Address wasm_code = reinterpret_cast( + i.ToConstant(instr->InputAt(0)).ToInt32()); + __ Call(wasm_code, rmode); + } else { + __ Call(i.InputRegister(0)); + } + RecordCallPosition(instr); + frame_access_state()->ClearSPDelta(); + break; + } case kArchTailCallCodeObjectFromJSFunction: case kArchTailCallCodeObject: { if (opcode == kArchTailCallCodeObjectFromJSFunction) { @@ -1231,6 +1250,25 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( frame_access_state()->SetFrameAccessToDefault(); break; } + 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 = reinterpret_cast( + i.ToConstant(instr->InputAt(0)).ToInt32()); + __ Jump(wasm_code, rmode); + } else { + __ Jump(i.InputRegister(0)); + } + frame_access_state()->ClearSPDelta(); + frame_access_state()->SetFrameAccessToDefault(); + break; + } case kArchTailCallAddress: { CHECK(!instr->InputAt(0)->IsImmediate()); __ Jump(i.InputRegister(0)); diff --git a/src/ppc/assembler-ppc-inl.h b/src/ppc/assembler-ppc-inl.h index 41f9419c54..d9b12ac8db 100644 --- a/src/ppc/assembler-ppc-inl.h +++ b/src/ppc/assembler-ppc-inl.h @@ -86,12 +86,12 @@ Address RelocInfo::target_internal_reference_address() { Address RelocInfo::target_address() { - DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); + DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); return Assembler::target_address_at(pc_, host_); } Address RelocInfo::target_address_address() { - DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || + DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_) || rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE); if (FLAG_enable_embedded_constant_pool && diff --git a/src/ppc/assembler-ppc.cc b/src/ppc/assembler-ppc.cc index e44e085862..0c4a518772 100644 --- a/src/ppc/assembler-ppc.cc +++ b/src/ppc/assembler-ppc.cc @@ -182,6 +182,17 @@ void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, reinterpret_cast(size), flush_mode); } +void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, + ICacheFlushMode icache_flush_mode) { + DCHECK_EQ(rmode_, JS_TO_WASM_CALL); + set_embedded_address(isolate, address, icache_flush_mode); +} + +Address RelocInfo::js_to_wasm_address() const { + DCHECK_EQ(rmode_, JS_TO_WASM_CALL); + return embedded_address(); +} + // ----------------------------------------------------------------------------- // Implementation of Operand and MemOperand // See assembler-ppc-inl.h for inlined constructors diff --git a/src/s390/assembler-s390-inl.h b/src/s390/assembler-s390-inl.h index e6ba96692b..d8d7ce4256 100644 --- a/src/s390/assembler-s390-inl.h +++ b/src/s390/assembler-s390-inl.h @@ -92,12 +92,12 @@ Address RelocInfo::target_internal_reference_address() { } Address RelocInfo::target_address() { - DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); + DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_)); return Assembler::target_address_at(pc_, host_); } Address RelocInfo::target_address_address() { - DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || + DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_) || rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE); // Read the address of the word containing the target_address in an diff --git a/src/s390/assembler-s390.cc b/src/s390/assembler-s390.cc index 3e8ce972a2..70701beb72 100644 --- a/src/s390/assembler-s390.cc +++ b/src/s390/assembler-s390.cc @@ -290,6 +290,17 @@ void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size, reinterpret_cast(size), flush_mode); } +void RelocInfo::set_js_to_wasm_address(Isolate* isolate, Address address, + ICacheFlushMode icache_flush_mode) { + DCHECK_EQ(rmode_, JS_TO_WASM_CALL); + set_embedded_address(isolate, address, icache_flush_mode); +} + +Address RelocInfo::js_to_wasm_address() const { + DCHECK_EQ(rmode_, JS_TO_WASM_CALL); + return embedded_address(); +} + // ----------------------------------------------------------------------------- // Implementation of Operand and MemOperand // See assembler-s390-inl.h for inlined constructors