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

Side by Side Diff: src/compiler/simplified-operator-reducer.cc

Issue 2080703006: [turbofan] Some strength reduction on Smi/HeapObject checks. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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/simplified-operator-reducer.h ('k') | src/globals.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/simplified-operator-reducer.h" 5 #include "src/compiler/simplified-operator-reducer.h"
6 6
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/machine-operator.h" 8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/node-matchers.h" 9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/operator-properties.h" 10 #include "src/compiler/operator-properties.h"
11 #include "src/compiler/simplified-operator.h" 11 #include "src/compiler/simplified-operator.h"
12 #include "src/conversions-inl.h" 12 #include "src/conversions-inl.h"
13 #include "src/type-cache.h" 13 #include "src/type-cache.h"
14 14
15 namespace v8 { 15 namespace v8 {
16 namespace internal { 16 namespace internal {
17 namespace compiler { 17 namespace compiler {
18 18
19 SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph) 19 namespace {
20 : jsgraph_(jsgraph), type_cache_(TypeCache::Get()) {} 20
21 Decision DecideObjectIsSmi(Node* const input) {
22 NumberMatcher m(input);
23 if (m.HasValue()) {
24 return IsSmiDouble(m.Value()) ? Decision::kTrue : Decision::kFalse;
25 }
26 if (m.IsAllocate()) return Decision::kFalse;
27 if (m.IsChangeBitToTagged()) return Decision::kFalse;
28 if (m.IsChangeInt31ToTaggedSigned()) return Decision::kTrue;
29 if (m.IsHeapConstant()) return Decision::kFalse;
30 return Decision::kUnknown;
31 }
32
33 } // namespace
34
35 SimplifiedOperatorReducer::SimplifiedOperatorReducer(Editor* editor,
36 JSGraph* jsgraph)
37 : AdvancedReducer(editor),
38 jsgraph_(jsgraph),
39 type_cache_(TypeCache::Get()) {}
21 40
22 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {} 41 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
23 42
24 43
25 Reduction SimplifiedOperatorReducer::Reduce(Node* node) { 44 Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
26 switch (node->opcode()) { 45 switch (node->opcode()) {
27 case IrOpcode::kBooleanNot: { 46 case IrOpcode::kBooleanNot: {
28 HeapObjectMatcher m(node->InputAt(0)); 47 HeapObjectMatcher m(node->InputAt(0));
29 if (m.HasValue()) { 48 if (m.HasValue()) {
30 return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue())); 49 return Replace(jsgraph()->BooleanConstant(!m.Value()->BooleanValue()));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value())); 122 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
104 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() || 123 if (m.IsChangeInt31ToTaggedSigned() || m.IsChangeInt32ToTagged() ||
105 m.IsChangeUint32ToTagged()) { 124 m.IsChangeUint32ToTagged()) {
106 return Replace(m.InputAt(0)); 125 return Replace(m.InputAt(0));
107 } 126 }
108 if (m.IsChangeFloat64ToTagged()) { 127 if (m.IsChangeFloat64ToTagged()) {
109 return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0)); 128 return Change(node, machine()->TruncateFloat64ToWord32(), m.InputAt(0));
110 } 129 }
111 break; 130 break;
112 } 131 }
132 case IrOpcode::kCheckTaggedPointer: {
133 Node* const input = node->InputAt(0);
134 if (DecideObjectIsSmi(input) == Decision::kFalse) {
135 ReplaceWithValue(node, input);
136 return Replace(input);
137 }
138 break;
139 }
140 case IrOpcode::kCheckTaggedSigned: {
141 Node* const input = node->InputAt(0);
142 if (DecideObjectIsSmi(input) == Decision::kTrue) {
143 ReplaceWithValue(node, input);
144 return Replace(input);
145 }
146 break;
147 }
113 case IrOpcode::kObjectIsSmi: { 148 case IrOpcode::kObjectIsSmi: {
114 NumberMatcher m(node->InputAt(0)); 149 Node* const input = node->InputAt(0);
115 if (m.HasValue()) return ReplaceBoolean(IsSmiDouble(m.Value())); 150 switch (DecideObjectIsSmi(input)) {
116 if (m.IsChangeBitToTagged()) return ReplaceBoolean(false); 151 case Decision::kTrue:
117 if (m.IsChangeInt31ToTaggedSigned()) return ReplaceBoolean(true); 152 return ReplaceBoolean(true);
118 if (m.IsHeapConstant()) return ReplaceBoolean(false); 153 case Decision::kFalse:
154 return ReplaceBoolean(false);
155 case Decision::kUnknown:
156 break;
157 }
119 break; 158 break;
120 } 159 }
121 case IrOpcode::kNumberCeil: 160 case IrOpcode::kNumberCeil:
122 case IrOpcode::kNumberFloor: 161 case IrOpcode::kNumberFloor:
123 case IrOpcode::kNumberRound: 162 case IrOpcode::kNumberRound:
124 case IrOpcode::kNumberTrunc: { 163 case IrOpcode::kNumberTrunc: {
125 Node* const input = NodeProperties::GetValueInput(node, 0); 164 Node* const input = NodeProperties::GetValueInput(node, 0);
126 Type* const input_type = NodeProperties::GetType(input); 165 Type* const input_type = NodeProperties::GetType(input);
127 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) { 166 if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) {
128 return Replace(input); 167 return Replace(input);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); } 239 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
201 240
202 241
203 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const { 242 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
204 return jsgraph()->machine(); 243 return jsgraph()->machine();
205 } 244 }
206 245
207 } // namespace compiler 246 } // namespace compiler
208 } // namespace internal 247 } // namespace internal
209 } // namespace v8 248 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator-reducer.h ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698