Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: src/compiler/mips64/instruction-selector-mips64.cc

Issue 1414183006: [turbofan] Avoid unnecessary write barriers and improve code generation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 179 }
180 180
181 181
182 void InstructionSelector::VisitStore(Node* node) { 182 void InstructionSelector::VisitStore(Node* node) {
183 Mips64OperandGenerator g(this); 183 Mips64OperandGenerator g(this);
184 Node* base = node->InputAt(0); 184 Node* base = node->InputAt(0);
185 Node* index = node->InputAt(1); 185 Node* index = node->InputAt(1);
186 Node* value = node->InputAt(2); 186 Node* value = node->InputAt(2);
187 187
188 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); 188 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
189 WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind();
189 MachineType rep = RepresentationOf(store_rep.machine_type()); 190 MachineType rep = RepresentationOf(store_rep.machine_type());
190 if (store_rep.write_barrier_kind() == kFullWriteBarrier) {
191 DCHECK(rep == kRepTagged);
192 // TODO(dcarney): refactor RecordWrite function to take temp registers
193 // and pass them here instead of using fixed regs
194 // TODO(dcarney): handle immediate indices.
195 InstructionOperand temps[] = {g.TempRegister(t1), g.TempRegister(t2)};
196 Emit(kMips64StoreWriteBarrier, g.NoOutput(), g.UseFixed(base, t0),
197 g.UseFixed(index, t1), g.UseFixed(value, t2), arraysize(temps), temps);
198 return;
199 }
200 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind());
201 191
202 ArchOpcode opcode; 192 ArchOpcode opcode;
203 switch (rep) { 193 switch (rep) {
204 case kRepFloat32: 194 case kRepFloat32:
205 opcode = kMips64Swc1; 195 opcode = kMips64Swc1;
206 break; 196 break;
207 case kRepFloat64: 197 case kRepFloat64:
208 opcode = kMips64Sdc1; 198 opcode = kMips64Sdc1;
209 break; 199 break;
210 case kRepBit: // Fall through. 200 case kRepBit: // Fall through.
(...skipping 19 matching lines...) Expand all
230 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), 220 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(),
231 g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value)); 221 g.UseRegister(base), g.UseImmediate(index), g.UseRegister(value));
232 } else { 222 } else {
233 InstructionOperand addr_reg = g.TempRegister(); 223 InstructionOperand addr_reg = g.TempRegister();
234 Emit(kMips64Dadd | AddressingModeField::encode(kMode_None), addr_reg, 224 Emit(kMips64Dadd | AddressingModeField::encode(kMode_None), addr_reg,
235 g.UseRegister(index), g.UseRegister(base)); 225 g.UseRegister(index), g.UseRegister(base));
236 // Emit desired store opcode, using temp addr_reg. 226 // Emit desired store opcode, using temp addr_reg.
237 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), 227 Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(),
238 addr_reg, g.TempImmediate(0), g.UseRegister(value)); 228 addr_reg, g.TempImmediate(0), g.UseRegister(value));
239 } 229 }
230
231 // TODO(mips): I guess this could be done in a better way.
232 if (write_barrier_kind != kNoWriteBarrier) {
233 DCHECK_EQ(kRepTagged, rep);
234 InstructionOperand inputs[3];
235 size_t input_count = 0;
236 inputs[input_count++] = g.UseUniqueRegister(base);
237 inputs[input_count++] = g.UseUniqueRegister(index);
238 RecordWriteMode record_write_mode;
239 switch (write_barrier_kind) {
240 case kNoWriteBarrier:
241 UNREACHABLE();
242 break;
243 case kMapWriteBarrier:
244 record_write_mode = RecordWriteMode::kValueIsMap;
245 break;
246 case kPointerWriteBarrier:
247 inputs[input_count++] = g.UseUniqueRegister(value);
248 record_write_mode = RecordWriteMode::kValueIsPointer;
249 break;
250 case kFullWriteBarrier:
251 inputs[input_count++] = g.UseUniqueRegister(value);
252 record_write_mode = RecordWriteMode::kValueIsAny;
253 break;
254 }
255 InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()};
256 size_t const temp_count = arraysize(temps);
257 InstructionCode code = kArchRecordWrite;
258 code |= MiscField::encode(static_cast<int>(record_write_mode));
259 Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
260 }
240 } 261 }
241 262
242 263
243 void InstructionSelector::VisitWord32And(Node* node) { 264 void InstructionSelector::VisitWord32And(Node* node) {
244 VisitBinop(this, node, kMips64And); 265 VisitBinop(this, node, kMips64And);
245 } 266 }
246 267
247 268
248 void InstructionSelector::VisitWord64And(Node* node) { 269 void InstructionSelector::VisitWord64And(Node* node) {
249 VisitBinop(this, node, kMips64And); 270 VisitBinop(this, node, kMips64And);
(...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 MachineOperatorBuilder::kFloat64Max | 1374 MachineOperatorBuilder::kFloat64Max |
1354 MachineOperatorBuilder::kFloat32Min | 1375 MachineOperatorBuilder::kFloat32Min |
1355 MachineOperatorBuilder::kFloat32Max | 1376 MachineOperatorBuilder::kFloat32Max |
1356 MachineOperatorBuilder::kFloat64RoundDown | 1377 MachineOperatorBuilder::kFloat64RoundDown |
1357 MachineOperatorBuilder::kFloat64RoundTruncate; 1378 MachineOperatorBuilder::kFloat64RoundTruncate;
1358 } 1379 }
1359 1380
1360 } // namespace compiler 1381 } // namespace compiler
1361 } // namespace internal 1382 } // namespace internal
1362 } // namespace v8 1383 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698