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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 void ClearEvacuationCandidate() { | 638 void ClearEvacuationCandidate() { |
639 ASSERT(slots_buffer_ == NULL); | 639 ASSERT(slots_buffer_ == NULL); |
640 ClearFlag(EVACUATION_CANDIDATE); | 640 ClearFlag(EVACUATION_CANDIDATE); |
641 } | 641 } |
642 | 642 |
643 Address area_start() { return area_start_; } | 643 Address area_start() { return area_start_; } |
644 Address area_end() { return area_end_; } | 644 Address area_end() { return area_end_; } |
645 int area_size() { | 645 int area_size() { |
646 return static_cast<int>(area_end() - area_start()); | 646 return static_cast<int>(area_end() - area_start()); |
647 } | 647 } |
| 648 bool CommitArea(size_t requested); |
648 | 649 |
649 // Approximate amount of physical memory committed for this chunk. | 650 // Approximate amount of physical memory committed for this chunk. |
650 size_t CommittedPhysicalMemory() { | 651 size_t CommittedPhysicalMemory() { |
651 return high_water_mark_; | 652 return high_water_mark_; |
652 } | 653 } |
653 | 654 |
654 static inline void UpdateHighWaterMark(Address mark); | 655 static inline void UpdateHighWaterMark(Address mark); |
655 | 656 |
656 protected: | 657 protected: |
657 MemoryChunk* next_chunk_; | 658 MemoryChunk* next_chunk_; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 bool exists() { return this != NULL && code_range_ != NULL; } | 881 bool exists() { return this != NULL && code_range_ != NULL; } |
881 bool contains(Address address) { | 882 bool contains(Address address) { |
882 if (this == NULL || code_range_ == NULL) return false; | 883 if (this == NULL || code_range_ == NULL) return false; |
883 Address start = static_cast<Address>(code_range_->address()); | 884 Address start = static_cast<Address>(code_range_->address()); |
884 return start <= address && address < start + code_range_->size(); | 885 return start <= address && address < start + code_range_->size(); |
885 } | 886 } |
886 | 887 |
887 // Allocates a chunk of memory from the large-object portion of | 888 // Allocates a chunk of memory from the large-object portion of |
888 // the code range. On platforms with no separate code range, should | 889 // the code range. On platforms with no separate code range, should |
889 // not be called. | 890 // not be called. |
890 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested, | 891 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested_size, |
| 892 const size_t commit_size, |
891 size_t* allocated); | 893 size_t* allocated); |
| 894 bool CommitRawMemory(Address start, size_t length); |
| 895 bool UncommitRawMemory(Address start, size_t length); |
892 void FreeRawMemory(Address buf, size_t length); | 896 void FreeRawMemory(Address buf, size_t length); |
893 | 897 |
894 private: | 898 private: |
895 Isolate* isolate_; | 899 Isolate* isolate_; |
896 | 900 |
897 // The reserved range of virtual memory that all code objects are put in. | 901 // The reserved range of virtual memory that all code objects are put in. |
898 VirtualMemory* code_range_; | 902 VirtualMemory* code_range_; |
899 // Plain old data class, just a struct plus a constructor. | 903 // Plain old data class, just a struct plus a constructor. |
900 class FreeBlock { | 904 class FreeBlock { |
901 public: | 905 public: |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 // Returns maximum available bytes that the old space can have. | 1033 // Returns maximum available bytes that the old space can have. |
1030 intptr_t MaxAvailable() { | 1034 intptr_t MaxAvailable() { |
1031 return (Available() / Page::kPageSize) * Page::kMaxNonCodeHeapObjectSize; | 1035 return (Available() / Page::kPageSize) * Page::kMaxNonCodeHeapObjectSize; |
1032 } | 1036 } |
1033 | 1037 |
1034 #ifdef DEBUG | 1038 #ifdef DEBUG |
1035 // Reports statistic info of the space. | 1039 // Reports statistic info of the space. |
1036 void ReportStatistics(); | 1040 void ReportStatistics(); |
1037 #endif | 1041 #endif |
1038 | 1042 |
1039 MemoryChunk* AllocateChunk(intptr_t body_size, | 1043 // Returns a MemoryChunk in which the memory region from commit_area_size to |
| 1044 // reserve_area_size of the chunk area is reserved but not committed, it |
| 1045 // could be committed later by calling MemoryChunk::CommitArea. |
| 1046 MemoryChunk* AllocateChunk(intptr_t reserve_area_size, |
| 1047 intptr_t commit_area_size, |
1040 Executability executable, | 1048 Executability executable, |
1041 Space* space); | 1049 Space* space); |
1042 | 1050 |
1043 Address ReserveAlignedMemory(size_t requested, | 1051 Address ReserveAlignedMemory(size_t requested, |
1044 size_t alignment, | 1052 size_t alignment, |
1045 VirtualMemory* controller); | 1053 VirtualMemory* controller); |
1046 Address AllocateAlignedMemory(size_t requested, | 1054 Address AllocateAlignedMemory(size_t reserve_size, |
| 1055 size_t commit_size, |
1047 size_t alignment, | 1056 size_t alignment, |
1048 Executability executable, | 1057 Executability executable, |
1049 VirtualMemory* controller); | 1058 VirtualMemory* controller); |
1050 | 1059 |
1051 void FreeMemory(VirtualMemory* reservation, Executability executable); | 1060 void FreeMemory(VirtualMemory* reservation, Executability executable); |
1052 void FreeMemory(Address addr, size_t size, Executability executable); | 1061 void FreeMemory(Address addr, size_t size, Executability executable); |
1053 | 1062 |
1054 // Commit a contiguous block of memory from the initial chunk. Assumes that | 1063 // Commit a contiguous block of memory from the initial chunk. Assumes that |
1055 // the address is not NULL, the size is greater than zero, and that the | 1064 // the address is not NULL, the size is greater than zero, and that the |
1056 // block is contained in the initial chunk. Returns true if it succeeded | 1065 // block is contained in the initial chunk. Returns true if it succeeded |
(...skipping 29 matching lines...) Expand all Loading... |
1086 static int CodePageGuardSize(); | 1095 static int CodePageGuardSize(); |
1087 | 1096 |
1088 static int CodePageAreaStartOffset(); | 1097 static int CodePageAreaStartOffset(); |
1089 | 1098 |
1090 static int CodePageAreaEndOffset(); | 1099 static int CodePageAreaEndOffset(); |
1091 | 1100 |
1092 static int CodePageAreaSize() { | 1101 static int CodePageAreaSize() { |
1093 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); | 1102 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); |
1094 } | 1103 } |
1095 | 1104 |
1096 MUST_USE_RESULT static bool CommitCodePage(VirtualMemory* vm, | 1105 MUST_USE_RESULT static bool CommitExecutableMemory(VirtualMemory* vm, |
1097 Address start, | 1106 Address start, |
1098 size_t size); | 1107 size_t commit_size, |
| 1108 size_t reserved_size); |
1099 | 1109 |
1100 private: | 1110 private: |
1101 Isolate* isolate_; | 1111 Isolate* isolate_; |
1102 | 1112 |
1103 // Maximum space size in bytes. | 1113 // Maximum space size in bytes. |
1104 size_t capacity_; | 1114 size_t capacity_; |
1105 // Maximum subset of capacity_ that can be executable | 1115 // Maximum subset of capacity_ that can be executable |
1106 size_t capacity_executable_; | 1116 size_t capacity_executable_; |
1107 | 1117 |
1108 // Allocated space size in bytes. | 1118 // Allocated space size in bytes. |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2763 } | 2773 } |
2764 // Must be small, since an iteration is used for lookup. | 2774 // Must be small, since an iteration is used for lookup. |
2765 static const int kMaxComments = 64; | 2775 static const int kMaxComments = 64; |
2766 }; | 2776 }; |
2767 #endif | 2777 #endif |
2768 | 2778 |
2769 | 2779 |
2770 } } // namespace v8::internal | 2780 } } // namespace v8::internal |
2771 | 2781 |
2772 #endif // V8_SPACES_H_ | 2782 #endif // V8_SPACES_H_ |
OLD | NEW |