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

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

Issue 2183373002: [turbofan] Remove dead code from representation changer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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') | no next file » | 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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 CHECK(!output_type->IsInhabited()); 535 CHECK(!output_type->IsInhabited());
536 return jsgraph()->graph()->NewNode(machine()->ImpossibleToFloat64(), node); 536 return jsgraph()->graph()->NewNode(machine()->ImpossibleToFloat64(), node);
537 } else if (output_rep == MachineRepresentation::kBit) { 537 } else if (output_rep == MachineRepresentation::kBit) {
538 return node; // Sloppy comparison -> word64 538 return node; // Sloppy comparison -> word64
539 } 539 }
540 // Can't really convert Word64 to anything else. Purported to be internal. 540 // Can't really convert Word64 to anything else. Purported to be internal.
541 return TypeError(node, output_rep, output_type, 541 return TypeError(node, output_rep, output_type,
542 MachineRepresentation::kWord64); 542 MachineRepresentation::kWord64);
543 } 543 }
544 544
545 Node* RepresentationChanger::GetCheckedWord32RepresentationFor(
546 Node* node, MachineRepresentation output_rep, Type* output_type,
547 Node* use_node, Truncation truncation, TypeCheckKind check) {
548 // TODO(jarin) Eagerly fold constants (or insert hard deopt if the constant
549 // does not pass the check).
550
551 // If the input is already Signed32 in Word32 representation, we do not
552 // have to do anything. (We could fold this into the big if below, but
553 // it feels nicer to have the shortcut return first).
554 if (output_rep == MachineRepresentation::kWord32 ||
555 output_type->Is(Type::Signed32())) {
556 return node;
557 }
558
559 // Select the correct X -> Word32 operator.
560 const Operator* op = nullptr;
561 if (output_rep == MachineRepresentation::kNone) {
562 // We should only use kNone representation if the type is empty.
563 CHECK(!output_type->IsInhabited());
564 op = machine()->ImpossibleToWord32();
565 } else if (output_rep == MachineRepresentation::kWord32) {
566 if (output_type->Is(Type::Unsigned32())) {
567 op = simplified()->CheckedUint32ToInt32();
568 }
569 } else if (output_rep == MachineRepresentation::kBit) {
570 return node; // Sloppy comparison -> word32
571 } else if (output_rep == MachineRepresentation::kFloat64) {
572 if (output_type->Is(Type::Unsigned32())) {
573 op = machine()->ChangeFloat64ToUint32();
574 } else if (output_type->Is(Type::Signed32())) {
575 op = machine()->ChangeFloat64ToInt32();
576 } else if (truncation.IsUsedAsWord32()) {
577 op = machine()->TruncateFloat64ToWord32();
578 } else if (check == TypeCheckKind::kSigned32) {
579 op = simplified()->CheckedFloat64ToInt32();
580 }
581 } else if (output_rep == MachineRepresentation::kFloat32) {
582 node = InsertChangeFloat32ToFloat64(node); // float32 -> float64 -> int32
583 if (output_type->Is(Type::Unsigned32())) {
584 op = machine()->ChangeFloat64ToUint32();
585 } else if (output_type->Is(Type::Signed32())) {
586 op = machine()->ChangeFloat64ToInt32();
587 } else if (truncation.IsUsedAsWord32()) {
588 op = machine()->TruncateFloat64ToWord32();
589 } else if (check == TypeCheckKind::kSigned32) {
590 op = simplified()->CheckedFloat64ToInt32();
591 }
592 } else if (output_rep == MachineRepresentation::kTagged) {
593 if (output_type->Is(Type::TaggedSigned())) {
594 op = simplified()->ChangeTaggedSignedToInt32();
595 } else if (output_type->Is(Type::Unsigned32())) {
596 op = simplified()->ChangeTaggedToUint32();
597 } else if (output_type->Is(Type::Signed32())) {
598 op = simplified()->ChangeTaggedToInt32();
599 } else if (truncation.IsUsedAsWord32()) {
600 op = simplified()->TruncateTaggedToWord32();
601 } else if (check == TypeCheckKind::kSigned32) {
602 op = simplified()->CheckedTaggedToInt32();
603 }
604 }
605 if (op == nullptr) {
606 return TypeError(node, output_rep, output_type,
607 MachineRepresentation::kWord32);
608 }
609 if (op->ControlInputCount() > 0) {
610 // If the operator can deoptimize (which means it has control
611 // input), we need to connect it to the effect and control chains.
612 UNIMPLEMENTED();
613 }
614 return jsgraph()->graph()->NewNode(op, node);
615 }
616
617 const Operator* RepresentationChanger::Int32OperatorFor( 545 const Operator* RepresentationChanger::Int32OperatorFor(
618 IrOpcode::Value opcode) { 546 IrOpcode::Value opcode) {
619 switch (opcode) { 547 switch (opcode) {
620 case IrOpcode::kSpeculativeNumberAdd: // Fall through. 548 case IrOpcode::kSpeculativeNumberAdd: // Fall through.
621 case IrOpcode::kNumberAdd: 549 case IrOpcode::kNumberAdd:
622 return machine()->Int32Add(); 550 return machine()->Int32Add();
623 case IrOpcode::kSpeculativeNumberSubtract: // Fall through. 551 case IrOpcode::kSpeculativeNumberSubtract: // Fall through.
624 case IrOpcode::kNumberSubtract: 552 case IrOpcode::kNumberSubtract:
625 return machine()->Int32Sub(); 553 return machine()->Int32Sub();
626 case IrOpcode::kSpeculativeNumberMultiply: 554 case IrOpcode::kSpeculativeNumberMultiply:
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 } 776 }
849 777
850 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 778 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
851 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 779 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
852 node); 780 node);
853 } 781 }
854 782
855 } // namespace compiler 783 } // namespace compiler
856 } // namespace internal 784 } // namespace internal
857 } // namespace v8 785 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/representation-change.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698