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

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

Issue 2170433002: Revert of [turbofan] Introduce TruncateTaggedToBit operator for ToBoolean truncation. (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/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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 return jsgraph()->graph()->NewNode(op, node); 475 return jsgraph()->graph()->NewNode(op, node);
476 } 476 }
477 477
478 478
479 Node* RepresentationChanger::GetBitRepresentationFor( 479 Node* RepresentationChanger::GetBitRepresentationFor(
480 Node* node, MachineRepresentation output_rep, Type* output_type) { 480 Node* node, MachineRepresentation output_rep, Type* output_type) {
481 // Eagerly fold representation changes for constants. 481 // Eagerly fold representation changes for constants.
482 switch (node->opcode()) { 482 switch (node->opcode()) {
483 case IrOpcode::kHeapConstant: { 483 case IrOpcode::kHeapConstant: {
484 Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node); 484 Handle<HeapObject> value = OpParameter<Handle<HeapObject>>(node);
485 return jsgraph()->Int32Constant(value->BooleanValue() ? 1 : 0); 485 DCHECK(value.is_identical_to(factory()->true_value()) ||
486 value.is_identical_to(factory()->false_value()));
487 return jsgraph()->Int32Constant(
488 value.is_identical_to(factory()->true_value()) ? 1 : 0);
486 } 489 }
487 default: 490 default:
488 break; 491 break;
489 } 492 }
490 // Select the correct X -> Bit operator. 493 // Select the correct X -> Bit operator.
491 const Operator* op; 494 const Operator* op;
492 if (IsWord(output_rep)) { 495 if (output_rep == MachineRepresentation::kTagged) {
493 return jsgraph()->graph()->NewNode(machine()->Word32Equal(), node, 496 op = simplified()->ChangeTaggedToBit();
494 jsgraph()->Int32Constant(0));
495 } else if (output_rep == MachineRepresentation::kFloat32) {
496 node = jsgraph()->graph()->NewNode(machine()->Float32Abs(), node);
497 return jsgraph()->graph()->NewNode(machine()->Float32LessThan(),
498 jsgraph()->Float32Constant(0.0), node);
499 } else if (output_rep == MachineRepresentation::kFloat64) {
500 node = jsgraph()->graph()->NewNode(machine()->Float64Abs(), node);
501 return jsgraph()->graph()->NewNode(machine()->Float64LessThan(),
502 jsgraph()->Float64Constant(0.0), node);
503 } else if (output_rep == MachineRepresentation::kTagged) {
504 if (output_type->Is(Type::Boolean())) {
505 op = simplified()->ChangeTaggedToBit();
506 } else {
507 op = simplified()->TruncateTaggedToBit();
508 }
509 } else { 497 } else {
510 return TypeError(node, output_rep, output_type, 498 return TypeError(node, output_rep, output_type,
511 MachineRepresentation::kBit); 499 MachineRepresentation::kBit);
512 } 500 }
513 return jsgraph()->graph()->NewNode(op, node); 501 return jsgraph()->graph()->NewNode(op, node);
514 } 502 }
515 503
516 Node* RepresentationChanger::GetWord64RepresentationFor( 504 Node* RepresentationChanger::GetWord64RepresentationFor(
517 Node* node, MachineRepresentation output_rep, Type* output_type) { 505 Node* node, MachineRepresentation output_rep, Type* output_type) {
518 if (output_rep == MachineRepresentation::kBit) { 506 if (output_rep == MachineRepresentation::kBit) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 } 809 }
822 810
823 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) { 811 Node* RepresentationChanger::InsertChangeTaggedToFloat64(Node* node) {
824 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(), 812 return jsgraph()->graph()->NewNode(simplified()->ChangeTaggedToFloat64(),
825 node); 813 node);
826 } 814 }
827 815
828 } // namespace compiler 816 } // namespace compiler
829 } // namespace internal 817 } // namespace internal
830 } // namespace v8 818 } // 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