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 5572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5583 Handle<JSObject> boilerplate; | 5583 Handle<JSObject> boilerplate; |
5584 if (!literals_cell->IsUndefined()) { | 5584 if (!literals_cell->IsUndefined()) { |
5585 // Retrieve the boilerplate | 5585 // Retrieve the boilerplate |
5586 site = Handle<AllocationSite>::cast(literals_cell); | 5586 site = Handle<AllocationSite>::cast(literals_cell); |
5587 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), | 5587 boilerplate = Handle<JSObject>(JSObject::cast(site->transition_info()), |
5588 isolate()); | 5588 isolate()); |
5589 } | 5589 } |
5590 | 5590 |
5591 if (!boilerplate.is_null() && | 5591 if (!boilerplate.is_null() && |
5592 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { | 5592 IsFastLiteral(boilerplate, kMaxFastLiteralDepth, &max_properties)) { |
5593 AllocationSiteUsageContext usage_context(isolate(), site, false); | 5593 AllocationSiteUsageContext site_context(isolate(), site, false); |
5594 usage_context.EnterNewScope(); | 5594 site_context.EnterNewScope(); |
5595 literal = BuildFastLiteral(boilerplate, &usage_context); | 5595 literal = BuildFastLiteral(boilerplate, &site_context); |
5596 usage_context.ExitScope(site, boilerplate); | 5596 site_context.ExitScope(site, boilerplate); |
5597 } else { | 5597 } else { |
5598 NoObservableSideEffectsScope no_effects(this); | 5598 NoObservableSideEffectsScope no_effects(this); |
5599 Handle<FixedArray> closure_literals(closure->literals(), isolate()); | 5599 Handle<FixedArray> closure_literals(closure->literals(), isolate()); |
5600 Handle<FixedArray> constant_properties = expr->constant_properties(); | 5600 Handle<FixedArray> constant_properties = expr->constant_properties(); |
5601 int literal_index = expr->literal_index(); | 5601 int literal_index = expr->literal_index(); |
5602 int flags = expr->ComputeFlags(true); | 5602 int flags = expr->ComputeFlags(true); |
5603 | 5603 |
5604 Add<HPushArguments>(Add<HConstant>(closure_literals), | 5604 Add<HPushArguments>(Add<HConstant>(closure_literals), |
5605 Add<HConstant>(literal_index), | 5605 Add<HConstant>(literal_index), |
5606 Add<HConstant>(constant_properties), | 5606 Add<HConstant>(constant_properties), |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5747 DCHECK(site->SitePointsToLiteral()); | 5747 DCHECK(site->SitePointsToLiteral()); |
5748 | 5748 |
5749 ElementsKind boilerplate_elements_kind = | 5749 ElementsKind boilerplate_elements_kind = |
5750 boilerplate_object->GetElementsKind(); | 5750 boilerplate_object->GetElementsKind(); |
5751 | 5751 |
5752 // Check whether to use fast or slow deep-copying for boilerplate. | 5752 // Check whether to use fast or slow deep-copying for boilerplate. |
5753 int max_properties = kMaxFastLiteralProperties; | 5753 int max_properties = kMaxFastLiteralProperties; |
5754 if (IsFastLiteral(boilerplate_object, | 5754 if (IsFastLiteral(boilerplate_object, |
5755 kMaxFastLiteralDepth, | 5755 kMaxFastLiteralDepth, |
5756 &max_properties)) { | 5756 &max_properties)) { |
5757 AllocationSiteUsageContext usage_context(isolate(), site, false); | 5757 AllocationSiteUsageContext site_context(isolate(), site, false); |
5758 usage_context.EnterNewScope(); | 5758 site_context.EnterNewScope(); |
5759 literal = BuildFastLiteral(boilerplate_object, &usage_context); | 5759 literal = BuildFastLiteral(boilerplate_object, &site_context); |
5760 usage_context.ExitScope(site, boilerplate_object); | 5760 site_context.ExitScope(site, boilerplate_object); |
5761 } else { | 5761 } else { |
5762 NoObservableSideEffectsScope no_effects(this); | 5762 NoObservableSideEffectsScope no_effects(this); |
5763 // Boilerplate already exists and constant elements are never accessed, | 5763 // Boilerplate already exists and constant elements are never accessed, |
5764 // pass an empty fixed array to the runtime function instead. | 5764 // pass an empty fixed array to the runtime function instead. |
5765 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); | 5765 Handle<FixedArray> constants = isolate()->factory()->empty_fixed_array(); |
5766 int literal_index = expr->literal_index(); | 5766 int literal_index = expr->literal_index(); |
5767 int flags = expr->ComputeFlags(true); | 5767 int flags = expr->ComputeFlags(true); |
5768 | 5768 |
5769 Add<HPushArguments>(Add<HConstant>(literals), | 5769 Add<HPushArguments>(Add<HConstant>(literals), |
5770 Add<HConstant>(literal_index), | 5770 Add<HConstant>(literal_index), |
(...skipping 5303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11074 NoObservableSideEffectsScope no_effects(this); | 11074 NoObservableSideEffectsScope no_effects(this); |
11075 InstanceType instance_type = boilerplate_object->map()->instance_type(); | 11075 InstanceType instance_type = boilerplate_object->map()->instance_type(); |
11076 DCHECK(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); | 11076 DCHECK(instance_type == JS_ARRAY_TYPE || instance_type == JS_OBJECT_TYPE); |
11077 | 11077 |
11078 HType type = instance_type == JS_ARRAY_TYPE | 11078 HType type = instance_type == JS_ARRAY_TYPE |
11079 ? HType::JSArray() : HType::JSObject(); | 11079 ? HType::JSArray() : HType::JSObject(); |
11080 HValue* object_size_constant = Add<HConstant>( | 11080 HValue* object_size_constant = Add<HConstant>( |
11081 boilerplate_object->map()->instance_size()); | 11081 boilerplate_object->map()->instance_size()); |
11082 | 11082 |
11083 PretenureFlag pretenure_flag = NOT_TENURED; | 11083 PretenureFlag pretenure_flag = NOT_TENURED; |
11084 Handle<AllocationSite> site(site_context->current()); | 11084 Handle<AllocationSite> current_site(*site_context->current(), isolate()); |
11085 if (FLAG_allocation_site_pretenuring) { | 11085 if (FLAG_allocation_site_pretenuring) { |
11086 pretenure_flag = site_context->current()->GetPretenureMode(); | 11086 pretenure_flag = current_site->GetPretenureMode(); |
11087 AllocationSite::RegisterForDeoptOnTenureChange(site, top_info()); | 11087 AllocationSite::RegisterForDeoptOnTenureChange(current_site, top_info()); |
11088 } | 11088 } |
11089 | 11089 |
11090 AllocationSite::RegisterForDeoptOnTransitionChange(site, top_info()); | 11090 AllocationSite::RegisterForDeoptOnTransitionChange(current_site, top_info()); |
11091 | 11091 |
11092 HInstruction* object = Add<HAllocate>(object_size_constant, type, | 11092 HInstruction* object = Add<HAllocate>( |
11093 pretenure_flag, instance_type, site_context->current()); | 11093 object_size_constant, type, pretenure_flag, instance_type, current_site); |
11094 | 11094 |
11095 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the | 11095 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the |
11096 // elements array may not get folded into the object. Hence, we set the | 11096 // elements array may not get folded into the object. Hence, we set the |
11097 // elements pointer to empty fixed array and let store elimination remove | 11097 // elements pointer to empty fixed array and let store elimination remove |
11098 // this store in the folding case. | 11098 // this store in the folding case. |
11099 HConstant* empty_fixed_array = Add<HConstant>( | 11099 HConstant* empty_fixed_array = Add<HConstant>( |
11100 isolate()->factory()->empty_fixed_array()); | 11100 isolate()->factory()->empty_fixed_array()); |
11101 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), | 11101 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
11102 empty_fixed_array); | 11102 empty_fixed_array); |
11103 | 11103 |
(...skipping 14 matching lines...) Expand all Loading... |
11118 isolate()->factory()->CopyAndTenureFixedCOWArray( | 11118 isolate()->factory()->CopyAndTenureFixedCOWArray( |
11119 Handle<FixedArray>::cast(elements))); | 11119 Handle<FixedArray>::cast(elements))); |
11120 boilerplate_object->set_elements(*elements); | 11120 boilerplate_object->set_elements(*elements); |
11121 } | 11121 } |
11122 | 11122 |
11123 HInstruction* object_elements = NULL; | 11123 HInstruction* object_elements = NULL; |
11124 if (elements_size > 0) { | 11124 if (elements_size > 0) { |
11125 HValue* object_elements_size = Add<HConstant>(elements_size); | 11125 HValue* object_elements_size = Add<HConstant>(elements_size); |
11126 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() | 11126 InstanceType instance_type = boilerplate_object->HasFastDoubleElements() |
11127 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; | 11127 ? FIXED_DOUBLE_ARRAY_TYPE : FIXED_ARRAY_TYPE; |
11128 object_elements = Add<HAllocate>( | 11128 object_elements = |
11129 object_elements_size, HType::HeapObject(), | 11129 Add<HAllocate>(object_elements_size, HType::HeapObject(), |
11130 pretenure_flag, instance_type, site_context->current()); | 11130 pretenure_flag, instance_type, current_site); |
11131 } | 11131 } |
11132 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); | 11132 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); |
11133 | 11133 |
11134 // Copy object elements if non-COW. | 11134 // Copy object elements if non-COW. |
11135 if (object_elements != NULL) { | 11135 if (object_elements != NULL) { |
11136 BuildEmitElements(boilerplate_object, elements, object_elements, | 11136 BuildEmitElements(boilerplate_object, elements, object_elements, |
11137 site_context); | 11137 site_context); |
11138 } | 11138 } |
11139 | 11139 |
11140 // Copy in-object properties. | 11140 // Copy in-object properties. |
(...skipping 1824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12965 if (ShouldProduceTraceOutput()) { | 12965 if (ShouldProduceTraceOutput()) { |
12966 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12966 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12967 } | 12967 } |
12968 | 12968 |
12969 #ifdef DEBUG | 12969 #ifdef DEBUG |
12970 graph_->Verify(false); // No full verify. | 12970 graph_->Verify(false); // No full verify. |
12971 #endif | 12971 #endif |
12972 } | 12972 } |
12973 | 12973 |
12974 } } // namespace v8::internal | 12974 } } // namespace v8::internal |
OLD | NEW |