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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
(...skipping 2633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 if_onebyte.End(); | 2644 if_onebyte.End(); |
2645 HValue* map = Pop(); | 2645 HValue* map = Pop(); |
2646 | 2646 |
2647 // Calculate the number of bytes needed for the characters in the | 2647 // Calculate the number of bytes needed for the characters in the |
2648 // string while observing object alignment. | 2648 // string while observing object alignment. |
2649 STATIC_ASSERT((SeqString::kHeaderSize & kObjectAlignmentMask) == 0); | 2649 STATIC_ASSERT((SeqString::kHeaderSize & kObjectAlignmentMask) == 0); |
2650 HValue* size = BuildObjectSizeAlignment(Pop(), SeqString::kHeaderSize); | 2650 HValue* size = BuildObjectSizeAlignment(Pop(), SeqString::kHeaderSize); |
2651 | 2651 |
2652 IfBuilder if_size(this); | 2652 IfBuilder if_size(this); |
2653 if_size.If<HCompareNumericAndBranch>( | 2653 if_size.If<HCompareNumericAndBranch>( |
2654 size, Add<HConstant>(Page::kMaxRegularHeapObjectSize), Token::LT); | 2654 size, Add<HConstant>(kMaxRegularHeapObjectSize), Token::LT); |
2655 if_size.Then(); | 2655 if_size.Then(); |
2656 { | 2656 { |
2657 // Allocate the string object. HAllocate does not care whether we pass | 2657 // Allocate the string object. HAllocate does not care whether we pass |
2658 // STRING_TYPE or ONE_BYTE_STRING_TYPE here, so we just use STRING_TYPE. | 2658 // STRING_TYPE or ONE_BYTE_STRING_TYPE here, so we just use STRING_TYPE. |
2659 HAllocate* result = | 2659 HAllocate* result = |
2660 BuildAllocate(size, HType::String(), STRING_TYPE, allocation_mode); | 2660 BuildAllocate(size, HType::String(), STRING_TYPE, allocation_mode); |
2661 Add<HStoreNamedField>(result, HObjectAccess::ForMap(), map); | 2661 Add<HStoreNamedField>(result, HObjectAccess::ForMap(), map); |
2662 | 2662 |
2663 // Initialize the string fields. | 2663 // Initialize the string fields. |
2664 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), | 2664 Add<HStoreNamedField>(result, HObjectAccess::ForStringHashField(), |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3067 return new_capacity; | 3067 return new_capacity; |
3068 } | 3068 } |
3069 | 3069 |
3070 | 3070 |
3071 HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, | 3071 HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, |
3072 HValue* elements, | 3072 HValue* elements, |
3073 ElementsKind kind, | 3073 ElementsKind kind, |
3074 ElementsKind new_kind, | 3074 ElementsKind new_kind, |
3075 HValue* length, | 3075 HValue* length, |
3076 HValue* new_capacity) { | 3076 HValue* new_capacity) { |
3077 Add<HBoundsCheck>(new_capacity, Add<HConstant>( | 3077 Add<HBoundsCheck>( |
3078 (Page::kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) >> | 3078 new_capacity, |
3079 ElementsKindToShiftSize(new_kind))); | 3079 Add<HConstant>((kMaxRegularHeapObjectSize - FixedArray::kHeaderSize) >> |
| 3080 ElementsKindToShiftSize(new_kind))); |
3080 | 3081 |
3081 HValue* new_elements = | 3082 HValue* new_elements = |
3082 BuildAllocateAndInitializeArray(new_kind, new_capacity); | 3083 BuildAllocateAndInitializeArray(new_kind, new_capacity); |
3083 | 3084 |
3084 BuildCopyElements(elements, kind, new_elements, | 3085 BuildCopyElements(elements, kind, new_elements, |
3085 new_kind, length, new_capacity); | 3086 new_kind, length, new_capacity); |
3086 | 3087 |
3087 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 3088 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
3088 new_elements); | 3089 new_elements); |
3089 | 3090 |
(...skipping 6844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9934 // objects we construct, and an int32-to-smi HChange could deopt. Accept | 9935 // objects we construct, and an int32-to-smi HChange could deopt. Accept |
9935 // the deopt possibility now, before allocation occurs. | 9936 // the deopt possibility now, before allocation occurs. |
9936 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); | 9937 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); |
9937 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); | 9938 capacity = AddUncasted<HForceRepresentation>(capacity, Representation::Smi()); |
9938 | 9939 |
9939 // Generate size calculation code here in order to make it dominate | 9940 // Generate size calculation code here in order to make it dominate |
9940 // the JSArray allocation. | 9941 // the JSArray allocation. |
9941 HValue* elements_size = BuildCalculateElementsSize(kind, capacity); | 9942 HValue* elements_size = BuildCalculateElementsSize(kind, capacity); |
9942 | 9943 |
9943 // Bail out for large objects. | 9944 // Bail out for large objects. |
9944 HValue* max_size = Add<HConstant>(Page::kMaxRegularHeapObjectSize); | 9945 HValue* max_size = Add<HConstant>(kMaxRegularHeapObjectSize); |
9945 Add<HBoundsCheck>(elements_size, max_size); | 9946 Add<HBoundsCheck>(elements_size, max_size); |
9946 | 9947 |
9947 // Allocate (dealing with failure appropriately). | 9948 // Allocate (dealing with failure appropriately). |
9948 AllocationSiteMode mode = DONT_TRACK_ALLOCATION_SITE; | 9949 AllocationSiteMode mode = DONT_TRACK_ALLOCATION_SITE; |
9949 HAllocate* new_object = AllocateJSArrayObject(mode); | 9950 HAllocate* new_object = AllocateJSArrayObject(mode); |
9950 | 9951 |
9951 // Fill in the fields: map, properties, length. | 9952 // Fill in the fields: map, properties, length. |
9952 Handle<Map> map_constant(isolate()->get_initial_js_array_map(kind)); | 9953 Handle<Map> map_constant(isolate()->get_initial_js_array_map(kind)); |
9953 HValue* map = Add<HConstant>(map_constant); | 9954 HValue* map = Add<HConstant>(map_constant); |
9954 | 9955 |
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11834 if (*top_site == *current_site) { | 11835 if (*top_site == *current_site) { |
11835 // We install a dependency for pretenuring only on the outermost literal. | 11836 // We install a dependency for pretenuring only on the outermost literal. |
11836 top_info()->dependencies()->AssumeTenuringDecision(top_site); | 11837 top_info()->dependencies()->AssumeTenuringDecision(top_site); |
11837 } | 11838 } |
11838 top_info()->dependencies()->AssumeTransitionStable(current_site); | 11839 top_info()->dependencies()->AssumeTransitionStable(current_site); |
11839 | 11840 |
11840 HInstruction* object = | 11841 HInstruction* object = |
11841 Add<HAllocate>(object_size_constant, type, pretenure_flag, instance_type, | 11842 Add<HAllocate>(object_size_constant, type, pretenure_flag, instance_type, |
11842 graph()->GetConstant0(), top_site); | 11843 graph()->GetConstant0(), top_site); |
11843 | 11844 |
11844 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the | 11845 // If allocation folding reaches kMaxRegularHeapObjectSize the |
11845 // elements array may not get folded into the object. Hence, we set the | 11846 // elements array may not get folded into the object. Hence, we set the |
11846 // elements pointer to empty fixed array and let store elimination remove | 11847 // elements pointer to empty fixed array and let store elimination remove |
11847 // this store in the folding case. | 11848 // this store in the folding case. |
11848 HConstant* empty_fixed_array = Add<HConstant>( | 11849 HConstant* empty_fixed_array = Add<HConstant>( |
11849 isolate()->factory()->empty_fixed_array()); | 11850 isolate()->factory()->empty_fixed_array()); |
11850 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11851 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
11851 empty_fixed_array); | 11852 empty_fixed_array); |
11852 | 11853 |
11853 BuildEmitObjectHeader(boilerplate_object, object); | 11854 BuildEmitObjectHeader(boilerplate_object, object); |
11854 | 11855 |
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13394 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13395 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13395 } | 13396 } |
13396 | 13397 |
13397 #ifdef DEBUG | 13398 #ifdef DEBUG |
13398 graph_->Verify(false); // No full verify. | 13399 graph_->Verify(false); // No full verify. |
13399 #endif | 13400 #endif |
13400 } | 13401 } |
13401 | 13402 |
13402 } // namespace internal | 13403 } // namespace internal |
13403 } // namespace v8 | 13404 } // namespace v8 |
OLD | NEW |