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

Side by Side Diff: src/heap.cc

Issue 8286020: Limit number of loop iterations in Heap::ReserveSpace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 2 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 | no next file » | 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 int cell_space_size, 564 int cell_space_size,
565 int large_object_size) { 565 int large_object_size) {
566 NewSpace* new_space = Heap::new_space(); 566 NewSpace* new_space = Heap::new_space();
567 PagedSpace* old_pointer_space = Heap::old_pointer_space(); 567 PagedSpace* old_pointer_space = Heap::old_pointer_space();
568 PagedSpace* old_data_space = Heap::old_data_space(); 568 PagedSpace* old_data_space = Heap::old_data_space();
569 PagedSpace* code_space = Heap::code_space(); 569 PagedSpace* code_space = Heap::code_space();
570 PagedSpace* map_space = Heap::map_space(); 570 PagedSpace* map_space = Heap::map_space();
571 PagedSpace* cell_space = Heap::cell_space(); 571 PagedSpace* cell_space = Heap::cell_space();
572 LargeObjectSpace* lo_space = Heap::lo_space(); 572 LargeObjectSpace* lo_space = Heap::lo_space();
573 bool gc_performed = true; 573 bool gc_performed = true;
574 while (gc_performed) { 574 int counter = 0;
575 static const int kThreshold = 20;
576 while (gc_performed && counter++ < kThreshold) {
575 gc_performed = false; 577 gc_performed = false;
576 if (!new_space->ReserveSpace(new_space_size)) { 578 if (!new_space->ReserveSpace(new_space_size)) {
577 Heap::CollectGarbage(NEW_SPACE); 579 Heap::CollectGarbage(NEW_SPACE);
578 gc_performed = true; 580 gc_performed = true;
579 } 581 }
580 if (!old_pointer_space->ReserveSpace(pointer_space_size)) { 582 if (!old_pointer_space->ReserveSpace(pointer_space_size)) {
581 Heap::CollectGarbage(OLD_POINTER_SPACE); 583 Heap::CollectGarbage(OLD_POINTER_SPACE);
582 gc_performed = true; 584 gc_performed = true;
583 } 585 }
584 if (!(old_data_space->ReserveSpace(data_space_size))) { 586 if (!(old_data_space->ReserveSpace(data_space_size))) {
(...skipping 18 matching lines...) Expand all
603 // The ReserveSpace method on the large object space checks how much 605 // The ReserveSpace method on the large object space checks how much
604 // we can expand the old generation. This includes expansion caused by 606 // we can expand the old generation. This includes expansion caused by
605 // allocation in the other spaces. 607 // allocation in the other spaces.
606 large_object_size += cell_space_size + map_space_size + code_space_size + 608 large_object_size += cell_space_size + map_space_size + code_space_size +
607 data_space_size + pointer_space_size; 609 data_space_size + pointer_space_size;
608 if (!(lo_space->ReserveSpace(large_object_size))) { 610 if (!(lo_space->ReserveSpace(large_object_size))) {
609 Heap::CollectGarbage(LO_SPACE); 611 Heap::CollectGarbage(LO_SPACE);
610 gc_performed = true; 612 gc_performed = true;
611 } 613 }
612 } 614 }
615
616 if (gc_performed) {
617 // Failed to reserve the space after several attempts.
618 V8::FatalProcessOutOfMemory("Heap::ReserveSpace");
619 }
613 } 620 }
614 621
615 622
616 void Heap::EnsureFromSpaceIsCommitted() { 623 void Heap::EnsureFromSpaceIsCommitted() {
617 if (new_space_.CommitFromSpaceIfNeeded()) return; 624 if (new_space_.CommitFromSpaceIfNeeded()) return;
618 625
619 // Committing memory to from space failed. 626 // Committing memory to from space failed.
620 // Try shrinking and try again. 627 // Try shrinking and try again.
621 Shrink(); 628 Shrink();
622 if (new_space_.CommitFromSpaceIfNeeded()) return; 629 if (new_space_.CommitFromSpaceIfNeeded()) return;
(...skipping 5780 matching lines...) Expand 10 before | Expand all | Expand 10 after
6403 isolate_->heap()->store_buffer()->Compact(); 6410 isolate_->heap()->store_buffer()->Compact();
6404 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); 6411 isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
6405 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { 6412 for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
6406 next = chunk->next_chunk(); 6413 next = chunk->next_chunk();
6407 isolate_->memory_allocator()->Free(chunk); 6414 isolate_->memory_allocator()->Free(chunk);
6408 } 6415 }
6409 chunks_queued_for_free_ = NULL; 6416 chunks_queued_for_free_ = NULL;
6410 } 6417 }
6411 6418
6412 } } // namespace v8::internal 6419 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698