Fixed a few cases where allocators did not respect always_allocate,

potentially leading to bogus FatalProcessOutOfMemory situations.  Also
fixed a few cases where callers relied on getting a NewSpace object
back (to avoid write barrier overhead) which they can't when
always_allocate is in effect.

Review URL: http://codereview.chromium.org/391018


git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3285 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6d91ffda
......@@ -1727,6 +1727,7 @@ Object* Heap::AllocateProxy(Address proxy, PretenureFlag pretenure) {
// Statically ensure that it is safe to allocate proxies in paged spaces.
STATIC_ASSERT(Proxy::kSize <= Page::kMaxHeapObjectSize);
AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
if (always_allocate()) space = OLD_DATA_SPACE;
Object* result = Allocate(proxy_map(), space);
if (result->IsFailure()) return result;
......@@ -1822,12 +1823,13 @@ Object* Heap::AllocateConsString(String* first, String* second) {
: long_cons_string_map();
}
Object* result = Allocate(map, NEW_SPACE);
Object* result = Allocate(map,
always_allocate() ? OLD_POINTER_SPACE : NEW_SPACE);
if (result->IsFailure()) return result;
ASSERT(InNewSpace(result));
ConsString* cons_string = ConsString::cast(result);
cons_string->set_first(first, SKIP_WRITE_BARRIER);
cons_string->set_second(second, SKIP_WRITE_BARRIER);
WriteBarrierMode mode = cons_string->GetWriteBarrierMode();
cons_string->set_first(first, mode);
cons_string->set_second(second, mode);
cons_string->set_length(length);
return result;
}
......@@ -1884,7 +1886,8 @@ Object* Heap::AllocateExternalStringFromAscii(
return Failure::OutOfMemoryException();
}
Object* result = Allocate(map, NEW_SPACE);
Object* result = Allocate(map,
always_allocate() ? OLD_DATA_SPACE : NEW_SPACE);
if (result->IsFailure()) return result;
ExternalAsciiString* external_string = ExternalAsciiString::cast(result);
......@@ -1903,7 +1906,8 @@ Object* Heap::AllocateExternalStringFromTwoByte(
return Failure::OutOfMemoryException();
}
Map* map = ExternalTwoByteString::StringMap(static_cast<int>(length));
Object* result = Allocate(map, NEW_SPACE);
Object* result = Allocate(map,
always_allocate() ? OLD_DATA_SPACE : NEW_SPACE);
if (result->IsFailure()) return result;
ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result);
......@@ -2288,6 +2292,7 @@ Object* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) {
AllocationSpace space =
(pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE;
if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE;
if (always_allocate()) space = OLD_POINTER_SPACE;
Object* obj = Allocate(map, space);
if (obj->IsFailure()) return obj;
......
......@@ -4368,8 +4368,6 @@ static Object* Runtime_NewArgumentsFast(Arguments args) {
Object* result = Heap::AllocateArgumentsObject(callee, length);
if (result->IsFailure()) return result;
ASSERT(Heap::InNewSpace(result));
// Allocate the elements if needed.
if (length > 0) {
// Allocate the fixed array.
......@@ -4382,8 +4380,7 @@ static Object* Runtime_NewArgumentsFast(Arguments args) {
for (int i = 0; i < length; i++) {
array->set(i, *--parameters, mode);
}
JSObject::cast(result)->set_elements(FixedArray::cast(obj),
SKIP_WRITE_BARRIER);
JSObject::cast(result)->set_elements(FixedArray::cast(obj));
}
return result;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment