Fix FixedDoubleArray crashes in chromebot
R=ricow@chromium.org BUG=non TEST=running urls from reliability bots Review URL: http://codereview.chromium.org/7497010 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8748 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
4ac6f0253f
commit
b7300c6fb1
@ -142,6 +142,11 @@ MaybeObject* Heap::CopyFixedArray(FixedArray* src) {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::CopyFixedDoubleArray(FixedDoubleArray* src) {
|
||||
return CopyFixedDoubleArrayWithMap(src, src->map());
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::AllocateRaw(int size_in_bytes,
|
||||
AllocationSpace space,
|
||||
AllocationSpace retry_space) {
|
||||
|
32
src/heap.cc
32
src/heap.cc
@ -3388,17 +3388,22 @@ MaybeObject* Heap::CopyJSObject(JSObject* source) {
|
||||
object_size);
|
||||
}
|
||||
|
||||
FixedArray* elements = FixedArray::cast(source->elements());
|
||||
FixedArrayBase* elements = FixedArrayBase::cast(source->elements());
|
||||
FixedArray* properties = FixedArray::cast(source->properties());
|
||||
// Update elements if necessary.
|
||||
if (elements->length() > 0) {
|
||||
Object* elem;
|
||||
{ MaybeObject* maybe_elem =
|
||||
(elements->map() == fixed_cow_array_map()) ?
|
||||
elements : CopyFixedArray(elements);
|
||||
{ MaybeObject* maybe_elem;
|
||||
if (elements->map() == fixed_cow_array_map()) {
|
||||
maybe_elem = FixedArray::cast(elements);
|
||||
} else if (source->HasFastDoubleElements()) {
|
||||
maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements));
|
||||
} else {
|
||||
maybe_elem = CopyFixedArray(FixedArray::cast(elements));
|
||||
}
|
||||
if (!maybe_elem->ToObject(&elem)) return maybe_elem;
|
||||
}
|
||||
JSObject::cast(clone)->set_elements(FixedArray::cast(elem));
|
||||
JSObject::cast(clone)->set_elements(FixedArrayBase::cast(elem));
|
||||
}
|
||||
// Update properties if necessary.
|
||||
if (properties->length() > 0) {
|
||||
@ -3757,6 +3762,23 @@ MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) {
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src,
|
||||
Map* map) {
|
||||
int len = src->length();
|
||||
Object* obj;
|
||||
{ MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(len, NOT_TENURED);
|
||||
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
||||
}
|
||||
HeapObject* dst = HeapObject::cast(obj);
|
||||
dst->set_map(map);
|
||||
CopyBlock(
|
||||
dst->address() + FixedDoubleArray::kLengthOffset,
|
||||
src->address() + FixedDoubleArray::kLengthOffset,
|
||||
FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
MaybeObject* Heap::AllocateFixedArray(int length) {
|
||||
ASSERT(length >= 0);
|
||||
if (length == 0) return empty_fixed_array();
|
||||
|
10
src/heap.h
10
src/heap.h
@ -617,6 +617,16 @@ class Heap {
|
||||
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
|
||||
MUST_USE_RESULT MaybeObject* CopyFixedArrayWithMap(FixedArray* src, Map* map);
|
||||
|
||||
// Make a copy of src and return it. Returns
|
||||
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
|
||||
MUST_USE_RESULT inline MaybeObject* CopyFixedDoubleArray(
|
||||
FixedDoubleArray* src);
|
||||
|
||||
// Make a copy of src, set the map, and return the copy. Returns
|
||||
// Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
|
||||
MUST_USE_RESULT MaybeObject* CopyFixedDoubleArrayWithMap(
|
||||
FixedDoubleArray* src, Map* map);
|
||||
|
||||
// Allocates a fixed array initialized with the hole values.
|
||||
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
|
||||
// failed.
|
||||
|
@ -219,8 +219,20 @@ MUST_USE_RESULT static MaybeObject* DeepCopyBoilerplate(Isolate* isolate,
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNREACHABLE();
|
||||
case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS:
|
||||
UNIMPLEMENTED();
|
||||
break;
|
||||
case JSObject::EXTERNAL_PIXEL_ELEMENTS:
|
||||
case JSObject::EXTERNAL_BYTE_ELEMENTS:
|
||||
case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
|
||||
case JSObject::EXTERNAL_SHORT_ELEMENTS:
|
||||
case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
|
||||
case JSObject::EXTERNAL_INT_ELEMENTS:
|
||||
case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS:
|
||||
case JSObject::EXTERNAL_FLOAT_ELEMENTS:
|
||||
case JSObject::EXTERNAL_DOUBLE_ELEMENTS:
|
||||
case JSObject::FAST_DOUBLE_ELEMENTS:
|
||||
// No contained objects, nothing to do.
|
||||
break;
|
||||
}
|
||||
return copy;
|
||||
|
Loading…
Reference in New Issue
Block a user