OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/code-generator.h" | 5 #include "src/compiler/code-generator.h" |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/arm64/macro-assembler-arm64.h" | 8 #include "src/arm64/macro-assembler-arm64.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler/code-generator-impl.h" | 10 #include "src/compiler/code-generator-impl.h" |
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 if (!branch->fallthru) __ B(flabel); // no fallthru to flabel. | 1697 if (!branch->fallthru) __ B(flabel); // no fallthru to flabel. |
1698 } | 1698 } |
1699 | 1699 |
1700 | 1700 |
1701 void CodeGenerator::AssembleArchJump(RpoNumber target) { | 1701 void CodeGenerator::AssembleArchJump(RpoNumber target) { |
1702 if (!IsNextInAssemblyOrder(target)) __ B(GetLabel(target)); | 1702 if (!IsNextInAssemblyOrder(target)) __ B(GetLabel(target)); |
1703 } | 1703 } |
1704 | 1704 |
1705 void CodeGenerator::AssembleArchTrap(Instruction* instr, | 1705 void CodeGenerator::AssembleArchTrap(Instruction* instr, |
1706 FlagsCondition condition) { | 1706 FlagsCondition condition) { |
1707 UNREACHABLE(); | 1707 class OutOfLineTrap final : public OutOfLineCode { |
| 1708 public: |
| 1709 OutOfLineTrap(CodeGenerator* gen, bool frame_elided, Instruction* instr) |
| 1710 : OutOfLineCode(gen), |
| 1711 frame_elided_(frame_elided), |
| 1712 instr_(instr), |
| 1713 gen_(gen) {} |
| 1714 void Generate() final { |
| 1715 Arm64OperandConverter i(gen_, instr_); |
| 1716 Runtime::FunctionId trap_id = static_cast<Runtime::FunctionId>( |
| 1717 i.InputInt32(instr_->InputCount() - 1)); |
| 1718 bool old_has_frame = __ has_frame(); |
| 1719 if (frame_elided_) { |
| 1720 __ set_has_frame(true); |
| 1721 __ EnterFrame(StackFrame::WASM); |
| 1722 } |
| 1723 GenerateCallToTrap(trap_id); |
| 1724 if (frame_elided_) { |
| 1725 __ set_has_frame(old_has_frame); |
| 1726 } |
| 1727 if (FLAG_debug_code) { |
| 1728 // The trap code should never return. |
| 1729 __ Brk(0); |
| 1730 } |
| 1731 } |
| 1732 |
| 1733 private: |
| 1734 void GenerateCallToTrap(Runtime::FunctionId trap_id) { |
| 1735 if (trap_id == Runtime::kNumFunctions) { |
| 1736 // We cannot test calls to the runtime in cctest/test-run-wasm. |
| 1737 // Therefore we emit a call to C here instead of a call to the runtime. |
| 1738 __ CallCFunction( |
| 1739 ExternalReference::wasm_call_trap_callback_for_testing(isolate()), |
| 1740 0); |
| 1741 } else { |
| 1742 DCHECK(csp.Is(__ StackPointer())); |
| 1743 __ Move(cp, isolate()->native_context()); |
| 1744 // Initialize the jssp because it is required for the runtime call. |
| 1745 __ Mov(jssp, csp); |
| 1746 gen_->AssembleSourcePosition(instr_); |
| 1747 __ CallRuntime(trap_id); |
| 1748 } |
| 1749 ReferenceMap* reference_map = |
| 1750 new (gen_->zone()) ReferenceMap(gen_->zone()); |
| 1751 gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0, |
| 1752 Safepoint::kNoLazyDeopt); |
| 1753 } |
| 1754 bool frame_elided_; |
| 1755 Instruction* instr_; |
| 1756 CodeGenerator* gen_; |
| 1757 }; |
| 1758 bool frame_elided = !frame_access_state()->has_frame(); |
| 1759 auto ool = new (zone()) OutOfLineTrap(this, frame_elided, instr); |
| 1760 Label* tlabel = ool->entry(); |
| 1761 Condition cc = FlagsConditionToCondition(condition); |
| 1762 __ B(cc, tlabel); |
1708 } | 1763 } |
1709 | 1764 |
1710 // Assemble boolean materializations after this instruction. | 1765 // Assemble boolean materializations after this instruction. |
1711 void CodeGenerator::AssembleArchBoolean(Instruction* instr, | 1766 void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
1712 FlagsCondition condition) { | 1767 FlagsCondition condition) { |
1713 Arm64OperandConverter i(this, instr); | 1768 Arm64OperandConverter i(this, instr); |
1714 | 1769 |
1715 // Materialize a full 64-bit 1 or 0 value. The result register is always the | 1770 // Materialize a full 64-bit 1 or 0 value. The result register is always the |
1716 // last output of the instruction. | 1771 // last output of the instruction. |
1717 DCHECK_NE(0u, instr->OutputCount()); | 1772 DCHECK_NE(0u, instr->OutputCount()); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2120 padding_size -= kInstructionSize; | 2175 padding_size -= kInstructionSize; |
2121 } | 2176 } |
2122 } | 2177 } |
2123 } | 2178 } |
2124 | 2179 |
2125 #undef __ | 2180 #undef __ |
2126 | 2181 |
2127 } // namespace compiler | 2182 } // namespace compiler |
2128 } // namespace internal | 2183 } // namespace internal |
2129 } // namespace v8 | 2184 } // namespace v8 |
OLD | NEW |