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 <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 11320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11331 } | 11331 } |
11332 | 11332 |
11333 HInstruction* object_elements = NULL; | 11333 HInstruction* object_elements = NULL; |
11334 if (elements_size > 0) { | 11334 if (elements_size > 0) { |
11335 HValue* object_elements_size = Add<HConstant>(elements_size); | 11335 HValue* object_elements_size = Add<HConstant>(elements_size); |
11336 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() | 11336 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() |
11337 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; | 11337 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; |
11338 object_elements = | 11338 object_elements = |
11339 Add<HAllocate>(object_elements_size, HType::HeapObject(), | 11339 Add<HAllocate>(object_elements_size, HType::HeapObject(), |
11340 pretenure_flag, instance_type, current_site); | 11340 pretenure_flag, instance_type, current_site); |
11341 } | |
11342 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); | |
11343 | |
11344 // Copy object elements if non-COW. | |
11345 if (object_elements != NULL) { | |
11346 BuildEmitElements(boilerplate_object, elements, object_elements, | 11341 BuildEmitElements(boilerplate_object, elements, object_elements, |
11347 site_context); | 11342 site_context); |
| 11343 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11344 object_elements); |
| 11345 } else { |
| 11346 Handle<Object> elements_field = |
| 11347 Handle<Object>(boilerplate_object->elements(), isolate()); |
| 11348 HInstruction* object_elements_cow = Add<HConstant>(elements_field); |
| 11349 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11350 object_elements_cow); |
11348 } | 11351 } |
11349 | 11352 |
11350 // Copy in-object properties. | 11353 // Copy in-object properties. |
11351 if (boilerplate_object->map()->NumberOfFields() != 0 || | 11354 if (boilerplate_object->map()->NumberOfFields() != 0 || |
11352 boilerplate_object->map()->unused_property_fields() > 0) { | 11355 boilerplate_object->map()->unused_property_fields() > 0) { |
11353 BuildEmitInObjectProperties(boilerplate_object, object, site_context, | 11356 BuildEmitInObjectProperties(boilerplate_object, object, site_context, |
11354 pretenure_flag); | 11357 pretenure_flag); |
11355 } | 11358 } |
11356 return object; | 11359 return object; |
11357 } | 11360 } |
(...skipping 21 matching lines...) Expand all Loading... |
11379 Handle<Object>(boilerplate_array->length(), isolate()); | 11382 Handle<Object>(boilerplate_array->length(), isolate()); |
11380 HInstruction* length = Add<HConstant>(length_field); | 11383 HInstruction* length = Add<HConstant>(length_field); |
11381 | 11384 |
11382 DCHECK(boilerplate_array->length()->IsSmi()); | 11385 DCHECK(boilerplate_array->length()->IsSmi()); |
11383 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( | 11386 Add<HStoreNamedField>(object, HObjectAccess::ForArrayLength( |
11384 boilerplate_array->GetElementsKind()), length); | 11387 boilerplate_array->GetElementsKind()), length); |
11385 } | 11388 } |
11386 } | 11389 } |
11387 | 11390 |
11388 | 11391 |
11389 void HOptimizedGraphBuilder::BuildInitElementsInObjectHeader( | |
11390 Handle<JSObject> boilerplate_object, | |
11391 HInstruction* object, | |
11392 HInstruction* object_elements) { | |
11393 DCHECK(boilerplate_object->properties()->length() == 0); | |
11394 if (object_elements == NULL) { | |
11395 Handle<Object> elements_field = | |
11396 Handle<Object>(boilerplate_object->elements(), isolate()); | |
11397 object_elements = Add<HConstant>(elements_field); | |
11398 } | |
11399 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | |
11400 object_elements); | |
11401 } | |
11402 | |
11403 | |
11404 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( | 11392 void HOptimizedGraphBuilder::BuildEmitInObjectProperties( |
11405 Handle<JSObject> boilerplate_object, | 11393 Handle<JSObject> boilerplate_object, |
11406 HInstruction* object, | 11394 HInstruction* object, |
11407 AllocationSiteUsageContext* site_context, | 11395 AllocationSiteUsageContext* site_context, |
11408 PretenureFlag pretenure_flag) { | 11396 PretenureFlag pretenure_flag) { |
11409 Handle<Map> boilerplate_map(boilerplate_object->map()); | 11397 Handle<Map> boilerplate_map(boilerplate_object->map()); |
11410 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors()); | 11398 Handle<DescriptorArray> descriptors(boilerplate_map->instance_descriptors()); |
11411 int limit = boilerplate_map->NumberOfOwnDescriptors(); | 11399 int limit = boilerplate_map->NumberOfOwnDescriptors(); |
11412 | 11400 |
11413 int copied_fields = 0; | 11401 int copied_fields = 0; |
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13150 if (ShouldProduceTraceOutput()) { | 13138 if (ShouldProduceTraceOutput()) { |
13151 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13139 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13152 } | 13140 } |
13153 | 13141 |
13154 #ifdef DEBUG | 13142 #ifdef DEBUG |
13155 graph_->Verify(false); // No full verify. | 13143 graph_->Verify(false); // No full verify. |
13156 #endif | 13144 #endif |
13157 } | 13145 } |
13158 | 13146 |
13159 } } // namespace v8::internal | 13147 } } // namespace v8::internal |
OLD | NEW |