| 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 11335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11346 NoObservableSideEffectsScope no_effects(this); | 11346 NoObservableSideEffectsScope no_effects(this); |
| 11347 Handle<Map> initial_map(boilerplate_object->map()); | 11347 Handle<Map> initial_map(boilerplate_object->map()); |
| 11348 InstanceType instance_type = initial_map->instance_type(); | 11348 InstanceType instance_type = initial_map->instance_type(); |
| 11349 DCHECK(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); | 11349 DCHECK(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); |
| 11350 | 11350 |
| 11351 HType type = instance_type == JS_ARRAY_TYPE | 11351 HType type = instance_type == JS_ARRAY_TYPE |
| 11352 ? HType::JSArray() : HType::JSObject(); | 11352 ? HType::JSArray() : HType::JSObject(); |
| 11353 HValue* object_size_constant = Add<HConstant>(initial_map->instance_size()); | 11353 HValue* object_size_constant = Add<HConstant>(initial_map->instance_size()); |
| 11354 | 11354 |
| 11355 PretenureFlag pretenure_flag = NOT_TENURED; | 11355 PretenureFlag pretenure_flag = NOT_TENURED; |
| 11356 Handle<AllocationSite> current_site(*site_context->current(), isolate()); | 11356 Handle<AllocationSite> top_site(*site_context->top(), isolate()); |
| 11357 if (FLAG_allocation_site_pretenuring) { | 11357 if (FLAG_allocation_site_pretenuring) { |
| 11358 pretenure_flag = current_site->GetPretenureMode(); | 11358 pretenure_flag = top_site->GetPretenureMode(); |
| 11359 top_info()->dependencies()->AssumeTenuringDecision(current_site); | |
| 11360 } | 11359 } |
| 11361 | 11360 |
| 11361 Handle<AllocationSite> current_site(*site_context->current(), isolate()); |
| 11362 if (*top_site == *current_site) { |
| 11363 // We install a dependency for pretenuring only on the outermost literal. |
| 11364 top_info()->dependencies()->AssumeTenuringDecision(top_site); |
| 11365 } |
| 11362 top_info()->dependencies()->AssumeTransitionStable(current_site); | 11366 top_info()->dependencies()->AssumeTransitionStable(current_site); |
| 11363 | 11367 |
| 11364 HInstruction* object = Add<HAllocate>( | 11368 HInstruction* object = Add<HAllocate>( |
| 11365 object_size_constant, type, pretenure_flag, instance_type, current_site); | 11369 object_size_constant, type, pretenure_flag, instance_type, top_site); |
| 11366 | 11370 |
| 11367 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the | 11371 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the |
| 11368 // elements array may not get folded into the object. Hence, we set the | 11372 // elements array may not get folded into the object. Hence, we set the |
| 11369 // elements pointer to empty fixed array and let store elimination remove | 11373 // elements pointer to empty fixed array and let store elimination remove |
| 11370 // this store in the folding case. | 11374 // this store in the folding case. |
| 11371 HConstant* empty_fixed_array = Add<HConstant>( | 11375 HConstant* empty_fixed_array = Add<HConstant>( |
| 11372 isolate()->factory()->empty_fixed_array()); | 11376 isolate()->factory()->empty_fixed_array()); |
| 11373 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11377 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11374 empty_fixed_array); | 11378 empty_fixed_array); |
| 11375 | 11379 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11395 isolate()->factory()->CopyAndTenureFixedCOWArray( | 11399 isolate()->factory()->CopyAndTenureFixedCOWArray( |
| 11396 Handle<FixedArray>::cast(elements))); | 11400 Handle<FixedArray>::cast(elements))); |
| 11397 boilerplate_object->set_elements(*elements); | 11401 boilerplate_object->set_elements(*elements); |
| 11398 } | 11402 } |
| 11399 | 11403 |
| 11400 HInstruction* object_elements = NULL; | 11404 HInstruction* object_elements = NULL; |
| 11401 if (elements_size > 0) { | 11405 if (elements_size > 0) { |
| 11402 HValue* object_elements_size = Add<HConstant>(elements_size); | 11406 HValue* object_elements_size = Add<HConstant>(elements_size); |
| 11403 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() | 11407 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() |
| 11404 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; | 11408 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; |
| 11405 object_elements = | 11409 object_elements = Add<HAllocate>(object_elements_size, HType::HeapObject(), |
| 11406 Add<HAllocate>(object_elements_size, HType::HeapObject(), | 11410 pretenure_flag, instance_type, top_site); |
| 11407 pretenure_flag, instance_type, current_site); | |
| 11408 BuildEmitElements(boilerplate_object, elements, object_elements, | 11411 BuildEmitElements(boilerplate_object, elements, object_elements, |
| 11409 site_context); | 11412 site_context); |
| 11410 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11413 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11411 object_elements); | 11414 object_elements); |
| 11412 } else { | 11415 } else { |
| 11413 Handle<Object> elements_field = | 11416 Handle<Object> elements_field = |
| 11414 Handle<Object>(boilerplate_object->elements(), isolate()); | 11417 Handle<Object>(boilerplate_object->elements(), isolate()); |
| 11415 HInstruction* object_elements_cow = Add<HConstant>(elements_field); | 11418 HInstruction* object_elements_cow = Add<HConstant>(elements_field); |
| 11416 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11419 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11417 object_elements_cow); | 11420 object_elements_cow); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11498 BuildFastLiteral(value_object, site_context); | 11501 BuildFastLiteral(value_object, site_context); |
| 11499 site_context->ExitScope(current_site, value_object); | 11502 site_context->ExitScope(current_site, value_object); |
| 11500 Add<HStoreNamedField>(object, access, result); | 11503 Add<HStoreNamedField>(object, access, result); |
| 11501 } else { | 11504 } else { |
| 11502 Representation representation = details.representation(); | 11505 Representation representation = details.representation(); |
| 11503 HInstruction* value_instruction; | 11506 HInstruction* value_instruction; |
| 11504 | 11507 |
| 11505 if (representation.IsDouble()) { | 11508 if (representation.IsDouble()) { |
| 11506 // Allocate a HeapNumber box and store the value into it. | 11509 // Allocate a HeapNumber box and store the value into it. |
| 11507 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); | 11510 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); |
| 11508 // This heap number alloc does not have a corresponding | |
| 11509 // AllocationSite. That is okay because | |
| 11510 // 1) it's a child object of another object with a valid allocation site | |
| 11511 // 2) we can just use the mode of the parent object for pretenuring | |
| 11512 HInstruction* double_box = | 11511 HInstruction* double_box = |
| 11513 Add<HAllocate>(heap_number_constant, HType::HeapObject(), | 11512 Add<HAllocate>(heap_number_constant, HType::HeapObject(), |
| 11514 pretenure_flag, MUTABLE_HEAP_NUMBER_TYPE); | 11513 pretenure_flag, MUTABLE_HEAP_NUMBER_TYPE); |
| 11515 AddStoreMapConstant(double_box, | 11514 AddStoreMapConstant(double_box, |
| 11516 isolate()->factory()->mutable_heap_number_map()); | 11515 isolate()->factory()->mutable_heap_number_map()); |
| 11517 // Unwrap the mutable heap number from the boilerplate. | 11516 // Unwrap the mutable heap number from the boilerplate. |
| 11518 HValue* double_value = | 11517 HValue* double_value = |
| 11519 Add<HConstant>(Handle<HeapNumber>::cast(value)->value()); | 11518 Add<HConstant>(Handle<HeapNumber>::cast(value)->value()); |
| 11520 Add<HStoreNamedField>( | 11519 Add<HStoreNamedField>( |
| 11521 double_box, HObjectAccess::ForHeapNumberValue(), double_value); | 11520 double_box, HObjectAccess::ForHeapNumberValue(), double_value); |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13245 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13244 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13246 } | 13245 } |
| 13247 | 13246 |
| 13248 #ifdef DEBUG | 13247 #ifdef DEBUG |
| 13249 graph_->Verify(false); // No full verify. | 13248 graph_->Verify(false); // No full verify. |
| 13250 #endif | 13249 #endif |
| 13251 } | 13250 } |
| 13252 | 13251 |
| 13253 } // namespace internal | 13252 } // namespace internal |
| 13254 } // namespace v8 | 13253 } // namespace v8 |
| OLD | NEW |