summaryrefslogtreecommitdiff
path: root/deps/v8/src/compiler/arm64/code-generator-arm64.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/compiler/arm64/code-generator-arm64.cc')
-rw-r--r--deps/v8/src/compiler/arm64/code-generator-arm64.cc141
1 files changed, 62 insertions, 79 deletions
diff --git a/deps/v8/src/compiler/arm64/code-generator-arm64.cc b/deps/v8/src/compiler/arm64/code-generator-arm64.cc
index 751ad4599b..a7c5beee4c 100644
--- a/deps/v8/src/compiler/arm64/code-generator-arm64.cc
+++ b/deps/v8/src/compiler/arm64/code-generator-arm64.cc
@@ -130,6 +130,7 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
return Operand(InputRegister32(index), SXTW);
case kMode_MRI:
case kMode_MRR:
+ case kMode_Root:
break;
}
UNREACHABLE();
@@ -159,13 +160,13 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
return Operand(InputRegister64(index), SXTW);
case kMode_MRI:
case kMode_MRR:
+ case kMode_Root:
break;
}
UNREACHABLE();
}
- MemOperand MemoryOperand(size_t* first_index) {
- const size_t index = *first_index;
+ MemOperand MemoryOperand(size_t index = 0) {
switch (AddressingModeField::decode(instr_->opcode())) {
case kMode_None:
case kMode_Operand2_R_LSR_I:
@@ -177,24 +178,19 @@ class Arm64OperandConverter final : public InstructionOperandConverter {
case kMode_Operand2_R_SXTH:
case kMode_Operand2_R_SXTW:
break;
+ case kMode_Root:
+ return MemOperand(kRootRegister, InputInt64(index));
case kMode_Operand2_R_LSL_I:
- *first_index += 3;
return MemOperand(InputRegister(index + 0), InputRegister(index + 1),
LSL, InputInt32(index + 2));
case kMode_MRI:
- *first_index += 2;
return MemOperand(InputRegister(index + 0), InputInt32(index + 1));
case kMode_MRR:
- *first_index += 2;
return MemOperand(InputRegister(index + 0), InputRegister(index + 1));
}
UNREACHABLE();
}
- MemOperand MemoryOperand(size_t first_index = 0) {
- return MemoryOperand(&first_index);
- }
-
Operand ToOperand(InstructionOperand* op) {
if (op->IsRegister()) {
return Operand(ToRegister(op));
@@ -601,17 +597,15 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
ArchOpcode arch_opcode = ArchOpcodeField::decode(opcode);
switch (arch_opcode) {
case kArchCallCodeObject: {
- // We must not share code targets for calls to builtins for wasm code, as
- // they might need to be patched individually.
- internal::Assembler::BlockCodeTargetSharingScope scope;
- if (info()->IsWasm()) scope.Open(tasm());
-
if (instr->InputAt(0)->IsImmediate()) {
__ Call(i.InputCode(0), RelocInfo::CODE_TARGET);
} else {
- Register target = i.InputRegister(0);
- __ Add(target, target, Code::kHeaderSize - kHeapObjectTag);
- __ Call(target);
+ Register reg = i.InputRegister(0);
+ DCHECK_IMPLIES(
+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister),
+ reg == kJavaScriptCallCodeStartRegister);
+ __ Add(reg, reg, Code::kHeaderSize - kHeapObjectTag);
+ __ Call(reg);
}
RecordCallPosition(instr);
frame_access_state()->ClearSPDelta();
@@ -619,13 +613,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
case kArchCallWasmFunction: {
if (instr->InputAt(0)->IsImmediate()) {
- Address wasm_code =
- static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt64());
- if (info()->IsWasm()) {
- __ Call(wasm_code, RelocInfo::WASM_CALL);
- } else {
- __ Call(wasm_code, RelocInfo::JS_TO_WASM_CALL);
- }
+ Constant constant = i.ToConstant(instr->InputAt(0));
+ Address wasm_code = static_cast<Address>(constant.ToInt64());
+ __ Call(wasm_code, constant.rmode());
} else {
Register target = i.InputRegister(0);
__ Call(target);
@@ -636,11 +626,6 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
case kArchTailCallCodeObjectFromJSFunction:
case kArchTailCallCodeObject: {
- // We must not share code targets for calls to builtins for wasm code, as
- // they might need to be patched individually.
- internal::Assembler::BlockCodeTargetSharingScope scope;
- if (info()->IsWasm()) scope.Open(tasm());
-
if (arch_opcode == kArchTailCallCodeObjectFromJSFunction) {
AssemblePopArgumentsAdaptorFrame(kJavaScriptCallArgCountRegister,
i.TempRegister(0), i.TempRegister(1),
@@ -649,9 +634,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
if (instr->InputAt(0)->IsImmediate()) {
__ Jump(i.InputCode(0), RelocInfo::CODE_TARGET);
} else {
- Register target = i.InputRegister(0);
- __ Add(target, target, Code::kHeaderSize - kHeapObjectTag);
- __ Jump(target);
+ Register reg = i.InputRegister(0);
+ DCHECK_IMPLIES(
+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister),
+ reg == kJavaScriptCallCodeStartRegister);
+ __ Add(reg, reg, Code::kHeaderSize - kHeapObjectTag);
+ __ Jump(reg);
}
unwinding_info_writer_.MarkBlockWillExit();
frame_access_state()->ClearSPDelta();
@@ -660,14 +648,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
case kArchTailCallWasm: {
if (instr->InputAt(0)->IsImmediate()) {
- Address wasm_code =
- static_cast<Address>(i.ToConstant(instr->InputAt(0)).ToInt64());
- if (info()->IsWasm()) {
- __ Jump(wasm_code, RelocInfo::WASM_CALL);
- } else {
- __ Jump(wasm_code, RelocInfo::JS_TO_WASM_CALL);
- }
-
+ Constant constant = i.ToConstant(instr->InputAt(0));
+ Address wasm_code = static_cast<Address>(constant.ToInt64());
+ __ Jump(wasm_code, constant.rmode());
} else {
Register target = i.InputRegister(0);
__ Jump(target);
@@ -679,7 +662,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
}
case kArchTailCallAddress: {
CHECK(!instr->InputAt(0)->IsImmediate());
- __ Jump(i.InputRegister(0));
+ Register reg = i.InputRegister(0);
+ DCHECK_IMPLIES(
+ HasCallDescriptorFlag(instr, CallDescriptor::kFixedTargetRegister),
+ reg == kJavaScriptCallCodeStartRegister);
+ __ Jump(reg);
unwinding_info_writer_.MarkBlockWillExit();
frame_access_state()->ClearSPDelta();
frame_access_state()->SetFrameAccessToDefault();
@@ -774,6 +761,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
case kArchTableSwitch:
AssembleArchTableSwitch(instr);
break;
+ case kArchBinarySearchSwitch:
+ AssembleArchBinarySearchSwitch(instr);
+ break;
case kArchLookupSwitch:
AssembleArchLookupSwitch(instr);
break;
@@ -829,12 +819,9 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mov(i.OutputRegister(), fp);
}
break;
- case kArchRootsPointer:
- __ mov(i.OutputRegister(), kRootRegister);
- break;
case kArchTruncateDoubleToI:
__ TruncateDoubleToI(isolate(), zone(), i.OutputRegister(),
- i.InputDoubleRegister(0));
+ i.InputDoubleRegister(0), DetermineStubCallMode());
break;
case kArchStoreWithWriteBarrier: {
RecordWriteMode mode =
@@ -2251,29 +2238,18 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
FlagsCondition condition) {
class OutOfLineTrap final : public OutOfLineCode {
public:
- OutOfLineTrap(CodeGenerator* gen, bool frame_elided, Instruction* instr)
- : OutOfLineCode(gen),
- frame_elided_(frame_elided),
- instr_(instr),
- gen_(gen) {}
+ OutOfLineTrap(CodeGenerator* gen, Instruction* instr)
+ : OutOfLineCode(gen), instr_(instr), gen_(gen) {}
void Generate() final {
Arm64OperandConverter i(gen_, instr_);
- Builtins::Name trap_id =
- static_cast<Builtins::Name>(i.InputInt32(instr_->InputCount() - 1));
- bool old_has_frame = __ has_frame();
- if (frame_elided_) {
- __ set_has_frame(true);
- __ EnterFrame(StackFrame::WASM_COMPILED);
- }
+ TrapId trap_id =
+ static_cast<TrapId>(i.InputInt32(instr_->InputCount() - 1));
GenerateCallToTrap(trap_id);
- if (frame_elided_) {
- __ set_has_frame(old_has_frame);
- }
}
private:
- void GenerateCallToTrap(Builtins::Name trap_id) {
- if (trap_id == Builtins::builtin_count) {
+ void GenerateCallToTrap(TrapId trap_id) {
+ if (trap_id == TrapId::kInvalid) {
// We cannot test calls to the runtime in cctest/test-run-wasm.
// Therefore we emit a call to C here instead of a call to the runtime.
__ CallCFunction(
@@ -2287,8 +2263,9 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
__ Ret();
} else {
gen_->AssembleSourcePosition(instr_);
- __ Call(__ isolate()->builtins()->builtin_handle(trap_id),
- RelocInfo::CODE_TARGET);
+ // A direct call to a wasm runtime stub defined in this module.
+ // Just encode the stub index. This will be patched at relocation.
+ __ Call(static_cast<Address>(trap_id), RelocInfo::WASM_STUB_CALL);
ReferenceMap* reference_map =
new (gen_->zone()) ReferenceMap(gen_->zone());
gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0,
@@ -2299,12 +2276,10 @@ void CodeGenerator::AssembleArchTrap(Instruction* instr,
}
}
}
- bool frame_elided_;
Instruction* instr_;
CodeGenerator* gen_;
};
- bool frame_elided = !frame_access_state()->has_frame();
- auto ool = new (zone()) OutOfLineTrap(this, frame_elided, instr);
+ auto ool = new (zone()) OutOfLineTrap(this, instr);
Label* tlabel = ool->entry();
Condition cc = FlagsConditionToCondition(condition);
__ B(cc, tlabel);
@@ -2323,6 +2298,16 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr,
__ Cset(reg, cc);
}
+void CodeGenerator::AssembleArchBinarySearchSwitch(Instruction* instr) {
+ Arm64OperandConverter i(this, instr);
+ Register input = i.InputRegister32(0);
+ std::vector<std::pair<int32_t, Label*>> cases;
+ for (size_t index = 2; index < instr->InputCount(); index += 2) {
+ cases.push_back({i.InputInt32(index + 0), GetLabel(i.InputRpo(index + 1))});
+ }
+ AssembleArchBinarySearchSwitchRange(input, i.InputRpo(1), cases.data(),
+ cases.data() + cases.size());
+}
void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) {
Arm64OperandConverter i(this, instr);
@@ -2433,23 +2418,17 @@ void CodeGenerator::AssembleConstructFrame() {
if (shrink_slots * kPointerSize < FLAG_stack_size * 1024) {
UseScratchRegisterScope scope(tasm());
Register scratch = scope.AcquireX();
- __ Mov(scratch, Operand(ExternalReference::address_of_real_stack_limit(
- __ isolate())));
+ __ Ldr(scratch, FieldMemOperand(
+ kWasmInstanceRegister,
+ WasmInstanceObject::kRealStackLimitAddressOffset));
__ Ldr(scratch, MemOperand(scratch));
__ Add(scratch, scratch, shrink_slots * kPointerSize);
__ Cmp(sp, scratch);
__ B(hs, &done);
}
- if (!frame_access_state()->has_frame()) {
- __ set_has_frame(true);
- // There is no need to leave the frame, we will not return from the
- // runtime call.
- __ EnterFrame(StackFrame::WASM_COMPILED);
- } else {
+ {
// Finish the frame that hasn't been fully built yet.
- // TODO(mstarzinger): This is a work-around, deferred frame building is
- // actually no longer supported, remove the associated code.
UseScratchRegisterScope temps(tasm());
__ Claim(2); // Claim extra slots for marker + instance.
Register scratch = temps.AcquireX();
@@ -2459,8 +2438,10 @@ void CodeGenerator::AssembleConstructFrame() {
__ Str(kWasmInstanceRegister,
MemOperand(fp, WasmCompiledFrameConstants::kWasmInstanceOffset));
}
+ __ Ldr(x2, FieldMemOperand(kWasmInstanceRegister,
+ WasmInstanceObject::kCEntryStubOffset));
__ Mov(cp, Smi::kZero);
- __ CallRuntimeDelayed(zone(), Runtime::kThrowWasmStackOverflow);
+ __ CallRuntimeWithCEntry(Runtime::kThrowWasmStackOverflow, x2);
// We come from WebAssembly, there are no references for the GC.
ReferenceMap* reference_map = new (zone()) ReferenceMap(zone());
RecordSafepoint(reference_map, Safepoint::kSimple, 0,
@@ -2599,8 +2580,10 @@ void CodeGenerator::AssembleMove(InstructionOperand* source,
if (IsMaterializableFromRoot(src_object, &index)) {
__ LoadRoot(dst, index);
} else {
- __ Mov(dst, src_object);
+ __ Move(dst, src_object);
}
+ } else if (src.type() == Constant::kExternalReference) {
+ __ Mov(dst, src.ToExternalReference());
} else {
__ Mov(dst, g.ToImmediate(source));
}