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

Side by Side Diff: src/compiler/change-lowering.cc

Issue 1943743003: Revert of [turbofan] Restore basic write barrier elimination. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months 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
« no previous file with comments | « src/compiler/access-builder.cc ('k') | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/compiler/change-lowering.h" 5 #include "src/compiler/change-lowering.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
10 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
11 #include "src/compiler/simplified-operator.h" 11 #include "src/compiler/simplified-operator.h"
12 #include "src/conversions-inl.h"
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 namespace compiler { 16 namespace compiler {
16 17
17 ChangeLowering::~ChangeLowering() {} 18 ChangeLowering::~ChangeLowering() {}
18 19
19 20
20 Reduction ChangeLowering::Reduce(Node* node) { 21 Reduction ChangeLowering::Reduce(Node* node) {
21 switch (node->opcode()) { 22 switch (node->opcode()) {
22 case IrOpcode::kLoadField: 23 case IrOpcode::kLoadField:
23 return ReduceLoadField(node); 24 return ReduceLoadField(node);
24 case IrOpcode::kStoreField: 25 case IrOpcode::kStoreField:
25 return ReduceStoreField(node); 26 return ReduceStoreField(node);
26 case IrOpcode::kLoadElement: 27 case IrOpcode::kLoadElement:
27 return ReduceLoadElement(node); 28 return ReduceLoadElement(node);
28 case IrOpcode::kStoreElement: 29 case IrOpcode::kStoreElement:
29 return ReduceStoreElement(node); 30 return ReduceStoreElement(node);
30 case IrOpcode::kAllocate: 31 case IrOpcode::kAllocate:
31 return ReduceAllocate(node); 32 return ReduceAllocate(node);
32 default: 33 default:
33 return NoChange(); 34 return NoChange();
34 } 35 }
35 UNREACHABLE(); 36 UNREACHABLE();
36 return NoChange(); 37 return NoChange();
37 } 38 }
38 39
40 namespace {
41
42 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
43 MachineRepresentation representation,
44 Node* value) {
45 // TODO(bmeurer): Optimize write barriers based on input.
46 if (base_is_tagged == kTaggedBase &&
47 representation == MachineRepresentation::kTagged) {
48 if (value->opcode() == IrOpcode::kHeapConstant) {
49 return kPointerWriteBarrier;
50 } else if (value->opcode() == IrOpcode::kNumberConstant) {
51 double const number_value = OpParameter<double>(value);
52 if (IsSmiDouble(number_value)) return kNoWriteBarrier;
53 return kPointerWriteBarrier;
54 }
55 return kFullWriteBarrier;
56 }
57 return kNoWriteBarrier;
58 }
59
60 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
61 MachineRepresentation representation,
62 int field_offset, Node* value) {
63 if (base_is_tagged == kTaggedBase && field_offset == HeapObject::kMapOffset) {
64 // Write barriers for storing maps are cheaper.
65 return kMapWriteBarrier;
66 }
67 return ComputeWriteBarrierKind(base_is_tagged, representation, value);
68 }
69
70 } // namespace
71
39 Reduction ChangeLowering::ReduceLoadField(Node* node) { 72 Reduction ChangeLowering::ReduceLoadField(Node* node) {
40 const FieldAccess& access = FieldAccessOf(node->op()); 73 const FieldAccess& access = FieldAccessOf(node->op());
41 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); 74 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag());
42 node->InsertInput(graph()->zone(), 1, offset); 75 node->InsertInput(graph()->zone(), 1, offset);
43 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); 76 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type));
44 return Changed(node); 77 return Changed(node);
45 } 78 }
46 79
47 Reduction ChangeLowering::ReduceStoreField(Node* node) { 80 Reduction ChangeLowering::ReduceStoreField(Node* node) {
48 const FieldAccess& access = FieldAccessOf(node->op()); 81 const FieldAccess& access = FieldAccessOf(node->op());
82 WriteBarrierKind kind = ComputeWriteBarrierKind(
83 access.base_is_tagged, access.machine_type.representation(),
84 access.offset, node->InputAt(1));
49 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag()); 85 Node* offset = jsgraph()->IntPtrConstant(access.offset - access.tag());
50 node->InsertInput(graph()->zone(), 1, offset); 86 node->InsertInput(graph()->zone(), 1, offset);
51 NodeProperties::ChangeOp(node, machine()->Store(StoreRepresentation( 87 NodeProperties::ChangeOp(node,
52 access.machine_type.representation(), 88 machine()->Store(StoreRepresentation(
53 access.write_barrier_kind))); 89 access.machine_type.representation(), kind)));
54 return Changed(node); 90 return Changed(node);
55 } 91 }
56 92
57 93
58 Node* ChangeLowering::ComputeIndex(const ElementAccess& access, 94 Node* ChangeLowering::ComputeIndex(const ElementAccess& access,
59 Node* const key) { 95 Node* const key) {
60 Node* index = key; 96 Node* index = key;
61 const int element_size_shift = 97 const int element_size_shift =
62 ElementSizeLog2Of(access.machine_type.representation()); 98 ElementSizeLog2Of(access.machine_type.representation());
63 if (element_size_shift) { 99 if (element_size_shift) {
(...skipping 17 matching lines...) Expand all
81 Reduction ChangeLowering::ReduceLoadElement(Node* node) { 117 Reduction ChangeLowering::ReduceLoadElement(Node* node) {
82 const ElementAccess& access = ElementAccessOf(node->op()); 118 const ElementAccess& access = ElementAccessOf(node->op());
83 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 119 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
84 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type)); 120 NodeProperties::ChangeOp(node, machine()->Load(access.machine_type));
85 return Changed(node); 121 return Changed(node);
86 } 122 }
87 123
88 Reduction ChangeLowering::ReduceStoreElement(Node* node) { 124 Reduction ChangeLowering::ReduceStoreElement(Node* node) {
89 const ElementAccess& access = ElementAccessOf(node->op()); 125 const ElementAccess& access = ElementAccessOf(node->op());
90 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); 126 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1)));
91 NodeProperties::ChangeOp(node, machine()->Store(StoreRepresentation( 127 NodeProperties::ChangeOp(
92 access.machine_type.representation(), 128 node, machine()->Store(StoreRepresentation(
93 access.write_barrier_kind))); 129 access.machine_type.representation(),
130 ComputeWriteBarrierKind(access.base_is_tagged,
131 access.machine_type.representation(),
132 node->InputAt(2)))));
94 return Changed(node); 133 return Changed(node);
95 } 134 }
96 135
97 Reduction ChangeLowering::ReduceAllocate(Node* node) { 136 Reduction ChangeLowering::ReduceAllocate(Node* node) {
98 PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op()); 137 PretenureFlag pretenure = OpParameter<PretenureFlag>(node->op());
99 Node* target = pretenure == NOT_TENURED 138 Node* target = pretenure == NOT_TENURED
100 ? jsgraph()->AllocateInNewSpaceStubConstant() 139 ? jsgraph()->AllocateInNewSpaceStubConstant()
101 : jsgraph()->AllocateInOldSpaceStubConstant(); 140 : jsgraph()->AllocateInOldSpaceStubConstant();
102 node->InsertInput(graph()->zone(), 0, target); 141 node->InsertInput(graph()->zone(), 0, target);
103 if (!allocate_operator_.is_set()) { 142 if (!allocate_operator_.is_set()) {
(...skipping 16 matching lines...) Expand all
120 } 159 }
121 160
122 161
123 MachineOperatorBuilder* ChangeLowering::machine() const { 162 MachineOperatorBuilder* ChangeLowering::machine() const {
124 return jsgraph()->machine(); 163 return jsgraph()->machine();
125 } 164 }
126 165
127 } // namespace compiler 166 } // namespace compiler
128 } // namespace internal 167 } // namespace internal
129 } // namespace v8 168 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/access-builder.cc ('k') | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698