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

Unified Diff: src/compiler/x87/instruction-selector-x87.cc

Issue 1435743003: X87: [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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/x87/instruction-codes-x87.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/x87/instruction-selector-x87.cc
diff --git a/src/compiler/x87/instruction-selector-x87.cc b/src/compiler/x87/instruction-selector-x87.cc
index a78bdb4b2849b5b56bee3828804a3d6cc015e02e..5c6f10255f6a8f20910fbbe9c32f46ede9f44d29 100644
--- a/src/compiler/x87/instruction-selector-x87.cc
+++ b/src/compiler/x87/instruction-selector-x87.cc
@@ -176,66 +176,89 @@ void InstructionSelector::VisitStore(Node* node) {
Node* value = node->InputAt(2);
StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node);
+ WriteBarrierKind write_barrier_kind = store_rep.write_barrier_kind();
MachineType rep = RepresentationOf(store_rep.machine_type());
- if (store_rep.write_barrier_kind() == kFullWriteBarrier) {
+
+ if (write_barrier_kind != kNoWriteBarrier) {
DCHECK_EQ(kRepTagged, rep);
- // TODO(dcarney): refactor RecordWrite function to take temp registers
- // and pass them here instead of using fixed regs
+ AddressingMode addressing_mode;
+ InstructionOperand inputs[3];
+ size_t input_count = 0;
+ inputs[input_count++] = g.UseUniqueRegister(base);
if (g.CanBeImmediate(index)) {
- InstructionOperand temps[] = {g.TempRegister(ecx), g.TempRegister()};
- Emit(kX87StoreWriteBarrier, g.NoOutput(), g.UseFixed(base, ebx),
- g.UseImmediate(index), g.UseFixed(value, ecx), arraysize(temps),
- temps);
+ inputs[input_count++] = g.UseImmediate(index);
+ addressing_mode = kMode_MRI;
} else {
- InstructionOperand temps[] = {g.TempRegister(ecx), g.TempRegister(edx)};
- Emit(kX87StoreWriteBarrier, g.NoOutput(), g.UseFixed(base, ebx),
- g.UseFixed(index, ecx), g.UseFixed(value, edx), arraysize(temps),
- temps);
+ inputs[input_count++] = g.UseUniqueRegister(index);
+ addressing_mode = kMode_MR1;
+ }
+ inputs[input_count++] = (write_barrier_kind == kMapWriteBarrier)
+ ? g.UseRegister(value)
+ : g.UseUniqueRegister(value);
+ RecordWriteMode record_write_mode = RecordWriteMode::kValueIsAny;
+ switch (write_barrier_kind) {
+ case kNoWriteBarrier:
+ UNREACHABLE();
+ break;
+ case kMapWriteBarrier:
+ record_write_mode = RecordWriteMode::kValueIsMap;
+ break;
+ case kPointerWriteBarrier:
+ record_write_mode = RecordWriteMode::kValueIsPointer;
+ break;
+ case kFullWriteBarrier:
+ record_write_mode = RecordWriteMode::kValueIsAny;
+ break;
+ }
+ InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()};
+ size_t const temp_count = arraysize(temps);
+ InstructionCode code = kArchStoreWithWriteBarrier;
+ code |= AddressingModeField::encode(addressing_mode);
+ code |= MiscField::encode(static_cast<int>(record_write_mode));
+ Emit(code, 0, nullptr, input_count, inputs, temp_count, temps);
+ } else {
+ ArchOpcode opcode;
+ switch (rep) {
+ case kRepFloat32:
+ opcode = kX87Movss;
+ break;
+ case kRepFloat64:
+ opcode = kX87Movsd;
+ break;
+ case kRepBit: // Fall through.
+ case kRepWord8:
+ opcode = kX87Movb;
+ break;
+ case kRepWord16:
+ opcode = kX87Movw;
+ break;
+ case kRepTagged: // Fall through.
+ case kRepWord32:
+ opcode = kX87Movl;
+ break;
+ default:
+ UNREACHABLE();
+ return;
}
- return;
- }
- DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind());
- ArchOpcode opcode;
- switch (rep) {
- case kRepFloat32:
- opcode = kX87Movss;
- break;
- case kRepFloat64:
- opcode = kX87Movsd;
- break;
- case kRepBit: // Fall through.
- case kRepWord8:
- opcode = kX87Movb;
- break;
- case kRepWord16:
- opcode = kX87Movw;
- break;
- case kRepTagged: // Fall through.
- case kRepWord32:
- opcode = kX87Movl;
- break;
- default:
- UNREACHABLE();
- return;
- }
+ InstructionOperand val;
+ if (g.CanBeImmediate(value)) {
+ val = g.UseImmediate(value);
+ } else if (rep == kRepWord8 || rep == kRepBit) {
+ val = g.UseByteRegister(value);
+ } else {
+ val = g.UseRegister(value);
+ }
- InstructionOperand val;
- if (g.CanBeImmediate(value)) {
- val = g.UseImmediate(value);
- } else if (rep == kRepWord8 || rep == kRepBit) {
- val = g.UseByteRegister(value);
- } else {
- val = g.UseRegister(value);
+ InstructionOperand inputs[4];
+ size_t input_count = 0;
+ AddressingMode addressing_mode =
+ g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
+ InstructionCode code =
+ opcode | AddressingModeField::encode(addressing_mode);
+ inputs[input_count++] = val;
+ Emit(code, 0, static_cast<InstructionOperand*>(NULL), input_count, inputs);
}
-
- InstructionOperand inputs[4];
- size_t input_count = 0;
- AddressingMode mode =
- g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count);
- InstructionCode code = opcode | AddressingModeField::encode(mode);
- inputs[input_count++] = val;
- Emit(code, 0, static_cast<InstructionOperand*>(NULL), input_count, inputs);
}
« no previous file with comments | « src/compiler/x87/instruction-codes-x87.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698