OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 23 matching lines...) Expand all Loading... |
34 return !isolate()->heap()->InNewSpace(*value); | 34 return !isolate()->heap()->InNewSpace(*value); |
35 } | 35 } |
36 default: | 36 default: |
37 return false; | 37 return false; |
38 } | 38 } |
39 } | 39 } |
40 }; | 40 }; |
41 | 41 |
42 | 42 |
43 void InstructionSelector::VisitLoad(Node* node) { | 43 void InstructionSelector::VisitLoad(Node* node) { |
44 MachineType rep = OpParameter<MachineType>(node); | 44 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
45 IA32OperandGenerator g(this); | 45 IA32OperandGenerator g(this); |
46 Node* base = node->InputAt(0); | 46 Node* base = node->InputAt(0); |
47 Node* index = node->InputAt(1); | 47 Node* index = node->InputAt(1); |
48 | 48 |
49 InstructionOperand* output = rep == kMachineFloat64 | 49 InstructionOperand* output = rep == kRepFloat64 |
50 ? g.DefineAsDoubleRegister(node) | 50 ? g.DefineAsDoubleRegister(node) |
51 : g.DefineAsRegister(node); | 51 : g.DefineAsRegister(node); |
52 ArchOpcode opcode; | 52 ArchOpcode opcode; |
| 53 // TODO(titzer): signed/unsigned small loads |
53 switch (rep) { | 54 switch (rep) { |
54 case kMachineFloat64: | 55 case kRepFloat64: |
55 opcode = kSSELoad; | 56 opcode = kSSELoad; |
56 break; | 57 break; |
57 case kMachineWord8: | 58 case kRepBit: // Fall through. |
| 59 case kRepWord8: |
58 opcode = kIA32LoadWord8; | 60 opcode = kIA32LoadWord8; |
59 break; | 61 break; |
60 case kMachineWord16: | 62 case kRepWord16: |
61 opcode = kIA32LoadWord16; | 63 opcode = kIA32LoadWord16; |
62 break; | 64 break; |
63 case kMachineTagged: // Fall through. | 65 case kRepTagged: // Fall through. |
64 case kMachineWord32: | 66 case kRepWord32: |
65 opcode = kIA32LoadWord32; | 67 opcode = kIA32LoadWord32; |
66 break; | 68 break; |
67 default: | 69 default: |
68 UNREACHABLE(); | 70 UNREACHABLE(); |
69 return; | 71 return; |
70 } | 72 } |
71 if (g.CanBeImmediate(base)) { | 73 if (g.CanBeImmediate(base)) { |
72 if (Int32Matcher(index).Is(0)) { // load [#base + #0] | 74 if (Int32Matcher(index).Is(0)) { // load [#base + #0] |
73 Emit(opcode | AddressingModeField::encode(kMode_MI), output, | 75 Emit(opcode | AddressingModeField::encode(kMode_MI), output, |
74 g.UseImmediate(base)); | 76 g.UseImmediate(base)); |
(...skipping 12 matching lines...) Expand all Loading... |
87 } | 89 } |
88 | 90 |
89 | 91 |
90 void InstructionSelector::VisitStore(Node* node) { | 92 void InstructionSelector::VisitStore(Node* node) { |
91 IA32OperandGenerator g(this); | 93 IA32OperandGenerator g(this); |
92 Node* base = node->InputAt(0); | 94 Node* base = node->InputAt(0); |
93 Node* index = node->InputAt(1); | 95 Node* index = node->InputAt(1); |
94 Node* value = node->InputAt(2); | 96 Node* value = node->InputAt(2); |
95 | 97 |
96 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 98 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
97 MachineType rep = store_rep.rep; | 99 MachineType rep = RepresentationOf(store_rep.machine_type); |
98 if (store_rep.write_barrier_kind == kFullWriteBarrier) { | 100 if (store_rep.write_barrier_kind == kFullWriteBarrier) { |
99 DCHECK_EQ(kMachineTagged, rep); | 101 DCHECK_EQ(kRepTagged, rep); |
100 // TODO(dcarney): refactor RecordWrite function to take temp registers | 102 // TODO(dcarney): refactor RecordWrite function to take temp registers |
101 // and pass them here instead of using fixed regs | 103 // and pass them here instead of using fixed regs |
102 // TODO(dcarney): handle immediate indices. | 104 // TODO(dcarney): handle immediate indices. |
103 InstructionOperand* temps[] = {g.TempRegister(ecx), g.TempRegister(edx)}; | 105 InstructionOperand* temps[] = {g.TempRegister(ecx), g.TempRegister(edx)}; |
104 Emit(kIA32StoreWriteBarrier, NULL, g.UseFixed(base, ebx), | 106 Emit(kIA32StoreWriteBarrier, NULL, g.UseFixed(base, ebx), |
105 g.UseFixed(index, ecx), g.UseFixed(value, edx), ARRAY_SIZE(temps), | 107 g.UseFixed(index, ecx), g.UseFixed(value, edx), ARRAY_SIZE(temps), |
106 temps); | 108 temps); |
107 return; | 109 return; |
108 } | 110 } |
109 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); | 111 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); |
110 bool is_immediate = false; | 112 bool is_immediate = false; |
111 InstructionOperand* val; | 113 InstructionOperand* val; |
112 if (rep == kMachineFloat64) { | 114 if (rep == kRepFloat64) { |
113 val = g.UseDoubleRegister(value); | 115 val = g.UseDoubleRegister(value); |
114 } else { | 116 } else { |
115 is_immediate = g.CanBeImmediate(value); | 117 is_immediate = g.CanBeImmediate(value); |
116 if (is_immediate) { | 118 if (is_immediate) { |
117 val = g.UseImmediate(value); | 119 val = g.UseImmediate(value); |
118 } else if (rep == kMachineWord8) { | 120 } else if (rep == kRepWord8 || rep == kRepBit) { |
119 val = g.UseByteRegister(value); | 121 val = g.UseByteRegister(value); |
120 } else { | 122 } else { |
121 val = g.UseRegister(value); | 123 val = g.UseRegister(value); |
122 } | 124 } |
123 } | 125 } |
124 ArchOpcode opcode; | 126 ArchOpcode opcode; |
125 switch (rep) { | 127 switch (rep) { |
126 case kMachineFloat64: | 128 case kRepFloat64: |
127 opcode = kSSEStore; | 129 opcode = kSSEStore; |
128 break; | 130 break; |
129 case kMachineWord8: | 131 case kRepBit: // Fall through. |
| 132 case kRepWord8: |
130 opcode = is_immediate ? kIA32StoreWord8I : kIA32StoreWord8; | 133 opcode = is_immediate ? kIA32StoreWord8I : kIA32StoreWord8; |
131 break; | 134 break; |
132 case kMachineWord16: | 135 case kRepWord16: |
133 opcode = is_immediate ? kIA32StoreWord16I : kIA32StoreWord16; | 136 opcode = is_immediate ? kIA32StoreWord16I : kIA32StoreWord16; |
134 break; | 137 break; |
135 case kMachineTagged: // Fall through. | 138 case kRepTagged: // Fall through. |
136 case kMachineWord32: | 139 case kRepWord32: |
137 opcode = is_immediate ? kIA32StoreWord32I : kIA32StoreWord32; | 140 opcode = is_immediate ? kIA32StoreWord32I : kIA32StoreWord32; |
138 break; | 141 break; |
139 default: | 142 default: |
140 UNREACHABLE(); | 143 UNREACHABLE(); |
141 return; | 144 return; |
142 } | 145 } |
143 if (g.CanBeImmediate(base)) { | 146 if (g.CanBeImmediate(base)) { |
144 if (Int32Matcher(index).Is(0)) { // store [#base], %|#value | 147 if (Int32Matcher(index).Is(0)) { // store [#base], %|#value |
145 Emit(opcode | AddressingModeField::encode(kMode_MI), NULL, | 148 Emit(opcode | AddressingModeField::encode(kMode_MI), NULL, |
146 g.UseImmediate(base), val); | 149 g.UseImmediate(base), val); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 if (descriptor->kind() == CallDescriptor::kCallAddress && | 559 if (descriptor->kind() == CallDescriptor::kCallAddress && |
557 buffer.pushed_count > 0) { | 560 buffer.pushed_count > 0) { |
558 DCHECK(deoptimization == NULL && continuation == NULL); | 561 DCHECK(deoptimization == NULL && continuation == NULL); |
559 Emit(kPopStack | MiscField::encode(buffer.pushed_count), NULL); | 562 Emit(kPopStack | MiscField::encode(buffer.pushed_count), NULL); |
560 } | 563 } |
561 } | 564 } |
562 | 565 |
563 } // namespace compiler | 566 } // namespace compiler |
564 } // namespace internal | 567 } // namespace internal |
565 } // namespace v8 | 568 } // namespace v8 |
OLD | NEW |