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

Side by Side Diff: src/heap.cc

Issue 7497010: Fix FixedDoubleArray crashes in chromebot (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 5 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 | « 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 3370 matching lines...) Expand 10 before | Expand all | Expand 10 after
3381 if (!maybe_clone->ToObject(&clone)) return maybe_clone; 3381 if (!maybe_clone->ToObject(&clone)) return maybe_clone;
3382 } 3382 }
3383 ASSERT(InNewSpace(clone)); 3383 ASSERT(InNewSpace(clone));
3384 // Since we know the clone is allocated in new space, we can copy 3384 // Since we know the clone is allocated in new space, we can copy
3385 // the contents without worrying about updating the write barrier. 3385 // the contents without worrying about updating the write barrier.
3386 CopyBlock(HeapObject::cast(clone)->address(), 3386 CopyBlock(HeapObject::cast(clone)->address(),
3387 source->address(), 3387 source->address(),
3388 object_size); 3388 object_size);
3389 } 3389 }
3390 3390
3391 FixedArray* elements = FixedArray::cast(source->elements()); 3391 FixedArrayBase* elements = FixedArrayBase::cast(source->elements());
3392 FixedArray* properties = FixedArray::cast(source->properties()); 3392 FixedArray* properties = FixedArray::cast(source->properties());
3393 // Update elements if necessary. 3393 // Update elements if necessary.
3394 if (elements->length() > 0) { 3394 if (elements->length() > 0) {
3395 Object* elem; 3395 Object* elem;
3396 { MaybeObject* maybe_elem = 3396 { MaybeObject* maybe_elem;
3397 (elements->map() == fixed_cow_array_map()) ? 3397 if (elements->map() == fixed_cow_array_map()) {
3398 elements : CopyFixedArray(elements); 3398 maybe_elem = FixedArray::cast(elements);
3399 } else if (source->HasFastDoubleElements()) {
3400 maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements));
3401 } else {
3402 maybe_elem = CopyFixedArray(FixedArray::cast(elements));
3403 }
3399 if (!maybe_elem->ToObject(&elem)) return maybe_elem; 3404 if (!maybe_elem->ToObject(&elem)) return maybe_elem;
3400 } 3405 }
3401 JSObject::cast(clone)->set_elements(FixedArray::cast(elem)); 3406 JSObject::cast(clone)->set_elements(FixedArrayBase::cast(elem));
3402 } 3407 }
3403 // Update properties if necessary. 3408 // Update properties if necessary.
3404 if (properties->length() > 0) { 3409 if (properties->length() > 0) {
3405 Object* prop; 3410 Object* prop;
3406 { MaybeObject* maybe_prop = CopyFixedArray(properties); 3411 { MaybeObject* maybe_prop = CopyFixedArray(properties);
3407 if (!maybe_prop->ToObject(&prop)) return maybe_prop; 3412 if (!maybe_prop->ToObject(&prop)) return maybe_prop;
3408 } 3413 }
3409 JSObject::cast(clone)->set_properties(FixedArray::cast(prop)); 3414 JSObject::cast(clone)->set_properties(FixedArray::cast(prop));
3410 } 3415 }
3411 // Return the new clone. 3416 // Return the new clone.
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
3750 result->set_length(len); 3755 result->set_length(len);
3751 3756
3752 // Copy the content 3757 // Copy the content
3753 AssertNoAllocation no_gc; 3758 AssertNoAllocation no_gc;
3754 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); 3759 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc);
3755 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); 3760 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode);
3756 return result; 3761 return result;
3757 } 3762 }
3758 3763
3759 3764
3765 MaybeObject* Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src,
3766 Map* map) {
3767 int len = src->length();
3768 Object* obj;
3769 { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(len, NOT_TENURED);
3770 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3771 }
3772 HeapObject* dst = HeapObject::cast(obj);
3773 dst->set_map(map);
3774 CopyBlock(
3775 dst->address() + FixedDoubleArray::kLengthOffset,
3776 src->address() + FixedDoubleArray::kLengthOffset,
3777 FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset);
3778 return obj;
3779 }
3780
3781
3760 MaybeObject* Heap::AllocateFixedArray(int length) { 3782 MaybeObject* Heap::AllocateFixedArray(int length) {
3761 ASSERT(length >= 0); 3783 ASSERT(length >= 0);
3762 if (length == 0) return empty_fixed_array(); 3784 if (length == 0) return empty_fixed_array();
3763 Object* result; 3785 Object* result;
3764 { MaybeObject* maybe_result = AllocateRawFixedArray(length); 3786 { MaybeObject* maybe_result = AllocateRawFixedArray(length);
3765 if (!maybe_result->ToObject(&result)) return maybe_result; 3787 if (!maybe_result->ToObject(&result)) return maybe_result;
3766 } 3788 }
3767 // Initialize header. 3789 // Initialize header.
3768 FixedArray* array = reinterpret_cast<FixedArray*>(result); 3790 FixedArray* array = reinterpret_cast<FixedArray*>(result);
3769 array->set_map(fixed_array_map()); 3791 array->set_map(fixed_array_map());
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after
6024 } 6046 }
6025 6047
6026 6048
6027 void ExternalStringTable::TearDown() { 6049 void ExternalStringTable::TearDown() {
6028 new_space_strings_.Free(); 6050 new_space_strings_.Free();
6029 old_space_strings_.Free(); 6051 old_space_strings_.Free();
6030 } 6052 }
6031 6053
6032 6054
6033 } } // namespace v8::internal 6055 } } // 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