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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 Label done; \ | 330 Label done; \ |
331 __ j(above_equal, &done, Label::kNear); \ | 331 __ j(above_equal, &done, Label::kNear); \ |
332 if (instr->InputAt(2)->IsRegister()) { \ | 332 if (instr->InputAt(2)->IsRegister()) { \ |
333 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ | 333 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ |
334 } else { \ | 334 } else { \ |
335 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ | 335 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ |
336 } \ | 336 } \ |
337 __ bind(&done); \ | 337 __ bind(&done); \ |
338 } while (false) | 338 } while (false) |
339 | 339 |
| 340 #define ASSEMBLE_COMPARE(asm_instr) \ |
| 341 do { \ |
| 342 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { \ |
| 343 size_t index = 0; \ |
| 344 Operand left = i.MemoryOperand(&index); \ |
| 345 if (HasImmediateInput(instr, index)) { \ |
| 346 __ asm_instr(left, i.InputImmediate(index)); \ |
| 347 } else { \ |
| 348 __ asm_instr(left, i.InputRegister(index)); \ |
| 349 } \ |
| 350 } else { \ |
| 351 if (HasImmediateInput(instr, 1)) { \ |
| 352 if (instr->InputAt(0)->IsRegister()) { \ |
| 353 __ asm_instr(i.InputRegister(0), i.InputImmediate(1)); \ |
| 354 } else { \ |
| 355 __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ |
| 356 } \ |
| 357 } else { \ |
| 358 if (instr->InputAt(1)->IsRegister()) { \ |
| 359 __ asm_instr(i.InputRegister(0), i.InputRegister(1)); \ |
| 360 } else { \ |
| 361 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ |
| 362 } \ |
| 363 } \ |
| 364 } \ |
| 365 } while (0) |
| 366 |
340 void CodeGenerator::AssembleDeconstructFrame() { | 367 void CodeGenerator::AssembleDeconstructFrame() { |
341 __ mov(esp, ebp); | 368 __ mov(esp, ebp); |
342 __ pop(ebp); | 369 __ pop(ebp); |
343 } | 370 } |
344 | 371 |
345 // For insert fninit/fld1 instructions after the Prologue | 372 // For insert fninit/fld1 instructions after the Prologue |
346 thread_local bool is_block_0 = false; | 373 thread_local bool is_block_0 = false; |
347 | 374 |
348 void CodeGenerator::AssembleSetupStackPointer() { is_block_0 = true; } | 375 void CodeGenerator::AssembleSetupStackPointer() { is_block_0 = true; } |
349 | 376 |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 } | 697 } |
671 break; | 698 break; |
672 case kX87And: | 699 case kX87And: |
673 if (HasImmediateInput(instr, 1)) { | 700 if (HasImmediateInput(instr, 1)) { |
674 __ and_(i.InputOperand(0), i.InputImmediate(1)); | 701 __ and_(i.InputOperand(0), i.InputImmediate(1)); |
675 } else { | 702 } else { |
676 __ and_(i.InputRegister(0), i.InputOperand(1)); | 703 __ and_(i.InputRegister(0), i.InputOperand(1)); |
677 } | 704 } |
678 break; | 705 break; |
679 case kX87Cmp: | 706 case kX87Cmp: |
680 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { | 707 ASSEMBLE_COMPARE(cmp); |
681 size_t index = 0; | 708 break; |
682 Operand operand = i.MemoryOperand(&index); | 709 case kX87Cmp16: |
683 if (HasImmediateInput(instr, index)) { | 710 ASSEMBLE_COMPARE(cmpw); |
684 __ cmp(operand, i.InputImmediate(index)); | 711 break; |
685 } else { | 712 case kX87Cmp8: |
686 __ cmp(operand, i.InputRegister(index)); | 713 ASSEMBLE_COMPARE(cmpb); |
687 } | |
688 } else { | |
689 if (HasImmediateInput(instr, 1)) { | |
690 __ cmp(i.InputOperand(0), i.InputImmediate(1)); | |
691 } else { | |
692 __ cmp(i.InputRegister(0), i.InputOperand(1)); | |
693 } | |
694 } | |
695 break; | 714 break; |
696 case kX87Test: | 715 case kX87Test: |
697 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { | 716 ASSEMBLE_COMPARE(test); |
698 size_t index = 0; | 717 break; |
699 Operand operand = i.MemoryOperand(&index); | 718 case kX87Test16: |
700 if (HasImmediateInput(instr, index)) { | 719 ASSEMBLE_COMPARE(test_w); |
701 __ test(operand, i.InputImmediate(index)); | 720 break; |
702 } else { | 721 case kX87Test8: |
703 __ test(i.InputRegister(index), operand); | 722 ASSEMBLE_COMPARE(test_b); |
704 } | |
705 } else { | |
706 if (HasImmediateInput(instr, 1)) { | |
707 __ test(i.InputOperand(0), i.InputImmediate(1)); | |
708 } else { | |
709 __ test(i.InputRegister(0), i.InputOperand(1)); | |
710 } | |
711 } | |
712 break; | 723 break; |
713 case kX87Imul: | 724 case kX87Imul: |
714 if (HasImmediateInput(instr, 1)) { | 725 if (HasImmediateInput(instr, 1)) { |
715 __ imul(i.OutputRegister(), i.InputOperand(0), i.InputInt32(1)); | 726 __ imul(i.OutputRegister(), i.InputOperand(0), i.InputInt32(1)); |
716 } else { | 727 } else { |
717 __ imul(i.OutputRegister(), i.InputOperand(1)); | 728 __ imul(i.OutputRegister(), i.InputOperand(1)); |
718 } | 729 } |
719 break; | 730 break; |
720 case kX87ImulHigh: | 731 case kX87ImulHigh: |
721 __ imul(i.InputRegister(1)); | 732 __ imul(i.InputRegister(1)); |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2439 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2429 __ Nop(padding_size); | 2440 __ Nop(padding_size); |
2430 } | 2441 } |
2431 } | 2442 } |
2432 | 2443 |
2433 #undef __ | 2444 #undef __ |
2434 | 2445 |
2435 } // namespace compiler | 2446 } // namespace compiler |
2436 } // namespace internal | 2447 } // namespace internal |
2437 } // namespace v8 | 2448 } // namespace v8 |
OLD | NEW |