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

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

Issue 1455103002: [turbofan] Only infer signedness for Float64->Word32 representation change from the input type. (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 unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/compiler/test-representation-change.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 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_ 5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_
6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_
7 7
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 if (use_type & kRepTagged) { 52 if (use_type & kRepTagged) {
53 return GetTaggedRepresentationFor(node, output_type); 53 return GetTaggedRepresentationFor(node, output_type);
54 } else if (use_type & kRepFloat32) { 54 } else if (use_type & kRepFloat32) {
55 return GetFloat32RepresentationFor(node, output_type); 55 return GetFloat32RepresentationFor(node, output_type);
56 } else if (use_type & kRepFloat64) { 56 } else if (use_type & kRepFloat64) {
57 return GetFloat64RepresentationFor(node, output_type); 57 return GetFloat64RepresentationFor(node, output_type);
58 } else if (use_type & kRepBit) { 58 } else if (use_type & kRepBit) {
59 return GetBitRepresentationFor(node, output_type); 59 return GetBitRepresentationFor(node, output_type);
60 } else if (IsWord(use_type)) { 60 } else if (IsWord(use_type)) {
61 return GetWord32RepresentationFor(node, output_type, 61 return GetWord32RepresentationFor(node, output_type);
62 use_type & kTypeUint32);
63 } else if (use_type & kRepWord64) { 62 } else if (use_type & kRepWord64) {
64 return GetWord64RepresentationFor(node, output_type); 63 return GetWord64RepresentationFor(node, output_type);
65 } else { 64 } else {
66 return node; 65 return node;
67 } 66 }
68 } 67 }
69 68
70 Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type) { 69 Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type) {
71 // Eagerly fold representation changes for constants. 70 // Eagerly fold representation changes for constants.
72 switch (node->opcode()) { 71 switch (node->opcode()) {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); 237 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
239 } else if (output_type & kRepTagged) { 238 } else if (output_type & kRepTagged) {
240 node = InsertChangeTaggedToFloat64(node); 239 node = InsertChangeTaggedToFloat64(node);
241 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); 240 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
242 } else { 241 } else {
243 return TypeError(node, output_type, kRepWord32); 242 return TypeError(node, output_type, kRepWord32);
244 } 243 }
245 return jsgraph()->graph()->NewNode(op, node); 244 return jsgraph()->graph()->NewNode(op, node);
246 } 245 }
247 246
248 Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type, 247 Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type) {
249 bool use_unsigned) {
250 // Eagerly fold representation changes for constants. 248 // Eagerly fold representation changes for constants.
251 switch (node->opcode()) { 249 switch (node->opcode()) {
252 case IrOpcode::kInt32Constant: 250 case IrOpcode::kInt32Constant:
253 return node; // No change necessary. 251 return node; // No change necessary.
254 case IrOpcode::kFloat32Constant: 252 case IrOpcode::kFloat32Constant:
255 return MakeInt32Constant(OpParameter<float>(node)); 253 return MakeInt32Constant(OpParameter<float>(node));
256 case IrOpcode::kNumberConstant: 254 case IrOpcode::kNumberConstant:
257 case IrOpcode::kFloat64Constant: 255 case IrOpcode::kFloat64Constant:
258 return MakeInt32Constant(OpParameter<double>(node)); 256 return MakeInt32Constant(OpParameter<double>(node));
259 default: 257 default:
260 break; 258 break;
261 } 259 }
262 // Select the correct X -> Word32 operator. 260 // Select the correct X -> Word32 operator.
263 const Operator* op; 261 const Operator* op;
262 Type* type = NodeProperties::GetType(node);
264 if (output_type & kRepBit) { 263 if (output_type & kRepBit) {
265 return node; // Sloppy comparison -> word32 264 return node; // Sloppy comparison -> word32
266 } else if (output_type & kRepFloat64) { 265 } else if (output_type & kRepFloat64) {
267 if (output_type & kTypeUint32 || use_unsigned) { 266 if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) {
268 op = machine()->ChangeFloat64ToUint32(); 267 op = machine()->ChangeFloat64ToUint32();
268 } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) {
269 op = machine()->ChangeFloat64ToInt32();
269 } else { 270 } else {
270 op = machine()->ChangeFloat64ToInt32(); 271 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
271 } 272 }
272 } else if (output_type & kRepFloat32) { 273 } else if (output_type & kRepFloat32) {
273 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32 274 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32
274 if (output_type & kTypeUint32 || use_unsigned) { 275 if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) {
275 op = machine()->ChangeFloat64ToUint32(); 276 op = machine()->ChangeFloat64ToUint32();
277 } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) {
278 op = machine()->ChangeFloat64ToInt32();
276 } else { 279 } else {
277 op = machine()->ChangeFloat64ToInt32(); 280 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
278 } 281 }
279 } else if (output_type & kRepTagged) { 282 } else if (output_type & kRepTagged) {
280 if (output_type & kTypeUint32 || use_unsigned) { 283 if (output_type & kTypeUint32 || type->Is(Type::Unsigned32())) {
281 op = simplified()->ChangeTaggedToUint32(); 284 op = simplified()->ChangeTaggedToUint32();
285 } else if (output_type & kTypeInt32 || type->Is(Type::Signed32())) {
286 op = simplified()->ChangeTaggedToInt32();
282 } else { 287 } else {
283 op = simplified()->ChangeTaggedToInt32(); 288 node = InsertChangeTaggedToFloat64(node);
289 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
284 } 290 }
285 } else { 291 } else {
286 return TypeError(node, output_type, kRepWord32); 292 return TypeError(node, output_type, kRepWord32);
287 } 293 }
288 return jsgraph()->graph()->NewNode(op, node); 294 return jsgraph()->graph()->NewNode(op, node);
289 } 295 }
290 296
291 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) { 297 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) {
292 // Eagerly fold representation changes for constants. 298 // Eagerly fold representation changes for constants.
293 switch (node->opcode()) { 299 switch (node->opcode()) {
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 Factory* factory() const { return isolate()->factory(); } 464 Factory* factory() const { return isolate()->factory(); }
459 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); } 465 SimplifiedOperatorBuilder* simplified() { return jsgraph()->simplified(); }
460 MachineOperatorBuilder* machine() { return jsgraph()->machine(); } 466 MachineOperatorBuilder* machine() { return jsgraph()->machine(); }
461 }; 467 };
462 468
463 } // namespace compiler 469 } // namespace compiler
464 } // namespace internal 470 } // namespace internal
465 } // namespace v8 471 } // namespace v8
466 472
467 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ 473 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_
OLDNEW
« no previous file with comments | « no previous file | test/cctest/compiler/test-representation-change.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698