diff options
Diffstat (limited to 'src/compiler/arm64/code-generator-arm64.cc')
-rw-r--r-- | src/compiler/arm64/code-generator-arm64.cc | 91 |
1 files changed, 76 insertions, 15 deletions
diff --git a/src/compiler/arm64/code-generator-arm64.cc b/src/compiler/arm64/code-generator-arm64.cc index 8b1cb578..1cdedb0f 100644 --- a/src/compiler/arm64/code-generator-arm64.cc +++ b/src/compiler/arm64/code-generator-arm64.cc @@ -209,17 +209,16 @@ class Arm64OperandConverter final : public InstructionOperandConverter { Constant constant = ToConstant(operand); switch (constant.type()) { case Constant::kInt32: - if (constant.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE) { + if (RelocInfo::IsWasmSizeReference(constant.rmode())) { return Operand(constant.ToInt32(), constant.rmode()); } else { return Operand(constant.ToInt32()); } case Constant::kInt64: - if (constant.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || - constant.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { + if (RelocInfo::IsWasmPtrReference(constant.rmode())) { return Operand(constant.ToInt64(), constant.rmode()); } else { - DCHECK(constant.rmode() != RelocInfo::WASM_MEMORY_SIZE_REFERENCE); + DCHECK(!RelocInfo::IsWasmSizeReference(constant.rmode())); return Operand(constant.ToInt64()); } case Constant::kFloat32: @@ -571,7 +570,8 @@ void CodeGenerator::AssemblePopArgumentsAdaptorFrame(Register args_reg, // Check if current frame is an arguments adaptor frame. __ Ldr(scratch1, MemOperand(fp, StandardFrameConstants::kContextOffset)); - __ Cmp(scratch1, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); + __ Cmp(scratch1, + Operand(StackFrame::TypeToMarker(StackFrame::ARGUMENTS_ADAPTOR))); __ B(ne, &done); // Load arguments count from current arguments adaptor frame (note, it @@ -775,10 +775,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( case kArchDeoptimize: { int deopt_state_id = BuildTranslation(instr, -1, 0, OutputFrameStateCombine::Ignore()); - Deoptimizer::BailoutType bailout_type = - Deoptimizer::BailoutType(MiscField::decode(instr->opcode())); - CodeGenResult result = AssembleDeoptimizerCall( - deopt_state_id, bailout_type, current_source_position_); + CodeGenResult result = + AssembleDeoptimizerCall(deopt_state_id, current_source_position_); if (result != kSuccess) return result; break; } @@ -1702,6 +1700,67 @@ void CodeGenerator::AssembleArchJump(RpoNumber target) { if (!IsNextInAssemblyOrder(target)) __ B(GetLabel(target)); } +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) {} + 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); + } + 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) { + // 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( + ExternalReference::wasm_call_trap_callback_for_testing(isolate()), + 0); + __ LeaveFrame(StackFrame::WASM_COMPILED); + __ Ret(); + } else { + DCHECK(csp.Is(__ StackPointer())); + // Initialize the jssp because it is required for the runtime call. + __ Mov(jssp, csp); + gen_->AssembleSourcePosition(instr_); + __ Call(handle(isolate()->builtins()->builtin(trap_id), isolate()), + RelocInfo::CODE_TARGET); + ReferenceMap* reference_map = + new (gen_->zone()) ReferenceMap(gen_->zone()); + gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0, + Safepoint::kNoLazyDeopt); + if (FLAG_debug_code) { + // The trap code should never return. + __ Brk(0); + } + } + } + bool frame_elided_; + Instruction* instr_; + CodeGenerator* gen_; + }; + bool frame_elided = !frame_access_state()->has_frame(); + auto ool = new (zone()) OutOfLineTrap(this, frame_elided, instr); + Label* tlabel = ool->entry(); + Condition cc = FlagsConditionToCondition(condition); + __ B(cc, tlabel); +} // Assemble boolean materializations after this instruction. void CodeGenerator::AssembleArchBoolean(Instruction* instr, @@ -1749,13 +1808,16 @@ void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { } CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall( - int deoptimization_id, Deoptimizer::BailoutType bailout_type, - SourcePosition pos) { + int deoptimization_id, SourcePosition pos) { + DeoptimizeKind deoptimization_kind = GetDeoptimizationKind(deoptimization_id); + DeoptimizeReason deoptimization_reason = + GetDeoptimizationReason(deoptimization_id); + Deoptimizer::BailoutType bailout_type = + deoptimization_kind == DeoptimizeKind::kSoft ? Deoptimizer::SOFT + : Deoptimizer::EAGER; Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( isolate(), deoptimization_id, bailout_type); if (deopt_entry == nullptr) return kTooManyDeoptimizationBailouts; - DeoptimizeReason deoptimization_reason = - GetDeoptimizationReason(deoptimization_id); __ RecordDeoptReason(deoptimization_reason, pos, deoptimization_id); __ Call(deopt_entry, RelocInfo::RUNTIME_ENTRY); return kSuccess; @@ -1828,7 +1890,6 @@ void CodeGenerator::AssembleConstructFrame() { osr_pc_offset_ = __ pc_offset(); shrink_slots -= OsrHelper(info()).UnoptimizedFrameSlots(); } - // Build remainder of frame, including accounting for and filling-in // frame-specific header information, e.g. claiming the extra slot that // other platforms explicitly push for STUB frames and frames recording @@ -1843,7 +1904,7 @@ void CodeGenerator::AssembleConstructFrame() { if (is_stub_frame) { UseScratchRegisterScope temps(masm()); Register temp = temps.AcquireX(); - __ Mov(temp, Smi::FromInt(info()->GetOutputStackFrameType())); + __ Mov(temp, StackFrame::TypeToMarker(info()->GetOutputStackFrameType())); __ Str(temp, MemOperand(fp, TypedFrameConstants::kFrameTypeOffset)); } } |