Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: src/hydrogen.cc

Issue 211103003: Always initialize elements pointer in fast literals. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 9742 matching lines...) Expand 10 before | Expand all | Expand 10 after
9753 if (FLAG_allocation_site_pretenuring) { 9753 if (FLAG_allocation_site_pretenuring) {
9754 pretenure_flag = site_context->current()->GetPretenureMode(); 9754 pretenure_flag = site_context->current()->GetPretenureMode();
9755 Handle<AllocationSite> site(site_context->current()); 9755 Handle<AllocationSite> site(site_context->current());
9756 AllocationSite::AddDependentCompilationInfo( 9756 AllocationSite::AddDependentCompilationInfo(
9757 site, AllocationSite::TENURING, top_info()); 9757 site, AllocationSite::TENURING, top_info());
9758 } 9758 }
9759 9759
9760 HInstruction* object = Add<HAllocate>(object_size_constant, type, 9760 HInstruction* object = Add<HAllocate>(object_size_constant, type,
9761 pretenure_flag, instance_type, site_context->current()); 9761 pretenure_flag, instance_type, site_context->current());
9762 9762
9763 // If allocation folding reaches Page::kMaxRegularHeapObjectSize the
9764 // elements array may not get folded into the object. Hence, we set the
9765 // elements pointer to empty fixed array and let store elimination remove
9766 // this store in the folding case.
9767 HConstant* empty_fixed_array = Add<HConstant>(
9768 isolate()->factory()->empty_fixed_array());
9769 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9770 empty_fixed_array, INITIALIZING_STORE);
9771
9763 BuildEmitObjectHeader(boilerplate_object, object); 9772 BuildEmitObjectHeader(boilerplate_object, object);
9764 9773
9765 Handle<FixedArrayBase> elements(boilerplate_object->elements()); 9774 Handle<FixedArrayBase> elements(boilerplate_object->elements());
9766 int elements_size = (elements->length() > 0 && 9775 int elements_size = (elements->length() > 0 &&
9767 elements->map() != isolate()->heap()->fixed_cow_array_map()) ? 9776 elements->map() != isolate()->heap()->fixed_cow_array_map()) ?
9768 elements->Size() : 0; 9777 elements->Size() : 0;
9769 9778
9770 if (pretenure_flag == TENURED && 9779 if (pretenure_flag == TENURED &&
9771 elements->map() == isolate()->heap()->fixed_cow_array_map() && 9780 elements->map() == isolate()->heap()->fixed_cow_array_map() &&
9772 isolate()->heap()->InNewSpace(*elements)) { 9781 isolate()->heap()->InNewSpace(*elements)) {
9773 // If we would like to pretenure a fixed cow array, we must ensure that the 9782 // If we would like to pretenure a fixed cow array, we must ensure that the
9774 // array is already in old space, otherwise we'll create too many old-to- 9783 // array is already in old space, otherwise we'll create too many old-to-
9775 // new-space pointers (overflowing the store buffer). 9784 // new-space pointers (overflowing the store buffer).
9776 elements = Handle<FixedArrayBase>( 9785 elements = Handle<FixedArrayBase>(
9777 isolate()->factory()->CopyAndTenureFixedCOWArray( 9786 isolate()->factory()->CopyAndTenureFixedCOWArray(
9778 Handle<FixedArray>::cast(elements))); 9787 Handle<FixedArray>::cast(elements)));
9779 boilerplate_object->set_elements(*elements); 9788 boilerplate_object->set_elements(*elements);
9780 } 9789 }
9781 9790
9782 HInstruction* object_elements = NULL; 9791 HInstruction* object_elements = NULL;
9783 if (elements_size > 0) { 9792 if (elements_size > 0) {
9784 HValue* object_elements_size = Add<HConstant>(elements_size); 9793 HValue* object_elements_size = Add<HConstant>(elements_size);
9785 if (boilerplate_object->HasFastDoubleElements()) { 9794 if (boilerplate_object->HasFastDoubleElements()) {
9786 // Allocation folding will not be able to fold |object| and
9787 // |object_elements| together if they are pre-tenured.
9788 if (pretenure_flag == TENURED) {
9789 HConstant* empty_fixed_array = Add<HConstant>(
9790 isolate()->factory()->empty_fixed_array());
9791 Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(),
9792 empty_fixed_array);
9793 }
9794 object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(), 9795 object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(),
9795 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current()); 9796 pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current());
9796 } else { 9797 } else {
9797 object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(), 9798 object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(),
9798 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current()); 9799 pretenure_flag, FIXED_ARRAY_TYPE, site_context->current());
9799 } 9800 }
9800 } 9801 }
9801 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements); 9802 BuildInitElementsInObjectHeader(boilerplate_object, object, object_elements);
9802 9803
9803 // Copy object elements if non-COW. 9804 // Copy object elements if non-COW.
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
11307 if (ShouldProduceTraceOutput()) { 11308 if (ShouldProduceTraceOutput()) {
11308 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 11309 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
11309 } 11310 }
11310 11311
11311 #ifdef DEBUG 11312 #ifdef DEBUG
11312 graph_->Verify(false); // No full verify. 11313 graph_->Verify(false); // No full verify.
11313 #endif 11314 #endif
11314 } 11315 }
11315 11316
11316 } } // namespace v8::internal 11317 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698