| 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 8833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8844 } | 8844 } |
| 8845 | 8845 |
| 8846 HAllocate* receiver = BuildAllocate( | 8846 HAllocate* receiver = BuildAllocate( |
| 8847 size_in_bytes, HType::JSObject(), JS_OBJECT_TYPE, allocation_mode); | 8847 size_in_bytes, HType::JSObject(), JS_OBJECT_TYPE, allocation_mode); |
| 8848 receiver->set_known_initial_map(initial_map); | 8848 receiver->set_known_initial_map(initial_map); |
| 8849 | 8849 |
| 8850 // Initialize map and fields of the newly allocated object. | 8850 // Initialize map and fields of the newly allocated object. |
| 8851 { NoObservableSideEffectsScope no_effects(this); | 8851 { NoObservableSideEffectsScope no_effects(this); |
| 8852 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); | 8852 ASSERT(initial_map->instance_type() == JS_OBJECT_TYPE); |
| 8853 Add<HStoreNamedField>(receiver, | 8853 Add<HStoreNamedField>(receiver, |
| 8854 HObjectAccess::ForMapAndOffset(initial_map, JSObject::kMapOffset), | 8854 HObjectAccess::ForMap(), |
| 8855 Add<HConstant>(initial_map)); | 8855 Add<HConstant>(initial_map)); |
| 8856 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); | 8856 HValue* empty_fixed_array = Add<HConstant>(factory->empty_fixed_array()); |
| 8857 Add<HStoreNamedField>(receiver, | 8857 Add<HStoreNamedField>(receiver, |
| 8858 HObjectAccess::ForMapAndOffset(initial_map, | 8858 HObjectAccess::ForPropertiesPointer(), |
| 8859 JSObject::kPropertiesOffset), | 8859 empty_fixed_array); |
| 8860 empty_fixed_array); | |
| 8861 Add<HStoreNamedField>(receiver, | 8860 Add<HStoreNamedField>(receiver, |
| 8862 HObjectAccess::ForMapAndOffset(initial_map, | 8861 HObjectAccess::ForElementsPointer(), |
| 8863 JSObject::kElementsOffset), | 8862 empty_fixed_array); |
| 8864 empty_fixed_array); | |
| 8865 if (initial_map->inobject_properties() != 0) { | 8863 if (initial_map->inobject_properties() != 0) { |
| 8866 HConstant* undefined = graph()->GetConstantUndefined(); | 8864 HConstant* undefined = graph()->GetConstantUndefined(); |
| 8867 for (int i = 0; i < initial_map->inobject_properties(); i++) { | 8865 for (int i = 0; i < initial_map->inobject_properties(); i++) { |
| 8868 int property_offset = initial_map->GetInObjectPropertyOffset(i); | 8866 int property_offset = initial_map->GetInObjectPropertyOffset(i); |
| 8869 Add<HStoreNamedField>(receiver, | 8867 Add<HStoreNamedField>(receiver, |
| 8870 HObjectAccess::ForMapAndOffset(initial_map, property_offset), | 8868 HObjectAccess::ForMapAndOffset(initial_map, property_offset), |
| 8871 undefined); | 8869 undefined); |
| 8872 } | 8870 } |
| 8873 } | 8871 } |
| 8874 } | 8872 } |
| (...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10482 PretenureFlag pretenure_flag = NOT_TENURED; | 10480 PretenureFlag pretenure_flag = NOT_TENURED; |
| 10483 if (FLAG_allocation_site_pretenuring) { | 10481 if (FLAG_allocation_site_pretenuring) { |
| 10484 pretenure_flag = site_context->current()->GetPretenureMode(); | 10482 pretenure_flag = site_context->current()->GetPretenureMode(); |
| 10485 Handle<AllocationSite> site(site_context->current()); | 10483 Handle<AllocationSite> site(site_context->current()); |
| 10486 AllocationSite::AddDependentCompilationInfo( | 10484 AllocationSite::AddDependentCompilationInfo( |
| 10487 site, AllocationSite::TENURING, top_info()); | 10485 site, AllocationSite::TENURING, top_info()); |
| 10488 } | 10486 } |
| 10489 | 10487 |
| 10490 HInstruction* object = Add<HAllocate>(object_size_constant, type, | 10488 HInstruction* object = Add<HAllocate>(object_size_constant, type, |
| 10491 pretenure_flag, instance_type, site_context->current()); | 10489 pretenure_flag, instance_type, site_context->current()); |
| 10490 BuildEmitObjectHeader(boilerplate_object, object); |
| 10492 | 10491 |
| 10493 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the | 10492 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the |
| 10494 // elements array may not get folded into the object. Hence, we set the | 10493 // elements array may not get folded into the object. Hence, we set the |
| 10495 // elements pointer to empty fixed array and let store elimination remove | 10494 // elements pointer to empty fixed array and let store elimination remove |
| 10496 // this store in the folding case. | 10495 // this store in the folding case. |
| 10497 HConstant* empty_fixed_array = Add<HConstant>( | 10496 HConstant* empty_fixed_array = Add<HConstant>( |
| 10498 isolate()->factory()->empty_fixed_array()); | 10497 isolate()->factory()->empty_fixed_array()); |
| 10499 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 10498 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 10500 empty_fixed_array); | 10499 empty_fixed_array); |
| 10501 | 10500 |
| 10502 BuildEmitObjectHeader(boilerplate_object, object); | |
| 10503 | |
| 10504 Handle<FixedArrayBase> elements(boilerplate_object->elements()); | 10501 Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
| 10505 int elements_size = (elements->length() > 0 && | 10502 int elements_size = (elements->length() > 0 && |
| 10506 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? | 10503 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? |
| 10507 elements->Size() : 0; | 10504 elements->Size() : 0; |
| 10508 | 10505 |
| 10509 if (pretenure_flag == TENURED && | 10506 if (pretenure_flag == TENURED && |
| 10510 elements->map() == isolate()->heap()->fixed_cow_array_map() && | 10507 elements->map() == isolate()->heap()->fixed_cow_array_map() && |
| 10511 isolate()->heap()->InNewSpace(*elements)) { | 10508 isolate()->heap()->InNewSpace(*elements)) { |
| 10512 // If we would like to pretenure a fixed cow array, we must ensure that the | 10509 // If we would like to pretenure a fixed cow array, we must ensure that the |
| 10513 // array is already in old space, otherwise we'll create too many old-to- | 10510 // array is already in old space, otherwise we'll create too many old-to- |
| (...skipping 1524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12038 if (ShouldProduceTraceOutput()) { | 12035 if (ShouldProduceTraceOutput()) { |
| 12039 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12036 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12040 } | 12037 } |
| 12041 | 12038 |
| 12042 #ifdef DEBUG | 12039 #ifdef DEBUG |
| 12043 graph_->Verify(false); // No full verify. | 12040 graph_->Verify(false); // No full verify. |
| 12044 #endif | 12041 #endif |
| 12045 } | 12042 } |
| 12046 | 12043 |
| 12047 } } // namespace v8::internal | 12044 } } // namespace v8::internal |
| OLD | NEW |