| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 2678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2689 | 2689 |
| 2690 void HGraphBuilder::BuildFillElementsWithValue(HValue* elements, | 2690 void HGraphBuilder::BuildFillElementsWithValue(HValue* elements, |
| 2691 ElementsKind elements_kind, | 2691 ElementsKind elements_kind, |
| 2692 HValue* from, | 2692 HValue* from, |
| 2693 HValue* to, | 2693 HValue* to, |
| 2694 HValue* value) { | 2694 HValue* value) { |
| 2695 if (to == NULL) { | 2695 if (to == NULL) { |
| 2696 to = AddLoadFixedArrayLength(elements); | 2696 to = AddLoadFixedArrayLength(elements); |
| 2697 } | 2697 } |
| 2698 | 2698 |
| 2699 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 |
| 2700 from = AddUncasted<HForceRepresentation>(from, Representation::Integer32()); |
| 2701 to = AddUncasted<HForceRepresentation>(to, Representation::Integer32()); |
| 2702 Add<HFillElements>(elements, from, to, value); |
| 2703 #else |
| 2699 // Special loop unfolding case | 2704 // Special loop unfolding case |
| 2700 STATIC_ASSERT(JSArray::kPreallocatedArrayElements <= | 2705 STATIC_ASSERT(JSArray::kPreallocatedArrayElements <= |
| 2701 kElementLoopUnrollThreshold); | 2706 kElementLoopUnrollThreshold); |
| 2702 int initial_capacity = -1; | 2707 int initial_capacity = -1; |
| 2703 if (from->IsInteger32Constant() && to->IsInteger32Constant()) { | 2708 if (from->IsInteger32Constant() && to->IsInteger32Constant()) { |
| 2704 int constant_from = from->GetInteger32Constant(); | 2709 int constant_from = from->GetInteger32Constant(); |
| 2705 int constant_to = to->GetInteger32Constant(); | 2710 int constant_to = to->GetInteger32Constant(); |
| 2706 | 2711 |
| 2707 if (constant_from == 0 && constant_to <= kElementLoopUnrollThreshold) { | 2712 if (constant_from == 0 && constant_to <= kElementLoopUnrollThreshold) { |
| 2708 initial_capacity = constant_to; | 2713 initial_capacity = constant_to; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2729 | 2734 |
| 2730 HValue* key = builder.BeginBody(to, from, Token::GT); | 2735 HValue* key = builder.BeginBody(to, from, Token::GT); |
| 2731 | 2736 |
| 2732 HValue* adjusted_key = AddUncasted<HSub>(key, graph()->GetConstant1()); | 2737 HValue* adjusted_key = AddUncasted<HSub>(key, graph()->GetConstant1()); |
| 2733 adjusted_key->ClearFlag(HValue::kCanOverflow); | 2738 adjusted_key->ClearFlag(HValue::kCanOverflow); |
| 2734 | 2739 |
| 2735 Add<HStoreKeyed>(elements, adjusted_key, value, elements_kind); | 2740 Add<HStoreKeyed>(elements, adjusted_key, value, elements_kind); |
| 2736 | 2741 |
| 2737 builder.EndBody(); | 2742 builder.EndBody(); |
| 2738 } | 2743 } |
| 2744 #endif |
| 2739 } | 2745 } |
| 2740 | 2746 |
| 2741 | 2747 |
| 2742 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, | 2748 void HGraphBuilder::BuildFillElementsWithHole(HValue* elements, |
| 2743 ElementsKind elements_kind, | 2749 ElementsKind elements_kind, |
| 2744 HValue* from, | 2750 HValue* from, |
| 2745 HValue* to) { | 2751 HValue* to) { |
| 2746 // Fast elements kinds need to be initialized in case statements below cause a | 2752 // Fast elements kinds need to be initialized in case statements below cause a |
| 2747 // garbage collection. | 2753 // garbage collection. |
| 2748 Factory* factory = isolate()->factory(); | 2754 Factory* factory = isolate()->factory(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2796 if (!pre_fill_with_holes && | 2802 if (!pre_fill_with_holes && |
| 2797 (capacity == NULL || !length->Equals(capacity))) { | 2803 (capacity == NULL || !length->Equals(capacity))) { |
| 2798 BuildFillElementsWithHole(to_elements, to_elements_kind, | 2804 BuildFillElementsWithHole(to_elements, to_elements_kind, |
| 2799 length, NULL); | 2805 length, NULL); |
| 2800 } | 2806 } |
| 2801 | 2807 |
| 2802 if (capacity == NULL) { | 2808 if (capacity == NULL) { |
| 2803 capacity = AddLoadFixedArrayLength(to_elements); | 2809 capacity = AddLoadFixedArrayLength(to_elements); |
| 2804 } | 2810 } |
| 2805 | 2811 |
| 2806 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); | 2812 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 |
| 2813 if (from_elements_kind == to_elements_kind) { |
| 2814 length = |
| 2815 AddUncasted<HForceRepresentation>(length, Representation::Integer32()); |
| 2816 Add<HCopyElements>(from_elements, to_elements, length, to_elements_kind); |
| 2817 } else { |
| 2818 #endif |
| 2819 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); |
| 2807 | 2820 |
| 2808 HValue* key = builder.BeginBody(length, graph()->GetConstant0(), | 2821 HValue* key = builder.BeginBody(length, graph()->GetConstant0(), |
| 2809 Token::GT); | 2822 Token::GT); |
| 2810 | 2823 |
| 2811 key = AddUncasted<HSub>(key, graph()->GetConstant1()); | 2824 key = AddUncasted<HSub>(key, graph()->GetConstant1()); |
| 2812 key->ClearFlag(HValue::kCanOverflow); | 2825 key->ClearFlag(HValue::kCanOverflow); |
| 2813 | 2826 |
| 2814 HValue* element = Add<HLoadKeyed>(from_elements, key, | 2827 HValue* element = Add<HLoadKeyed>(from_elements, key, |
| 2815 static_cast<HValue*>(NULL), | 2828 static_cast<HValue*>(NULL), |
| 2816 from_elements_kind, | 2829 from_elements_kind, |
| 2817 ALLOW_RETURN_HOLE); | 2830 ALLOW_RETURN_HOLE); |
| 2818 | 2831 |
| 2819 ElementsKind kind = (IsHoleyElementsKind(from_elements_kind) && | 2832 ElementsKind kind = (IsHoleyElementsKind(from_elements_kind) && |
| 2820 IsFastSmiElementsKind(to_elements_kind)) | 2833 IsFastSmiElementsKind(to_elements_kind)) |
| 2821 ? FAST_HOLEY_ELEMENTS : to_elements_kind; | 2834 ? FAST_HOLEY_ELEMENTS : to_elements_kind; |
| 2822 | 2835 |
| 2823 if (IsHoleyElementsKind(from_elements_kind) && | 2836 if (IsHoleyElementsKind(from_elements_kind) && |
| 2824 from_elements_kind != to_elements_kind) { | 2837 from_elements_kind != to_elements_kind) { |
| 2825 IfBuilder if_hole(this); | 2838 IfBuilder if_hole(this); |
| 2826 if_hole.If<HCompareHoleAndBranch>(element); | 2839 if_hole.If<HCompareHoleAndBranch>(element); |
| 2827 if_hole.Then(); | 2840 if_hole.Then(); |
| 2828 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) | 2841 HConstant* hole_constant = IsFastDoubleElementsKind(to_elements_kind) |
| 2829 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) | 2842 ? Add<HConstant>(FixedDoubleArray::hole_nan_as_double()) |
| 2830 : graph()->GetConstantHole(); | 2843 : graph()->GetConstantHole(); |
| 2831 Add<HStoreKeyed>(to_elements, key, hole_constant, kind); | 2844 Add<HStoreKeyed>(to_elements, key, hole_constant, kind); |
| 2832 if_hole.Else(); | 2845 if_hole.Else(); |
| 2833 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); | 2846 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); |
| 2834 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 2847 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
| 2835 if_hole.End(); | 2848 if_hole.End(); |
| 2836 } else { | 2849 } else { |
| 2837 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); | 2850 HStoreKeyed* store = Add<HStoreKeyed>(to_elements, key, element, kind); |
| 2838 store->SetFlag(HValue::kAllowUndefinedAsNaN); | 2851 store->SetFlag(HValue::kAllowUndefinedAsNaN); |
| 2852 } |
| 2853 |
| 2854 builder.EndBody(); |
| 2855 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 |
| 2839 } | 2856 } |
| 2840 | 2857 #endif |
| 2841 builder.EndBody(); | |
| 2842 } | 2858 } |
| 2843 | 2859 |
| 2844 Counters* counters = isolate()->counters(); | 2860 Counters* counters = isolate()->counters(); |
| 2845 AddIncrementCounter(counters->inlined_copied_elements()); | 2861 AddIncrementCounter(counters->inlined_copied_elements()); |
| 2846 } | 2862 } |
| 2847 | 2863 |
| 2848 | 2864 |
| 2849 HValue* HGraphBuilder::BuildCloneShallowArrayCow(HValue* boilerplate, | 2865 HValue* HGraphBuilder::BuildCloneShallowArrayCow(HValue* boilerplate, |
| 2850 HValue* allocation_site, | 2866 HValue* allocation_site, |
| 2851 AllocationSiteMode mode, | 2867 AllocationSiteMode mode, |
| (...skipping 9492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12344 if (ShouldProduceTraceOutput()) { | 12360 if (ShouldProduceTraceOutput()) { |
| 12345 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12361 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12346 } | 12362 } |
| 12347 | 12363 |
| 12348 #ifdef DEBUG | 12364 #ifdef DEBUG |
| 12349 graph_->Verify(false); // No full verify. | 12365 graph_->Verify(false); // No full verify. |
| 12350 #endif | 12366 #endif |
| 12351 } | 12367 } |
| 12352 | 12368 |
| 12353 } } // namespace v8::internal | 12369 } } // namespace v8::internal |
| OLD | NEW |