OLD | NEW |
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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.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/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 3195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3206 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); | 3206 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); |
3207 Node* buffer = node->InputAt(0); | 3207 Node* buffer = node->InputAt(0); |
3208 Node* base = node->InputAt(1); | 3208 Node* base = node->InputAt(1); |
3209 Node* external = node->InputAt(2); | 3209 Node* external = node->InputAt(2); |
3210 Node* index = node->InputAt(3); | 3210 Node* index = node->InputAt(3); |
3211 | 3211 |
3212 // We need to keep the {buffer} alive so that the GC will not release the | 3212 // We need to keep the {buffer} alive so that the GC will not release the |
3213 // ArrayBuffer (if there's any) as long as we are still operating on it. | 3213 // ArrayBuffer (if there's any) as long as we are still operating on it. |
3214 effect = graph()->NewNode(common()->Retain(), buffer, effect); | 3214 effect = graph()->NewNode(common()->Retain(), buffer, effect); |
3215 | 3215 |
3216 // Compute the effective storage pointer. | 3216 // Compute the effective storage pointer, handling the case where the |
3217 Node* storage = effect = graph()->NewNode(machine()->UnsafePointerAdd(), base, | 3217 // {external} pointer is the effective storage pointer (i.e. the {base} |
3218 external, effect, control); | 3218 // is Smi zero). |
| 3219 Node* storage = |
| 3220 NumberMatcher(base).Is(0) |
| 3221 ? external |
| 3222 : effect = graph()->NewNode(machine()->UnsafePointerAdd(), base, |
| 3223 external, effect, control); |
3219 | 3224 |
3220 // Perform the actual typed element access. | 3225 // Perform the actual typed element access. |
3221 Node* value = effect = graph()->NewNode( | 3226 Node* value = effect = graph()->NewNode( |
3222 simplified()->LoadElement( | 3227 simplified()->LoadElement( |
3223 AccessBuilder::ForTypedArrayElement(array_type, true)), | 3228 AccessBuilder::ForTypedArrayElement(array_type, true)), |
3224 storage, index, effect, control); | 3229 storage, index, effect, control); |
3225 | 3230 |
3226 return ValueEffectControl(value, effect, control); | 3231 return ValueEffectControl(value, effect, control); |
3227 } | 3232 } |
3228 | 3233 |
3229 EffectControlLinearizer::ValueEffectControl | 3234 EffectControlLinearizer::ValueEffectControl |
3230 EffectControlLinearizer::LowerStoreTypedElement(Node* node, Node* effect, | 3235 EffectControlLinearizer::LowerStoreTypedElement(Node* node, Node* effect, |
3231 Node* control) { | 3236 Node* control) { |
3232 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); | 3237 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); |
3233 Node* buffer = node->InputAt(0); | 3238 Node* buffer = node->InputAt(0); |
3234 Node* base = node->InputAt(1); | 3239 Node* base = node->InputAt(1); |
3235 Node* external = node->InputAt(2); | 3240 Node* external = node->InputAt(2); |
3236 Node* index = node->InputAt(3); | 3241 Node* index = node->InputAt(3); |
3237 Node* value = node->InputAt(4); | 3242 Node* value = node->InputAt(4); |
3238 | 3243 |
3239 // We need to keep the {buffer} alive so that the GC will not release the | 3244 // We need to keep the {buffer} alive so that the GC will not release the |
3240 // ArrayBuffer (if there's any) as long as we are still operating on it. | 3245 // ArrayBuffer (if there's any) as long as we are still operating on it. |
3241 effect = graph()->NewNode(common()->Retain(), buffer, effect); | 3246 effect = graph()->NewNode(common()->Retain(), buffer, effect); |
3242 | 3247 |
3243 // Compute the effective storage pointer. | 3248 // Compute the effective storage pointer, handling the case where the |
3244 Node* storage = effect = graph()->NewNode(machine()->UnsafePointerAdd(), base, | 3249 // {external} pointer is the effective storage pointer (i.e. the {base} |
3245 external, effect, control); | 3250 // is Smi zero). |
| 3251 Node* storage = |
| 3252 NumberMatcher(base).Is(0) |
| 3253 ? external |
| 3254 : effect = graph()->NewNode(machine()->UnsafePointerAdd(), base, |
| 3255 external, effect, control); |
3246 | 3256 |
3247 // Perform the actual typed element access. | 3257 // Perform the actual typed element access. |
3248 effect = graph()->NewNode( | 3258 effect = graph()->NewNode( |
3249 simplified()->StoreElement( | 3259 simplified()->StoreElement( |
3250 AccessBuilder::ForTypedArrayElement(array_type, true)), | 3260 AccessBuilder::ForTypedArrayElement(array_type, true)), |
3251 storage, index, value, effect, control); | 3261 storage, index, value, effect, control); |
3252 | 3262 |
3253 return ValueEffectControl(nullptr, effect, control); | 3263 return ValueEffectControl(nullptr, effect, control); |
3254 } | 3264 } |
3255 | 3265 |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3754 isolate(), graph()->zone(), callable.descriptor(), 0, flags, | 3764 isolate(), graph()->zone(), callable.descriptor(), 0, flags, |
3755 Operator::kEliminatable); | 3765 Operator::kEliminatable); |
3756 to_number_operator_.set(common()->Call(desc)); | 3766 to_number_operator_.set(common()->Call(desc)); |
3757 } | 3767 } |
3758 return to_number_operator_.get(); | 3768 return to_number_operator_.get(); |
3759 } | 3769 } |
3760 | 3770 |
3761 } // namespace compiler | 3771 } // namespace compiler |
3762 } // namespace internal | 3772 } // namespace internal |
3763 } // namespace v8 | 3773 } // namespace v8 |
OLD | NEW |