OLD | NEW |
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 2373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2384 | 2384 |
2385 allocation_info_.top = NULL; | 2385 allocation_info_.top = NULL; |
2386 allocation_info_.limit = NULL; | 2386 allocation_info_.limit = NULL; |
2387 } | 2387 } |
2388 } | 2388 } |
2389 | 2389 |
2390 | 2390 |
2391 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { | 2391 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { |
2392 // Allocation in this space has failed. | 2392 // Allocation in this space has failed. |
2393 | 2393 |
2394 // If there are unswept pages advance lazy sweeper then sweep one page before | 2394 // If there are unswept pages advance lazy sweeper a bounded number of times |
2395 // allocating a new page. | 2395 // until we find a size_in_bytes contiguous piece of memory |
2396 if (first_unswept_page_->is_valid()) { | 2396 const int kMaxSweepingTries = 5; |
2397 AdvanceSweeper(size_in_bytes); | 2397 bool sweeping_complete = false; |
| 2398 |
| 2399 for (int i = 0; i < kMaxSweepingTries && !sweeping_complete; i++) { |
| 2400 sweeping_complete = AdvanceSweeper(size_in_bytes); |
2398 | 2401 |
2399 // Retry the free list allocation. | 2402 // Retry the free list allocation. |
2400 HeapObject* object = free_list_.Allocate(size_in_bytes); | 2403 HeapObject* object = free_list_.Allocate(size_in_bytes); |
2401 if (object != NULL) return object; | 2404 if (object != NULL) return object; |
2402 } | 2405 } |
2403 | 2406 |
2404 // Free list allocation failed and there is no next page. Fail if we have | 2407 // Free list allocation failed and there is no next page. Fail if we have |
2405 // hit the old generation size limit that should cause a garbage | 2408 // hit the old generation size limit that should cause a garbage |
2406 // collection. | 2409 // collection. |
2407 if (!heap()->always_allocate() && | 2410 if (!heap()->always_allocate() && |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2947 object->ShortPrint(); | 2950 object->ShortPrint(); |
2948 PrintF("\n"); | 2951 PrintF("\n"); |
2949 } | 2952 } |
2950 printf(" --------------------------------------\n"); | 2953 printf(" --------------------------------------\n"); |
2951 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 2954 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
2952 } | 2955 } |
2953 | 2956 |
2954 #endif // DEBUG | 2957 #endif // DEBUG |
2955 | 2958 |
2956 } } // namespace v8::internal | 2959 } } // namespace v8::internal |
OLD | NEW |