PPC/s390: [wasm] JIT using WasmCodeManager: codegen components.

Port fdb067dc2c

Original Commit Message:

    This CL introduces those codegen changes necessary for JIT-ing using
    the WasmCodeManager.

R=mtrofin@chromium.org, joransiu@ca.ibm.com, bjaideep@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Iee9f4f63fe28ab2d25b4b37d10e44a7a1337c7e0
Reviewed-on: https://chromium-review.googlesource.com/783877
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: Mircea Trofin <mtrofin@chromium.org>
Reviewed-by: Joran Siu <joransiu@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#49590}
This commit is contained in:
Junliang Yan 2017-11-22 14:50:33 -05:00 committed by Commit Bot
parent cb46310a79
commit 1f7b015160
6 changed files with 104 additions and 4 deletions

View File

@ -994,6 +994,26 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
frame_access_state()->ClearSPDelta(); frame_access_state()->ClearSPDelta();
break; 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<Address>(
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 kArchTailCallCodeObjectFromJSFunction:
case kArchTailCallCodeObject: { case kArchTailCallCodeObject: {
if (opcode == kArchTailCallCodeObjectFromJSFunction) { if (opcode == kArchTailCallCodeObjectFromJSFunction) {
@ -1016,6 +1036,26 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
frame_access_state()->SetFrameAccessToDefault(); frame_access_state()->SetFrameAccessToDefault();
break; 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<Address>(
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: { case kArchTailCallAddress: {
CHECK(!instr->InputAt(0)->IsImmediate()); CHECK(!instr->InputAt(0)->IsImmediate());
__ Jump(i.InputRegister(0)); __ Jump(i.InputRegister(0));

View File

@ -1210,6 +1210,25 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
frame_access_state()->ClearSPDelta(); frame_access_state()->ClearSPDelta();
break; 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<Address>(
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 kArchTailCallCodeObjectFromJSFunction:
case kArchTailCallCodeObject: { case kArchTailCallCodeObject: {
if (opcode == kArchTailCallCodeObjectFromJSFunction) { if (opcode == kArchTailCallCodeObjectFromJSFunction) {
@ -1231,6 +1250,25 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
frame_access_state()->SetFrameAccessToDefault(); frame_access_state()->SetFrameAccessToDefault();
break; 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<Address>(
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: { case kArchTailCallAddress: {
CHECK(!instr->InputAt(0)->IsImmediate()); CHECK(!instr->InputAt(0)->IsImmediate());
__ Jump(i.InputRegister(0)); __ Jump(i.InputRegister(0));

View File

@ -86,12 +86,12 @@ Address RelocInfo::target_internal_reference_address() {
Address RelocInfo::target_address() { Address RelocInfo::target_address() {
DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_));
return Assembler::target_address_at(pc_, host_); 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_) || IsWasmCall(rmode_) ||
rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE); rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE);
if (FLAG_enable_embedded_constant_pool && if (FLAG_enable_embedded_constant_pool &&

View File

@ -182,6 +182,17 @@ void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size,
reinterpret_cast<Address>(size), flush_mode); reinterpret_cast<Address>(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 // Implementation of Operand and MemOperand
// See assembler-ppc-inl.h for inlined constructors // See assembler-ppc-inl.h for inlined constructors

View File

@ -92,12 +92,12 @@ Address RelocInfo::target_internal_reference_address() {
} }
Address RelocInfo::target_address() { Address RelocInfo::target_address() {
DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)); DCHECK(IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_) || IsWasmCall(rmode_));
return Assembler::target_address_at(pc_, host_); 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_) || IsWasmCall(rmode_) ||
rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE); rmode_ == EMBEDDED_OBJECT || rmode_ == EXTERNAL_REFERENCE);
// Read the address of the word containing the target_address in an // Read the address of the word containing the target_address in an

View File

@ -290,6 +290,17 @@ void RelocInfo::set_embedded_size(Isolate* isolate, uint32_t size,
reinterpret_cast<Address>(size), flush_mode); reinterpret_cast<Address>(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 // Implementation of Operand and MemOperand
// See assembler-s390-inl.h for inlined constructors // See assembler-s390-inl.h for inlined constructors