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 "hydrogen.h" | 5 #include "hydrogen.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "v8.h" | 9 #include "v8.h" |
10 #include "allocation-site-scopes.h" | 10 #include "allocation-site-scopes.h" |
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 Push(checked_length); // length | 2262 Push(checked_length); // length |
2263 } | 2263 } |
2264 if_builder.End(); | 2264 if_builder.End(); |
2265 | 2265 |
2266 // Figure out total size | 2266 // Figure out total size |
2267 HValue* length = Pop(); | 2267 HValue* length = Pop(); |
2268 HValue* capacity = Pop(); | 2268 HValue* capacity = Pop(); |
2269 return array_builder->AllocateArray(capacity, length); | 2269 return array_builder->AllocateArray(capacity, length); |
2270 } | 2270 } |
2271 | 2271 |
| 2272 |
2272 HValue* HGraphBuilder::BuildAllocateElements(ElementsKind kind, | 2273 HValue* HGraphBuilder::BuildAllocateElements(ElementsKind kind, |
2273 HValue* capacity) { | 2274 HValue* capacity) { |
2274 int elements_size; | 2275 int elements_size; |
2275 InstanceType instance_type; | 2276 InstanceType instance_type; |
2276 | 2277 |
2277 if (IsFastDoubleElementsKind(kind)) { | 2278 if (IsFastDoubleElementsKind(kind)) { |
2278 elements_size = kDoubleSize; | 2279 elements_size = kDoubleSize; |
2279 instance_type = FIXED_DOUBLE_ARRAY_TYPE; | 2280 instance_type = FIXED_DOUBLE_ARRAY_TYPE; |
2280 } else { | 2281 } else { |
2281 elements_size = kPointerSize; | 2282 elements_size = kPointerSize; |
2282 instance_type = FIXED_ARRAY_TYPE; | 2283 instance_type = FIXED_ARRAY_TYPE; |
2283 } | 2284 } |
2284 | 2285 |
2285 HConstant* elements_size_value = Add<HConstant>(elements_size); | 2286 HConstant* elements_size_value = Add<HConstant>(elements_size); |
2286 HValue* mul = AddUncasted<HMul>(capacity, elements_size_value); | 2287 HValue* mul = AddUncasted<HMul>(capacity, elements_size_value); |
2287 mul->ClearFlag(HValue::kCanOverflow); | 2288 mul->ClearFlag(HValue::kCanOverflow); |
2288 | 2289 |
2289 HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize); | 2290 HConstant* header_size = Add<HConstant>(FixedArray::kHeaderSize); |
2290 HValue* total_size = AddUncasted<HAdd>(mul, header_size); | 2291 HValue* total_size = AddUncasted<HAdd>(mul, header_size); |
2291 total_size->ClearFlag(HValue::kCanOverflow); | 2292 total_size->ClearFlag(HValue::kCanOverflow); |
2292 | 2293 |
2293 PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ? | 2294 PretenureFlag pretenure_flag = !FLAG_allocation_site_pretenuring ? |
2294 isolate()->heap()->GetPretenureMode() : NOT_TENURED; | 2295 isolate()->heap()->GetPretenureMode() : NOT_TENURED; |
2295 | 2296 |
2296 return Add<HAllocate>(total_size, HType::Tagged(), pretenure_flag, | 2297 return Add<HAllocate>(total_size, HType::NonPrimitive(), |
2297 instance_type); | 2298 pretenure_flag, instance_type); |
2298 } | 2299 } |
2299 | 2300 |
2300 | 2301 |
2301 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, | 2302 void HGraphBuilder::BuildInitializeElementsHeader(HValue* elements, |
2302 ElementsKind kind, | 2303 ElementsKind kind, |
2303 HValue* capacity) { | 2304 HValue* capacity) { |
2304 Factory* factory = isolate()->factory(); | 2305 Factory* factory = isolate()->factory(); |
2305 Handle<Map> map = IsFastDoubleElementsKind(kind) | 2306 Handle<Map> map = IsFastDoubleElementsKind(kind) |
2306 ? factory->fixed_double_array_map() | 2307 ? factory->fixed_double_array_map() |
2307 : factory->fixed_array_map(); | 2308 : factory->fixed_array_map(); |
(...skipping 6479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8787 HValue* buffer, HValue* byte_offset, HValue* length) { | 8788 HValue* buffer, HValue* byte_offset, HValue* length) { |
8788 Handle<Map> external_array_map( | 8789 Handle<Map> external_array_map( |
8789 isolate()->heap()->MapForExternalArrayType(array_type)); | 8790 isolate()->heap()->MapForExternalArrayType(array_type)); |
8790 | 8791 |
8791 // The HForceRepresentation is to prevent possible deopt on int-smi | 8792 // The HForceRepresentation is to prevent possible deopt on int-smi |
8792 // conversion after allocation but before the new object fields are set. | 8793 // conversion after allocation but before the new object fields are set. |
8793 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); | 8794 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); |
8794 HValue* elements = | 8795 HValue* elements = |
8795 Add<HAllocate>( | 8796 Add<HAllocate>( |
8796 Add<HConstant>(ExternalArray::kAlignedSize), | 8797 Add<HConstant>(ExternalArray::kAlignedSize), |
8797 HType::Tagged(), | 8798 HType::NonPrimitive(), |
8798 NOT_TENURED, | 8799 NOT_TENURED, |
8799 external_array_map->instance_type()); | 8800 external_array_map->instance_type()); |
8800 | 8801 |
8801 AddStoreMapConstant(elements, external_array_map); | 8802 AddStoreMapConstant(elements, external_array_map); |
8802 Add<HStoreNamedField>(elements, | 8803 Add<HStoreNamedField>(elements, |
8803 HObjectAccess::ForFixedArrayLength(), length); | 8804 HObjectAccess::ForFixedArrayLength(), length); |
8804 | 8805 |
8805 HValue* backing_store = Add<HLoadNamedField>( | 8806 HValue* backing_store = Add<HLoadNamedField>( |
8806 buffer, static_cast<HValue*>(NULL), | 8807 buffer, static_cast<HValue*>(NULL), |
8807 HObjectAccess::ForJSArrayBufferBackingStore()); | 8808 HObjectAccess::ForJSArrayBufferBackingStore()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8844 Add<HConstant>(FixedTypedArrayBase::kHeaderSize)); | 8845 Add<HConstant>(FixedTypedArrayBase::kHeaderSize)); |
8845 total_size->ClearFlag(HValue::kCanOverflow); | 8846 total_size->ClearFlag(HValue::kCanOverflow); |
8846 } | 8847 } |
8847 | 8848 |
8848 // The HForceRepresentation is to prevent possible deopt on int-smi | 8849 // The HForceRepresentation is to prevent possible deopt on int-smi |
8849 // conversion after allocation but before the new object fields are set. | 8850 // conversion after allocation but before the new object fields are set. |
8850 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); | 8851 length = AddUncasted<HForceRepresentation>(length, Representation::Smi()); |
8851 Handle<Map> fixed_typed_array_map( | 8852 Handle<Map> fixed_typed_array_map( |
8852 isolate()->heap()->MapForFixedTypedArray(array_type)); | 8853 isolate()->heap()->MapForFixedTypedArray(array_type)); |
8853 HValue* elements = | 8854 HValue* elements = |
8854 Add<HAllocate>(total_size, HType::Tagged(), | 8855 Add<HAllocate>(total_size, HType::NonPrimitive(), |
8855 NOT_TENURED, | 8856 NOT_TENURED, fixed_typed_array_map->instance_type()); |
8856 fixed_typed_array_map->instance_type()); | |
8857 AddStoreMapConstant(elements, fixed_typed_array_map); | 8857 AddStoreMapConstant(elements, fixed_typed_array_map); |
8858 | 8858 |
8859 Add<HStoreNamedField>(elements, | 8859 Add<HStoreNamedField>(elements, |
8860 HObjectAccess::ForFixedArrayLength(), | 8860 HObjectAccess::ForFixedArrayLength(), |
8861 length); | 8861 length); |
8862 | 8862 |
8863 HValue* filler = Add<HConstant>(static_cast<int32_t>(0)); | 8863 HValue* filler = Add<HConstant>(static_cast<int32_t>(0)); |
8864 | 8864 |
8865 { | 8865 { |
8866 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); | 8866 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement); |
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10285 // new-space pointers (overflowing the store buffer). | 10285 // new-space pointers (overflowing the store buffer). |
10286 elements = Handle<FixedArrayBase>( | 10286 elements = Handle<FixedArrayBase>( |
10287 isolate()->factory()->CopyAndTenureFixedCOWArray( | 10287 isolate()->factory()->CopyAndTenureFixedCOWArray( |
10288 Handle<FixedArray>::cast(elements))); | 10288 Handle<FixedArray>::cast(elements))); |
10289 boilerplate_object->set_elements(*elements); | 10289 boilerplate_object->set_elements(*elements); |
10290 } | 10290 } |
10291 | 10291 |
10292 HInstruction* object_elements = NULL; | 10292 HInstruction* object_elements = NULL; |
10293 if (elements_size > 0) { | 10293 if (elements_size > 0) { |
10294 HValue* object_elements_size = Add<HConstant>(elements_size); | 10294 HValue* object_elements_size = Add<HConstant>(elements_size); |
10295 if (boilerplate_object->HasFastDoubleElements()) { | 10295 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() |
10296 object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(), | 10296 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; |
10297 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current()); | 10297 object_elements = Add<HAllocate>( |
10298 } else { | 10298 object_elements_size, HType::NonPrimitive(), |
10299 object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(), | 10299 pretenure_flag, instance_type, site_context->current()); |
10300 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current()); | |
10301 } | |
10302 } | 10300 } |
10303 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); | 10301 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); |
10304 | 10302 |
10305 // Copy object elements if non-COW. | 10303 // Copy object elements if non-COW. |
10306 if (object_elements != NULL) { | 10304 if (object_elements != NULL) { |
10307 BuildEmitElements(boilerplate_object, elements, object_elements, | 10305 BuildEmitElements(boilerplate_object, elements, object_elements, |
10308 site_context); | 10306 site_context); |
10309 } | 10307 } |
10310 | 10308 |
10311 // Copy in-object properties. | 10309 // Copy in-object properties. |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11811 if (ShouldProduceTraceOutput()) { | 11809 if (ShouldProduceTraceOutput()) { |
11812 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 11810 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
11813 } | 11811 } |
11814 | 11812 |
11815 #ifdef DEBUG | 11813 #ifdef DEBUG |
11816 graph_->Verify(false); // No full verify. | 11814 graph_->Verify(false); // No full verify. |
11817 #endif | 11815 #endif |
11818 } | 11816 } |
11819 | 11817 |
11820 } } // namespace v8::internal | 11818 } } // namespace v8::internal |
OLD | NEW |