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

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

Issue 2371833007: [wasm] Initial signal handler (Closed)
Patch Set: Avoid signed/unsigned comparisons for windows Created 3 years, 10 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
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 <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
263 Operand const operand_; 263 Operand const operand_;
264 Register const value_; 264 Register const value_;
265 Register const scratch0_; 265 Register const scratch0_;
266 Register const scratch1_; 266 Register const scratch1_;
267 RecordWriteMode const mode_; 267 RecordWriteMode const mode_;
268 }; 268 };
269 269
270 class WasmOutOfLineTrap final : public OutOfLineCode { 270 class WasmOutOfLineTrap final : public OutOfLineCode {
271 public: 271 public:
272 WasmOutOfLineTrap(CodeGenerator* gen, int pc, bool frame_elided, 272 WasmOutOfLineTrap(CodeGenerator* gen, int pc, bool frame_elided,
273 int32_t position, Instruction* instr) 273 int32_t position)
274 : OutOfLineCode(gen), 274 : OutOfLineCode(gen),
275 gen_(gen), 275 gen_(gen),
276 pc_(pc), 276 pc_(pc),
277 frame_elided_(frame_elided), 277 frame_elided_(frame_elided),
278 position_(position), 278 position_(position) {}
279 instr_(instr) {}
280 279
281 // TODO(eholk): Refactor this method to take the code generator as a 280 // TODO(eholk): Refactor this method to take the code generator as a
282 // parameter. 281 // parameter.
283 void Generate() final { 282 void Generate() final {
284 __ RecordProtectedInstructionLanding(pc_); 283 __ RecordProtectedInstructionLanding(pc_);
285 284
286 if (frame_elided_) { 285 if (frame_elided_) {
287 __ EnterFrame(StackFrame::WASM_COMPILED); 286 __ EnterFrame(StackFrame::WASM_COMPILED);
288 } 287 }
289 288
290 wasm::TrapReason trap_id = wasm::kTrapMemOutOfBounds; 289 wasm::TrapReason trap_id = wasm::kTrapMemOutOfBounds;
291 int trap_reason = wasm::WasmOpcodes::TrapReasonToMessageId(trap_id); 290 int trap_reason = wasm::WasmOpcodes::TrapReasonToMessageId(trap_id);
292 __ Push(Smi::FromInt(trap_reason)); 291 __ Push(Smi::FromInt(trap_reason));
292 // TODO(eholk): use AssembleSourcePosition instead of passing in position_
293 // as a parameter. See AssembleArchTrap as an example. Consider sharing code
294 // with AssembleArchTrap.
293 __ Push(Smi::FromInt(position_)); 295 __ Push(Smi::FromInt(position_));
294 __ Move(rsi, gen_->isolate()->native_context()); 296 __ Move(rsi, Smi::kZero);
295 __ CallRuntime(Runtime::kThrowWasmError); 297 __ CallRuntime(Runtime::kThrowWasmError);
296 298
297 if (instr_->reference_map() != nullptr) { 299 ReferenceMap* reference_map =
298 gen_->RecordSafepoint(instr_->reference_map(), Safepoint::kSimple, 0, 300 new (gen_->code()->zone()) ReferenceMap(gen_->code()->zone());
299 Safepoint::kNoLazyDeopt); 301 gen_->RecordSafepoint(reference_map, Safepoint::kSimple, 0,
300 } 302 Safepoint::kNoLazyDeopt);
301 } 303 }
302 304
303 private: 305 private:
304 CodeGenerator* gen_; 306 CodeGenerator* gen_;
305 int pc_; 307 int pc_;
306 bool frame_elided_; 308 bool frame_elided_;
307 int32_t position_; 309 int32_t position_;
308 Instruction* instr_;
309 }; 310 };
310 311
311 void EmitOOLTrapIfNeeded(Zone* zone, CodeGenerator* codegen, 312 void EmitOOLTrapIfNeeded(Zone* zone, CodeGenerator* codegen,
312 InstructionCode opcode, size_t input_count, 313 InstructionCode opcode, size_t input_count,
313 X64OperandConverter& i, int pc, Instruction* instr) { 314 X64OperandConverter& i, int pc) {
314 const X64MemoryProtection protection = 315 const X64MemoryProtection protection =
315 static_cast<X64MemoryProtection>(MiscField::decode(opcode)); 316 static_cast<X64MemoryProtection>(MiscField::decode(opcode));
316 if (protection == X64MemoryProtection::kProtected) { 317 if (protection == X64MemoryProtection::kProtected) {
317 const bool frame_elided = !codegen->frame_access_state()->has_frame(); 318 const bool frame_elided = !codegen->frame_access_state()->has_frame();
318 const int32_t position = i.InputInt32(input_count - 1); 319 const int32_t position = i.InputInt32(input_count - 1);
319 new (zone) WasmOutOfLineTrap(codegen, pc, frame_elided, position, instr); 320 new (zone) WasmOutOfLineTrap(codegen, pc, frame_elided, position);
320 } 321 }
321 } 322 }
322 } // namespace 323 } // namespace
323 324
324 325
325 #define ASSEMBLE_UNOP(asm_instr) \ 326 #define ASSEMBLE_UNOP(asm_instr) \
326 do { \ 327 do { \
327 if (instr->Output()->IsRegister()) { \ 328 if (instr->Output()->IsRegister()) { \
328 __ asm_instr(i.OutputRegister()); \ 329 __ asm_instr(i.OutputRegister()); \
329 } else { \ 330 } else { \
(...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 i.InputOperand(0)); 1848 i.InputOperand(0));
1848 } 1849 }
1849 break; 1850 break;
1850 } 1851 }
1851 case kSSEFloat64SilenceNaN: 1852 case kSSEFloat64SilenceNaN:
1852 __ Xorpd(kScratchDoubleReg, kScratchDoubleReg); 1853 __ Xorpd(kScratchDoubleReg, kScratchDoubleReg);
1853 __ Subsd(i.InputDoubleRegister(0), kScratchDoubleReg); 1854 __ Subsd(i.InputDoubleRegister(0), kScratchDoubleReg);
1854 break; 1855 break;
1855 case kX64Movsxbl: 1856 case kX64Movsxbl:
1856 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1857 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1857 __ pc_offset(), instr); 1858 __ pc_offset());
1858 ASSEMBLE_MOVX(movsxbl); 1859 ASSEMBLE_MOVX(movsxbl);
1859 __ AssertZeroExtended(i.OutputRegister()); 1860 __ AssertZeroExtended(i.OutputRegister());
1860 break; 1861 break;
1861 case kX64Movzxbl: 1862 case kX64Movzxbl:
1862 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1863 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1863 __ pc_offset(), instr); 1864 __ pc_offset());
1864 ASSEMBLE_MOVX(movzxbl); 1865 ASSEMBLE_MOVX(movzxbl);
1865 __ AssertZeroExtended(i.OutputRegister()); 1866 __ AssertZeroExtended(i.OutputRegister());
1866 break; 1867 break;
1867 case kX64Movsxbq: 1868 case kX64Movsxbq:
1868 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1869 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1869 __ pc_offset(), instr); 1870 __ pc_offset());
1870 ASSEMBLE_MOVX(movsxbq); 1871 ASSEMBLE_MOVX(movsxbq);
1871 break; 1872 break;
1872 case kX64Movzxbq: 1873 case kX64Movzxbq:
1873 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1874 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1874 __ pc_offset(), instr); 1875 __ pc_offset());
1875 ASSEMBLE_MOVX(movzxbq); 1876 ASSEMBLE_MOVX(movzxbq);
1876 __ AssertZeroExtended(i.OutputRegister()); 1877 __ AssertZeroExtended(i.OutputRegister());
1877 break; 1878 break;
1878 case kX64Movb: { 1879 case kX64Movb: {
1879 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1880 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1880 __ pc_offset(), instr); 1881 __ pc_offset());
1881 size_t index = 0; 1882 size_t index = 0;
1882 Operand operand = i.MemoryOperand(&index); 1883 Operand operand = i.MemoryOperand(&index);
1883 if (HasImmediateInput(instr, index)) { 1884 if (HasImmediateInput(instr, index)) {
1884 __ movb(operand, Immediate(i.InputInt8(index))); 1885 __ movb(operand, Immediate(i.InputInt8(index)));
1885 } else { 1886 } else {
1886 __ movb(operand, i.InputRegister(index)); 1887 __ movb(operand, i.InputRegister(index));
1887 } 1888 }
1888 break; 1889 break;
1889 } 1890 }
1890 case kX64Movsxwl: 1891 case kX64Movsxwl:
1891 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1892 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1892 __ pc_offset(), instr); 1893 __ pc_offset());
1893 ASSEMBLE_MOVX(movsxwl); 1894 ASSEMBLE_MOVX(movsxwl);
1894 __ AssertZeroExtended(i.OutputRegister()); 1895 __ AssertZeroExtended(i.OutputRegister());
1895 break; 1896 break;
1896 case kX64Movzxwl: 1897 case kX64Movzxwl:
1897 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1898 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1898 __ pc_offset(), instr); 1899 __ pc_offset());
1899 ASSEMBLE_MOVX(movzxwl); 1900 ASSEMBLE_MOVX(movzxwl);
1900 __ AssertZeroExtended(i.OutputRegister()); 1901 __ AssertZeroExtended(i.OutputRegister());
1901 break; 1902 break;
1902 case kX64Movsxwq: 1903 case kX64Movsxwq:
1903 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1904 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1904 __ pc_offset(), instr); 1905 __ pc_offset());
1905 ASSEMBLE_MOVX(movsxwq); 1906 ASSEMBLE_MOVX(movsxwq);
1906 break; 1907 break;
1907 case kX64Movzxwq: 1908 case kX64Movzxwq:
1908 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1909 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1909 __ pc_offset(), instr); 1910 __ pc_offset());
1910 ASSEMBLE_MOVX(movzxwq); 1911 ASSEMBLE_MOVX(movzxwq);
1911 __ AssertZeroExtended(i.OutputRegister()); 1912 __ AssertZeroExtended(i.OutputRegister());
1912 break; 1913 break;
1913 case kX64Movw: { 1914 case kX64Movw: {
1914 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1915 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1915 __ pc_offset(), instr); 1916 __ pc_offset());
1916 size_t index = 0; 1917 size_t index = 0;
1917 Operand operand = i.MemoryOperand(&index); 1918 Operand operand = i.MemoryOperand(&index);
1918 if (HasImmediateInput(instr, index)) { 1919 if (HasImmediateInput(instr, index)) {
1919 __ movw(operand, Immediate(i.InputInt16(index))); 1920 __ movw(operand, Immediate(i.InputInt16(index)));
1920 } else { 1921 } else {
1921 __ movw(operand, i.InputRegister(index)); 1922 __ movw(operand, i.InputRegister(index));
1922 } 1923 }
1923 break; 1924 break;
1924 } 1925 }
1925 case kX64Movl: 1926 case kX64Movl:
1926 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1927 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1927 __ pc_offset(), instr); 1928 __ pc_offset());
1928 if (instr->HasOutput()) { 1929 if (instr->HasOutput()) {
1929 if (instr->addressing_mode() == kMode_None) { 1930 if (instr->addressing_mode() == kMode_None) {
1930 if (instr->InputAt(0)->IsRegister()) { 1931 if (instr->InputAt(0)->IsRegister()) {
1931 __ movl(i.OutputRegister(), i.InputRegister(0)); 1932 __ movl(i.OutputRegister(), i.InputRegister(0));
1932 } else { 1933 } else {
1933 __ movl(i.OutputRegister(), i.InputOperand(0)); 1934 __ movl(i.OutputRegister(), i.InputOperand(0));
1934 } 1935 }
1935 } else { 1936 } else {
1936 __ movl(i.OutputRegister(), i.MemoryOperand()); 1937 __ movl(i.OutputRegister(), i.MemoryOperand());
1937 } 1938 }
1938 __ AssertZeroExtended(i.OutputRegister()); 1939 __ AssertZeroExtended(i.OutputRegister());
1939 } else { 1940 } else {
1940 size_t index = 0; 1941 size_t index = 0;
1941 Operand operand = i.MemoryOperand(&index); 1942 Operand operand = i.MemoryOperand(&index);
1942 if (HasImmediateInput(instr, index)) { 1943 if (HasImmediateInput(instr, index)) {
1943 __ movl(operand, i.InputImmediate(index)); 1944 __ movl(operand, i.InputImmediate(index));
1944 } else { 1945 } else {
1945 __ movl(operand, i.InputRegister(index)); 1946 __ movl(operand, i.InputRegister(index));
1946 } 1947 }
1947 } 1948 }
1948 break; 1949 break;
1949 case kX64Movsxlq: 1950 case kX64Movsxlq:
1950 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1951 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1951 __ pc_offset(), instr); 1952 __ pc_offset());
1952 ASSEMBLE_MOVX(movsxlq); 1953 ASSEMBLE_MOVX(movsxlq);
1953 break; 1954 break;
1954 case kX64Movq: 1955 case kX64Movq:
1955 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1956 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1956 __ pc_offset(), instr); 1957 __ pc_offset());
1957 if (instr->HasOutput()) { 1958 if (instr->HasOutput()) {
1958 __ movq(i.OutputRegister(), i.MemoryOperand()); 1959 __ movq(i.OutputRegister(), i.MemoryOperand());
1959 } else { 1960 } else {
1960 size_t index = 0; 1961 size_t index = 0;
1961 Operand operand = i.MemoryOperand(&index); 1962 Operand operand = i.MemoryOperand(&index);
1962 if (HasImmediateInput(instr, index)) { 1963 if (HasImmediateInput(instr, index)) {
1963 __ movq(operand, i.InputImmediate(index)); 1964 __ movq(operand, i.InputImmediate(index));
1964 } else { 1965 } else {
1965 __ movq(operand, i.InputRegister(index)); 1966 __ movq(operand, i.InputRegister(index));
1966 } 1967 }
1967 } 1968 }
1968 break; 1969 break;
1969 case kX64Movss: 1970 case kX64Movss:
1970 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1971 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1971 __ pc_offset(), instr); 1972 __ pc_offset());
1972 if (instr->HasOutput()) { 1973 if (instr->HasOutput()) {
1973 __ movss(i.OutputDoubleRegister(), i.MemoryOperand()); 1974 __ movss(i.OutputDoubleRegister(), i.MemoryOperand());
1974 } else { 1975 } else {
1975 size_t index = 0; 1976 size_t index = 0;
1976 Operand operand = i.MemoryOperand(&index); 1977 Operand operand = i.MemoryOperand(&index);
1977 __ movss(operand, i.InputDoubleRegister(index)); 1978 __ movss(operand, i.InputDoubleRegister(index));
1978 } 1979 }
1979 break; 1980 break;
1980 case kX64Movsd: 1981 case kX64Movsd:
1981 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i, 1982 EmitOOLTrapIfNeeded(zone(), this, opcode, instr->InputCount(), i,
1982 __ pc_offset(), instr); 1983 __ pc_offset());
1983 if (instr->HasOutput()) { 1984 if (instr->HasOutput()) {
1984 __ Movsd(i.OutputDoubleRegister(), i.MemoryOperand()); 1985 __ Movsd(i.OutputDoubleRegister(), i.MemoryOperand());
1985 } else { 1986 } else {
1986 size_t index = 0; 1987 size_t index = 0;
1987 Operand operand = i.MemoryOperand(&index); 1988 Operand operand = i.MemoryOperand(&index);
1988 __ Movsd(operand, i.InputDoubleRegister(index)); 1989 __ Movsd(operand, i.InputDoubleRegister(index));
1989 } 1990 }
1990 break; 1991 break;
1991 case kX64BitcastFI: 1992 case kX64BitcastFI:
1992 if (instr->InputAt(0)->IsFPStackSlot()) { 1993 if (instr->InputAt(0)->IsFPStackSlot()) {
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
2861 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2862 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2862 __ Nop(padding_size); 2863 __ Nop(padding_size);
2863 } 2864 }
2864 } 2865 }
2865 2866
2866 #undef __ 2867 #undef __
2867 2868
2868 } // namespace compiler 2869 } // namespace compiler
2869 } // namespace internal 2870 } // namespace internal
2870 } // namespace v8 2871 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/wasm-compiler.cc ('k') | src/d8.cc » ('j') | src/isolate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698