| 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 11282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11293 NoObservableSideEffectsScope no_effects(this); | 11293 NoObservableSideEffectsScope no_effects(this); |
| 11294 Handle<Map> initial_map(boilerplate_object->map()); | 11294 Handle<Map> initial_map(boilerplate_object->map()); |
| 11295 InstanceType instance_type = initial_map->instance_type(); | 11295 InstanceType instance_type = initial_map->instance_type(); |
| 11296 DCHECK(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); | 11296 DCHECK(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); |
| 11297 | 11297 |
| 11298 HType type = instance_type == JS_ARRAY_TYPE | 11298 HType type = instance_type == JS_ARRAY_TYPE |
| 11299 ? HType::JSArray() : HType::JSObject(); | 11299 ? HType::JSArray() : HType::JSObject(); |
| 11300 HValue* object_size_constant = Add<HConstant>(initial_map->instance_size()); | 11300 HValue* object_size_constant = Add<HConstant>(initial_map->instance_size()); |
| 11301 | 11301 |
| 11302 PretenureFlag pretenure_flag = NOT_TENURED; | 11302 PretenureFlag pretenure_flag = NOT_TENURED; |
| 11303 Handle<AllocationSite> current_site(*site_context->current(), isolate()); | 11303 Handle<AllocationSite> top_site(*site_context->top(), isolate()); |
| 11304 if (FLAG_allocation_site_pretenuring) { | 11304 if (FLAG_allocation_site_pretenuring) { |
| 11305 pretenure_flag = current_site->GetPretenureMode(); | 11305 pretenure_flag = top_site->GetPretenureMode(); |
| 11306 top_info()->dependencies()->AssumeTenuringDecision(current_site); | |
| 11307 } | 11306 } |
| 11308 | 11307 |
| 11308 Handle<AllocationSite> current_site(*site_context->current(), isolate()); |
| 11309 if (*top_site == *current_site) { |
| 11310 // We install a dependency for pretenuring only on the outermost literal. |
| 11311 top_info()->dependencies()->AssumeTenuringDecision(top_site); |
| 11312 } |
| 11309 top_info()->dependencies()->AssumeTransitionStable(current_site); | 11313 top_info()->dependencies()->AssumeTransitionStable(current_site); |
| 11310 | 11314 |
| 11311 HInstruction* object = Add<HAllocate>( | 11315 HInstruction* object = Add<HAllocate>( |
| 11312 object_size_constant, type, pretenure_flag, instance_type, current_site); | 11316 object_size_constant, type, pretenure_flag, instance_type, top_site); |
| 11313 | 11317 |
| 11314 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the | 11318 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the |
| 11315 // elements array may not get folded into the object. Hence, we set the | 11319 // elements array may not get folded into the object. Hence, we set the |
| 11316 // elements pointer to empty fixed array and let store elimination remove | 11320 // elements pointer to empty fixed array and let store elimination remove |
| 11317 // this store in the folding case. | 11321 // this store in the folding case. |
| 11318 HConstant* empty_fixed_array = Add<HConstant>( | 11322 HConstant* empty_fixed_array = Add<HConstant>( |
| 11319 isolate()->factory()->empty_fixed_array()); | 11323 isolate()->factory()->empty_fixed_array()); |
| 11320 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11324 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11321 empty_fixed_array); | 11325 empty_fixed_array); |
| 11322 | 11326 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 11342 isolate()->factory()->CopyAndTenureFixedCOWArray( | 11346 isolate()->factory()->CopyAndTenureFixedCOWArray( |
| 11343 Handle<FixedArray>::cast(elements))); | 11347 Handle<FixedArray>::cast(elements))); |
| 11344 boilerplate_object->set_elements(*elements); | 11348 boilerplate_object->set_elements(*elements); |
| 11345 } | 11349 } |
| 11346 | 11350 |
| 11347 HInstruction* object_elements = NULL; | 11351 HInstruction* object_elements = NULL; |
| 11348 if (elements_size > 0) { | 11352 if (elements_size > 0) { |
| 11349 HValue* object_elements_size = Add<HConstant>(elements_size); | 11353 HValue* object_elements_size = Add<HConstant>(elements_size); |
| 11350 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() | 11354 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() |
| 11351 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; | 11355 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; |
| 11352 object_elements = | 11356 object_elements = Add<HAllocate>(object_elements_size, HType::HeapObject(), |
| 11353 Add<HAllocate>(object_elements_size, HType::HeapObject(), | 11357 pretenure_flag, instance_type, top_site); |
| 11354 pretenure_flag, instance_type, current_site); | |
| 11355 BuildEmitElements(boilerplate_object, elements, object_elements, | 11358 BuildEmitElements(boilerplate_object, elements, object_elements, |
| 11356 site_context); | 11359 site_context); |
| 11357 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11360 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11358 object_elements); | 11361 object_elements); |
| 11359 } else { | 11362 } else { |
| 11360 Handle<Object> elements_field = | 11363 Handle<Object> elements_field = |
| 11361 Handle<Object>(boilerplate_object->elements(), isolate()); | 11364 Handle<Object>(boilerplate_object->elements(), isolate()); |
| 11362 HInstruction* object_elements_cow = Add<HConstant>(elements_field); | 11365 HInstruction* object_elements_cow = Add<HConstant>(elements_field); |
| 11363 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11366 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
| 11364 object_elements_cow); | 11367 object_elements_cow); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11445 BuildFastLiteral(value_object, site_context); | 11448 BuildFastLiteral(value_object, site_context); |
| 11446 site_context->ExitScope(current_site, value_object); | 11449 site_context->ExitScope(current_site, value_object); |
| 11447 Add<HStoreNamedField>(object, access, result); | 11450 Add<HStoreNamedField>(object, access, result); |
| 11448 } else { | 11451 } else { |
| 11449 Representation representation = details.representation(); | 11452 Representation representation = details.representation(); |
| 11450 HInstruction* value_instruction; | 11453 HInstruction* value_instruction; |
| 11451 | 11454 |
| 11452 if (representation.IsDouble()) { | 11455 if (representation.IsDouble()) { |
| 11453 // Allocate a HeapNumber box and store the value into it. | 11456 // Allocate a HeapNumber box and store the value into it. |
| 11454 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); | 11457 HValue* heap_number_constant = Add<HConstant>(HeapNumber::kSize); |
| 11455 // This heap number alloc does not have a corresponding | |
| 11456 // AllocationSite. That is okay because | |
| 11457 // 1) it's a child object of another object with a valid allocation site | |
| 11458 // 2) we can just use the mode of the parent object for pretenuring | |
| 11459 HInstruction* double_box = | 11458 HInstruction* double_box = |
| 11460 Add<HAllocate>(heap_number_constant, HType::HeapObject(), | 11459 Add<HAllocate>(heap_number_constant, HType::HeapObject(), |
| 11461 pretenure_flag, MUTABLE_HEAP_NUMBER_TYPE); | 11460 pretenure_flag, MUTABLE_HEAP_NUMBER_TYPE); |
| 11462 AddStoreMapConstant(double_box, | 11461 AddStoreMapConstant(double_box, |
| 11463 isolate()->factory()->mutable_heap_number_map()); | 11462 isolate()->factory()->mutable_heap_number_map()); |
| 11464 // Unwrap the mutable heap number from the boilerplate. | 11463 // Unwrap the mutable heap number from the boilerplate. |
| 11465 HValue* double_value = | 11464 HValue* double_value = |
| 11466 Add<HConstant>(Handle<HeapNumber>::cast(value)->value()); | 11465 Add<HConstant>(Handle<HeapNumber>::cast(value)->value()); |
| 11467 Add<HStoreNamedField>( | 11466 Add<HStoreNamedField>( |
| 11468 double_box, HObjectAccess::ForHeapNumberValue(), double_value); | 11467 double_box, HObjectAccess::ForHeapNumberValue(), double_value); |
| (...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13152 if (ShouldProduceTraceOutput()) { | 13151 if (ShouldProduceTraceOutput()) { |
| 13153 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13152 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13154 } | 13153 } |
| 13155 | 13154 |
| 13156 #ifdef DEBUG | 13155 #ifdef DEBUG |
| 13157 graph_->Verify(false); // No full verify. | 13156 graph_->Verify(false); // No full verify. |
| 13158 #endif | 13157 #endif |
| 13159 } | 13158 } |
| 13160 | 13159 |
| 13161 } } // namespace v8::internal | 13160 } } // namespace v8::internal |
| OLD | NEW |