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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1418643002: [turbofan] Respect effect input when lowering JSToBoolean for string inputs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 5 years, 2 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 | « no previous file | test/mjsunit/mjsunit.status » ('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 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compiler/access-builder.h" 6 #include "src/compiler/access-builder.h"
7 #include "src/compiler/js-graph.h" 7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/js-typed-lowering.h" 8 #include "src/compiler/js-typed-lowering.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 NodeProperties::ChangeOp(node, simplified()->NumberEqual()); 689 NodeProperties::ChangeOp(node, simplified()->NumberEqual());
690 return Changed(node); 690 return Changed(node);
691 } 691 }
692 return NoChange(); 692 return NoChange();
693 } 693 }
694 694
695 695
696 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { 696 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) {
697 Node* const input = node->InputAt(0); 697 Node* const input = node->InputAt(0);
698 Type* const input_type = NodeProperties::GetType(input); 698 Type* const input_type = NodeProperties::GetType(input);
699 Node* const effect = NodeProperties::GetEffectInput(node);
699 if (input_type->Is(Type::Boolean())) { 700 if (input_type->Is(Type::Boolean())) {
700 // JSToBoolean(x:boolean) => x 701 // JSToBoolean(x:boolean) => x
701 ReplaceWithValue(node, input); 702 ReplaceWithValue(node, input, effect);
702 return Replace(input); 703 return Replace(input);
703 } else if (input_type->Is(Type::OrderedNumber())) { 704 } else if (input_type->Is(Type::OrderedNumber())) {
704 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0)) 705 // JSToBoolean(x:ordered-number) => BooleanNot(NumberEqual(x,#0))
705 RelaxEffectsAndControls(node); 706 RelaxEffectsAndControls(node);
706 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input, 707 node->ReplaceInput(0, graph()->NewNode(simplified()->NumberEqual(), input,
707 jsgraph()->ZeroConstant())); 708 jsgraph()->ZeroConstant()));
708 node->TrimInputCount(1); 709 node->TrimInputCount(1);
709 NodeProperties::ChangeOp(node, simplified()->BooleanNot()); 710 NodeProperties::ChangeOp(node, simplified()->BooleanNot());
710 return Changed(node); 711 return Changed(node);
711 } else if (input_type->Is(Type::String())) { 712 } else if (input_type->Is(Type::String())) {
712 // JSToBoolean(x:string) => NumberLessThan(#0,x.length) 713 // JSToBoolean(x:string) => NumberLessThan(#0,x.length)
713 FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone()); 714 FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone());
714 // It is safe for the load to be effect-free (i.e. not linked into effect
715 // chain) because we assume String::length to be immutable.
716 Node* length = graph()->NewNode(simplified()->LoadField(access), input, 715 Node* length = graph()->NewNode(simplified()->LoadField(access), input,
717 graph()->start(), graph()->start()); 716 effect, graph()->start());
718 ReplaceWithValue(node, node, length); 717 ReplaceWithValue(node, node, length);
719 node->ReplaceInput(0, jsgraph()->ZeroConstant()); 718 node->ReplaceInput(0, jsgraph()->ZeroConstant());
720 node->ReplaceInput(1, length); 719 node->ReplaceInput(1, length);
721 node->TrimInputCount(2); 720 node->TrimInputCount(2);
722 NodeProperties::ChangeOp(node, simplified()->NumberLessThan()); 721 NodeProperties::ChangeOp(node, simplified()->NumberLessThan());
723 return Changed(node); 722 return Changed(node);
724 } 723 }
725 return NoChange(); 724 return NoChange();
726 } 725 }
727 726
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 } 1840 }
1842 1841
1843 1842
1844 MachineOperatorBuilder* JSTypedLowering::machine() const { 1843 MachineOperatorBuilder* JSTypedLowering::machine() const {
1845 return jsgraph()->machine(); 1844 return jsgraph()->machine();
1846 } 1845 }
1847 1846
1848 } // namespace compiler 1847 } // namespace compiler
1849 } // namespace internal 1848 } // namespace internal
1850 } // namespace v8 1849 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698