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

Side by Side Diff: src/spaces.h

Issue 4634003: Landing for Justin Schuh.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 1 month 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.cc ('k') | src/spaces.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 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 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // The fact that pages for paged spaces are allocated and deallocated in chunks 484 // The fact that pages for paged spaces are allocated and deallocated in chunks
485 // induces a constraint on the order of pages in a linked lists. We say that 485 // induces a constraint on the order of pages in a linked lists. We say that
486 // pages are linked in the chunk-order if and only if every two consecutive 486 // pages are linked in the chunk-order if and only if every two consecutive
487 // pages from the same chunk are consecutive in the linked list. 487 // pages from the same chunk are consecutive in the linked list.
488 // 488 //
489 489
490 490
491 class MemoryAllocator : public AllStatic { 491 class MemoryAllocator : public AllStatic {
492 public: 492 public:
493 // Initializes its internal bookkeeping structures. 493 // Initializes its internal bookkeeping structures.
494 // Max capacity of the total space. 494 // Max capacity of the total space and executable memory limit.
495 static bool Setup(intptr_t max_capacity); 495 static bool Setup(int max_capacity, int capacity_executable);
496 496
497 // Deletes valid chunks. 497 // Deletes valid chunks.
498 static void TearDown(); 498 static void TearDown();
499 499
500 // Reserves an initial address range of virtual memory to be split between 500 // Reserves an initial address range of virtual memory to be split between
501 // the two new space semispaces, the old space, and the map space. The 501 // the two new space semispaces, the old space, and the map space. The
502 // memory is not yet committed or assigned to spaces and split into pages. 502 // memory is not yet committed or assigned to spaces and split into pages.
503 // The initial chunk is unmapped when the memory allocator is torn down. 503 // The initial chunk is unmapped when the memory allocator is torn down.
504 // This function should only be called when there is not already a reserved 504 // This function should only be called when there is not already a reserved
505 // initial chunk (initial_chunk_ should be NULL). It returns the start 505 // initial chunk (initial_chunk_ should be NULL). It returns the start
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 MemoryAllocationCallback callback); 583 MemoryAllocationCallback callback);
584 584
585 // Returns the maximum available bytes of heaps. 585 // Returns the maximum available bytes of heaps.
586 static intptr_t Available() { 586 static intptr_t Available() {
587 return capacity_ < size_ ? 0 : capacity_ - size_; 587 return capacity_ < size_ ? 0 : capacity_ - size_;
588 } 588 }
589 589
590 // Returns allocated spaces in bytes. 590 // Returns allocated spaces in bytes.
591 static intptr_t Size() { return size_; } 591 static intptr_t Size() { return size_; }
592 592
593 // Returns the maximum available executable bytes of heaps.
594 static int AvailableExecutable() {
595 if (capacity_executable_ < size_executable_) return 0;
596 return capacity_executable_ - size_executable_;
597 }
598
593 // Returns allocated executable spaces in bytes. 599 // Returns allocated executable spaces in bytes.
594 static intptr_t SizeExecutable() { return size_executable_; } 600 static intptr_t SizeExecutable() { return size_executable_; }
595 601
596 // Returns maximum available bytes that the old space can have. 602 // Returns maximum available bytes that the old space can have.
597 static intptr_t MaxAvailable() { 603 static intptr_t MaxAvailable() {
598 return (Available() / Page::kPageSize) * Page::kObjectAreaSize; 604 return (Available() / Page::kPageSize) * Page::kObjectAreaSize;
599 } 605 }
600 606
601 // Links two pages. 607 // Links two pages.
602 static inline void SetNextPage(Page* prev, Page* next); 608 static inline void SetNextPage(Page* prev, Page* next);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 #ifdef V8_TARGET_ARCH_X64 652 #ifdef V8_TARGET_ARCH_X64
647 static const int kPagesPerChunk = 32; 653 static const int kPagesPerChunk = 32;
648 #else 654 #else
649 static const int kPagesPerChunk = 16; 655 static const int kPagesPerChunk = 16;
650 #endif 656 #endif
651 static const int kChunkSize = kPagesPerChunk * Page::kPageSize; 657 static const int kChunkSize = kPagesPerChunk * Page::kPageSize;
652 658
653 private: 659 private:
654 // Maximum space size in bytes. 660 // Maximum space size in bytes.
655 static intptr_t capacity_; 661 static intptr_t capacity_;
662 // Maximum subset of capacity_ that can be executable
663 static intptr_t capacity_executable_;
656 664
657 // Allocated space size in bytes. 665 // Allocated space size in bytes.
658 static intptr_t size_; 666 static intptr_t size_;
659 // Allocated executable space size in bytes. 667 // Allocated executable space size in bytes.
660 static intptr_t size_executable_; 668 static intptr_t size_executable_;
661 669
662 struct MemoryAllocationCallbackRegistration { 670 struct MemoryAllocationCallbackRegistration {
663 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback, 671 MemoryAllocationCallbackRegistration(MemoryAllocationCallback callback,
664 ObjectSpace space, 672 ObjectSpace space,
665 AllocationAction action) 673 AllocationAction action)
(...skipping 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 2269
2262 private: 2270 private:
2263 LargeObjectChunk* current_; 2271 LargeObjectChunk* current_;
2264 HeapObjectCallback size_func_; 2272 HeapObjectCallback size_func_;
2265 }; 2273 };
2266 2274
2267 2275
2268 } } // namespace v8::internal 2276 } } // namespace v8::internal
2269 2277
2270 #endif // V8_SPACES_H_ 2278 #endif // V8_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698