Chromium Code Reviews| 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 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 646 return static_cast<int>(area_end() - area_start()); | 646 return static_cast<int>(area_end() - area_start()); |
| 647 } | 647 } |
| 648 | 648 |
| 649 // Approximate amount of physical memory committed for this chunk. | 649 // Approximate amount of physical memory committed for this chunk. |
| 650 size_t CommittedPhysicalMemory() { | 650 size_t CommittedPhysicalMemory() { |
| 651 return high_water_mark_; | 651 return high_water_mark_; |
| 652 } | 652 } |
| 653 | 653 |
| 654 static inline void UpdateHighWaterMark(Address mark); | 654 static inline void UpdateHighWaterMark(Address mark); |
| 655 | 655 |
| 656 // Commit chunk body up to the body_size. If body_size is within the | |
| 657 // committed size, the committed pages are never uncommitted. | |
|
danno
2013/01/17 16:00:55
Why not uncommit? It seems to me that uncommitting
haitao.feng
2013/01/18 12:59:26
Done.
| |
| 658 bool CommitBody(size_t body_size, Executability executable); | |
| 659 | |
| 656 protected: | 660 protected: |
| 657 MemoryChunk* next_chunk_; | 661 MemoryChunk* next_chunk_; |
| 658 MemoryChunk* prev_chunk_; | 662 MemoryChunk* prev_chunk_; |
| 659 size_t size_; | 663 size_t size_; |
| 660 intptr_t flags_; | 664 intptr_t flags_; |
| 661 | 665 |
| 662 // Start and end of allocatable memory on this chunk. | 666 // Start and end of allocatable memory on this chunk. |
| 663 Address area_start_; | 667 Address area_start_; |
| 664 Address area_end_; | 668 Address area_end_; |
| 665 | 669 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 880 bool exists() { return this != NULL && code_range_ != NULL; } | 884 bool exists() { return this != NULL && code_range_ != NULL; } |
| 881 bool contains(Address address) { | 885 bool contains(Address address) { |
| 882 if (this == NULL || code_range_ == NULL) return false; | 886 if (this == NULL || code_range_ == NULL) return false; |
| 883 Address start = static_cast<Address>(code_range_->address()); | 887 Address start = static_cast<Address>(code_range_->address()); |
| 884 return start <= address && address < start + code_range_->size(); | 888 return start <= address && address < start + code_range_->size(); |
| 885 } | 889 } |
| 886 | 890 |
| 887 // Allocates a chunk of memory from the large-object portion of | 891 // Allocates a chunk of memory from the large-object portion of |
| 888 // the code range. On platforms with no separate code range, should | 892 // the code range. On platforms with no separate code range, should |
| 889 // not be called. | 893 // not be called. |
| 890 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested, | 894 MUST_USE_RESULT Address AllocateRawMemory(const size_t requested_size, |
| 895 const size_t commit_size, | |
| 891 size_t* allocated); | 896 size_t* allocated); |
| 897 bool CommitRawMemory(Address start, size_t length); | |
| 892 void FreeRawMemory(Address buf, size_t length); | 898 void FreeRawMemory(Address buf, size_t length); |
| 893 | 899 |
| 894 private: | 900 private: |
| 895 Isolate* isolate_; | 901 Isolate* isolate_; |
| 896 | 902 |
| 897 // The reserved range of virtual memory that all code objects are put in. | 903 // The reserved range of virtual memory that all code objects are put in. |
| 898 VirtualMemory* code_range_; | 904 VirtualMemory* code_range_; |
| 899 // Plain old data class, just a struct plus a constructor. | 905 // Plain old data class, just a struct plus a constructor. |
| 900 class FreeBlock { | 906 class FreeBlock { |
| 901 public: | 907 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. | 1035 // Returns maximum available bytes that the old space can have. |
| 1030 intptr_t MaxAvailable() { | 1036 intptr_t MaxAvailable() { |
| 1031 return (Available() / Page::kPageSize) * Page::kMaxNonCodeHeapObjectSize; | 1037 return (Available() / Page::kPageSize) * Page::kMaxNonCodeHeapObjectSize; |
| 1032 } | 1038 } |
| 1033 | 1039 |
| 1034 #ifdef DEBUG | 1040 #ifdef DEBUG |
| 1035 // Reports statistic info of the space. | 1041 // Reports statistic info of the space. |
| 1036 void ReportStatistics(); | 1042 void ReportStatistics(); |
| 1037 #endif | 1043 #endif |
| 1038 | 1044 |
| 1039 MemoryChunk* AllocateChunk(intptr_t body_size, | 1045 // After calling this function, the memory region from commit_body_size to |
|
danno
2013/01/17 16:00:55
How about just:
// Returns a MemoryChunk in which
haitao.feng
2013/01/18 12:59:26
Done.
| |
| 1046 // reserve_body_size of the body is reserved but not committed, they could be | |
|
danno
2013/01/17 16:00:55
nit: s/they could/it could/
haitao.feng
2013/01/18 12:59:26
Done.
| |
| 1047 // committed later by calling MemoryChunk::CommitBody with a new body size. | |
| 1048 MemoryChunk* AllocateChunk(intptr_t reserve_body_size, | |
| 1049 intptr_t commit_body_size, | |
| 1040 Executability executable, | 1050 Executability executable, |
| 1041 Space* space); | 1051 Space* space); |
| 1042 | 1052 |
| 1043 Address ReserveAlignedMemory(size_t requested, | 1053 Address ReserveAlignedMemory(size_t requested, |
| 1044 size_t alignment, | 1054 size_t alignment, |
| 1045 VirtualMemory* controller); | 1055 VirtualMemory* controller); |
| 1046 Address AllocateAlignedMemory(size_t requested, | 1056 Address AllocateAlignedMemory(size_t requested_size, |
|
danno
2013/01/17 16:00:55
s/requested_size/reserve_size/
haitao.feng
2013/01/18 12:59:26
Done.
| |
| 1057 size_t commit_size, | |
| 1047 size_t alignment, | 1058 size_t alignment, |
| 1048 Executability executable, | 1059 Executability executable, |
| 1049 VirtualMemory* controller); | 1060 VirtualMemory* controller); |
| 1050 | 1061 |
| 1051 void FreeMemory(VirtualMemory* reservation, Executability executable); | 1062 void FreeMemory(VirtualMemory* reservation, Executability executable); |
| 1052 void FreeMemory(Address addr, size_t size, Executability executable); | 1063 void FreeMemory(Address addr, size_t size, Executability executable); |
| 1053 | 1064 |
| 1054 // Commit a contiguous block of memory from the initial chunk. Assumes that | 1065 // 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 | 1066 // 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 | 1067 // block is contained in the initial chunk. Returns true if it succeeded |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1086 static int CodePageGuardSize(); | 1097 static int CodePageGuardSize(); |
| 1087 | 1098 |
| 1088 static int CodePageAreaStartOffset(); | 1099 static int CodePageAreaStartOffset(); |
| 1089 | 1100 |
| 1090 static int CodePageAreaEndOffset(); | 1101 static int CodePageAreaEndOffset(); |
| 1091 | 1102 |
| 1092 static int CodePageAreaSize() { | 1103 static int CodePageAreaSize() { |
| 1093 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); | 1104 return CodePageAreaEndOffset() - CodePageAreaStartOffset(); |
| 1094 } | 1105 } |
| 1095 | 1106 |
| 1096 MUST_USE_RESULT static bool CommitCodePage(VirtualMemory* vm, | 1107 MUST_USE_RESULT static bool CommitExecutableMemory(VirtualMemory* vm, |
| 1097 Address start, | 1108 Address start, |
| 1098 size_t size); | 1109 size_t commit_size, |
| 1110 size_t reserved_size); | |
| 1099 | 1111 |
| 1100 private: | 1112 private: |
| 1101 Isolate* isolate_; | 1113 Isolate* isolate_; |
| 1102 | 1114 |
| 1103 // Maximum space size in bytes. | 1115 // Maximum space size in bytes. |
| 1104 size_t capacity_; | 1116 size_t capacity_; |
| 1105 // Maximum subset of capacity_ that can be executable | 1117 // Maximum subset of capacity_ that can be executable |
| 1106 size_t capacity_executable_; | 1118 size_t capacity_executable_; |
| 1107 | 1119 |
| 1108 // Allocated space size in bytes. | 1120 // Allocated space size in bytes. |
| (...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2763 } | 2775 } |
| 2764 // Must be small, since an iteration is used for lookup. | 2776 // Must be small, since an iteration is used for lookup. |
| 2765 static const int kMaxComments = 64; | 2777 static const int kMaxComments = 64; |
| 2766 }; | 2778 }; |
| 2767 #endif | 2779 #endif |
| 2768 | 2780 |
| 2769 | 2781 |
| 2770 } } // namespace v8::internal | 2782 } } // namespace v8::internal |
| 2771 | 2783 |
| 2772 #endif // V8_SPACES_H_ | 2784 #endif // V8_SPACES_H_ |
| OLD | NEW |