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 25 matching lines...) Expand all Loading... |
36 } | 36 } |
37 | 37 |
38 Operand OutputOperand() { return ToOperand(instr_->Output()); } | 38 Operand OutputOperand() { return ToOperand(instr_->Output()); } |
39 | 39 |
40 Immediate ToImmediate(InstructionOperand* operand) { | 40 Immediate ToImmediate(InstructionOperand* operand) { |
41 Constant constant = ToConstant(operand); | 41 Constant constant = ToConstant(operand); |
42 if (constant.type() == Constant::kFloat64) { | 42 if (constant.type() == Constant::kFloat64) { |
43 DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64())); | 43 DCHECK_EQ(0, bit_cast<int64_t>(constant.ToFloat64())); |
44 return Immediate(0); | 44 return Immediate(0); |
45 } | 45 } |
46 if (constant.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || | 46 if (RelocInfo::IsWasmReference(constant.rmode())) { |
47 constant.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE || | |
48 constant.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { | |
49 return Immediate(constant.ToInt32(), constant.rmode()); | 47 return Immediate(constant.ToInt32(), constant.rmode()); |
50 } | 48 } |
51 return Immediate(constant.ToInt32()); | 49 return Immediate(constant.ToInt32()); |
52 } | 50 } |
53 | 51 |
54 Operand ToOperand(InstructionOperand* op, int extra = 0) { | 52 Operand ToOperand(InstructionOperand* op, int extra = 0) { |
55 DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); | 53 DCHECK(op->IsStackSlot() || op->IsFPStackSlot()); |
56 return SlotToOperand(AllocatedOperand::cast(op)->index(), extra); | 54 return SlotToOperand(AllocatedOperand::cast(op)->index(), extra); |
57 } | 55 } |
58 | 56 |
(...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2629 __ movq(dst, tmp); | 2627 __ movq(dst, tmp); |
2630 } | 2628 } |
2631 } else if (source->IsConstant()) { | 2629 } else if (source->IsConstant()) { |
2632 ConstantOperand* constant_source = ConstantOperand::cast(source); | 2630 ConstantOperand* constant_source = ConstantOperand::cast(source); |
2633 Constant src = g.ToConstant(constant_source); | 2631 Constant src = g.ToConstant(constant_source); |
2634 if (destination->IsRegister() || destination->IsStackSlot()) { | 2632 if (destination->IsRegister() || destination->IsStackSlot()) { |
2635 Register dst = destination->IsRegister() ? g.ToRegister(destination) | 2633 Register dst = destination->IsRegister() ? g.ToRegister(destination) |
2636 : kScratchRegister; | 2634 : kScratchRegister; |
2637 switch (src.type()) { | 2635 switch (src.type()) { |
2638 case Constant::kInt32: { | 2636 case Constant::kInt32: { |
2639 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || | 2637 if (RelocInfo::IsWasmPtrReference(src.rmode())) { |
2640 src.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { | |
2641 __ movq(dst, src.ToInt64(), src.rmode()); | 2638 __ movq(dst, src.ToInt64(), src.rmode()); |
2642 } else { | 2639 } else { |
2643 // TODO(dcarney): don't need scratch in this case. | 2640 // TODO(dcarney): don't need scratch in this case. |
2644 int32_t value = src.ToInt32(); | 2641 int32_t value = src.ToInt32(); |
2645 if (value == 0) { | 2642 if (value == 0) { |
2646 __ xorl(dst, dst); | 2643 __ xorl(dst, dst); |
2647 } else { | 2644 } else { |
2648 if (src.rmode() == RelocInfo::WASM_MEMORY_SIZE_REFERENCE) { | 2645 if (RelocInfo::IsWasmSizeReference(src.rmode())) { |
2649 __ movl(dst, Immediate(value, src.rmode())); | 2646 __ movl(dst, Immediate(value, src.rmode())); |
2650 } else { | 2647 } else { |
2651 __ movl(dst, Immediate(value)); | 2648 __ movl(dst, Immediate(value)); |
2652 } | 2649 } |
2653 } | 2650 } |
2654 } | 2651 } |
2655 break; | 2652 break; |
2656 } | 2653 } |
2657 case Constant::kInt64: | 2654 case Constant::kInt64: |
2658 if (src.rmode() == RelocInfo::WASM_MEMORY_REFERENCE || | 2655 if (RelocInfo::IsWasmPtrReference(src.rmode())) { |
2659 src.rmode() == RelocInfo::WASM_GLOBAL_REFERENCE) { | |
2660 __ movq(dst, src.ToInt64(), src.rmode()); | 2656 __ movq(dst, src.ToInt64(), src.rmode()); |
2661 } else { | 2657 } else { |
2662 DCHECK(src.rmode() != RelocInfo::WASM_MEMORY_SIZE_REFERENCE); | 2658 DCHECK(!RelocInfo::IsWasmSizeReference(src.rmode())); |
2663 __ Set(dst, src.ToInt64()); | 2659 __ Set(dst, src.ToInt64()); |
2664 } | 2660 } |
2665 break; | 2661 break; |
2666 case Constant::kFloat32: | 2662 case Constant::kFloat32: |
2667 __ Move(dst, | 2663 __ Move(dst, |
2668 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); | 2664 isolate()->factory()->NewNumber(src.ToFloat32(), TENURED)); |
2669 break; | 2665 break; |
2670 case Constant::kFloat64: | 2666 case Constant::kFloat64: |
2671 __ Move(dst, | 2667 __ Move(dst, |
2672 isolate()->factory()->NewNumber(src.ToFloat64(), TENURED)); | 2668 isolate()->factory()->NewNumber(src.ToFloat64(), TENURED)); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2858 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; | 2854 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; |
2859 __ Nop(padding_size); | 2855 __ Nop(padding_size); |
2860 } | 2856 } |
2861 } | 2857 } |
2862 | 2858 |
2863 #undef __ | 2859 #undef __ |
2864 | 2860 |
2865 } // namespace compiler | 2861 } // namespace compiler |
2866 } // namespace internal | 2862 } // namespace internal |
2867 } // namespace v8 | 2863 } // namespace v8 |
OLD | NEW |