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

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

Issue 1909343002: [turbofan] Move more type checks to the representation selector. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 if (IsWord(output_rep)) { 315 if (IsWord(output_rep)) {
316 if (output_type->Is(Type::Signed32())) { 316 if (output_type->Is(Type::Signed32())) {
317 op = machine()->ChangeInt32ToFloat64(); 317 op = machine()->ChangeInt32ToFloat64();
318 } else if (output_type->Is(Type::Unsigned32()) || 318 } else if (output_type->Is(Type::Unsigned32()) ||
319 truncation.TruncatesToWord32()) { 319 truncation.TruncatesToWord32()) {
320 // Either the output is uint32 or the uses only care about the 320 // Either the output is uint32 or the uses only care about the
321 // low 32 bits (so we can pick uint32 safely). 321 // low 32 bits (so we can pick uint32 safely).
322 op = machine()->ChangeUint32ToFloat64(); 322 op = machine()->ChangeUint32ToFloat64();
323 } 323 }
324 } else if (output_rep == MachineRepresentation::kTagged) { 324 } else if (output_rep == MachineRepresentation::kTagged) {
325 if (output_type->Is(Type::NumberOrUndefined())) { 325 if (output_type->Is(Type::Undefined())) {
326 return jsgraph()->Float64Constant(
327 std::numeric_limits<double>::quiet_NaN());
Jarin 2016/04/22 10:35:30 Nice! Thanks.
328 } else if (output_type->Is(Type::TaggedSigned())) {
329 node = InsertChangeTaggedSignedToInt32(node);
330 op = machine()->ChangeInt32ToFloat64();
331 } else if (output_type->Is(Type::NumberOrUndefined())) {
326 op = simplified()->ChangeTaggedToFloat64(); 332 op = simplified()->ChangeTaggedToFloat64();
327 } 333 }
328 } else if (output_rep == MachineRepresentation::kFloat32) { 334 } else if (output_rep == MachineRepresentation::kFloat32) {
329 op = machine()->ChangeFloat32ToFloat64(); 335 op = machine()->ChangeFloat32ToFloat64();
330 } 336 }
331 if (op == nullptr) { 337 if (op == nullptr) {
332 return TypeError(node, output_rep, output_type, 338 return TypeError(node, output_rep, output_type,
333 MachineRepresentation::kFloat64); 339 MachineRepresentation::kFloat64);
334 } 340 }
335 return jsgraph()->graph()->NewNode(op, node); 341 return jsgraph()->graph()->NewNode(op, node);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } else if (output_rep == MachineRepresentation::kFloat32) { 376 } else if (output_rep == MachineRepresentation::kFloat32) {
371 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32 377 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32
372 if (output_type->Is(Type::Unsigned32())) { 378 if (output_type->Is(Type::Unsigned32())) {
373 op = machine()->ChangeFloat64ToUint32(); 379 op = machine()->ChangeFloat64ToUint32();
374 } else if (output_type->Is(Type::Signed32())) { 380 } else if (output_type->Is(Type::Signed32())) {
375 op = machine()->ChangeFloat64ToInt32(); 381 op = machine()->ChangeFloat64ToInt32();
376 } else if (truncation.TruncatesToWord32()) { 382 } else if (truncation.TruncatesToWord32()) {
377 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); 383 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
378 } 384 }
379 } else if (output_rep == MachineRepresentation::kTagged) { 385 } else if (output_rep == MachineRepresentation::kTagged) {
380 if (output_type->Is(Type::Unsigned32())) { 386 if (output_type->Is(Type::TaggedSigned())) {
387 op = simplified()->ChangeTaggedSignedToInt32();
388 } else if (output_type->Is(Type::Unsigned32())) {
381 op = simplified()->ChangeTaggedToUint32(); 389 op = simplified()->ChangeTaggedToUint32();
382 } else if (output_type->Is(Type::Signed32())) { 390 } else if (output_type->Is(Type::Signed32())) {
383 op = simplified()->ChangeTaggedToInt32(); 391 op = simplified()->ChangeTaggedToInt32();
384 } else if (truncation.TruncatesToWord32()) { 392 } else if (truncation.TruncatesToWord32()) {
385 node = InsertChangeTaggedToFloat64(node); 393 node = InsertChangeTaggedToFloat64(node);
386 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript); 394 op = machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript);
387 } 395 }
388 } 396 }
389 if (op == nullptr) { 397 if (op == nullptr) {
390 return TypeError(node, output_rep, output_type, 398 return TypeError(node, output_rep, output_type,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 554 }
547 555
548 Node* RepresentationChanger::InsertChangeFloat64ToUint32(Node* node) { 556 Node* RepresentationChanger::InsertChangeFloat64ToUint32(Node* node) {
549 return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToUint32(), node); 557 return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToUint32(), node);
550 } 558 }
551 559
552 Node* RepresentationChanger::InsertChangeFloat64ToInt32(Node* node) { 560 Node* RepresentationChanger::InsertChangeFloat64ToInt32(Node* node) {
553 return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToInt32(), node); 561 return jsgraph()->graph()->NewNode(machine()->ChangeFloat64ToInt32(), node);
554 } 562 }
555 563
564 Node* RepresentationChanger::InsertChangeTaggedSignedToInt32(Node* node) {
565 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedSignedToInt32(),
566 node);
567 }
568
556 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 569 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
557 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 570 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
558 node); 571 node);
559 } 572 }
560 573
561 } // namespace compiler 574 } // namespace compiler
562 } // namespace internal 575 } // namespace internal
563 } // namespace v8 576 } // 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