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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 // A LargeObjectChunk holds exactly one large object page with exactly one | 2137 // A LargeObjectChunk holds exactly one large object page with exactly one |
2138 // large object. | 2138 // large object. |
2139 class LargeObjectChunk { | 2139 class LargeObjectChunk { |
2140 public: | 2140 public: |
2141 // Allocates a new LargeObjectChunk that contains a large object page | 2141 // Allocates a new LargeObjectChunk that contains a large object page |
2142 // (Page::kPageSize aligned) that has at least size_in_bytes (for a large | 2142 // (Page::kPageSize aligned) that has at least size_in_bytes (for a large |
2143 // object) bytes after the object area start of that page. | 2143 // object) bytes after the object area start of that page. |
2144 static LargeObjectChunk* New(int size_in_bytes, Executability executable); | 2144 static LargeObjectChunk* New(int size_in_bytes, Executability executable); |
2145 | 2145 |
2146 // Free the memory associated with the chunk. | 2146 // Free the memory associated with the chunk. |
2147 inline void Free(Executability executable); | 2147 void Free(Executability executable); |
2148 | 2148 |
2149 // Interpret a raw address as a large object chunk. | 2149 // Interpret a raw address as a large object chunk. |
2150 static LargeObjectChunk* FromAddress(Address address) { | 2150 static LargeObjectChunk* FromAddress(Address address) { |
2151 return reinterpret_cast<LargeObjectChunk*>(address); | 2151 return reinterpret_cast<LargeObjectChunk*>(address); |
2152 } | 2152 } |
2153 | 2153 |
2154 // Returns the address of this chunk. | 2154 // Returns the address of this chunk. |
2155 Address address() { return reinterpret_cast<Address>(this); } | 2155 Address address() { return reinterpret_cast<Address>(this); } |
2156 | 2156 |
| 2157 Page* GetPage() { |
| 2158 return Page::FromAddress(RoundUp(address(), Page::kPageSize)); |
| 2159 } |
| 2160 |
2157 // Accessors for the fields of the chunk. | 2161 // Accessors for the fields of the chunk. |
2158 LargeObjectChunk* next() { return next_; } | 2162 LargeObjectChunk* next() { return next_; } |
2159 void set_next(LargeObjectChunk* chunk) { next_ = chunk; } | 2163 void set_next(LargeObjectChunk* chunk) { next_ = chunk; } |
2160 size_t size() { return size_ & ~Page::kPageFlagMask; } | 2164 size_t size() { return size_ & ~Page::kPageFlagMask; } |
2161 | 2165 |
2162 // Compute the start address in the chunk. | 2166 // Compute the start address in the chunk. |
2163 inline Address GetStartAddress(); | 2167 Address GetStartAddress() { return GetPage()->ObjectAreaStart(); } |
2164 | 2168 |
2165 // Returns the object in this chunk. | 2169 // Returns the object in this chunk. |
2166 HeapObject* GetObject() { return HeapObject::FromAddress(GetStartAddress()); } | 2170 HeapObject* GetObject() { return HeapObject::FromAddress(GetStartAddress()); } |
2167 | 2171 |
2168 // Given a requested size returns the physical size of a chunk to be | 2172 // Given a requested size returns the physical size of a chunk to be |
2169 // allocated. | 2173 // allocated. |
2170 static int ChunkSizeFor(int size_in_bytes); | 2174 static int ChunkSizeFor(int size_in_bytes); |
2171 | 2175 |
2172 // Given a chunk size, returns the object size it can accommodate. Used by | 2176 // Given a chunk size, returns the object size it can accommodate. Used by |
2173 // LargeObjectSpace::Available. | 2177 // LargeObjectSpace::Available. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2305 } | 2309 } |
2306 // Must be small, since an iteration is used for lookup. | 2310 // Must be small, since an iteration is used for lookup. |
2307 static const int kMaxComments = 64; | 2311 static const int kMaxComments = 64; |
2308 }; | 2312 }; |
2309 #endif | 2313 #endif |
2310 | 2314 |
2311 | 2315 |
2312 } } // namespace v8::internal | 2316 } } // namespace v8::internal |
2313 | 2317 |
2314 #endif // V8_SPACES_H_ | 2318 #endif // V8_SPACES_H_ |
OLD | NEW |