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