Index: src/heap.cc |
=================================================================== |
--- src/heap.cc (revision 10368) |
+++ src/heap.cc (working copy) |
@@ -582,8 +582,11 @@ |
PagedSpace* map_space = Heap::map_space(); |
PagedSpace* cell_space = Heap::cell_space(); |
LargeObjectSpace* lo_space = Heap::lo_space(); |
+ bool one_old_space_gc_has_been_performed = false; |
bool gc_performed = true; |
+ bool old_space_gc_performed; |
while (gc_performed) { |
+ old_space_gc_performed = false; |
gc_performed = false; |
if (!new_space->ReserveSpace(new_space_size)) { |
Heap::CollectGarbage(NEW_SPACE); |
@@ -592,22 +595,27 @@ |
if (!old_pointer_space->ReserveSpace(pointer_space_size)) { |
Heap::CollectGarbage(OLD_POINTER_SPACE); |
gc_performed = true; |
+ old_space_gc_performed = true; |
} |
if (!(old_data_space->ReserveSpace(data_space_size))) { |
Heap::CollectGarbage(OLD_DATA_SPACE); |
gc_performed = true; |
+ old_space_gc_performed = true; |
} |
if (!(code_space->ReserveSpace(code_space_size))) { |
Heap::CollectGarbage(CODE_SPACE); |
gc_performed = true; |
+ old_space_gc_performed = true; |
} |
if (!(map_space->ReserveSpace(map_space_size))) { |
Heap::CollectGarbage(MAP_SPACE); |
gc_performed = true; |
+ old_space_gc_performed = true; |
} |
if (!(cell_space->ReserveSpace(cell_space_size))) { |
Heap::CollectGarbage(CELL_SPACE); |
gc_performed = true; |
+ old_space_gc_performed = true; |
} |
// We add a slack-factor of 2 in order to have space for a series of |
// large-object allocations that are only just larger than the page size. |
@@ -617,10 +625,17 @@ |
// allocation in the other spaces. |
large_object_size += cell_space_size + map_space_size + code_space_size + |
data_space_size + pointer_space_size; |
- if (!(lo_space->ReserveSpace(large_object_size))) { |
+ |
+ // If we already did one GC in order to make space in old space, there is |
+ // no sense in doing another one. We will attempt to force through the |
+ // large object space allocation, which comes directly from the OS, |
+ // regardless of any soft limit. |
+ if (!one_old_space_gc_has_been_performed && |
+ !(lo_space->ReserveSpace(large_object_size))) { |
Heap::CollectGarbage(LO_SPACE); |
gc_performed = true; |
} |
+ if (old_space_gc_performed) one_old_space_gc_has_been_performed = true; |
} |
} |
@@ -2888,8 +2903,8 @@ |
bool is_ascii_data_in_two_byte_string = false; |
if (!is_ascii) { |
// At least one of the strings uses two-byte representation so we |
- // can't use the fast case code for short ascii strings below, but |
- // we can try to save memory if all chars actually fit in ascii. |
+ // can't use the fast case code for short ASCII strings below, but |
+ // we can try to save memory if all chars actually fit in ASCII. |
is_ascii_data_in_two_byte_string = |
first->HasOnlyAsciiChars() && second->HasOnlyAsciiChars(); |
if (is_ascii_data_in_two_byte_string) { |
@@ -3600,8 +3615,8 @@ |
// TODO(1240798): Initialize the object's body using valid initial values |
// according to the object's initial map. For example, if the map's |
// instance type is JS_ARRAY_TYPE, the length field should be initialized |
- // to a number (eg, Smi::FromInt(0)) and the elements initialized to a |
- // fixed array (eg, Heap::empty_fixed_array()). Currently, the object |
+ // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a |
+ // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object |
// verification code has to cope with (temporarily) invalid objects. See |
// for example, JSArray::JSArrayVerify). |
Object* filler; |
@@ -4068,7 +4083,7 @@ |
ASSERT(chars >= 0); |
// Ensure the chars matches the number of characters in the buffer. |
ASSERT(static_cast<unsigned>(chars) == buffer->Length()); |
- // Determine whether the string is ascii. |
+ // Determine whether the string is ASCII. |
bool is_ascii = true; |
while (buffer->has_more()) { |
if (buffer->GetNext() > unibrow::Utf8::kMaxOneByteChar) { |
@@ -5561,7 +5576,7 @@ |
// goes wrong, just return false. The caller should check the results and |
// call Heap::TearDown() to release allocated memory. |
// |
- // If the heap is not yet configured (eg, through the API), configure it. |
+ // If the heap is not yet configured (e.g. through the API), configure it. |
// Configuration is based on the flags new-space-size (really the semispace |
// size) and old-space-size if set or the initial values of semispace_size_ |
// and old_generation_size_ otherwise. |
@@ -6625,4 +6640,9 @@ |
chunks_queued_for_free_ = NULL; |
} |
+ |
+void AboutToGoWrong() { |
+ printf("About to go wrong\n"); |
+} |
+ |
} } // namespace v8::internal |