| 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 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 while (it.has_next()) { | 750 while (it.has_next()) { |
| 751 it.next(); | 751 it.next(); |
| 752 count++; | 752 count++; |
| 753 } | 753 } |
| 754 return count; | 754 return count; |
| 755 } | 755 } |
| 756 #endif | 756 #endif |
| 757 | 757 |
| 758 | 758 |
| 759 void PagedSpace::Shrink() { | 759 void PagedSpace::Shrink() { |
| 760 // TODO(gc) release half of pages? | 760 // TODO(1614) Not implemented. |
| 761 } | 761 } |
| 762 | 762 |
| 763 | 763 |
| 764 bool PagedSpace::EnsureCapacity(int capacity) { | 764 bool PagedSpace::EnsureCapacity(int capacity) { |
| 765 while (Capacity() < capacity) { | 765 while (Capacity() < capacity) { |
| 766 // Expand the space until it has the required capacity or expansion fails. | 766 // Expand the space until it has the required capacity or expansion fails. |
| 767 if (!Expand()) return false; | 767 if (!Expand()) return false; |
| 768 } | 768 } |
| 769 return true; | 769 return true; |
| 770 } | 770 } |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2302 space, kAllocationActionFree, page->size()); | 2302 space, kAllocationActionFree, page->size()); |
| 2303 heap()->isolate()->memory_allocator()->Free(page); | 2303 heap()->isolate()->memory_allocator()->Free(page); |
| 2304 } | 2304 } |
| 2305 | 2305 |
| 2306 size_ = 0; | 2306 size_ = 0; |
| 2307 page_count_ = 0; | 2307 page_count_ = 0; |
| 2308 objects_size_ = 0; | 2308 objects_size_ = 0; |
| 2309 } | 2309 } |
| 2310 | 2310 |
| 2311 | 2311 |
| 2312 MaybeObject* LargeObjectSpace::AllocateRawInternal(int object_size, | 2312 MaybeObject* LargeObjectSpace::AllocateRaw(int object_size, |
| 2313 Executability executable) { | 2313 Executability executable) { |
| 2314 // Check if we want to force a GC before growing the old space further. | 2314 // Check if we want to force a GC before growing the old space further. |
| 2315 // If so, fail the allocation. | 2315 // If so, fail the allocation. |
| 2316 if (!heap()->always_allocate() && | 2316 if (!heap()->always_allocate() && |
| 2317 heap()->OldGenerationAllocationLimitReached()) { | 2317 heap()->OldGenerationAllocationLimitReached()) { |
| 2318 return Failure::RetryAfterGC(identity()); | 2318 return Failure::RetryAfterGC(identity()); |
| 2319 } | 2319 } |
| 2320 | 2320 |
| 2321 // TODO(gc) isolates merge | |
| 2322 LargePage* page = heap()->isolate()->memory_allocator()-> | 2321 LargePage* page = heap()->isolate()->memory_allocator()-> |
| 2323 AllocateLargePage(object_size, executable, this); | 2322 AllocateLargePage(object_size, executable, this); |
| 2324 if (page == NULL) return Failure::RetryAfterGC(identity()); | 2323 if (page == NULL) return Failure::RetryAfterGC(identity()); |
| 2325 ASSERT(page->body_size() >= object_size); | 2324 ASSERT(page->body_size() >= object_size); |
| 2326 | 2325 |
| 2327 size_ += static_cast<int>(page->size()); | 2326 size_ += static_cast<int>(page->size()); |
| 2328 objects_size_ += object_size; | 2327 objects_size_ += object_size; |
| 2329 page_count_++; | 2328 page_count_++; |
| 2330 page->set_next_page(first_page_); | 2329 page->set_next_page(first_page_); |
| 2331 first_page_ = page; | 2330 first_page_ = page; |
| 2332 | 2331 |
| 2333 | 2332 |
| 2334 heap()->incremental_marking()->OldSpaceStep(object_size); | 2333 heap()->incremental_marking()->OldSpaceStep(object_size); |
| 2335 return page->GetObject(); | 2334 return page->GetObject(); |
| 2336 } | 2335 } |
| 2337 | 2336 |
| 2338 | 2337 |
| 2339 MaybeObject* LargeObjectSpace::AllocateRawCode(int size_in_bytes) { | |
| 2340 ASSERT(0 < size_in_bytes); | |
| 2341 return AllocateRawInternal(size_in_bytes, EXECUTABLE); | |
| 2342 } | |
| 2343 | |
| 2344 | |
| 2345 MaybeObject* LargeObjectSpace::AllocateRawFixedArray(int size_in_bytes) { | |
| 2346 ASSERT(0 < size_in_bytes); | |
| 2347 return AllocateRawInternal(size_in_bytes, NOT_EXECUTABLE); | |
| 2348 } | |
| 2349 | |
| 2350 | |
| 2351 MaybeObject* LargeObjectSpace::AllocateRawData(int size_in_bytes) { | |
| 2352 ASSERT(0 < size_in_bytes); | |
| 2353 return AllocateRawInternal(size_in_bytes, NOT_EXECUTABLE); | |
| 2354 } | |
| 2355 | |
| 2356 | |
| 2357 // GC support | 2338 // GC support |
| 2358 MaybeObject* LargeObjectSpace::FindObject(Address a) { | 2339 MaybeObject* LargeObjectSpace::FindObject(Address a) { |
| 2359 for (LargePage* page = first_page_; | 2340 for (LargePage* page = first_page_; |
| 2360 page != NULL; | 2341 page != NULL; |
| 2361 page = page->next_page()) { | 2342 page = page->next_page()) { |
| 2362 Address page_address = page->address(); | 2343 Address page_address = page->address(); |
| 2363 if (page_address <= a && a < page_address + page->size()) { | 2344 if (page_address <= a && a < page_address + page->size()) { |
| 2364 return page->GetObject(); | 2345 return page->GetObject(); |
| 2365 } | 2346 } |
| 2366 } | 2347 } |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2517 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 2498 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 2518 if (obj->IsCode()) { | 2499 if (obj->IsCode()) { |
| 2519 Code* code = Code::cast(obj); | 2500 Code* code = Code::cast(obj); |
| 2520 isolate->code_kind_statistics()[code->kind()] += code->Size(); | 2501 isolate->code_kind_statistics()[code->kind()] += code->Size(); |
| 2521 } | 2502 } |
| 2522 } | 2503 } |
| 2523 } | 2504 } |
| 2524 #endif // DEBUG | 2505 #endif // DEBUG |
| 2525 | 2506 |
| 2526 } } // namespace v8::internal | 2507 } } // namespace v8::internal |
| OLD | NEW |