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/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 | 6 |
7 #include "src/compilation-dependencies.h" | 7 #include "src/compilation-dependencies.h" |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 | 923 |
924 } // namespace | 924 } // namespace |
925 | 925 |
926 Reduction JSBuiltinReducer::ReduceArrayBufferViewAccessor( | 926 Reduction JSBuiltinReducer::ReduceArrayBufferViewAccessor( |
927 Node* node, InstanceType instance_type, FieldAccess const& access) { | 927 Node* node, InstanceType instance_type, FieldAccess const& access) { |
928 Node* receiver = NodeProperties::GetValueInput(node, 1); | 928 Node* receiver = NodeProperties::GetValueInput(node, 1); |
929 Node* effect = NodeProperties::GetEffectInput(node); | 929 Node* effect = NodeProperties::GetEffectInput(node); |
930 Node* control = NodeProperties::GetControlInput(node); | 930 Node* control = NodeProperties::GetControlInput(node); |
931 if (HasInstanceTypeWitness(receiver, effect, instance_type)) { | 931 if (HasInstanceTypeWitness(receiver, effect, instance_type)) { |
932 // Load the {receiver}s field. | 932 // Load the {receiver}s field. |
933 Node* receiver_length = effect = graph()->NewNode( | 933 Node* receiver_value = effect = graph()->NewNode( |
934 simplified()->LoadField(access), receiver, effect, control); | 934 simplified()->LoadField(access), receiver, effect, control); |
935 | 935 |
936 // Check if the {receiver}s buffer was neutered. | 936 // Check if the {receiver}s buffer was neutered. |
937 Node* receiver_buffer = effect = graph()->NewNode( | 937 Node* receiver_buffer = effect = graph()->NewNode( |
938 simplified()->LoadField(AccessBuilder::ForJSArrayBufferViewBuffer()), | 938 simplified()->LoadField(AccessBuilder::ForJSArrayBufferViewBuffer()), |
939 receiver, effect, control); | 939 receiver, effect, control); |
940 Node* receiver_buffer_bitfield = effect = graph()->NewNode( | 940 Node* check = effect = |
941 simplified()->LoadField(AccessBuilder::ForJSArrayBufferBitField()), | 941 graph()->NewNode(simplified()->ArrayBufferWasNeutered(), |
942 receiver_buffer, effect, control); | 942 receiver_buffer, effect, control); |
943 Node* check = graph()->NewNode( | |
944 simplified()->NumberEqual(), | |
945 graph()->NewNode( | |
946 simplified()->NumberBitwiseAnd(), receiver_buffer_bitfield, | |
947 jsgraph()->Constant(JSArrayBuffer::WasNeutered::kMask)), | |
948 jsgraph()->ZeroConstant()); | |
949 | 943 |
950 // Default to zero if the {receiver}s buffer was neutered. | 944 // Default to zero if the {receiver}s buffer was neutered. |
951 Node* value = graph()->NewNode( | 945 Node* value = graph()->NewNode( |
952 common()->Select(MachineRepresentation::kTagged, BranchHint::kTrue), | 946 common()->Select(MachineRepresentation::kTagged, BranchHint::kFalse), |
953 check, receiver_length, jsgraph()->ZeroConstant()); | 947 check, jsgraph()->ZeroConstant(), receiver_value); |
954 | 948 |
955 ReplaceWithValue(node, value, effect, control); | 949 ReplaceWithValue(node, value, effect, control); |
956 return Replace(value); | 950 return Replace(value); |
957 } | 951 } |
958 return NoChange(); | 952 return NoChange(); |
959 } | 953 } |
960 | 954 |
961 Reduction JSBuiltinReducer::Reduce(Node* node) { | 955 Reduction JSBuiltinReducer::Reduce(Node* node) { |
962 Reduction reduction = NoChange(); | 956 Reduction reduction = NoChange(); |
963 JSCallReduction r(node); | 957 JSCallReduction r(node); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 } | 1127 } |
1134 | 1128 |
1135 | 1129 |
1136 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { | 1130 SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const { |
1137 return jsgraph()->simplified(); | 1131 return jsgraph()->simplified(); |
1138 } | 1132 } |
1139 | 1133 |
1140 } // namespace compiler | 1134 } // namespace compiler |
1141 } // namespace internal | 1135 } // namespace internal |
1142 } // namespace v8 | 1136 } // namespace v8 |
OLD | NEW |