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

Side by Side Diff: src/spaces.cc

Issue 3418035: Use intptr_t instead of int for heap sizes. This is a step towards... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | « src/spaces.h ('k') | test/mjsunit/math-abs.js » ('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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 delete code_range_; // Frees all memory in the virtual memory range. 263 delete code_range_; // Frees all memory in the virtual memory range.
264 code_range_ = NULL; 264 code_range_ = NULL;
265 free_list_.Free(); 265 free_list_.Free();
266 allocation_list_.Free(); 266 allocation_list_.Free();
267 } 267 }
268 268
269 269
270 // ----------------------------------------------------------------------------- 270 // -----------------------------------------------------------------------------
271 // MemoryAllocator 271 // MemoryAllocator
272 // 272 //
273 int MemoryAllocator::capacity_ = 0; 273 intptr_t MemoryAllocator::capacity_ = 0;
274 int MemoryAllocator::size_ = 0; 274 intptr_t MemoryAllocator::size_ = 0;
275 int MemoryAllocator::size_executable_ = 0; 275 intptr_t MemoryAllocator::size_executable_ = 0;
276 276
277 List<MemoryAllocator::MemoryAllocationCallbackRegistration> 277 List<MemoryAllocator::MemoryAllocationCallbackRegistration>
278 MemoryAllocator::memory_allocation_callbacks_; 278 MemoryAllocator::memory_allocation_callbacks_;
279 279
280 VirtualMemory* MemoryAllocator::initial_chunk_ = NULL; 280 VirtualMemory* MemoryAllocator::initial_chunk_ = NULL;
281 281
282 // 270 is an estimate based on the static default heap size of a pair of 256K 282 // 270 is an estimate based on the static default heap size of a pair of 256K
283 // semispaces and a 64M old generation. 283 // semispaces and a 64M old generation.
284 const int kEstimatedNumberOfChunks = 270; 284 const int kEstimatedNumberOfChunks = 270;
285 List<MemoryAllocator::ChunkInfo> MemoryAllocator::chunks_( 285 List<MemoryAllocator::ChunkInfo> MemoryAllocator::chunks_(
286 kEstimatedNumberOfChunks); 286 kEstimatedNumberOfChunks);
287 List<int> MemoryAllocator::free_chunk_ids_(kEstimatedNumberOfChunks); 287 List<int> MemoryAllocator::free_chunk_ids_(kEstimatedNumberOfChunks);
288 int MemoryAllocator::max_nof_chunks_ = 0; 288 int MemoryAllocator::max_nof_chunks_ = 0;
289 int MemoryAllocator::top_ = 0; 289 int MemoryAllocator::top_ = 0;
290 290
291 291
292 void MemoryAllocator::Push(int free_chunk_id) { 292 void MemoryAllocator::Push(int free_chunk_id) {
293 ASSERT(max_nof_chunks_ > 0); 293 ASSERT(max_nof_chunks_ > 0);
294 ASSERT(top_ < max_nof_chunks_); 294 ASSERT(top_ < max_nof_chunks_);
295 free_chunk_ids_[top_++] = free_chunk_id; 295 free_chunk_ids_[top_++] = free_chunk_id;
296 } 296 }
297 297
298 298
299 int MemoryAllocator::Pop() { 299 int MemoryAllocator::Pop() {
300 ASSERT(top_ > 0); 300 ASSERT(top_ > 0);
301 return free_chunk_ids_[--top_]; 301 return free_chunk_ids_[--top_];
302 } 302 }
303 303
304 304
305 bool MemoryAllocator::Setup(int capacity) { 305 bool MemoryAllocator::Setup(intptr_t capacity) {
306 capacity_ = RoundUp(capacity, Page::kPageSize); 306 capacity_ = RoundUp(capacity, Page::kPageSize);
307 307
308 // Over-estimate the size of chunks_ array. It assumes the expansion of old 308 // Over-estimate the size of chunks_ array. It assumes the expansion of old
309 // space is always in the unit of a chunk (kChunkSize) except the last 309 // space is always in the unit of a chunk (kChunkSize) except the last
310 // expansion. 310 // expansion.
311 // 311 //
312 // Due to alignment, allocated space might be one page less than required 312 // Due to alignment, allocated space might be one page less than required
313 // number (kPagesPerChunk) of pages for old spaces. 313 // number (kPagesPerChunk) of pages for old spaces.
314 // 314 //
315 // Reserve two chunk ids for semispaces, one for map space, one for old 315 // Reserve two chunk ids for semispaces, one for map space, one for old
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 Address high = RoundDown(chunk_start + chunk_size, Page::kPageSize); 684 Address high = RoundDown(chunk_start + chunk_size, Page::kPageSize);
685 ASSERT(chunk_start <= p->address() && p->address() < high); 685 ASSERT(chunk_start <= p->address() && p->address() < high);
686 686
687 return Page::FromAddress(high - Page::kPageSize); 687 return Page::FromAddress(high - Page::kPageSize);
688 } 688 }
689 689
690 690
691 #ifdef DEBUG 691 #ifdef DEBUG
692 void MemoryAllocator::ReportStatistics() { 692 void MemoryAllocator::ReportStatistics() {
693 float pct = static_cast<float>(capacity_ - size_) / capacity_; 693 float pct = static_cast<float>(capacity_ - size_) / capacity_;
694 PrintF(" capacity: %d, used: %d, available: %%%d\n\n", 694 PrintF(" capacity: %" V8_PTR_PREFIX "d"
695 ", used: %" V8_PTR_PREFIX "d"
696 ", available: %%%d\n\n",
695 capacity_, size_, static_cast<int>(pct*100)); 697 capacity_, size_, static_cast<int>(pct*100));
696 } 698 }
697 #endif 699 #endif
698 700
699 701
700 void MemoryAllocator::RelinkPageListInChunkOrder(PagedSpace* space, 702 void MemoryAllocator::RelinkPageListInChunkOrder(PagedSpace* space,
701 Page** first_page, 703 Page** first_page,
702 Page** last_page, 704 Page** last_page,
703 Page** last_page_in_use) { 705 Page** last_page_in_use) {
704 Page* first = NULL; 706 Page* first = NULL;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 764 }
763 765
764 return last_page; 766 return last_page;
765 } 767 }
766 768
767 769
768 770
769 // ----------------------------------------------------------------------------- 771 // -----------------------------------------------------------------------------
770 // PagedSpace implementation 772 // PagedSpace implementation
771 773
772 PagedSpace::PagedSpace(int max_capacity, 774 PagedSpace::PagedSpace(intptr_t max_capacity,
773 AllocationSpace id, 775 AllocationSpace id,
774 Executability executable) 776 Executability executable)
775 : Space(id, executable) { 777 : Space(id, executable) {
776 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize) 778 max_capacity_ = (RoundDown(max_capacity, Page::kPageSize) / Page::kPageSize)
777 * Page::kObjectAreaSize; 779 * Page::kObjectAreaSize;
778 accounting_stats_.Clear(); 780 accounting_stats_.Clear();
779 781
780 allocation_info_.top = NULL; 782 allocation_info_.top = NULL;
781 allocation_info_.limit = NULL; 783 allocation_info_.limit = NULL;
782 784
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 } 1638 }
1637 LOG(HeapSampleEndEvent("NewSpace", description)); 1639 LOG(HeapSampleEndEvent("NewSpace", description));
1638 } 1640 }
1639 #endif // ENABLE_LOGGING_AND_PROFILING 1641 #endif // ENABLE_LOGGING_AND_PROFILING
1640 1642
1641 1643
1642 void NewSpace::ReportStatistics() { 1644 void NewSpace::ReportStatistics() {
1643 #ifdef DEBUG 1645 #ifdef DEBUG
1644 if (FLAG_heap_stats) { 1646 if (FLAG_heap_stats) {
1645 float pct = static_cast<float>(Available()) / Capacity(); 1647 float pct = static_cast<float>(Available()) / Capacity();
1646 PrintF(" capacity: %d, available: %d, %%%d\n", 1648 PrintF(" capacity: %" V8_PTR_PREFIX "d"
1649 ", available: %" V8_PTR_PREFIX "d, %%%d\n",
1647 Capacity(), Available(), static_cast<int>(pct*100)); 1650 Capacity(), Available(), static_cast<int>(pct*100));
1648 PrintF("\n Object Histogram:\n"); 1651 PrintF("\n Object Histogram:\n");
1649 for (int i = 0; i <= LAST_TYPE; i++) { 1652 for (int i = 0; i <= LAST_TYPE; i++) {
1650 if (allocated_histogram_[i].number() > 0) { 1653 if (allocated_histogram_[i].number() > 0) {
1651 PrintF(" %-34s%10d (%10d bytes)\n", 1654 PrintF(" %-34s%10d (%10d bytes)\n",
1652 allocated_histogram_[i].name(), 1655 allocated_histogram_[i].name(),
1653 allocated_histogram_[i].number(), 1656 allocated_histogram_[i].number(),
1654 allocated_histogram_[i].bytes()); 1657 allocated_histogram_[i].bytes());
1655 } 1658 }
1656 } 1659 }
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
2395 prev_pc <= code->instruction_end()); 2398 prev_pc <= code->instruction_end());
2396 delta += static_cast<int>(code->instruction_end() - prev_pc); 2399 delta += static_cast<int>(code->instruction_end() - prev_pc);
2397 EnterComment("NoComment", delta); 2400 EnterComment("NoComment", delta);
2398 } 2401 }
2399 } 2402 }
2400 } 2403 }
2401 2404
2402 2405
2403 void OldSpace::ReportStatistics() { 2406 void OldSpace::ReportStatistics() {
2404 int pct = Available() * 100 / Capacity(); 2407 int pct = Available() * 100 / Capacity();
2405 PrintF(" capacity: %d, waste: %d, available: %d, %%%d\n", 2408 PrintF(" capacity: %" V8_PTR_PREFIX "d"
2409 ", waste: %" V8_PTR_PREFIX "d"
2410 ", available: %" V8_PTR_PREFIX "d, %%%d\n",
2406 Capacity(), Waste(), Available(), pct); 2411 Capacity(), Waste(), Available(), pct);
2407 2412
2408 ClearHistograms(); 2413 ClearHistograms();
2409 HeapObjectIterator obj_it(this); 2414 HeapObjectIterator obj_it(this);
2410 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) 2415 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next())
2411 CollectHistogramInfo(obj); 2416 CollectHistogramInfo(obj);
2412 ReportHistogram(true); 2417 ReportHistogram(true);
2413 } 2418 }
2414 #endif 2419 #endif
2415 2420
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2552 Address end = start + size_in_bytes; 2557 Address end = start + size_in_bytes;
2553 for (Address a = start; a < end; a += size) { 2558 for (Address a = start; a < end; a += size) {
2554 Free(a, add_to_freelist); 2559 Free(a, add_to_freelist);
2555 } 2560 }
2556 } 2561 }
2557 2562
2558 2563
2559 #ifdef DEBUG 2564 #ifdef DEBUG
2560 void FixedSpace::ReportStatistics() { 2565 void FixedSpace::ReportStatistics() {
2561 int pct = Available() * 100 / Capacity(); 2566 int pct = Available() * 100 / Capacity();
2562 PrintF(" capacity: %d, waste: %d, available: %d, %%%d\n", 2567 PrintF(" capacity: %" V8_PTR_PREFIX "d"
2568 ", waste: %" V8_PTR_PREFIX "d"
2569 ", available: %" V8_PTR_PREFIX "d, %%%d\n",
2563 Capacity(), Waste(), Available(), pct); 2570 Capacity(), Waste(), Available(), pct);
2564 2571
2565 ClearHistograms(); 2572 ClearHistograms();
2566 HeapObjectIterator obj_it(this); 2573 HeapObjectIterator obj_it(this);
2567 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) 2574 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next())
2568 CollectHistogramInfo(obj); 2575 CollectHistogramInfo(obj);
2569 ReportHistogram(false); 2576 ReportHistogram(false);
2570 } 2577 }
2571 #endif 2578 #endif
2572 2579
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 3011
3005 void LargeObjectSpace::Print() { 3012 void LargeObjectSpace::Print() {
3006 LargeObjectIterator it(this); 3013 LargeObjectIterator it(this);
3007 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { 3014 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
3008 obj->Print(); 3015 obj->Print();
3009 } 3016 }
3010 } 3017 }
3011 3018
3012 3019
3013 void LargeObjectSpace::ReportStatistics() { 3020 void LargeObjectSpace::ReportStatistics() {
3014 PrintF(" size: %d\n", size_); 3021 PrintF(" size: %" V8_PTR_PREFIX "d\n", size_);
3015 int num_objects = 0; 3022 int num_objects = 0;
3016 ClearHistograms(); 3023 ClearHistograms();
3017 LargeObjectIterator it(this); 3024 LargeObjectIterator it(this);
3018 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) { 3025 for (HeapObject* obj = it.next(); obj != NULL; obj = it.next()) {
3019 num_objects++; 3026 num_objects++;
3020 CollectHistogramInfo(obj); 3027 CollectHistogramInfo(obj);
3021 } 3028 }
3022 3029
3023 PrintF(" number of objects %d\n", num_objects); 3030 PrintF(" number of objects %d\n", num_objects);
3024 if (num_objects > 0) ReportHistogram(false); 3031 if (num_objects > 0) ReportHistogram(false);
3025 } 3032 }
3026 3033
3027 3034
3028 void LargeObjectSpace::CollectCodeStatistics() { 3035 void LargeObjectSpace::CollectCodeStatistics() {
3029 LargeObjectIterator obj_it(this); 3036 LargeObjectIterator obj_it(this);
3030 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) { 3037 for (HeapObject* obj = obj_it.next(); obj != NULL; obj = obj_it.next()) {
3031 if (obj->IsCode()) { 3038 if (obj->IsCode()) {
3032 Code* code = Code::cast(obj); 3039 Code* code = Code::cast(obj);
3033 code_kind_statistics[code->kind()] += code->Size(); 3040 code_kind_statistics[code->kind()] += code->Size();
3034 } 3041 }
3035 } 3042 }
3036 } 3043 }
3037 #endif // DEBUG 3044 #endif // DEBUG
3038 3045
3039 } } // namespace v8::internal 3046 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/spaces.h ('k') | test/mjsunit/math-abs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698