Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 2301833004: [wasm] Trap handling: ProtectedLoad instruction (Closed)
Patch Set: Add VisitProtectedLoad stubs for other architectures Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/compilation-info.h" 7 #include "src/compilation-info.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
11 #include "src/compiler/osr.h" 11 #include "src/compiler/osr.h"
12 #include "src/wasm/wasm-module.h"
12 #include "src/x64/assembler-x64.h" 13 #include "src/x64/assembler-x64.h"
13 #include "src/x64/macro-assembler-x64.h" 14 #include "src/x64/macro-assembler-x64.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 namespace compiler { 18 namespace compiler {
18 19
19 #define __ masm()-> 20 #define __ masm()->
20 21
21 // Adds X64 specific methods for decoding operands. 22 // Adds X64 specific methods for decoding operands.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 254
254 private: 255 private:
255 Register const object_; 256 Register const object_;
256 Operand const operand_; 257 Operand const operand_;
257 Register const value_; 258 Register const value_;
258 Register const scratch0_; 259 Register const scratch0_;
259 Register const scratch1_; 260 Register const scratch1_;
260 RecordWriteMode const mode_; 261 RecordWriteMode const mode_;
261 }; 262 };
262 263
264 class WasmOutOfLineTrap final : public OutOfLineCode {
265 public:
266 WasmOutOfLineTrap(CodeGenerator* gen, Address pc, bool frame_elided,
267 Register context, int32_t position)
268 : OutOfLineCode(gen),
269 pc_(pc),
270 frame_elided_(frame_elided),
271 context_(context),
272 position_(position) {}
273
274 void Generate() final {
275 // TODO(eholk): record pc_ and the current pc in a table so that
276 // the signal handler can find it.
277 USE(pc_);
278
279 if (frame_elided_) {
280 __ EnterFrame(StackFrame::WASM);
281 }
282
283 wasm::TrapReason trap_id = wasm::kTrapMemOutOfBounds;
284 int trap_reason = wasm::WasmOpcodes::TrapReasonToMessageId(trap_id);
285 __ Push(Smi::FromInt(trap_reason));
286 __ Push(Smi::FromInt(position_));
287 __ Move(rsi, context_);
288 __ CallRuntime(Runtime::kThrowWasmError);
289 }
290
291 private:
292 Address pc_;
293 bool frame_elided_;
294 Register context_;
295 int32_t position_;
296 };
297
263 } // namespace 298 } // namespace
264 299
265 300
266 #define ASSEMBLE_UNOP(asm_instr) \ 301 #define ASSEMBLE_UNOP(asm_instr) \
267 do { \ 302 do { \
268 if (instr->Output()->IsRegister()) { \ 303 if (instr->Output()->IsRegister()) { \
269 __ asm_instr(i.OutputRegister()); \ 304 __ asm_instr(i.OutputRegister()); \
270 } else { \ 305 } else { \
271 __ asm_instr(i.OutputOperand()); \ 306 __ asm_instr(i.OutputOperand()); \
272 } \ 307 } \
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1842 size_t index = 0; 1877 size_t index = 0;
1843 Operand operand = i.MemoryOperand(&index); 1878 Operand operand = i.MemoryOperand(&index);
1844 if (HasImmediateInput(instr, index)) { 1879 if (HasImmediateInput(instr, index)) {
1845 __ movw(operand, Immediate(i.InputInt16(index))); 1880 __ movw(operand, Immediate(i.InputInt16(index)));
1846 } else { 1881 } else {
1847 __ movw(operand, i.InputRegister(index)); 1882 __ movw(operand, i.InputRegister(index));
1848 } 1883 }
1849 break; 1884 break;
1850 } 1885 }
1851 case kX64Movl: 1886 case kX64Movl:
1887 case kX64TrapMovl:
1852 if (instr->HasOutput()) { 1888 if (instr->HasOutput()) {
1853 if (instr->addressing_mode() == kMode_None) { 1889 if (instr->addressing_mode() == kMode_None) {
1854 if (instr->InputAt(0)->IsRegister()) { 1890 if (instr->InputAt(0)->IsRegister()) {
1855 __ movl(i.OutputRegister(), i.InputRegister(0)); 1891 __ movl(i.OutputRegister(), i.InputRegister(0));
1856 } else { 1892 } else {
1857 __ movl(i.OutputRegister(), i.InputOperand(0)); 1893 __ movl(i.OutputRegister(), i.InputOperand(0));
1858 } 1894 }
1859 } else { 1895 } else {
1896 Address pc = __ pc();
1860 __ movl(i.OutputRegister(), i.MemoryOperand()); 1897 __ movl(i.OutputRegister(), i.MemoryOperand());
1898
1899 if (arch_opcode == kX64TrapMovl) {
1900 bool frame_elided = !frame_access_state()->has_frame();
1901 new (zone()) WasmOutOfLineTrap(this, pc, frame_elided,
1902 i.InputRegister(2), i.InputInt32(3));
1903 }
1861 } 1904 }
1862 __ AssertZeroExtended(i.OutputRegister()); 1905 __ AssertZeroExtended(i.OutputRegister());
1863 } else { 1906 } else {
1864 size_t index = 0; 1907 size_t index = 0;
1865 Operand operand = i.MemoryOperand(&index); 1908 Operand operand = i.MemoryOperand(&index);
1866 if (HasImmediateInput(instr, index)) { 1909 if (HasImmediateInput(instr, index)) {
1867 __ movl(operand, i.InputImmediate(index)); 1910 __ movl(operand, i.InputImmediate(index));
1868 } else { 1911 } else {
1869 __ movl(operand, i.InputRegister(index)); 1912 __ movl(operand, i.InputRegister(index));
1870 } 1913 }
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2674 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2717 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2675 __ Nop(padding_size); 2718 __ Nop(padding_size);
2676 } 2719 }
2677 } 2720 }
2678 2721
2679 #undef __ 2722 #undef __
2680 2723
2681 } // namespace compiler 2724 } // namespace compiler
2682 } // namespace internal 2725 } // namespace internal
2683 } // namespace v8 2726 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698