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

Side by Side Diff: src/heap.cc

Issue 3466013: Fix copy-on-write assert by setting the new array map early. (Closed)
Patch Set: Created 10 years, 3 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
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 3187 matching lines...) Expand 10 before | Expand all | Expand 10 after
3198 // Use the general function if we're forced to always allocate. 3198 // Use the general function if we're forced to always allocate.
3199 if (always_allocate()) return AllocateFixedArray(length, TENURED); 3199 if (always_allocate()) return AllocateFixedArray(length, TENURED);
3200 // Allocate the raw data for a fixed array. 3200 // Allocate the raw data for a fixed array.
3201 int size = FixedArray::SizeFor(length); 3201 int size = FixedArray::SizeFor(length);
3202 return size <= kMaxObjectSizeInNewSpace 3202 return size <= kMaxObjectSizeInNewSpace
3203 ? new_space_.AllocateRaw(size) 3203 ? new_space_.AllocateRaw(size)
3204 : lo_space_->AllocateRawFixedArray(size); 3204 : lo_space_->AllocateRawFixedArray(size);
3205 } 3205 }
3206 3206
3207 3207
3208 Object* Heap::CopyFixedArray(FixedArray* src) { 3208 Object* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) {
3209 int len = src->length(); 3209 int len = src->length();
3210 Object* obj = AllocateRawFixedArray(len); 3210 Object* obj = AllocateRawFixedArray(len);
3211 if (obj->IsFailure()) return obj; 3211 if (obj->IsFailure()) return obj;
3212 if (Heap::InNewSpace(obj)) { 3212 if (Heap::InNewSpace(obj)) {
3213 HeapObject* dst = HeapObject::cast(obj); 3213 HeapObject* dst = HeapObject::cast(obj);
3214 CopyBlock(dst->address(), src->address(), FixedArray::SizeFor(len)); 3214 dst->set_map(map);
3215 CopyBlock(dst->address() + kPointerSize,
3216 src->address() + kPointerSize,
3217 FixedArray::SizeFor(len) - kPointerSize);
3215 return obj; 3218 return obj;
3216 } 3219 }
3217 HeapObject::cast(obj)->set_map(src->map()); 3220 HeapObject::cast(obj)->set_map(map);
3218 FixedArray* result = FixedArray::cast(obj); 3221 FixedArray* result = FixedArray::cast(obj);
3219 result->set_length(len); 3222 result->set_length(len);
3220 3223
3221 // Copy the content 3224 // Copy the content
3222 AssertNoAllocation no_gc; 3225 AssertNoAllocation no_gc;
3223 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); 3226 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
3224 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); 3227 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode);
3225 return result; 3228 return result;
3226 } 3229 }
3227 3230
(...skipping 1737 matching lines...) Expand 10 before | Expand all | Expand 10 after
4965 void ExternalStringTable::TearDown() { 4968 void ExternalStringTable::TearDown() {
4966 new_space_strings_.Free(); 4969 new_space_strings_.Free();
4967 old_space_strings_.Free(); 4970 old_space_strings_.Free();
4968 } 4971 }
4969 4972
4970 4973
4971 List<Object*> ExternalStringTable::new_space_strings_; 4974 List<Object*> ExternalStringTable::new_space_strings_;
4972 List<Object*> ExternalStringTable::old_space_strings_; 4975 List<Object*> ExternalStringTable::old_space_strings_;
4973 4976
4974 } } // namespace v8::internal 4977 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698