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 "src/ast/scopes.h" | 7 #include "src/ast/scopes.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" |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } else { \ | 356 } else { \ |
357 if (instr->InputAt(1)->IsRegister()) { \ | 357 if (instr->InputAt(1)->IsRegister()) { \ |
358 __ asm_instr(i.InputRegister(0), i.InputRegister(1)); \ | 358 __ asm_instr(i.InputRegister(0), i.InputRegister(1)); \ |
359 } else { \ | 359 } else { \ |
360 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ | 360 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ |
361 } \ | 361 } \ |
362 } \ | 362 } \ |
363 } \ | 363 } \ |
364 } while (0) | 364 } while (0) |
365 | 365 |
| 366 #define ASSEMBLE_IEEE754_BINOP(name) \ |
| 367 do { \ |
| 368 /* Pass two doubles as arguments on the stack. */ \ |
| 369 __ PrepareCallCFunction(4, eax); \ |
| 370 __ movsd(Operand(esp, 0 * kDoubleSize), i.InputDoubleRegister(0)); \ |
| 371 __ movsd(Operand(esp, 1 * kDoubleSize), i.InputDoubleRegister(1)); \ |
| 372 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
| 373 4); \ |
| 374 /* Return value is in st(0) on ia32. */ \ |
| 375 /* Store it into the result register. */ \ |
| 376 __ sub(esp, Immediate(kDoubleSize)); \ |
| 377 __ fstp_d(Operand(esp, 0)); \ |
| 378 __ movsd(i.OutputDoubleRegister(), Operand(esp, 0)); \ |
| 379 __ add(esp, Immediate(kDoubleSize)); \ |
| 380 } while (false) |
| 381 |
366 #define ASSEMBLE_IEEE754_UNOP(name) \ | 382 #define ASSEMBLE_IEEE754_UNOP(name) \ |
367 do { \ | 383 do { \ |
368 /* Pass one double as argument on the stack.*/ \ | 384 /* Pass one double as argument on the stack. */ \ |
369 __ PrepareCallCFunction(2, eax); \ | 385 __ PrepareCallCFunction(2, eax); \ |
370 __ movsd(Operand(esp, 0 * kDoubleSize), i.InputDoubleRegister(0)); \ | 386 __ movsd(Operand(esp, 0 * kDoubleSize), i.InputDoubleRegister(0)); \ |
371 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ | 387 __ CallCFunction(ExternalReference::ieee754_##name##_function(isolate()), \ |
372 2); \ | 388 2); \ |
373 /* Return value is in st(0) on ia32. */ \ | 389 /* Return value is in st(0) on ia32. */ \ |
374 /* Store it into the result register. */ \ | 390 /* Store it into the result register. */ \ |
375 __ sub(esp, Immediate(kDoubleSize)); \ | 391 __ sub(esp, Immediate(kDoubleSize)); \ |
376 __ fstp_d(Operand(esp, 0)); \ | 392 __ fstp_d(Operand(esp, 0)); \ |
377 __ movsd(i.OutputDoubleRegister(), Operand(esp, 0)); \ | 393 __ movsd(i.OutputDoubleRegister(), Operand(esp, 0)); \ |
378 __ add(esp, Immediate(kDoubleSize)); \ | 394 __ add(esp, Immediate(kDoubleSize)); \ |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 frame_access_state()->GetFrameOffset(i.InputInt32(0)); | 641 frame_access_state()->GetFrameOffset(i.InputInt32(0)); |
626 Register base; | 642 Register base; |
627 if (offset.from_stack_pointer()) { | 643 if (offset.from_stack_pointer()) { |
628 base = esp; | 644 base = esp; |
629 } else { | 645 } else { |
630 base = ebp; | 646 base = ebp; |
631 } | 647 } |
632 __ lea(i.OutputRegister(), Operand(base, offset.offset())); | 648 __ lea(i.OutputRegister(), Operand(base, offset.offset())); |
633 break; | 649 break; |
634 } | 650 } |
| 651 case kIeee754Float64Atan: |
| 652 ASSEMBLE_IEEE754_UNOP(atan); |
| 653 break; |
| 654 case kIeee754Float64Atan2: |
| 655 ASSEMBLE_IEEE754_BINOP(atan2); |
| 656 break; |
635 case kIeee754Float64Log: | 657 case kIeee754Float64Log: |
636 ASSEMBLE_IEEE754_UNOP(log); | 658 ASSEMBLE_IEEE754_UNOP(log); |
637 break; | 659 break; |
638 case kIeee754Float64Log1p: | 660 case kIeee754Float64Log1p: |
639 ASSEMBLE_IEEE754_UNOP(log1p); | 661 ASSEMBLE_IEEE754_UNOP(log1p); |
640 break; | 662 break; |
641 case kIA32Add: | 663 case kIA32Add: |
642 if (HasImmediateInput(instr, 1)) { | 664 if (HasImmediateInput(instr, 1)) { |
643 __ add(i.InputOperand(0), i.InputImmediate(1)); | 665 __ add(i.InputOperand(0), i.InputImmediate(1)); |
644 } else { | 666 } else { |
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2005 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1984 __ Nop(padding_size); | 2006 __ Nop(padding_size); |
1985 } | 2007 } |
1986 } | 2008 } |
1987 | 2009 |
1988 #undef __ | 2010 #undef __ |
1989 | 2011 |
1990 } // namespace compiler | 2012 } // namespace compiler |
1991 } // namespace internal | 2013 } // namespace internal |
1992 } // namespace v8 | 2014 } // namespace v8 |
OLD | NEW |