Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(817)

Side by Side Diff: src/heap.cc

Issue 9226020: Merge r10466 from the bleeding_edge to the 3.7 branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.7/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 int cell_space_size, 569 int cell_space_size,
570 int large_object_size) { 570 int large_object_size) {
571 NewSpace* new_space = Heap::new_space(); 571 NewSpace* new_space = Heap::new_space();
572 PagedSpace* old_pointer_space = Heap::old_pointer_space(); 572 PagedSpace* old_pointer_space = Heap::old_pointer_space();
573 PagedSpace* old_data_space = Heap::old_data_space(); 573 PagedSpace* old_data_space = Heap::old_data_space();
574 PagedSpace* code_space = Heap::code_space(); 574 PagedSpace* code_space = Heap::code_space();
575 PagedSpace* map_space = Heap::map_space(); 575 PagedSpace* map_space = Heap::map_space();
576 PagedSpace* cell_space = Heap::cell_space(); 576 PagedSpace* cell_space = Heap::cell_space();
577 LargeObjectSpace* lo_space = Heap::lo_space(); 577 LargeObjectSpace* lo_space = Heap::lo_space();
578 bool gc_performed = true; 578 bool gc_performed = true;
579 while (gc_performed) { 579 int counter = 0;
580 static const int kThreshold = 20;
581 while (gc_performed && counter++ < kThreshold) {
580 gc_performed = false; 582 gc_performed = false;
581 if (!new_space->ReserveSpace(new_space_size)) { 583 if (!new_space->ReserveSpace(new_space_size)) {
582 Heap::CollectGarbage(NEW_SPACE); 584 Heap::CollectGarbage(NEW_SPACE);
583 gc_performed = true; 585 gc_performed = true;
584 } 586 }
585 if (!old_pointer_space->ReserveSpace(pointer_space_size)) { 587 if (!old_pointer_space->ReserveSpace(pointer_space_size)) {
586 Heap::CollectGarbage(OLD_POINTER_SPACE); 588 Heap::CollectGarbage(OLD_POINTER_SPACE);
587 gc_performed = true; 589 gc_performed = true;
588 } 590 }
589 if (!(old_data_space->ReserveSpace(data_space_size))) { 591 if (!(old_data_space->ReserveSpace(data_space_size))) {
(...skipping 18 matching lines...) Expand all
608 // The ReserveSpace method on the large object space checks how much 610 // The ReserveSpace method on the large object space checks how much
609 // we can expand the old generation. This includes expansion caused by 611 // we can expand the old generation. This includes expansion caused by
610 // allocation in the other spaces. 612 // allocation in the other spaces.
611 large_object_size += cell_space_size + map_space_size + code_space_size + 613 large_object_size += cell_space_size + map_space_size + code_space_size +
612 data_space_size + pointer_space_size; 614 data_space_size + pointer_space_size;
613 if (!(lo_space->ReserveSpace(large_object_size))) { 615 if (!(lo_space->ReserveSpace(large_object_size))) {
614 Heap::CollectGarbage(LO_SPACE); 616 Heap::CollectGarbage(LO_SPACE);
615 gc_performed = true; 617 gc_performed = true;
616 } 618 }
617 } 619 }
620
621 if (gc_performed) {
622 // Failed to reserve the space after several attempts.
623 V8::FatalProcessOutOfMemory("Heap::ReserveSpace");
624 }
618 } 625 }
619 626
620 627
621 void Heap::EnsureFromSpaceIsCommitted() { 628 void Heap::EnsureFromSpaceIsCommitted() {
622 if (new_space_.CommitFromSpaceIfNeeded()) return; 629 if (new_space_.CommitFromSpaceIfNeeded()) return;
623 630
624 // Committing memory to from space failed. 631 // Committing memory to from space failed.
625 // Try shrinking and try again. 632 // Try shrinking and try again.
626 Shrink(); 633 Shrink();
627 if (new_space_.CommitFromSpaceIfNeeded()) return; 634 if (new_space_.CommitFromSpaceIfNeeded()) return;
(...skipping 5885 matching lines...) Expand 10 before | Expand all | Expand 10 after
6513 isolate_->heap()->store_buffer()->Compact(); 6520 isolate_->heap()->store_buffer()->Compact();
6514 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6521 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6515 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6522 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6516 next = chunk->next_chunk(); 6523 next = chunk->next_chunk();
6517 isolate_->memory_allocator()->Free(chunk); 6524 isolate_->memory_allocator()->Free(chunk);
6518 } 6525 }
6519 chunks_queued_for_free_ = NULL; 6526 chunks_queued_for_free_ = NULL;
6520 } 6527 }
6521 6528
6522 } } // namespace v8::internal 6529 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698