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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 Label done; \ | 323 Label done; \ |
324 __ j(above_equal, &done, Label::kNear); \ | 324 __ j(above_equal, &done, Label::kNear); \ |
325 if (instr->InputAt(2)->IsRegister()) { \ | 325 if (instr->InputAt(2)->IsRegister()) { \ |
326 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ | 326 __ asm_instr(i.MemoryOperand(3), i.InputRegister(2)); \ |
327 } else { \ | 327 } else { \ |
328 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ | 328 __ asm_instr(i.MemoryOperand(3), i.InputImmediate(2)); \ |
329 } \ | 329 } \ |
330 __ bind(&done); \ | 330 __ bind(&done); \ |
331 } while (false) | 331 } while (false) |
332 | 332 |
| 333 #define ASSEMBLE_COMPARE(asm_instr) \ |
| 334 do { \ |
| 335 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { \ |
| 336 size_t index = 0; \ |
| 337 Operand left = i.MemoryOperand(&index); \ |
| 338 if (HasImmediateInput(instr, index)) { \ |
| 339 __ asm_instr(left, i.InputImmediate(index)); \ |
| 340 } else { \ |
| 341 __ asm_instr(left, i.InputRegister(index)); \ |
| 342 } \ |
| 343 } else { \ |
| 344 if (HasImmediateInput(instr, 1)) { \ |
| 345 if (instr->InputAt(0)->IsRegister()) { \ |
| 346 __ asm_instr(i.InputRegister(0), i.InputImmediate(1)); \ |
| 347 } else { \ |
| 348 __ asm_instr(i.InputOperand(0), i.InputImmediate(1)); \ |
| 349 } \ |
| 350 } else { \ |
| 351 if (instr->InputAt(1)->IsRegister()) { \ |
| 352 __ asm_instr(i.InputRegister(0), i.InputRegister(1)); \ |
| 353 } else { \ |
| 354 __ asm_instr(i.InputRegister(0), i.InputOperand(1)); \ |
| 355 } \ |
| 356 } \ |
| 357 } \ |
| 358 } while (0) |
| 359 |
333 void CodeGenerator::AssembleDeconstructFrame() { | 360 void CodeGenerator::AssembleDeconstructFrame() { |
334 __ mov(esp, ebp); | 361 __ mov(esp, ebp); |
335 __ pop(ebp); | 362 __ pop(ebp); |
336 } | 363 } |
337 | 364 |
338 void CodeGenerator::AssembleSetupStackPointer() {} | 365 void CodeGenerator::AssembleSetupStackPointer() {} |
339 | 366 |
340 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { | 367 void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
341 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); | 368 int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
342 if (sp_slot_delta > 0) { | 369 if (sp_slot_delta > 0) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 } | 601 } |
575 break; | 602 break; |
576 case kIA32And: | 603 case kIA32And: |
577 if (HasImmediateInput(instr, 1)) { | 604 if (HasImmediateInput(instr, 1)) { |
578 __ and_(i.InputOperand(0), i.InputImmediate(1)); | 605 __ and_(i.InputOperand(0), i.InputImmediate(1)); |
579 } else { | 606 } else { |
580 __ and_(i.InputRegister(0), i.InputOperand(1)); | 607 __ and_(i.InputRegister(0), i.InputOperand(1)); |
581 } | 608 } |
582 break; | 609 break; |
583 case kIA32Cmp: | 610 case kIA32Cmp: |
584 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { | 611 ASSEMBLE_COMPARE(cmp); |
585 size_t index = 0; | 612 break; |
586 Operand operand = i.MemoryOperand(&index); | 613 case kIA32Cmp16: |
587 if (HasImmediateInput(instr, index)) { | 614 ASSEMBLE_COMPARE(cmpw); |
588 __ cmp(operand, i.InputImmediate(index)); | 615 break; |
589 } else { | 616 case kIA32Cmp8: |
590 __ cmp(operand, i.InputRegister(index)); | 617 ASSEMBLE_COMPARE(cmpb); |
591 } | |
592 } else { | |
593 if (HasImmediateInput(instr, 1)) { | |
594 __ cmp(i.InputOperand(0), i.InputImmediate(1)); | |
595 } else { | |
596 __ cmp(i.InputRegister(0), i.InputOperand(1)); | |
597 } | |
598 } | |
599 break; | 618 break; |
600 case kIA32Test: | 619 case kIA32Test: |
601 if (AddressingModeField::decode(instr->opcode()) != kMode_None) { | 620 ASSEMBLE_COMPARE(test); |
602 size_t index = 0; | 621 break; |
603 Operand operand = i.MemoryOperand(&index); | 622 case kIA32Test16: |
604 if (HasImmediateInput(instr, index)) { | 623 ASSEMBLE_COMPARE(test_w); |
605 __ test(operand, i.InputImmediate(index)); | 624 break; |
606 } else { | 625 case kIA32Test8: |
607 __ test(i.InputRegister(index), operand); | 626 ASSEMBLE_COMPARE(test_b); |
608 } | |
609 } else { | |
610 if (HasImmediateInput(instr, 1)) { | |
611 __ test(i.InputOperand(0), i.InputImmediate(1)); | |
612 } else { | |
613 __ test(i.InputRegister(0), i.InputOperand(1)); | |
614 } | |
615 } | |
616 break; | 627 break; |
617 case kIA32Imul: | 628 case kIA32Imul: |
618 if (HasImmediateInput(instr, 1)) { | 629 if (HasImmediateInput(instr, 1)) { |
619 __ imul(i.OutputRegister(), i.InputOperand(0), i.InputInt32(1)); | 630 __ imul(i.OutputRegister(), i.InputOperand(0), i.InputInt32(1)); |
620 } else { | 631 } else { |
621 __ imul(i.OutputRegister(), i.InputOperand(1)); | 632 __ imul(i.OutputRegister(), i.InputOperand(1)); |
622 } | 633 } |
623 break; | 634 break; |
624 case kIA32ImulHigh: | 635 case kIA32ImulHigh: |
625 __ imul(i.InputRegister(1)); | 636 __ imul(i.InputRegister(1)); |
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 1897 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
1887 __ Nop(padding_size); | 1898 __ Nop(padding_size); |
1888 } | 1899 } |
1889 } | 1900 } |
1890 | 1901 |
1891 #undef __ | 1902 #undef __ |
1892 | 1903 |
1893 } // namespace compiler | 1904 } // namespace compiler |
1894 } // namespace internal | 1905 } // namespace internal |
1895 } // namespace v8 | 1906 } // namespace v8 |
OLD | NEW |