OLD | NEW |
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 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
997 // Sets up the semispace using the given chunk. | 997 // Sets up the semispace using the given chunk. |
998 bool Setup(Address start, int initial_capacity, int maximum_capacity); | 998 bool Setup(Address start, int initial_capacity, int maximum_capacity); |
999 | 999 |
1000 // Tear down the space. Heap memory was not allocated by the space, so it | 1000 // Tear down the space. Heap memory was not allocated by the space, so it |
1001 // is not deallocated here. | 1001 // is not deallocated here. |
1002 void TearDown(); | 1002 void TearDown(); |
1003 | 1003 |
1004 // True if the space has been set up but not torn down. | 1004 // True if the space has been set up but not torn down. |
1005 bool HasBeenSetup() { return start_ != NULL; } | 1005 bool HasBeenSetup() { return start_ != NULL; } |
1006 | 1006 |
1007 // Double the size of the semispace by committing extra virtual memory. | 1007 // Grow the size of the semispace by committing extra virtual memory. |
1008 // Assumes that the caller has checked that the semispace has not reached | 1008 // Assumes that the caller has checked that the semispace has not reached |
1009 // its maximum capacity (and thus there is space available in the reserved | 1009 // its maximum capacity (and thus there is space available in the reserved |
1010 // address range to grow). | 1010 // address range to grow). |
1011 bool Double(); | 1011 bool Grow(); |
1012 | 1012 |
1013 // Returns the start address of the space. | 1013 // Returns the start address of the space. |
1014 Address low() { return start_; } | 1014 Address low() { return start_; } |
1015 // Returns one past the end address of the space. | 1015 // Returns one past the end address of the space. |
1016 Address high() { return low() + capacity_; } | 1016 Address high() { return low() + capacity_; } |
1017 | 1017 |
1018 // Age mark accessors. | 1018 // Age mark accessors. |
1019 Address age_mark() { return age_mark_; } | 1019 Address age_mark() { return age_mark_; } |
1020 void set_age_mark(Address mark) { age_mark_ = mark; } | 1020 void set_age_mark(Address mark) { age_mark_ = mark; } |
1021 | 1021 |
(...skipping 22 matching lines...) Expand all Loading... |
1044 | 1044 |
1045 bool is_committed() { return committed_; } | 1045 bool is_committed() { return committed_; } |
1046 bool Commit(); | 1046 bool Commit(); |
1047 bool Uncommit(); | 1047 bool Uncommit(); |
1048 | 1048 |
1049 #ifdef DEBUG | 1049 #ifdef DEBUG |
1050 virtual void Print(); | 1050 virtual void Print(); |
1051 virtual void Verify(); | 1051 virtual void Verify(); |
1052 #endif | 1052 #endif |
1053 | 1053 |
| 1054 // Returns the current capacity of the semi space. |
| 1055 int Capacity() { return capacity_; } |
| 1056 |
| 1057 // Returns the maximum capacity of the semi space. |
| 1058 int MaximumCapacity() { return maximum_capacity_; } |
| 1059 |
| 1060 |
1054 private: | 1061 private: |
1055 // The current and maximum capacity of the space. | 1062 // The current and maximum capacity of the space. |
1056 int capacity_; | 1063 int capacity_; |
1057 int maximum_capacity_; | 1064 int maximum_capacity_; |
1058 | 1065 |
1059 // The start address of the space. | 1066 // The start address of the space. |
1060 Address start_; | 1067 Address start_; |
1061 // Used to govern object promotion during mark-compact collection. | 1068 // Used to govern object promotion during mark-compact collection. |
1062 Address age_mark_; | 1069 Address age_mark_; |
1063 | 1070 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1137 void TearDown(); | 1144 void TearDown(); |
1138 | 1145 |
1139 // True if the space has been set up but not torn down. | 1146 // True if the space has been set up but not torn down. |
1140 bool HasBeenSetup() { | 1147 bool HasBeenSetup() { |
1141 return to_space_.HasBeenSetup() && from_space_.HasBeenSetup(); | 1148 return to_space_.HasBeenSetup() && from_space_.HasBeenSetup(); |
1142 } | 1149 } |
1143 | 1150 |
1144 // Flip the pair of spaces. | 1151 // Flip the pair of spaces. |
1145 void Flip(); | 1152 void Flip(); |
1146 | 1153 |
1147 // Doubles the capacity of the semispaces. Assumes that they are not at | 1154 // Grow the capacity of the semispaces. Assumes that they are not at |
1148 // their maximum capacity. Returns a flag indicating success or failure. | 1155 // their maximum capacity. Returns a flag indicating success or failure. |
1149 bool Double(); | 1156 bool Grow(); |
1150 | 1157 |
1151 // True if the address or object lies in the address range of either | 1158 // True if the address or object lies in the address range of either |
1152 // semispace (not necessarily below the allocation pointer). | 1159 // semispace (not necessarily below the allocation pointer). |
1153 bool Contains(Address a) { | 1160 bool Contains(Address a) { |
1154 return (reinterpret_cast<uintptr_t>(a) & address_mask_) | 1161 return (reinterpret_cast<uintptr_t>(a) & address_mask_) |
1155 == reinterpret_cast<uintptr_t>(start_); | 1162 == reinterpret_cast<uintptr_t>(start_); |
1156 } | 1163 } |
1157 bool Contains(Object* o) { | 1164 bool Contains(Object* o) { |
1158 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; | 1165 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
1159 } | 1166 } |
1160 | 1167 |
1161 // Return the allocated bytes in the active semispace. | 1168 // Return the allocated bytes in the active semispace. |
1162 virtual int Size() { return top() - bottom(); } | 1169 virtual int Size() { return top() - bottom(); } |
1163 // Return the current capacity of a semispace. | 1170 // Return the current capacity of a semispace. |
1164 int Capacity() { return capacity_; } | 1171 int Capacity() { |
| 1172 ASSERT(to_space_.Capacity() == from_space_.Capacity()); |
| 1173 return to_space_.Capacity(); |
| 1174 } |
1165 // Return the available bytes without growing in the active semispace. | 1175 // Return the available bytes without growing in the active semispace. |
1166 int Available() { return Capacity() - Size(); } | 1176 int Available() { return Capacity() - Size(); } |
1167 | 1177 |
1168 // Return the maximum capacity of a semispace. | 1178 // Return the maximum capacity of a semispace. |
1169 int MaximumCapacity() { return maximum_capacity_; } | 1179 int MaximumCapacity() { |
| 1180 ASSERT(to_space_.MaximumCapacity() == from_space_.MaximumCapacity()); |
| 1181 return to_space_.MaximumCapacity(); |
| 1182 } |
1170 | 1183 |
1171 // Return the address of the allocation pointer in the active semispace. | 1184 // Return the address of the allocation pointer in the active semispace. |
1172 Address top() { return allocation_info_.top; } | 1185 Address top() { return allocation_info_.top; } |
1173 // Return the address of the first object in the active semispace. | 1186 // Return the address of the first object in the active semispace. |
1174 Address bottom() { return to_space_.low(); } | 1187 Address bottom() { return to_space_.low(); } |
1175 | 1188 |
1176 // Get the age mark of the inactive semispace. | 1189 // Get the age mark of the inactive semispace. |
1177 Address age_mark() { return from_space_.age_mark(); } | 1190 Address age_mark() { return from_space_.age_mark(); } |
1178 // Set the age mark in the active semispace. | 1191 // Set the age mark in the active semispace. |
1179 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); } | 1192 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1265 if (from_space_.is_committed()) return true; | 1278 if (from_space_.is_committed()) return true; |
1266 return from_space_.Commit(); | 1279 return from_space_.Commit(); |
1267 } | 1280 } |
1268 | 1281 |
1269 bool UncommitFromSpace() { | 1282 bool UncommitFromSpace() { |
1270 if (!from_space_.is_committed()) return true; | 1283 if (!from_space_.is_committed()) return true; |
1271 return from_space_.Uncommit(); | 1284 return from_space_.Uncommit(); |
1272 } | 1285 } |
1273 | 1286 |
1274 private: | 1287 private: |
1275 // The current and maximum capacities of a semispace. | |
1276 int capacity_; | |
1277 int maximum_capacity_; | |
1278 | |
1279 // The semispaces. | 1288 // The semispaces. |
1280 SemiSpace to_space_; | 1289 SemiSpace to_space_; |
1281 SemiSpace from_space_; | 1290 SemiSpace from_space_; |
1282 | 1291 |
1283 // Start address and bit mask for containment testing. | 1292 // Start address and bit mask for containment testing. |
1284 Address start_; | 1293 Address start_; |
1285 uintptr_t address_mask_; | 1294 uintptr_t address_mask_; |
1286 uintptr_t object_mask_; | 1295 uintptr_t object_mask_; |
1287 uintptr_t object_expected_; | 1296 uintptr_t object_expected_; |
1288 | 1297 |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 | 1842 |
1834 private: | 1843 private: |
1835 LargeObjectChunk* current_; | 1844 LargeObjectChunk* current_; |
1836 HeapObjectCallback size_func_; | 1845 HeapObjectCallback size_func_; |
1837 }; | 1846 }; |
1838 | 1847 |
1839 | 1848 |
1840 } } // namespace v8::internal | 1849 } } // namespace v8::internal |
1841 | 1850 |
1842 #endif // V8_SPACES_H_ | 1851 #endif // V8_SPACES_H_ |
OLD | NEW |