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

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

Issue 1941673002: [turbofan] Remove left-over change bits from ChangeLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Don't mess with the regions yet 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/change-lowering.h ('k') | src/compiler/effect-control-linearizer.h » ('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/address-map.h"
8 #include "src/code-factory.h"
9 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
10 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
11 #include "src/compiler/machine-operator.h" 9 #include "src/compiler/machine-operator.h"
12 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
13 #include "src/compiler/operator-properties.h"
14 #include "src/compiler/simplified-operator.h" 11 #include "src/compiler/simplified-operator.h"
12 #include "src/conversions-inl.h"
15 13
16 namespace v8 { 14 namespace v8 {
17 namespace internal { 15 namespace internal {
18 namespace compiler { 16 namespace compiler {
19 17
20 ChangeLowering::~ChangeLowering() {} 18 ChangeLowering::~ChangeLowering() {}
21 19
22 20
23 Reduction ChangeLowering::Reduce(Node* node) { 21 Reduction ChangeLowering::Reduce(Node* node) {
24 Node* control = graph()->start();
25 switch (node->opcode()) { 22 switch (node->opcode()) {
26 case IrOpcode::kChangeBitToBool:
27 return ReduceChangeBitToBool(node->InputAt(0), control);
28 case IrOpcode::kChangeBoolToBit:
29 return ReduceChangeBoolToBit(node->InputAt(0));
30 case IrOpcode::kChangeInt31ToTagged:
31 return ReduceChangeInt31ToTagged(node->InputAt(0), control);
32 case IrOpcode::kChangeTaggedSignedToInt32:
33 return ReduceChangeTaggedSignedToInt32(node->InputAt(0));
34 case IrOpcode::kLoadField: 23 case IrOpcode::kLoadField:
35 return ReduceLoadField(node); 24 return ReduceLoadField(node);
36 case IrOpcode::kStoreField: 25 case IrOpcode::kStoreField:
37 return ReduceStoreField(node); 26 return ReduceStoreField(node);
38 case IrOpcode::kLoadElement: 27 case IrOpcode::kLoadElement:
39 return ReduceLoadElement(node); 28 return ReduceLoadElement(node);
40 case IrOpcode::kStoreElement: 29 case IrOpcode::kStoreElement:
41 return ReduceStoreElement(node); 30 return ReduceStoreElement(node);
42 case IrOpcode::kAllocate: 31 case IrOpcode::kAllocate:
43 return ReduceAllocate(node); 32 return ReduceAllocate(node);
44 case IrOpcode::kObjectIsSmi:
45 return ReduceObjectIsSmi(node);
46 default: 33 default:
47 return NoChange(); 34 return NoChange();
48 } 35 }
49 UNREACHABLE(); 36 UNREACHABLE();
50 return NoChange(); 37 return NoChange();
51 } 38 }
52 39
53 Node* ChangeLowering::SmiShiftBitsConstant() {
54 return jsgraph()->IntPtrConstant(kSmiShiftSize + kSmiTagSize);
55 }
56
57 Node* ChangeLowering::ChangeInt32ToSmi(Node* value) {
58 if (machine()->Is64()) {
59 value = graph()->NewNode(machine()->ChangeInt32ToInt64(), value);
60 }
61 return graph()->NewNode(machine()->WordShl(), value, SmiShiftBitsConstant());
62 }
63
64 Node* ChangeLowering::ChangeSmiToWord32(Node* value) {
65 value = graph()->NewNode(machine()->WordSar(), value, SmiShiftBitsConstant());
66 if (machine()->Is64()) {
67 value = graph()->NewNode(machine()->TruncateInt64ToInt32(), value);
68 }
69 return value;
70 }
71
72
73 Node* ChangeLowering::ChangeUint32ToFloat64(Node* value) {
74 return graph()->NewNode(machine()->ChangeUint32ToFloat64(), value);
75 }
76
77 Reduction ChangeLowering::ReduceChangeBitToBool(Node* value, Node* control) {
78 return Replace(
79 graph()->NewNode(common()->Select(MachineRepresentation::kTagged), value,
80 jsgraph()->TrueConstant(), jsgraph()->FalseConstant()));
81 }
82
83 Reduction ChangeLowering::ReduceChangeBoolToBit(Node* value) {
84 return Replace(graph()->NewNode(machine()->WordEqual(), value,
85 jsgraph()->TrueConstant()));
86 }
87
88 Reduction ChangeLowering::ReduceChangeInt31ToTagged(Node* value,
89 Node* control) {
90 return Replace(ChangeInt32ToSmi(value));
91 }
92
93 Reduction ChangeLowering::ReduceChangeTaggedSignedToInt32(Node* value) {
94 return Replace(ChangeSmiToWord32(value));
95 }
96
97 namespace { 40 namespace {
98 41
99 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, 42 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged,
100 MachineRepresentation representation, 43 MachineRepresentation representation,
101 Node* value) { 44 Node* value) {
102 // TODO(bmeurer): Optimize write barriers based on input. 45 // TODO(bmeurer): Optimize write barriers based on input.
103 if (base_is_tagged == kTaggedBase && 46 if (base_is_tagged == kTaggedBase &&
104 representation == MachineRepresentation::kTagged) { 47 representation == MachineRepresentation::kTagged) {
105 if (value->opcode() == IrOpcode::kHeapConstant) { 48 if (value->opcode() == IrOpcode::kHeapConstant) {
106 return kPointerWriteBarrier; 49 return kPointerWriteBarrier;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 node->InsertInput(graph()->zone(), 0, target); 141 node->InsertInput(graph()->zone(), 0, target);
199 if (!allocate_operator_.is_set()) { 142 if (!allocate_operator_.is_set()) {
200 CallDescriptor* descriptor = 143 CallDescriptor* descriptor =
201 Linkage::GetAllocateCallDescriptor(graph()->zone()); 144 Linkage::GetAllocateCallDescriptor(graph()->zone());
202 allocate_operator_.set(common()->Call(descriptor)); 145 allocate_operator_.set(common()->Call(descriptor));
203 } 146 }
204 NodeProperties::ChangeOp(node, allocate_operator_.get()); 147 NodeProperties::ChangeOp(node, allocate_operator_.get());
205 return Changed(node); 148 return Changed(node);
206 } 149 }
207 150
208 Reduction ChangeLowering::ReduceObjectIsSmi(Node* node) {
209 node->ReplaceInput(0,
210 graph()->NewNode(machine()->WordAnd(), node->InputAt(0),
211 jsgraph()->IntPtrConstant(kSmiTagMask)));
212 node->AppendInput(graph()->zone(), jsgraph()->IntPtrConstant(kSmiTag));
213 NodeProperties::ChangeOp(node, machine()->WordEqual());
214 return Changed(node);
215 }
216
217 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); } 151 Isolate* ChangeLowering::isolate() const { return jsgraph()->isolate(); }
218 152
219 153
220 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); } 154 Graph* ChangeLowering::graph() const { return jsgraph()->graph(); }
221 155
222 156
223 CommonOperatorBuilder* ChangeLowering::common() const { 157 CommonOperatorBuilder* ChangeLowering::common() const {
224 return jsgraph()->common(); 158 return jsgraph()->common();
225 } 159 }
226 160
227 161
228 MachineOperatorBuilder* ChangeLowering::machine() const { 162 MachineOperatorBuilder* ChangeLowering::machine() const {
229 return jsgraph()->machine(); 163 return jsgraph()->machine();
230 } 164 }
231 165
232 } // namespace compiler 166 } // namespace compiler
233 } // namespace internal 167 } // namespace internal
234 } // namespace v8 168 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/change-lowering.h ('k') | src/compiler/effect-control-linearizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698