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

Side by Side Diff: src/heap.cc

Issue 542073: * Improve the interface to the memory-reservation functionality.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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 | « src/heap.h ('k') | src/serialize.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 473
474 static void VerifySymbolTable() { 474 static void VerifySymbolTable() {
475 #ifdef DEBUG 475 #ifdef DEBUG
476 SymbolTableVerifier verifier; 476 SymbolTableVerifier verifier;
477 Heap::symbol_table()->IterateElements(&verifier); 477 Heap::symbol_table()->IterateElements(&verifier);
478 #endif // DEBUG 478 #endif // DEBUG
479 } 479 }
480 480
481 481
482 void Heap::ReserveSpace(
483 int new_space_size,
484 int pointer_space_size,
485 int data_space_size,
486 int code_space_size,
487 int map_space_size,
488 int cell_space_size,
489 int large_object_size) {
490 NewSpace* new_space = Heap::new_space();
491 PagedSpace* old_pointer_space = Heap::old_pointer_space();
492 PagedSpace* old_data_space = Heap::old_data_space();
493 PagedSpace* code_space = Heap::code_space();
494 PagedSpace* map_space = Heap::map_space();
495 PagedSpace* cell_space = Heap::cell_space();
496 LargeObjectSpace* lo_space = Heap::lo_space();
497 bool gc_performed = true;
498 while (gc_performed) {
499 gc_performed = false;
500 if (!new_space->ReserveSpace(new_space_size)) {
501 Heap::CollectGarbage(new_space_size, NEW_SPACE);
502 gc_performed = true;
503 }
504 if (!old_pointer_space->ReserveSpace(pointer_space_size)) {
505 Heap::CollectGarbage(pointer_space_size, OLD_POINTER_SPACE);
506 gc_performed = true;
507 }
508 if (!(old_data_space->ReserveSpace(data_space_size))) {
509 Heap::CollectGarbage(data_space_size, OLD_DATA_SPACE);
510 gc_performed = true;
511 }
512 if (!(code_space->ReserveSpace(code_space_size))) {
513 Heap::CollectGarbage(code_space_size, CODE_SPACE);
514 gc_performed = true;
515 }
516 if (!(map_space->ReserveSpace(map_space_size))) {
517 Heap::CollectGarbage(map_space_size, MAP_SPACE);
518 gc_performed = true;
519 }
520 if (!(cell_space->ReserveSpace(cell_space_size))) {
521 Heap::CollectGarbage(cell_space_size, CELL_SPACE);
522 gc_performed = true;
523 }
524 // We add a slack-factor of 2 in order to have space for the remembered
525 // set and a series of large-object allocations that are only just larger
526 // than the page size.
527 large_object_size *= 2;
528 // The ReserveSpace method on the large object space checks how much
529 // we can expand the old generation. This includes expansion caused by
530 // allocation in the other spaces.
531 large_object_size += cell_space_size + map_space_size + code_space_size +
532 data_space_size + pointer_space_size;
533 if (!(lo_space->ReserveSpace(large_object_size))) {
534 Heap::CollectGarbage(large_object_size, LO_SPACE);
535 gc_performed = true;
536 }
537 }
538 }
539
540
482 void Heap::EnsureFromSpaceIsCommitted() { 541 void Heap::EnsureFromSpaceIsCommitted() {
483 if (new_space_.CommitFromSpaceIfNeeded()) return; 542 if (new_space_.CommitFromSpaceIfNeeded()) return;
484 543
485 // Committing memory to from space failed. 544 // Committing memory to from space failed.
486 // Try shrinking and try again. 545 // Try shrinking and try again.
487 Shrink(); 546 Shrink();
488 if (new_space_.CommitFromSpaceIfNeeded()) return; 547 if (new_space_.CommitFromSpaceIfNeeded()) return;
489 548
490 // Committing memory to from space failed again. 549 // Committing memory to from space failed again.
491 // Memory is exhausted and we will die. 550 // Memory is exhausted and we will die.
(...skipping 3643 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 void ExternalStringTable::TearDown() { 4194 void ExternalStringTable::TearDown() {
4136 new_space_strings_.Free(); 4195 new_space_strings_.Free();
4137 old_space_strings_.Free(); 4196 old_space_strings_.Free();
4138 } 4197 }
4139 4198
4140 4199
4141 List<Object*> ExternalStringTable::new_space_strings_; 4200 List<Object*> ExternalStringTable::new_space_strings_;
4142 List<Object*> ExternalStringTable::old_space_strings_; 4201 List<Object*> ExternalStringTable::old_space_strings_;
4143 4202
4144 } } // namespace v8::internal 4203 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698