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/js-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 case Runtime::kInlineToNumber: | 69 case Runtime::kInlineToNumber: |
70 return ReduceToNumber(node); | 70 return ReduceToNumber(node); |
71 case Runtime::kInlineToObject: | 71 case Runtime::kInlineToObject: |
72 return ReduceToObject(node); | 72 return ReduceToObject(node); |
73 case Runtime::kInlineToString: | 73 case Runtime::kInlineToString: |
74 return ReduceToString(node); | 74 return ReduceToString(node); |
75 case Runtime::kInlineCall: | 75 case Runtime::kInlineCall: |
76 return ReduceCall(node); | 76 return ReduceCall(node); |
77 case Runtime::kInlineGetSuperConstructor: | 77 case Runtime::kInlineGetSuperConstructor: |
78 return ReduceGetSuperConstructor(node); | 78 return ReduceGetSuperConstructor(node); |
| 79 case Runtime::kInlineArrayBufferViewGetByteLength: |
| 80 return ReduceArrayBufferViewField( |
| 81 node, AccessBuilder::ForJSArrayBufferViewByteLength()); |
| 82 case Runtime::kInlineArrayBufferViewGetByteOffset: |
| 83 return ReduceArrayBufferViewField( |
| 84 node, AccessBuilder::ForJSArrayBufferViewByteOffset()); |
79 case Runtime::kInlineMaxSmi: | 85 case Runtime::kInlineMaxSmi: |
80 return ReduceMaxSmi(node); | 86 return ReduceMaxSmi(node); |
| 87 case Runtime::kInlineTypedArrayGetLength: |
| 88 return ReduceArrayBufferViewField(node, |
| 89 AccessBuilder::ForJSTypedArrayLength()); |
81 case Runtime::kInlineTypedArrayMaxSizeInHeap: | 90 case Runtime::kInlineTypedArrayMaxSizeInHeap: |
82 return ReduceTypedArrayMaxSizeInHeap(node); | 91 return ReduceTypedArrayMaxSizeInHeap(node); |
83 case Runtime::kInlineJSCollectionGetTable: | 92 case Runtime::kInlineJSCollectionGetTable: |
84 return ReduceJSCollectionGetTable(node); | 93 return ReduceJSCollectionGetTable(node); |
85 case Runtime::kInlineStringGetRawHashField: | 94 case Runtime::kInlineStringGetRawHashField: |
86 return ReduceStringGetRawHashField(node); | 95 return ReduceStringGetRawHashField(node); |
87 case Runtime::kInlineTheHole: | 96 case Runtime::kInlineTheHole: |
88 return ReduceTheHole(node); | 97 return ReduceTheHole(node); |
89 case Runtime::kInlineClassOf: | 98 case Runtime::kInlineClassOf: |
90 return ReduceClassOf(node); | 99 return ReduceClassOf(node); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 Node* active_function = NodeProperties::GetValueInput(node, 0); | 323 Node* active_function = NodeProperties::GetValueInput(node, 0); |
315 Node* effect = NodeProperties::GetEffectInput(node); | 324 Node* effect = NodeProperties::GetEffectInput(node); |
316 Node* control = NodeProperties::GetControlInput(node); | 325 Node* control = NodeProperties::GetControlInput(node); |
317 Node* active_function_map = effect = | 326 Node* active_function_map = effect = |
318 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), | 327 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()), |
319 active_function, effect, control); | 328 active_function, effect, control); |
320 return Change(node, simplified()->LoadField(AccessBuilder::ForMapPrototype()), | 329 return Change(node, simplified()->LoadField(AccessBuilder::ForMapPrototype()), |
321 active_function_map, effect, control); | 330 active_function_map, effect, control); |
322 } | 331 } |
323 | 332 |
| 333 Reduction JSIntrinsicLowering::ReduceArrayBufferViewField( |
| 334 Node* node, FieldAccess const& access) { |
| 335 Node* receiver = NodeProperties::GetValueInput(node, 0); |
| 336 Node* effect = NodeProperties::GetEffectInput(node); |
| 337 Node* control = NodeProperties::GetControlInput(node); |
| 338 |
| 339 // Load the {receiver}s field. |
| 340 Node* value = effect = graph()->NewNode(simplified()->LoadField(access), |
| 341 receiver, effect, control); |
| 342 |
| 343 // Check if the {receiver}s buffer was neutered. |
| 344 Node* receiver_buffer = effect = graph()->NewNode( |
| 345 simplified()->LoadField(AccessBuilder::ForJSArrayBufferViewBuffer()), |
| 346 receiver, effect, control); |
| 347 Node* check = effect = graph()->NewNode( |
| 348 simplified()->ArrayBufferWasNeutered(), receiver_buffer, effect, control); |
| 349 |
| 350 // Default to zero if the {receiver}s buffer was neutered. |
| 351 value = graph()->NewNode( |
| 352 common()->Select(MachineRepresentation::kTagged, BranchHint::kFalse), |
| 353 check, jsgraph()->ZeroConstant(), value); |
| 354 |
| 355 ReplaceWithValue(node, value, effect, control); |
| 356 return Replace(value); |
| 357 } |
| 358 |
324 Reduction JSIntrinsicLowering::ReduceMaxSmi(Node* node) { | 359 Reduction JSIntrinsicLowering::ReduceMaxSmi(Node* node) { |
325 Node* value = jsgraph()->Constant(Smi::kMaxValue); | 360 Node* value = jsgraph()->Constant(Smi::kMaxValue); |
326 ReplaceWithValue(node, value); | 361 ReplaceWithValue(node, value); |
327 return Replace(value); | 362 return Replace(value); |
328 } | 363 } |
329 | 364 |
330 Reduction JSIntrinsicLowering::ReduceTypedArrayMaxSizeInHeap(Node* node) { | 365 Reduction JSIntrinsicLowering::ReduceTypedArrayMaxSizeInHeap(Node* node) { |
331 Node* value = jsgraph()->Constant(FLAG_typed_array_max_size_in_heap); | 366 Node* value = jsgraph()->Constant(FLAG_typed_array_max_size_in_heap); |
332 ReplaceWithValue(node, value); | 367 ReplaceWithValue(node, value); |
333 return Replace(value); | 368 return Replace(value); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 return jsgraph_->javascript(); | 461 return jsgraph_->javascript(); |
427 } | 462 } |
428 | 463 |
429 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 464 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
430 return jsgraph()->simplified(); | 465 return jsgraph()->simplified(); |
431 } | 466 } |
432 | 467 |
433 } // namespace compiler | 468 } // namespace compiler |
434 } // namespace internal | 469 } // namespace internal |
435 } // namespace v8 | 470 } // namespace v8 |
OLD | NEW |