 Chromium Code Reviews
 Chromium Code Reviews Issue 10657022:
  Expose more detailed memory statistics  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 10657022:
  Expose more detailed memory statistics  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 320 // TODO(gc) make code_range part of memory allocator? | 320 // TODO(gc) make code_range part of memory allocator? | 
| 321 ASSERT(size_ >= size); | 321 ASSERT(size_ >= size); | 
| 322 size_ -= size; | 322 size_ -= size; | 
| 323 | 323 | 
| 324 isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size)); | 324 isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size)); | 
| 325 | 325 | 
| 326 if (executable == EXECUTABLE) { | 326 if (executable == EXECUTABLE) { | 
| 327 ASSERT(size_executable_ >= size); | 327 ASSERT(size_executable_ >= size); | 
| 328 size_executable_ -= size; | 328 size_executable_ -= size; | 
| 329 } | 329 } | 
| 330 if (isolate_->code_range()->contains(static_cast<Address>(base))) { | 330 if (isolate_->code_range()->contains(base)) { | 
| 331 ASSERT(executable == EXECUTABLE); | 331 ASSERT(executable == EXECUTABLE); | 
| 332 isolate_->code_range()->FreeRawMemory(base, size); | 332 isolate_->code_range()->FreeRawMemory(base, size); | 
| 333 } else { | 333 } else { | 
| 334 ASSERT(executable == NOT_EXECUTABLE || !isolate_->code_range()->exists()); | 334 ASSERT(executable == NOT_EXECUTABLE || !isolate_->code_range()->exists()); | 
| 335 bool result = VirtualMemory::ReleaseRegion(base, size); | 335 bool result = VirtualMemory::ReleaseRegion(base, size); | 
| 336 USE(result); | 336 USE(result); | 
| 337 ASSERT(result); | 337 ASSERT(result); | 
| 338 } | 338 } | 
| 339 } | 339 } | 
| 340 | 340 | 
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 548 #endif | 548 #endif | 
| 549 | 549 | 
| 550 area_start = base + Page::kObjectStartOffset; | 550 area_start = base + Page::kObjectStartOffset; | 
| 551 area_end = base + chunk_size; | 551 area_end = base + chunk_size; | 
| 552 } | 552 } | 
| 553 | 553 | 
| 554 isolate_->counters()->memory_allocated()-> | 554 isolate_->counters()->memory_allocated()-> | 
| 555 Increment(static_cast<int>(chunk_size)); | 555 Increment(static_cast<int>(chunk_size)); | 
| 556 | 556 | 
| 557 LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size)); | 557 LOG(isolate_, NewEvent("MemoryChunk", base, chunk_size)); | 
| 558 if (owner != NULL) { | 558 | 
| 559 ObjectSpace space = static_cast<ObjectSpace>(1 << owner->identity()); | 559 ObjectSpace space = static_cast<ObjectSpace>(1 << owner->identity()); | 
| 
Michael Starzinger
2012/06/25 15:49:19
The deoptimizer (i.e. Deoptimizer::CreateCode) use
 | |
| 560 PerformAllocationCallback(space, kAllocationActionAllocate, chunk_size); | 560 PerformAllocationCallback(space, kAllocationActionAllocate, chunk_size); | 
| 561 | |
| 562 switch (owner->identity()) { | |
| 563 case OLD_POINTER_SPACE: | |
| 564 isolate_->counters()->old_pointer_space_bytes_allocated()-> | |
| 565 Increment(static_cast<int>(chunk_size)); | |
| 566 isolate_->counters()->old_pointer_space_bytes_used()-> | |
| 567 Set(static_cast<int>(owner->SizeOfObjects())); | |
| 568 break; | |
| 569 | |
| 570 case OLD_DATA_SPACE: | |
| 571 isolate_->counters()->old_data_space_bytes_allocated()-> | |
| 572 Increment(static_cast<int>(chunk_size)); | |
| 573 isolate_->counters()->old_data_space_bytes_allocated()-> | |
| 574 Set(static_cast<int>(owner->SizeOfObjects())); | |
| 575 break; | |
| 576 | |
| 577 case CODE_SPACE: | |
| 578 isolate_->counters()->code_space_bytes_allocated()-> | |
| 579 Increment(static_cast<int>(chunk_size)); | |
| 580 isolate_->counters()->code_space_bytes_allocated()-> | |
| 581 Set(static_cast<int>(owner->SizeOfObjects())); | |
| 582 break; | |
| 583 | |
| 584 case MAP_SPACE: | |
| 585 isolate_->counters()->map_space_bytes_allocated()-> | |
| 586 Increment(static_cast<int>(chunk_size)); | |
| 587 isolate_->counters()->map_space_bytes_allocated()-> | |
| 588 Set(static_cast<int>(owner->SizeOfObjects())); | |
| 589 break; | |
| 590 | |
| 591 case CELL_SPACE: | |
| 592 isolate_->counters()->cell_space_bytes_allocated()-> | |
| 593 Increment(static_cast<int>(chunk_size)); | |
| 594 isolate_->counters()->cell_space_bytes_allocated()-> | |
| 595 Set(static_cast<int>(owner->SizeOfObjects())); | |
| 596 break; | |
| 597 | |
| 598 case LO_SPACE: | |
| 599 isolate_->counters()->lo_space_bytes_allocated()-> | |
| 600 Increment(static_cast<int>(chunk_size)); | |
| 601 isolate_->counters()->lo_space_bytes_allocated()-> | |
| 602 Set(static_cast<int>(owner->SizeOfObjects())); | |
| 603 break; | |
| 604 | |
| 605 case NEW_SPACE: | |
| 606 // NEW_SPACE is released using ReserveAlignedMemory and CommitBlock. | |
| 607 | |
| 608 default: | |
| 609 UNREACHABLE(); | |
| 561 } | 610 } | 
| 562 | 611 | 
| 563 MemoryChunk* result = MemoryChunk::Initialize(heap, | 612 MemoryChunk* result = MemoryChunk::Initialize(heap, | 
| 564 base, | 613 base, | 
| 565 chunk_size, | 614 chunk_size, | 
| 566 area_start, | 615 area_start, | 
| 567 area_end, | 616 area_end, | 
| 568 executable, | 617 executable, | 
| 569 owner); | 618 owner); | 
| 570 result->set_reserved_memory(&reservation); | 619 result->set_reserved_memory(&reservation); | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 587 Space* owner, | 636 Space* owner, | 
| 588 Executability executable) { | 637 Executability executable) { | 
| 589 MemoryChunk* chunk = AllocateChunk(object_size, executable, owner); | 638 MemoryChunk* chunk = AllocateChunk(object_size, executable, owner); | 
| 590 if (chunk == NULL) return NULL; | 639 if (chunk == NULL) return NULL; | 
| 591 return LargePage::Initialize(isolate_->heap(), chunk); | 640 return LargePage::Initialize(isolate_->heap(), chunk); | 
| 592 } | 641 } | 
| 593 | 642 | 
| 594 | 643 | 
| 595 void MemoryAllocator::Free(MemoryChunk* chunk) { | 644 void MemoryAllocator::Free(MemoryChunk* chunk) { | 
| 596 LOG(isolate_, DeleteEvent("MemoryChunk", chunk)); | 645 LOG(isolate_, DeleteEvent("MemoryChunk", chunk)); | 
| 597 if (chunk->owner() != NULL) { | 646 size_t chunk_size; | 
| 598 ObjectSpace space = | 647 ObjectSpace space = | 
| 599 static_cast<ObjectSpace>(1 << chunk->owner()->identity()); | 648 static_cast<ObjectSpace>(1 << chunk->owner()->identity()); | 
| 600 PerformAllocationCallback(space, kAllocationActionFree, chunk->size()); | 649 PerformAllocationCallback(space, kAllocationActionFree, chunk->size()); | 
| 601 } | |
| 602 | 650 | 
| 603 isolate_->heap()->RememberUnmappedPage( | 651 isolate_->heap()->RememberUnmappedPage( | 
| 604 reinterpret_cast<Address>(chunk), chunk->IsEvacuationCandidate()); | 652 reinterpret_cast<Address>(chunk), chunk->IsEvacuationCandidate()); | 
| 605 | 653 | 
| 606 delete chunk->slots_buffer(); | 654 delete chunk->slots_buffer(); | 
| 607 delete chunk->skip_list(); | 655 delete chunk->skip_list(); | 
| 608 | 656 | 
| 609 VirtualMemory* reservation = chunk->reserved_memory(); | 657 VirtualMemory* reservation = chunk->reserved_memory(); | 
| 610 if (reservation->IsReserved()) { | 658 if (reservation->IsReserved()) { | 
| 659 chunk_size = reservation->size(); | |
| 611 FreeMemory(reservation, chunk->executable()); | 660 FreeMemory(reservation, chunk->executable()); | 
| 612 } else { | 661 } else { | 
| 662 chunk_size = chunk->size(); | |
| 613 FreeMemory(chunk->address(), | 663 FreeMemory(chunk->address(), | 
| 614 chunk->size(), | 664 chunk->size(), | 
| 615 chunk->executable()); | 665 chunk->executable()); | 
| 616 } | 666 } | 
| 667 | |
| 668 switch (chunk->owner()->identity()) { | |
| 669 case OLD_POINTER_SPACE: | |
| 670 isolate_->counters()->old_pointer_space_bytes_allocated()-> | |
| 671 Decrement(static_cast<int>(chunk_size)); | |
| 672 break; | |
| 673 | |
| 674 case OLD_DATA_SPACE: | |
| 675 isolate_->counters()->old_data_space_bytes_allocated()-> | |
| 676 Decrement(static_cast<int>(chunk_size)); | |
| 677 break; | |
| 678 | |
| 679 case CODE_SPACE: | |
| 680 isolate_->counters()->code_space_bytes_allocated()-> | |
| 681 Decrement(static_cast<int>(chunk_size)); | |
| 682 break; | |
| 683 | |
| 684 case MAP_SPACE: | |
| 685 isolate_->counters()->map_space_bytes_allocated()-> | |
| 686 Decrement(static_cast<int>(chunk_size)); | |
| 687 break; | |
| 688 | |
| 689 case CELL_SPACE: | |
| 690 isolate_->counters()->cell_space_bytes_allocated()-> | |
| 691 Decrement(static_cast<int>(chunk_size)); | |
| 692 break; | |
| 693 | |
| 694 case LO_SPACE: | |
| 695 isolate_->counters()->lo_space_bytes_allocated()-> | |
| 696 Decrement(static_cast<int>(chunk_size)); | |
| 697 break; | |
| 698 | |
| 699 case NEW_SPACE: | |
| 700 // NEW_SPACE is released using UncommitBlock. | |
| 701 | |
| 702 default: | |
| 703 UNREACHABLE(); | |
| 704 } | |
| 617 } | 705 } | 
| 618 | 706 | 
| 619 | 707 | 
| 620 bool MemoryAllocator::CommitBlock(Address start, | 708 bool MemoryAllocator::CommitBlock(Address start, | 
| 621 size_t size, | 709 size_t size, | 
| 622 Executability executable) { | 710 Executability executable) { | 
| 623 if (!VirtualMemory::CommitRegion(start, size, executable)) return false; | 711 if (!VirtualMemory::CommitRegion(start, size, executable)) return false; | 
| 624 #ifdef DEBUG | 712 #ifdef DEBUG | 
| 625 ZapBlock(start, size); | 713 ZapBlock(start, size); | 
| 626 #endif | 714 #endif | 
| 627 isolate_->counters()->memory_allocated()->Increment(static_cast<int>(size)); | 715 isolate_->counters()->memory_allocated()->Increment(static_cast<int>(size)); | 
| 716 isolate_->counters()->new_space_bytes_allocated()->Increment( | |
| 717 static_cast<int>(size)); | |
| 628 return true; | 718 return true; | 
| 629 } | 719 } | 
| 630 | 720 | 
| 631 | 721 | 
| 632 bool MemoryAllocator::UncommitBlock(Address start, size_t size) { | 722 bool MemoryAllocator::UncommitBlock(Address start, size_t size) { | 
| 633 if (!VirtualMemory::UncommitRegion(start, size)) return false; | 723 if (!VirtualMemory::UncommitRegion(start, size)) return false; | 
| 634 isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size)); | 724 isolate_->counters()->memory_allocated()->Decrement(static_cast<int>(size)); | 
| 725 isolate_->counters()->new_space_bytes_allocated()->Decrement( | |
| 726 static_cast<int>(size)); | |
| 635 return true; | 727 return true; | 
| 636 } | 728 } | 
| 637 | 729 | 
| 638 | 730 | 
| 639 void MemoryAllocator::ZapBlock(Address start, size_t size) { | 731 void MemoryAllocator::ZapBlock(Address start, size_t size) { | 
| 640 for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) { | 732 for (size_t s = 0; s + kPointerSize <= size; s += kPointerSize) { | 
| 641 Memory::Address_at(start + s) = kZapValue; | 733 Memory::Address_at(start + s) = kZapValue; | 
| 642 } | 734 } | 
| 643 } | 735 } | 
| 644 | 736 | 
| (...skipping 2212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2857 object->ShortPrint(); | 2949 object->ShortPrint(); | 
| 2858 PrintF("\n"); | 2950 PrintF("\n"); | 
| 2859 } | 2951 } | 
| 2860 printf(" --------------------------------------\n"); | 2952 printf(" --------------------------------------\n"); | 
| 2861 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 2953 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 
| 2862 } | 2954 } | 
| 2863 | 2955 | 
| 2864 #endif // DEBUG | 2956 #endif // DEBUG | 
| 2865 | 2957 | 
| 2866 } } // namespace v8::internal | 2958 } } // namespace v8::internal | 
| OLD | NEW |