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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // Checks whether an address is page aligned. | 165 // Checks whether an address is page aligned. |
166 static bool IsAlignedToPageSize(Address a) { | 166 static bool IsAlignedToPageSize(Address a) { |
167 return 0 == (OffsetFrom(a) & kPageAlignmentMask); | 167 return 0 == (OffsetFrom(a) & kPageAlignmentMask); |
168 } | 168 } |
169 | 169 |
170 // True if this page is a large object page. | 170 // True if this page is a large object page. |
171 bool IsLargeObjectPage() { return (is_normal_page & 0x1) == 0; } | 171 bool IsLargeObjectPage() { return (is_normal_page & 0x1) == 0; } |
172 | 172 |
173 // Returns the offset of a given address to this page. | 173 // Returns the offset of a given address to this page. |
174 INLINE(int Offset(Address a)) { | 174 INLINE(int Offset(Address a)) { |
175 int offset = a - address(); | 175 int offset = static_cast<int>(a - address()); |
176 ASSERT_PAGE_OFFSET(offset); | 176 ASSERT_PAGE_OFFSET(offset); |
177 return offset; | 177 return offset; |
178 } | 178 } |
179 | 179 |
180 // Returns the address for a given offset to the this page. | 180 // Returns the address for a given offset to the this page. |
181 Address OffsetToAddress(int offset) { | 181 Address OffsetToAddress(int offset) { |
182 ASSERT_PAGE_OFFSET(offset); | 182 ASSERT_PAGE_OFFSET(offset); |
183 return address() + offset; | 183 return address() + offset; |
184 } | 184 } |
185 | 185 |
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 == reinterpret_cast<uintptr_t>(start_); | 1109 == reinterpret_cast<uintptr_t>(start_); |
1110 } | 1110 } |
1111 | 1111 |
1112 // True if the object is a heap object in the address range of this | 1112 // True if the object is a heap object in the address range of this |
1113 // semispace (not necessarily below the allocation pointer). | 1113 // semispace (not necessarily below the allocation pointer). |
1114 bool Contains(Object* o) { | 1114 bool Contains(Object* o) { |
1115 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; | 1115 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
1116 } | 1116 } |
1117 | 1117 |
1118 // The offset of an address from the beginning of the space. | 1118 // The offset of an address from the beginning of the space. |
1119 int SpaceOffsetForAddress(Address addr) { return addr - low(); } | 1119 int SpaceOffsetForAddress(Address addr) { |
| 1120 return static_cast<int>(addr - low()); |
| 1121 } |
1120 | 1122 |
1121 // If we don't have this here then SemiSpace will be abstract. However | 1123 // If we don't have this here then SemiSpace will be abstract. However |
1122 // it should never be called. | 1124 // it should never be called. |
1123 virtual int Size() { | 1125 virtual int Size() { |
1124 UNREACHABLE(); | 1126 UNREACHABLE(); |
1125 return 0; | 1127 return 0; |
1126 } | 1128 } |
1127 | 1129 |
1128 bool is_committed() { return committed_; } | 1130 bool is_committed() { return committed_; } |
1129 bool Commit(); | 1131 bool Commit(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1248 // semispace (not necessarily below the allocation pointer). | 1250 // semispace (not necessarily below the allocation pointer). |
1249 bool Contains(Address a) { | 1251 bool Contains(Address a) { |
1250 return (reinterpret_cast<uintptr_t>(a) & address_mask_) | 1252 return (reinterpret_cast<uintptr_t>(a) & address_mask_) |
1251 == reinterpret_cast<uintptr_t>(start_); | 1253 == reinterpret_cast<uintptr_t>(start_); |
1252 } | 1254 } |
1253 bool Contains(Object* o) { | 1255 bool Contains(Object* o) { |
1254 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; | 1256 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
1255 } | 1257 } |
1256 | 1258 |
1257 // Return the allocated bytes in the active semispace. | 1259 // Return the allocated bytes in the active semispace. |
1258 virtual int Size() { return top() - bottom(); } | 1260 virtual int Size() { return static_cast<int>(top() - bottom()); } |
1259 | 1261 |
1260 // Return the current capacity of a semispace. | 1262 // Return the current capacity of a semispace. |
1261 int Capacity() { | 1263 int Capacity() { |
1262 ASSERT(to_space_.Capacity() == from_space_.Capacity()); | 1264 ASSERT(to_space_.Capacity() == from_space_.Capacity()); |
1263 return to_space_.Capacity(); | 1265 return to_space_.Capacity(); |
1264 } | 1266 } |
1265 | 1267 |
1266 // Return the total amount of memory committed for new space. | 1268 // Return the total amount of memory committed for new space. |
1267 int CommittedMemory() { | 1269 int CommittedMemory() { |
1268 if (from_space_.is_committed()) return 2 * Capacity(); | 1270 if (from_space_.is_committed()) return 2 * Capacity(); |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1947 | 1949 |
1948 private: | 1950 private: |
1949 LargeObjectChunk* current_; | 1951 LargeObjectChunk* current_; |
1950 HeapObjectCallback size_func_; | 1952 HeapObjectCallback size_func_; |
1951 }; | 1953 }; |
1952 | 1954 |
1953 | 1955 |
1954 } } // namespace v8::internal | 1956 } } // namespace v8::internal |
1955 | 1957 |
1956 #endif // V8_SPACES_H_ | 1958 #endif // V8_SPACES_H_ |
OLD | NEW |