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 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 | 2271 |
2272 HeapObject* object = current_->GetObject(); | 2272 HeapObject* object = current_->GetObject(); |
2273 current_ = current_->next_page(); | 2273 current_ = current_->next_page(); |
2274 return object; | 2274 return object; |
2275 } | 2275 } |
2276 | 2276 |
2277 | 2277 |
2278 // ----------------------------------------------------------------------------- | 2278 // ----------------------------------------------------------------------------- |
2279 // LargeObjectSpace | 2279 // LargeObjectSpace |
2280 | 2280 |
2281 LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id) | 2281 LargeObjectSpace::LargeObjectSpace(Heap* heap, |
| 2282 intptr_t max_capacity, |
| 2283 AllocationSpace id) |
2282 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis | 2284 : Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis |
| 2285 max_capacity_(max_capacity), |
2283 first_page_(NULL), | 2286 first_page_(NULL), |
2284 size_(0), | 2287 size_(0), |
2285 page_count_(0), | 2288 page_count_(0), |
2286 objects_size_(0) {} | 2289 objects_size_(0) {} |
2287 | 2290 |
2288 | 2291 |
2289 bool LargeObjectSpace::Setup() { | 2292 bool LargeObjectSpace::Setup() { |
2290 first_page_ = NULL; | 2293 first_page_ = NULL; |
2291 size_ = 0; | 2294 size_ = 0; |
2292 page_count_ = 0; | 2295 page_count_ = 0; |
(...skipping 19 matching lines...) Expand all Loading... |
2312 | 2315 |
2313 MaybeObject* LargeObjectSpace::AllocateRaw(int object_size, | 2316 MaybeObject* LargeObjectSpace::AllocateRaw(int object_size, |
2314 Executability executable) { | 2317 Executability executable) { |
2315 // Check if we want to force a GC before growing the old space further. | 2318 // Check if we want to force a GC before growing the old space further. |
2316 // If so, fail the allocation. | 2319 // If so, fail the allocation. |
2317 if (!heap()->always_allocate() && | 2320 if (!heap()->always_allocate() && |
2318 heap()->OldGenerationAllocationLimitReached()) { | 2321 heap()->OldGenerationAllocationLimitReached()) { |
2319 return Failure::RetryAfterGC(identity()); | 2322 return Failure::RetryAfterGC(identity()); |
2320 } | 2323 } |
2321 | 2324 |
| 2325 if (Size() + object_size > max_capacity_) { |
| 2326 return Failure::RetryAfterGC(identity()); |
| 2327 } |
| 2328 |
2322 LargePage* page = heap()->isolate()->memory_allocator()-> | 2329 LargePage* page = heap()->isolate()->memory_allocator()-> |
2323 AllocateLargePage(object_size, executable, this); | 2330 AllocateLargePage(object_size, executable, this); |
2324 if (page == NULL) return Failure::RetryAfterGC(identity()); | 2331 if (page == NULL) return Failure::RetryAfterGC(identity()); |
2325 ASSERT(page->body_size() >= object_size); | 2332 ASSERT(page->body_size() >= object_size); |
2326 | 2333 |
2327 size_ += static_cast<int>(page->size()); | 2334 size_ += static_cast<int>(page->size()); |
2328 objects_size_ += object_size; | 2335 objects_size_ += object_size; |
2329 page_count_++; | 2336 page_count_++; |
2330 page->set_next_page(first_page_); | 2337 page->set_next_page(first_page_); |
2331 first_page_ = page; | 2338 first_page_ = page; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 object->ShortPrint(); | 2530 object->ShortPrint(); |
2524 PrintF("\n"); | 2531 PrintF("\n"); |
2525 } | 2532 } |
2526 printf(" --------------------------------------\n"); | 2533 printf(" --------------------------------------\n"); |
2527 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 2534 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
2528 } | 2535 } |
2529 | 2536 |
2530 #endif // DEBUG | 2537 #endif // DEBUG |
2531 | 2538 |
2532 } } // namespace v8::internal | 2539 } } // namespace v8::internal |
OLD | NEW |