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/base/adapters.h" | 5 #include "src/base/adapters.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 169 } |
170 | 170 |
171 | 171 |
172 void InstructionSelector::VisitStore(Node* node) { | 172 void InstructionSelector::VisitStore(Node* node) { |
173 X87OperandGenerator g(this); | 173 X87OperandGenerator g(this); |
174 Node* base = node->InputAt(0); | 174 Node* base = node->InputAt(0); |
175 Node* index = node->InputAt(1); | 175 Node* index = node->InputAt(1); |
176 Node* value = node->InputAt(2); | 176 Node* value = node->InputAt(2); |
177 | 177 |
178 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 178 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
| 179 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind(); |
179 MachineType rep = RepresentationOf(store_rep.machine_type()); | 180 MachineType rep = RepresentationOf(store_rep.machine_type()); |
180 if (store_rep.write_barrier_kind() == kFullWriteBarrier) { | 181 |
| 182 if (write_barrier_kind != kNoWriteBarrier) { |
181 DCHECK_EQ(kRepTagged, rep); | 183 DCHECK_EQ(kRepTagged, rep); |
182 // TODO(dcarney): refactor RecordWrite function to take temp registers | 184 AddressingMode addressing_mode; |
183 // and pass them here instead of using fixed regs | 185 InstructionOperand inputs[3]; |
| 186 size_t input_count = 0; |
| 187 inputs[input_count++] = g.UseUniqueRegister(base); |
184 if (g.CanBeImmediate(index)) { | 188 if (g.CanBeImmediate(index)) { |
185 InstructionOperand temps[] = {g.TempRegister(ecx), g.TempRegister()}; | 189 inputs[input_count++] = g.UseImmediate(index); |
186 Emit(kX87StoreWriteBarrier, g.NoOutput(), g.UseFixed(base, ebx), | 190 addressing_mode = kMode_MRI; |
187 g.UseImmediate(index), g.UseFixed(value, ecx), arraysize(temps), | |
188 temps); | |
189 } else { | 191 } else { |
190 InstructionOperand temps[] = {g.TempRegister(ecx), g.TempRegister(edx)}; | 192 inputs[input_count++] = g.UseUniqueRegister(index); |
191 Emit(kX87StoreWriteBarrier, g.NoOutput(), g.UseFixed(base, ebx), | 193 addressing_mode = kMode_MR1; |
192 g.UseFixed(index, ecx), g.UseFixed(value, edx), arraysize(temps), | |
193 temps); | |
194 } | 194 } |
195 return; | 195 inputs[input_count++] = (write_barrier_kind == kMapWriteBarrier) |
| 196 ? g.UseRegister(value) |
| 197 : g.UseUniqueRegister(value); |
| 198 RecordWriteMode record_write_mode = RecordWriteMode::kValueIsAny; |
| 199 switch (write_barrier_kind) { |
| 200 case kNoWriteBarrier: |
| 201 UNREACHABLE(); |
| 202 break; |
| 203 case kMapWriteBarrier: |
| 204 record_write_mode = RecordWriteMode::kValueIsMap; |
| 205 break; |
| 206 case kPointerWriteBarrier: |
| 207 record_write_mode = RecordWriteMode::kValueIsPointer; |
| 208 break; |
| 209 case kFullWriteBarrier: |
| 210 record_write_mode = RecordWriteMode::kValueIsAny; |
| 211 break; |
| 212 } |
| 213 InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; |
| 214 size_t const temp_count = arraysize(temps); |
| 215 InstructionCode code = kArchStoreWithWriteBarrier; |
| 216 code |= AddressingModeField::encode(addressing_mode); |
| 217 code |= MiscField::encode(static_cast<int>(record_write_mode)); |
| 218 Emit(code, 0, nullptr, input_count, inputs, temp_count, temps); |
| 219 } else { |
| 220 ArchOpcode opcode; |
| 221 switch (rep) { |
| 222 case kRepFloat32: |
| 223 opcode = kX87Movss; |
| 224 break; |
| 225 case kRepFloat64: |
| 226 opcode = kX87Movsd; |
| 227 break; |
| 228 case kRepBit: // Fall through. |
| 229 case kRepWord8: |
| 230 opcode = kX87Movb; |
| 231 break; |
| 232 case kRepWord16: |
| 233 opcode = kX87Movw; |
| 234 break; |
| 235 case kRepTagged: // Fall through. |
| 236 case kRepWord32: |
| 237 opcode = kX87Movl; |
| 238 break; |
| 239 default: |
| 240 UNREACHABLE(); |
| 241 return; |
| 242 } |
| 243 |
| 244 InstructionOperand val; |
| 245 if (g.CanBeImmediate(value)) { |
| 246 val = g.UseImmediate(value); |
| 247 } else if (rep == kRepWord8 || rep == kRepBit) { |
| 248 val = g.UseByteRegister(value); |
| 249 } else { |
| 250 val = g.UseRegister(value); |
| 251 } |
| 252 |
| 253 InstructionOperand inputs[4]; |
| 254 size_t input_count = 0; |
| 255 AddressingMode addressing_mode = |
| 256 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); |
| 257 InstructionCode code = |
| 258 opcode | AddressingModeField::encode(addressing_mode); |
| 259 inputs[input_count++] = val; |
| 260 Emit(code, 0, static_cast<InstructionOperand*>(NULL), input_count, inputs); |
196 } | 261 } |
197 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind()); | |
198 | |
199 ArchOpcode opcode; | |
200 switch (rep) { | |
201 case kRepFloat32: | |
202 opcode = kX87Movss; | |
203 break; | |
204 case kRepFloat64: | |
205 opcode = kX87Movsd; | |
206 break; | |
207 case kRepBit: // Fall through. | |
208 case kRepWord8: | |
209 opcode = kX87Movb; | |
210 break; | |
211 case kRepWord16: | |
212 opcode = kX87Movw; | |
213 break; | |
214 case kRepTagged: // Fall through. | |
215 case kRepWord32: | |
216 opcode = kX87Movl; | |
217 break; | |
218 default: | |
219 UNREACHABLE(); | |
220 return; | |
221 } | |
222 | |
223 InstructionOperand val; | |
224 if (g.CanBeImmediate(value)) { | |
225 val = g.UseImmediate(value); | |
226 } else if (rep == kRepWord8 || rep == kRepBit) { | |
227 val = g.UseByteRegister(value); | |
228 } else { | |
229 val = g.UseRegister(value); | |
230 } | |
231 | |
232 InstructionOperand inputs[4]; | |
233 size_t input_count = 0; | |
234 AddressingMode mode = | |
235 g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); | |
236 InstructionCode code = opcode | AddressingModeField::encode(mode); | |
237 inputs[input_count++] = val; | |
238 Emit(code, 0, static_cast<InstructionOperand*>(NULL), input_count, inputs); | |
239 } | 262 } |
240 | 263 |
241 | 264 |
242 void InstructionSelector::VisitCheckedLoad(Node* node) { | 265 void InstructionSelector::VisitCheckedLoad(Node* node) { |
243 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); | 266 MachineType rep = RepresentationOf(OpParameter<MachineType>(node)); |
244 MachineType typ = TypeOf(OpParameter<MachineType>(node)); | 267 MachineType typ = TypeOf(OpParameter<MachineType>(node)); |
245 X87OperandGenerator g(this); | 268 X87OperandGenerator g(this); |
246 Node* const buffer = node->InputAt(0); | 269 Node* const buffer = node->InputAt(0); |
247 Node* const offset = node->InputAt(1); | 270 Node* const offset = node->InputAt(1); |
248 Node* const length = node->InputAt(2); | 271 Node* const length = node->InputAt(2); |
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 MachineOperatorBuilder::kWord32ShiftIsSafe; | 1275 MachineOperatorBuilder::kWord32ShiftIsSafe; |
1253 if (CpuFeatures::IsSupported(POPCNT)) { | 1276 if (CpuFeatures::IsSupported(POPCNT)) { |
1254 flags |= MachineOperatorBuilder::kWord32Popcnt; | 1277 flags |= MachineOperatorBuilder::kWord32Popcnt; |
1255 } | 1278 } |
1256 return flags; | 1279 return flags; |
1257 } | 1280 } |
1258 | 1281 |
1259 } // namespace compiler | 1282 } // namespace compiler |
1260 } // namespace internal | 1283 } // namespace internal |
1261 } // namespace v8 | 1284 } // namespace v8 |
OLD | NEW |