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

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

Issue 2312003005: [turbofan] Handle word32 truncation in word32->tagged representation change. (Closed)
Patch Set: Created 4 years, 3 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/representation-change.h ('k') | src/compiler/simplified-lowering.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/representation-change.h" 5 #include "src/compiler/representation-change.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 switch (use_info.representation()) { 143 switch (use_info.representation()) {
144 case MachineRepresentation::kTaggedSigned: 144 case MachineRepresentation::kTaggedSigned:
145 DCHECK(use_info.type_check() == TypeCheckKind::kNone); 145 DCHECK(use_info.type_check() == TypeCheckKind::kNone);
146 return GetTaggedSignedRepresentationFor(node, output_rep, output_type); 146 return GetTaggedSignedRepresentationFor(node, output_rep, output_type);
147 case MachineRepresentation::kTaggedPointer: 147 case MachineRepresentation::kTaggedPointer:
148 DCHECK(use_info.type_check() == TypeCheckKind::kNone); 148 DCHECK(use_info.type_check() == TypeCheckKind::kNone);
149 return GetTaggedPointerRepresentationFor(node, output_rep, output_type); 149 return GetTaggedPointerRepresentationFor(node, output_rep, output_type);
150 case MachineRepresentation::kTagged: 150 case MachineRepresentation::kTagged:
151 DCHECK(use_info.type_check() == TypeCheckKind::kNone); 151 DCHECK(use_info.type_check() == TypeCheckKind::kNone);
152 return GetTaggedRepresentationFor(node, output_rep, output_type); 152 return GetTaggedRepresentationFor(node, output_rep, output_type,
153 use_info.truncation());
153 case MachineRepresentation::kFloat32: 154 case MachineRepresentation::kFloat32:
154 DCHECK(use_info.type_check() == TypeCheckKind::kNone); 155 DCHECK(use_info.type_check() == TypeCheckKind::kNone);
155 return GetFloat32RepresentationFor(node, output_rep, output_type, 156 return GetFloat32RepresentationFor(node, output_rep, output_type,
156 use_info.truncation()); 157 use_info.truncation());
157 case MachineRepresentation::kFloat64: 158 case MachineRepresentation::kFloat64:
158 return GetFloat64RepresentationFor(node, output_rep, output_type, 159 return GetFloat64RepresentationFor(node, output_rep, output_type,
159 use_node, use_info); 160 use_node, use_info);
160 case MachineRepresentation::kBit: 161 case MachineRepresentation::kBit:
161 DCHECK(use_info.type_check() == TypeCheckKind::kNone); 162 DCHECK(use_info.type_check() == TypeCheckKind::kNone);
162 return GetBitRepresentationFor(node, output_rep, output_type); 163 return GetBitRepresentationFor(node, output_rep, output_type);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) { 256 if (Type::Semantic(output_type, jsgraph()->zone())->Is(Type::None())) {
256 // This is an impossible value; it should not be used at runtime. 257 // This is an impossible value; it should not be used at runtime.
257 // We just provide a dummy value here. 258 // We just provide a dummy value here.
258 return jsgraph()->TheHoleConstant(); 259 return jsgraph()->TheHoleConstant();
259 } 260 }
260 return TypeError(node, output_rep, output_type, 261 return TypeError(node, output_rep, output_type,
261 MachineRepresentation::kTaggedPointer); 262 MachineRepresentation::kTaggedPointer);
262 } 263 }
263 264
264 Node* RepresentationChanger::GetTaggedRepresentationFor( 265 Node* RepresentationChanger::GetTaggedRepresentationFor(
265 Node* node, MachineRepresentation output_rep, Type* output_type) { 266 Node* node, MachineRepresentation output_rep, Type* output_type,
267 Truncation truncation) {
266 // Eagerly fold representation changes for constants. 268 // Eagerly fold representation changes for constants.
267 switch (node->opcode()) { 269 switch (node->opcode()) {
268 case IrOpcode::kNumberConstant: 270 case IrOpcode::kNumberConstant:
269 case IrOpcode::kHeapConstant: 271 case IrOpcode::kHeapConstant:
270 return node; // No change necessary. 272 return node; // No change necessary.
271 case IrOpcode::kInt32Constant: 273 case IrOpcode::kInt32Constant:
272 if (output_type->Is(Type::Signed32())) { 274 if (output_type->Is(Type::Signed32())) {
273 int32_t value = OpParameter<int32_t>(node); 275 int32_t value = OpParameter<int32_t>(node);
274 return jsgraph()->Constant(value); 276 return jsgraph()->Constant(value);
275 } else if (output_type->Is(Type::Unsigned32())) { 277 } else if (output_type->Is(Type::Unsigned32())) {
(...skipping 29 matching lines...) Expand all
305 op = simplified()->ChangeBitToTagged(); 307 op = simplified()->ChangeBitToTagged();
306 } else { 308 } else {
307 return TypeError(node, output_rep, output_type, 309 return TypeError(node, output_rep, output_type,
308 MachineRepresentation::kTagged); 310 MachineRepresentation::kTagged);
309 } 311 }
310 } else if (IsWord(output_rep)) { 312 } else if (IsWord(output_rep)) {
311 if (output_type->Is(Type::Signed31())) { 313 if (output_type->Is(Type::Signed31())) {
312 op = simplified()->ChangeInt31ToTaggedSigned(); 314 op = simplified()->ChangeInt31ToTaggedSigned();
313 } else if (output_type->Is(Type::Signed32())) { 315 } else if (output_type->Is(Type::Signed32())) {
314 op = simplified()->ChangeInt32ToTagged(); 316 op = simplified()->ChangeInt32ToTagged();
315 } else if (output_type->Is(Type::Unsigned32())) { 317 } else if (output_type->Is(Type::Unsigned32()) ||
318 truncation.IsUsedAsWord32()) {
319 // Either the output is uint32 or the uses only care about the
320 // low 32 bits (so we can pick uint32 safely).
316 op = simplified()->ChangeUint32ToTagged(); 321 op = simplified()->ChangeUint32ToTagged();
317 } else { 322 } else {
318 return TypeError(node, output_rep, output_type, 323 return TypeError(node, output_rep, output_type,
319 MachineRepresentation::kTagged); 324 MachineRepresentation::kTagged);
320 } 325 }
321 } else if (output_rep == 326 } else if (output_rep ==
322 MachineRepresentation::kFloat32) { // float32 -> float64 -> tagged 327 MachineRepresentation::kFloat32) { // float32 -> float64 -> tagged
323 node = InsertChangeFloat32ToFloat64(node); 328 node = InsertChangeFloat32ToFloat64(node);
324 op = simplified()->ChangeFloat64ToTagged( 329 op = simplified()->ChangeFloat64ToTagged(
325 output_type->Maybe(Type::MinusZero()) 330 output_type->Maybe(Type::MinusZero())
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 } 934 }
930 935
931 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 936 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
932 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 937 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
933 node); 938 node);
934 } 939 }
935 940
936 } // namespace compiler 941 } // namespace compiler
937 } // namespace internal 942 } // namespace internal
938 } // namespace v8 943 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/representation-change.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698