Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 Register const object_; | 263 Register const object_; |
| 264 Operand const operand_; | 264 Operand const operand_; |
| 265 Register const value_; | 265 Register const value_; |
| 266 Register const scratch0_; | 266 Register const scratch0_; |
| 267 Register const scratch1_; | 267 Register const scratch1_; |
| 268 RecordWriteMode const mode_; | 268 RecordWriteMode const mode_; |
| 269 }; | 269 }; |
| 270 | 270 |
| 271 class WasmOutOfLineTrap final : public OutOfLineCode { | 271 class WasmOutOfLineTrap final : public OutOfLineCode { |
| 272 public: | 272 public: |
| 273 WasmOutOfLineTrap(CodeGenerator* gen, Address pc, bool frame_elided, | 273 WasmOutOfLineTrap(CodeGenerator* gen, int pc, bool frame_elided, |
| 274 Register context, int32_t position) | 274 Register context, int32_t position) |
| 275 : OutOfLineCode(gen), | 275 : OutOfLineCode(gen), |
| 276 gen_(gen), | |
| 276 pc_(pc), | 277 pc_(pc), |
| 277 frame_elided_(frame_elided), | 278 frame_elided_(frame_elided), |
| 278 context_(context), | 279 context_(context), |
| 279 position_(position) {} | 280 position_(position) {} |
| 280 | 281 |
| 281 void Generate() final { | 282 void Generate() final { |
|
titzer
2016/11/30 17:31:12
We should probably refactor this method to take th
Eric Holk
2016/11/30 20:16:19
Done.
| |
| 282 // TODO(eholk): record pc_ and the current pc in a table so that | 283 int current_pc = __ pc_offset(); |
| 283 // the signal handler can find it. | 284 |
| 284 USE(pc_); | 285 gen_->AddProtectedInstruction(pc_, current_pc); |
| 285 | 286 |
| 286 if (frame_elided_) { | 287 if (frame_elided_) { |
| 287 __ EnterFrame(StackFrame::WASM); | 288 __ EnterFrame(StackFrame::WASM); |
| 288 } | 289 } |
| 289 | 290 |
| 290 wasm::TrapReason trap_id = wasm::kTrapMemOutOfBounds; | 291 wasm::TrapReason trap_id = wasm::kTrapMemOutOfBounds; |
| 291 int trap_reason = wasm::WasmOpcodes::TrapReasonToMessageId(trap_id); | 292 int trap_reason = wasm::WasmOpcodes::TrapReasonToMessageId(trap_id); |
| 292 __ Push(Smi::FromInt(trap_reason)); | 293 __ Push(Smi::FromInt(trap_reason)); |
| 293 __ Push(Smi::FromInt(position_)); | 294 __ Push(Smi::FromInt(position_)); |
| 294 __ Move(rsi, context_); | 295 __ Move(rsi, context_); |
| 295 __ CallRuntime(Runtime::kThrowWasmError); | 296 __ CallRuntime(Runtime::kThrowWasmError); |
| 296 } | 297 } |
| 297 | 298 |
| 298 private: | 299 private: |
| 299 Address pc_; | 300 CodeGenerator* gen_; |
| 301 int pc_; | |
| 300 bool frame_elided_; | 302 bool frame_elided_; |
| 301 Register context_; | 303 Register context_; |
| 302 int32_t position_; | 304 int32_t position_; |
| 303 }; | 305 }; |
| 304 | 306 |
| 305 } // namespace | 307 } // namespace |
| 306 | 308 |
| 307 | 309 |
| 308 #define ASSEMBLE_UNOP(asm_instr) \ | 310 #define ASSEMBLE_UNOP(asm_instr) \ |
| 309 do { \ | 311 do { \ |
| (...skipping 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1890 case kX64Movl: | 1892 case kX64Movl: |
| 1891 case kX64TrapMovl: | 1893 case kX64TrapMovl: |
| 1892 if (instr->HasOutput()) { | 1894 if (instr->HasOutput()) { |
| 1893 if (instr->addressing_mode() == kMode_None) { | 1895 if (instr->addressing_mode() == kMode_None) { |
| 1894 if (instr->InputAt(0)->IsRegister()) { | 1896 if (instr->InputAt(0)->IsRegister()) { |
| 1895 __ movl(i.OutputRegister(), i.InputRegister(0)); | 1897 __ movl(i.OutputRegister(), i.InputRegister(0)); |
| 1896 } else { | 1898 } else { |
| 1897 __ movl(i.OutputRegister(), i.InputOperand(0)); | 1899 __ movl(i.OutputRegister(), i.InputOperand(0)); |
| 1898 } | 1900 } |
| 1899 } else { | 1901 } else { |
| 1900 Address pc = __ pc(); | 1902 int pc = __ pc_offset(); |
| 1901 __ movl(i.OutputRegister(), i.MemoryOperand()); | 1903 __ movl(i.OutputRegister(), i.MemoryOperand()); |
| 1902 | 1904 |
| 1903 if (arch_opcode == kX64TrapMovl) { | 1905 if (arch_opcode == kX64TrapMovl) { |
| 1904 bool frame_elided = !frame_access_state()->has_frame(); | 1906 bool frame_elided = !frame_access_state()->has_frame(); |
| 1905 new (zone()) WasmOutOfLineTrap(this, pc, frame_elided, | 1907 new (zone()) WasmOutOfLineTrap(this, pc, frame_elided, |
| 1906 i.InputRegister(2), i.InputInt32(3)); | 1908 i.InputRegister(2), i.InputInt32(3)); |
| 1907 } | 1909 } |
| 1908 } | 1910 } |
| 1909 __ AssertZeroExtended(i.OutputRegister()); | 1911 __ AssertZeroExtended(i.OutputRegister()); |
| 1910 } else { | 1912 } else { |
| (...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2777 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2779 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
| 2778 __ Nop(padding_size); | 2780 __ Nop(padding_size); |
| 2779 } | 2781 } |
| 2780 } | 2782 } |
| 2781 | 2783 |
| 2782 #undef __ | 2784 #undef __ |
| 2783 | 2785 |
| 2784 } // namespace compiler | 2786 } // namespace compiler |
| 2785 } // namespace internal | 2787 } // namespace internal |
| 2786 } // namespace v8 | 2788 } // namespace v8 |
| OLD | NEW |