OLD | NEW |
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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 node->ReplaceInput(1, jsgraph()->ZeroConstant()); | 637 node->ReplaceInput(1, jsgraph()->ZeroConstant()); |
638 NodeProperties::ChangeOp(node, simplified()->NumberEqual()); | 638 NodeProperties::ChangeOp(node, simplified()->NumberEqual()); |
639 return Changed(node); | 639 return Changed(node); |
640 } else if (input_type->Is(Type::String())) { | 640 } else if (input_type->Is(Type::String())) { |
641 // JSUnaryNot(x:string) => NumberEqual(x.length,#0) | 641 // JSUnaryNot(x:string) => NumberEqual(x.length,#0) |
642 FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone()); | 642 FieldAccess const access = AccessBuilder::ForStringLength(graph()->zone()); |
643 // It is safe for the load to be effect-free (i.e. not linked into effect | 643 // It is safe for the load to be effect-free (i.e. not linked into effect |
644 // chain) because we assume String::length to be immutable. | 644 // chain) because we assume String::length to be immutable. |
645 Node* length = graph()->NewNode(simplified()->LoadField(access), input, | 645 Node* length = graph()->NewNode(simplified()->LoadField(access), input, |
646 graph()->start(), graph()->start()); | 646 graph()->start(), graph()->start()); |
| 647 ReplaceWithValue(node, node, length); |
647 node->ReplaceInput(0, length); | 648 node->ReplaceInput(0, length); |
648 node->ReplaceInput(1, jsgraph()->ZeroConstant()); | 649 node->ReplaceInput(1, jsgraph()->ZeroConstant()); |
649 NodeProperties::ChangeOp(node, simplified()->NumberEqual()); | 650 NodeProperties::ChangeOp(node, simplified()->NumberEqual()); |
650 ReplaceWithValue(node, node, length); | |
651 return Changed(node); | 651 return Changed(node); |
652 } | 652 } |
653 return NoChange(); | 653 return NoChange(); |
654 } | 654 } |
655 | 655 |
656 | 656 |
657 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { | 657 Reduction JSTypedLowering::ReduceJSToBoolean(Node* node) { |
658 Node* const input = node->InputAt(0); | 658 Node* const input = node->InputAt(0); |
659 Type* const input_type = NodeProperties::GetType(input); | 659 Type* const input_type = NodeProperties::GetType(input); |
660 if (input_type->Is(Type::Boolean())) { | 660 if (input_type->Is(Type::Boolean())) { |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 // For integer-typed arrays, convert to the integer type. | 898 // For integer-typed arrays, convert to the integer type. |
899 if (TypeOf(access.machine_type()) == kTypeInt32 && | 899 if (TypeOf(access.machine_type()) == kTypeInt32 && |
900 !value_type->Is(Type::Signed32())) { | 900 !value_type->Is(Type::Signed32())) { |
901 value = graph()->NewNode(simplified()->NumberToInt32(), value); | 901 value = graph()->NewNode(simplified()->NumberToInt32(), value); |
902 } else if (TypeOf(access.machine_type()) == kTypeUint32 && | 902 } else if (TypeOf(access.machine_type()) == kTypeUint32 && |
903 !value_type->Is(Type::Unsigned32())) { | 903 !value_type->Is(Type::Unsigned32())) { |
904 value = graph()->NewNode(simplified()->NumberToUint32(), value); | 904 value = graph()->NewNode(simplified()->NumberToUint32(), value); |
905 } | 905 } |
906 // Check if we can avoid the bounds check. | 906 // Check if we can avoid the bounds check. |
907 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { | 907 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { |
| 908 RelaxControls(node); |
908 node->ReplaceInput(0, buffer); | 909 node->ReplaceInput(0, buffer); |
909 DCHECK_EQ(key, node->InputAt(1)); | 910 DCHECK_EQ(key, node->InputAt(1)); |
910 node->ReplaceInput(2, value); | 911 node->ReplaceInput(2, value); |
911 node->ReplaceInput(3, effect); | 912 node->ReplaceInput(3, effect); |
912 node->ReplaceInput(4, control); | 913 node->ReplaceInput(4, control); |
913 node->TrimInputCount(5); | 914 node->TrimInputCount(5); |
914 NodeProperties::ChangeOp( | 915 NodeProperties::ChangeOp( |
915 node, | 916 node, |
916 simplified()->StoreElement( | 917 simplified()->StoreElement( |
917 AccessBuilder::ForTypedArrayElement(array->type(), true))); | 918 AccessBuilder::ForTypedArrayElement(array->type(), true))); |
918 RelaxControls(node); | |
919 return Changed(node); | 919 return Changed(node); |
920 } | 920 } |
921 // Compute byte offset. | 921 // Compute byte offset. |
922 Node* offset = Word32Shl(key, static_cast<int>(k)); | 922 Node* offset = Word32Shl(key, static_cast<int>(k)); |
923 // Turn into a StoreBuffer operation. | 923 // Turn into a StoreBuffer operation. |
| 924 RelaxControls(node); |
924 node->ReplaceInput(0, buffer); | 925 node->ReplaceInput(0, buffer); |
925 node->ReplaceInput(1, offset); | 926 node->ReplaceInput(1, offset); |
926 node->ReplaceInput(2, length); | 927 node->ReplaceInput(2, length); |
927 node->ReplaceInput(3, value); | 928 node->ReplaceInput(3, value); |
928 node->ReplaceInput(4, effect); | 929 node->ReplaceInput(4, effect); |
929 node->ReplaceInput(5, control); | 930 node->ReplaceInput(5, control); |
930 node->TrimInputCount(6); | 931 node->TrimInputCount(6); |
931 NodeProperties::ChangeOp(node, simplified()->StoreBuffer(access)); | 932 NodeProperties::ChangeOp(node, simplified()->StoreBuffer(access)); |
932 RelaxControls(node); | |
933 return Changed(node); | 933 return Changed(node); |
934 } | 934 } |
935 } | 935 } |
936 } | 936 } |
937 return NoChange(); | 937 return NoChange(); |
938 } | 938 } |
939 | 939 |
940 | 940 |
941 Reduction JSTypedLowering::ReduceJSLoadContext(Node* node) { | 941 Reduction JSTypedLowering::ReduceJSLoadContext(Node* node) { |
942 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); | 942 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1746 } | 1746 } |
1747 | 1747 |
1748 | 1748 |
1749 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1749 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1750 return jsgraph()->machine(); | 1750 return jsgraph()->machine(); |
1751 } | 1751 } |
1752 | 1752 |
1753 } // namespace compiler | 1753 } // namespace compiler |
1754 } // namespace internal | 1754 } // namespace internal |
1755 } // namespace v8 | 1755 } // namespace v8 |
OLD | NEW |