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/compiler-source-position-table.h" | 9 #include "src/compiler/compiler-source-position-table.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 break; | 784 break; |
785 case IrOpcode::kEnsureWritableFastElements: | 785 case IrOpcode::kEnsureWritableFastElements: |
786 result = LowerEnsureWritableFastElements(node); | 786 result = LowerEnsureWritableFastElements(node); |
787 break; | 787 break; |
788 case IrOpcode::kMaybeGrowFastElements: | 788 case IrOpcode::kMaybeGrowFastElements: |
789 result = LowerMaybeGrowFastElements(node, frame_state); | 789 result = LowerMaybeGrowFastElements(node, frame_state); |
790 break; | 790 break; |
791 case IrOpcode::kTransitionElementsKind: | 791 case IrOpcode::kTransitionElementsKind: |
792 LowerTransitionElementsKind(node); | 792 LowerTransitionElementsKind(node); |
793 break; | 793 break; |
| 794 case IrOpcode::kLoadFieldByIndex: |
| 795 result = LowerLoadFieldByIndex(node); |
| 796 break; |
794 case IrOpcode::kLoadTypedElement: | 797 case IrOpcode::kLoadTypedElement: |
795 result = LowerLoadTypedElement(node); | 798 result = LowerLoadTypedElement(node); |
796 break; | 799 break; |
797 case IrOpcode::kStoreTypedElement: | 800 case IrOpcode::kStoreTypedElement: |
798 LowerStoreTypedElement(node); | 801 LowerStoreTypedElement(node); |
799 break; | 802 break; |
800 case IrOpcode::kFloat64RoundUp: | 803 case IrOpcode::kFloat64RoundUp: |
801 if (!LowerFloat64RoundUp(node).To(&result)) { | 804 if (!LowerFloat64RoundUp(node).To(&result)) { |
802 return false; | 805 return false; |
803 } | 806 } |
(...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2547 __ ExternalConstant(ExternalReference(id, isolate())), | 2550 __ ExternalConstant(ExternalReference(id, isolate())), |
2548 __ Int32Constant(2), __ NoContextConstant()); | 2551 __ Int32Constant(2), __ NoContextConstant()); |
2549 break; | 2552 break; |
2550 } | 2553 } |
2551 } | 2554 } |
2552 __ Goto(&done); | 2555 __ Goto(&done); |
2553 | 2556 |
2554 __ Bind(&done); | 2557 __ Bind(&done); |
2555 } | 2558 } |
2556 | 2559 |
| 2560 Node* EffectControlLinearizer::LowerLoadFieldByIndex(Node* node) { |
| 2561 Node* object = node->InputAt(0); |
| 2562 Node* index = node->InputAt(1); |
| 2563 Node* zero = __ IntPtrConstant(0); |
| 2564 Node* one = __ IntPtrConstant(1); |
| 2565 |
| 2566 // Sign-extend the {index} on 64-bit architectures. |
| 2567 if (machine()->Is64()) { |
| 2568 index = __ ChangeInt32ToInt64(index); |
| 2569 } |
| 2570 |
| 2571 auto if_double = __ MakeDeferredLabel<1>(); |
| 2572 auto done = __ MakeLabel<3>(MachineRepresentation::kTagged); |
| 2573 |
| 2574 // Check if field is a mutable double field. |
| 2575 __ GotoUnless(__ WordEqual(__ WordAnd(index, one), zero), &if_double); |
| 2576 |
| 2577 // The field is a proper Tagged field on {object}. The {index} is shifted |
| 2578 // to the left by one in the code below. |
| 2579 { |
| 2580 // Check if field is in-object or out-of-object. |
| 2581 auto if_outofobject = __ MakeLabel<1>(); |
| 2582 __ GotoIf(__ IntLessThan(index, zero), &if_outofobject); |
| 2583 |
| 2584 // The field is located in the {object} itself. |
| 2585 { |
| 2586 Node* offset = |
| 2587 __ IntAdd(__ WordShl(index, __ IntPtrConstant(kPointerSizeLog2 - 1)), |
| 2588 __ IntPtrConstant(JSObject::kHeaderSize - kHeapObjectTag)); |
| 2589 Node* result = __ Load(MachineType::AnyTagged(), object, offset); |
| 2590 __ Goto(&done, result); |
| 2591 } |
| 2592 |
| 2593 // The field is located in the properties backing store of {object}. |
| 2594 // The {index} is equal to the negated out of property index plus 1. |
| 2595 __ Bind(&if_outofobject); |
| 2596 { |
| 2597 Node* properties = |
| 2598 __ LoadField(AccessBuilder::ForJSObjectProperties(), object); |
| 2599 Node* offset = |
| 2600 __ IntAdd(__ WordShl(__ IntSub(zero, index), |
| 2601 __ IntPtrConstant(kPointerSizeLog2 - 1)), |
| 2602 __ IntPtrConstant((FixedArray::kHeaderSize - kPointerSize) - |
| 2603 kHeapObjectTag)); |
| 2604 Node* result = __ Load(MachineType::AnyTagged(), properties, offset); |
| 2605 __ Goto(&done, result); |
| 2606 } |
| 2607 } |
| 2608 |
| 2609 // The field is a Double field, either unboxed in the object on 64-bit |
| 2610 // architectures, or as MutableHeapNumber. |
| 2611 __ Bind(&if_double); |
| 2612 { |
| 2613 auto done_double = __ MakeLabel<2>(MachineRepresentation::kFloat64); |
| 2614 |
| 2615 index = __ WordSar(index, one); |
| 2616 |
| 2617 // Check if field is in-object or out-of-object. |
| 2618 auto if_outofobject = __ MakeLabel<1>(); |
| 2619 __ GotoIf(__ IntLessThan(index, zero), &if_outofobject); |
| 2620 |
| 2621 // The field is located in the {object} itself. |
| 2622 { |
| 2623 Node* offset = |
| 2624 __ IntAdd(__ WordShl(index, __ IntPtrConstant(kPointerSizeLog2)), |
| 2625 __ IntPtrConstant(JSObject::kHeaderSize - kHeapObjectTag)); |
| 2626 if (FLAG_unbox_double_fields) { |
| 2627 Node* result = __ Load(MachineType::Float64(), object, offset); |
| 2628 __ Goto(&done_double, result); |
| 2629 } else { |
| 2630 Node* result = __ Load(MachineType::AnyTagged(), object, offset); |
| 2631 result = __ LoadField(AccessBuilder::ForHeapNumberValue(), result); |
| 2632 __ Goto(&done_double, result); |
| 2633 } |
| 2634 } |
| 2635 |
| 2636 __ Bind(&if_outofobject); |
| 2637 { |
| 2638 Node* properties = |
| 2639 __ LoadField(AccessBuilder::ForJSObjectProperties(), object); |
| 2640 Node* offset = |
| 2641 __ IntAdd(__ WordShl(__ IntSub(zero, index), |
| 2642 __ IntPtrConstant(kPointerSizeLog2)), |
| 2643 __ IntPtrConstant((FixedArray::kHeaderSize - kPointerSize) - |
| 2644 kHeapObjectTag)); |
| 2645 Node* result = __ Load(MachineType::AnyTagged(), properties, offset); |
| 2646 result = __ LoadField(AccessBuilder::ForHeapNumberValue(), result); |
| 2647 __ Goto(&done_double, result); |
| 2648 } |
| 2649 |
| 2650 __ Bind(&done_double); |
| 2651 { |
| 2652 Node* result = AllocateHeapNumberWithValue(done_double.PhiAt(0)); |
| 2653 __ Goto(&done, result); |
| 2654 } |
| 2655 } |
| 2656 |
| 2657 __ Bind(&done); |
| 2658 return done.PhiAt(0); |
| 2659 } |
| 2660 |
2557 Node* EffectControlLinearizer::LowerLoadTypedElement(Node* node) { | 2661 Node* EffectControlLinearizer::LowerLoadTypedElement(Node* node) { |
2558 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); | 2662 ExternalArrayType array_type = ExternalArrayTypeOf(node->op()); |
2559 Node* buffer = node->InputAt(0); | 2663 Node* buffer = node->InputAt(0); |
2560 Node* base = node->InputAt(1); | 2664 Node* base = node->InputAt(1); |
2561 Node* external = node->InputAt(2); | 2665 Node* external = node->InputAt(2); |
2562 Node* index = node->InputAt(3); | 2666 Node* index = node->InputAt(3); |
2563 | 2667 |
2564 // We need to keep the {buffer} alive so that the GC will not release the | 2668 // We need to keep the {buffer} alive so that the GC will not release the |
2565 // ArrayBuffer (if there's any) as long as we are still operating on it. | 2669 // ArrayBuffer (if there's any) as long as we are still operating on it. |
2566 __ Retain(buffer); | 2670 __ Retain(buffer); |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2931 return isolate()->factory(); | 3035 return isolate()->factory(); |
2932 } | 3036 } |
2933 | 3037 |
2934 Isolate* EffectControlLinearizer::isolate() const { | 3038 Isolate* EffectControlLinearizer::isolate() const { |
2935 return jsgraph()->isolate(); | 3039 return jsgraph()->isolate(); |
2936 } | 3040 } |
2937 | 3041 |
2938 } // namespace compiler | 3042 } // namespace compiler |
2939 } // namespace internal | 3043 } // namespace internal |
2940 } // namespace v8 | 3044 } // namespace v8 |
OLD | NEW |