Chromium Code Reviews| 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 | 10 |
| (...skipping 2771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2782 int initial_capacity = -1; | 2782 int initial_capacity = -1; |
| 2783 if (from->IsInteger32Constant() && to->IsInteger32Constant()) { | 2783 if (from->IsInteger32Constant() && to->IsInteger32Constant()) { |
| 2784 int constant_from = from->GetInteger32Constant(); | 2784 int constant_from = from->GetInteger32Constant(); |
| 2785 int constant_to = to->GetInteger32Constant(); | 2785 int constant_to = to->GetInteger32Constant(); |
| 2786 | 2786 |
| 2787 if (constant_from == 0 && constant_to <= kElementLoopUnrollThreshold) { | 2787 if (constant_from == 0 && constant_to <= kElementLoopUnrollThreshold) { |
| 2788 initial_capacity = constant_to; | 2788 initial_capacity = constant_to; |
| 2789 } | 2789 } |
| 2790 } | 2790 } |
| 2791 | 2791 |
| 2792 // Since we're about to store a hole value, the store instruction below must | |
| 2793 // assume an elements kind that supports heap object values. | |
| 2794 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | |
| 2795 elements_kind = FAST_HOLEY_ELEMENTS; | |
| 2796 } | |
| 2797 | |
| 2798 if (initial_capacity >= 0) { | 2792 if (initial_capacity >= 0) { |
| 2799 for (int i = 0; i < initial_capacity; i++) { | 2793 for (int i = 0; i < initial_capacity; i++) { |
| 2800 HInstruction* key = Add<HConstant>(i); | 2794 HInstruction* key = Add<HConstant>(i); |
| 2801 Add<HStoreKeyed>(elements, key, value, elements_kind); | 2795 Add<HStoreKeyed>(elements, key, value, elements_kind); |
| 2802 } | 2796 } |
| 2803 } else { | 2797 } else { |
| 2804 // Carefully loop backwards so that the "from" remains live through the loop | 2798 // Carefully loop backwards so that the "from" remains live through the loop |
| 2805 // rather than the to. This often corresponds to keeping length live rather | 2799 // rather than the to. This often corresponds to keeping length live rather |
| 2806 // then capacity, which helps register allocation, since length is used more | 2800 // then capacity, which helps register allocation, since length is used more |
| 2807 // other than capacity after filling with holes. | 2801 // other than capacity after filling with holes. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 2825 HValue* to) { | 2819 HValue* to) { |
| 2826 // Fast elements kinds need to be initialized in case statements below cause a | 2820 // Fast elements kinds need to be initialized in case statements below cause a |
| 2827 // garbage collection. | 2821 // garbage collection. |
| 2828 Factory* factory = isolate()->factory(); | 2822 Factory* factory = isolate()->factory(); |
| 2829 | 2823 |
| 2830 double nan_double = FixedDoubleArray::hole_nan_as_double(); | 2824 double nan_double = FixedDoubleArray::hole_nan_as_double(); |
| 2831 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) | 2825 HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind) |
| 2832 ? Add<HConstant>(factory->the_hole_value()) | 2826 ? Add<HConstant>(factory->the_hole_value()) |
| 2833 : Add<HConstant>(nan_double); | 2827 : Add<HConstant>(nan_double); |
| 2834 | 2828 |
| 2829 // Since we're about to store a hole value, the store instruction below must | |
| 2830 // assume an elements kind that supports heap object values. | |
| 2831 if (IsFastSmiOrObjectElementsKind(elements_kind)) { | |
| 2832 elements_kind = FAST_HOLEY_ELEMENTS; | |
| 2833 } | |
| 2834 | |
| 2835 BuildFillElementsWithValue(elements, elements_kind, from, to, hole); | 2835 BuildFillElementsWithValue(elements, elements_kind, from, to, hole); |
| 2836 } | 2836 } |
| 2837 | 2837 |
| 2838 | 2838 |
| 2839 void HGraphBuilder::BuildCopyProperties(HValue* from_properties, | |
| 2840 HValue* to_properties, HValue* length, | |
| 2841 HValue* capacity) { | |
| 2842 ElementsKind kind = FAST_ELEMENTS; | |
| 2843 | |
| 2844 BuildFillElementsWithValue(to_properties, kind, length, capacity, | |
| 2845 graph()->GetConstantUndefined()); | |
| 2846 | |
| 2847 LoopBuilder builder(this, context(), LoopBuilder::kPostDecrement); | |
| 2848 | |
| 2849 HValue* key = builder.BeginBody(length, graph()->GetConstant0(), Token::GT); | |
| 2850 | |
| 2851 key = AddUncasted<HSub>(key, graph()->GetConstant1()); | |
| 2852 key->ClearFlag(HValue::kCanOverflow); | |
| 2853 | |
| 2854 HValue* element = | |
| 2855 Add<HLoadKeyed>(from_properties, key, static_cast<HValue*>(NULL), kind); | |
| 2856 | |
| 2857 HStoreKeyed* store = Add<HStoreKeyed>(to_properties, key, element, kind); | |
| 2858 store->SetFlag(HValue::kAllowUndefinedAsNaN); | |
|
Toon Verwaest
2014/09/22 08:55:29
I don't think this flag has any meaning for FAST_E
Igor Sheludko
2014/09/23 07:38:47
Done.
| |
| 2859 | |
| 2860 builder.EndBody(); | |
| 2861 } | |
| 2862 | |
| 2863 | |
| 2839 void HGraphBuilder::BuildCopyElements(HValue* from_elements, | 2864 void HGraphBuilder::BuildCopyElements(HValue* from_elements, |
| 2840 ElementsKind from_elements_kind, | 2865 ElementsKind from_elements_kind, |
| 2841 HValue* to_elements, | 2866 HValue* to_elements, |
| 2842 ElementsKind to_elements_kind, | 2867 ElementsKind to_elements_kind, |
| 2843 HValue* length, | 2868 HValue* length, |
| 2844 HValue* capacity) { | 2869 HValue* capacity) { |
| 2845 int constant_capacity = -1; | 2870 int constant_capacity = -1; |
| 2846 if (capacity != NULL && | 2871 if (capacity != NULL && |
| 2847 capacity->IsConstant() && | 2872 capacity->IsConstant() && |
| 2848 HConstant::cast(capacity)->HasInteger32Value()) { | 2873 HConstant::cast(capacity)->HasInteger32Value()) { |
| (...skipping 9674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 12523 if (ShouldProduceTraceOutput()) { | 12548 if (ShouldProduceTraceOutput()) { |
| 12524 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12549 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12525 } | 12550 } |
| 12526 | 12551 |
| 12527 #ifdef DEBUG | 12552 #ifdef DEBUG |
| 12528 graph_->Verify(false); // No full verify. | 12553 graph_->Verify(false); // No full verify. |
| 12529 #endif | 12554 #endif |
| 12530 } | 12555 } |
| 12531 | 12556 |
| 12532 } } // namespace v8::internal | 12557 } } // namespace v8::internal |
| OLD | NEW |