| 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 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2056 | 2056 |
| 2057 // ----------------------------------------------------------------------------- | 2057 // ----------------------------------------------------------------------------- |
| 2058 // Old space for all map objects | 2058 // Old space for all map objects |
| 2059 | 2059 |
| 2060 class MapSpace : public FixedSpace { | 2060 class MapSpace : public FixedSpace { |
| 2061 public: | 2061 public: |
| 2062 // Creates a map space object with a maximum capacity. | 2062 // Creates a map space object with a maximum capacity. |
| 2063 MapSpace(intptr_t max_capacity, int max_map_space_pages, AllocationSpace id) | 2063 MapSpace(intptr_t max_capacity, int max_map_space_pages, AllocationSpace id) |
| 2064 : FixedSpace(max_capacity, id, Map::kSize, "map"), | 2064 : FixedSpace(max_capacity, id, Map::kSize, "map"), |
| 2065 max_map_space_pages_(max_map_space_pages) { | 2065 max_map_space_pages_(max_map_space_pages) { |
| 2066 ASSERT(max_map_space_pages < kMaxMapPageIndex); | |
| 2067 } | 2066 } |
| 2068 | 2067 |
| 2069 // Prepares for a mark-compact GC. | 2068 // Prepares for a mark-compact GC. |
| 2070 virtual void PrepareForMarkCompact(bool will_compact); | 2069 virtual void PrepareForMarkCompact(bool will_compact); |
| 2071 | 2070 |
| 2072 // Given an index, returns the page address. | 2071 // Given an index, returns the page address. |
| 2073 Address PageAddress(int page_index) { return page_addresses_[page_index]; } | 2072 // TODO(gc): this limit is artifical just to keep code compilable |
| 2074 | 2073 static const int kMaxMapPageIndex = 1 << 16; |
| 2075 static const int kMaxMapPageIndex = 1 << MapWord::kMapPageIndexBits; | |
| 2076 | 2074 |
| 2077 // Are map pointers encodable into map word? | 2075 // Are map pointers encodable into map word? |
| 2078 bool MapPointersEncodable() { | 2076 bool MapPointersEncodable() { |
| 2079 if (!FLAG_use_big_map_space) { | 2077 return false; |
| 2080 ASSERT(CountPagesToTop() <= kMaxMapPageIndex); | |
| 2081 return true; | |
| 2082 } | |
| 2083 return CountPagesToTop() <= max_map_space_pages_; | |
| 2084 } | 2078 } |
| 2085 | 2079 |
| 2086 // Should be called after forced sweep to find out if map space needs | 2080 // Should be called after forced sweep to find out if map space needs |
| 2087 // compaction. | 2081 // compaction. |
| 2088 bool NeedsCompaction(int live_maps) { | 2082 bool NeedsCompaction(int live_maps) { |
| 2089 return !MapPointersEncodable() && live_maps <= CompactionThreshold(); | 2083 return !MapPointersEncodable() && live_maps <= CompactionThreshold(); |
| 2090 } | 2084 } |
| 2091 | 2085 |
| 2092 Address TopAfterCompaction(int live_maps) { | 2086 Address TopAfterCompaction(int live_maps) { |
| 2093 ASSERT(NeedsCompaction(live_maps)); | 2087 ASSERT(NeedsCompaction(live_maps)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2144 private: | 2138 private: |
| 2145 static const int kMapsPerPage = Page::kObjectAreaSize / Map::kSize; | 2139 static const int kMapsPerPage = Page::kObjectAreaSize / Map::kSize; |
| 2146 | 2140 |
| 2147 // Do map space compaction if there is a page gap. | 2141 // Do map space compaction if there is a page gap. |
| 2148 int CompactionThreshold() { | 2142 int CompactionThreshold() { |
| 2149 return kMapsPerPage * (max_map_space_pages_ - 1); | 2143 return kMapsPerPage * (max_map_space_pages_ - 1); |
| 2150 } | 2144 } |
| 2151 | 2145 |
| 2152 const int max_map_space_pages_; | 2146 const int max_map_space_pages_; |
| 2153 | 2147 |
| 2154 // An array of page start address in a map space. | |
| 2155 Address page_addresses_[kMaxMapPageIndex]; | |
| 2156 | |
| 2157 public: | 2148 public: |
| 2158 TRACK_MEMORY("MapSpace") | 2149 TRACK_MEMORY("MapSpace") |
| 2159 }; | 2150 }; |
| 2160 | 2151 |
| 2161 | 2152 |
| 2162 // ----------------------------------------------------------------------------- | 2153 // ----------------------------------------------------------------------------- |
| 2163 // Old space for all global object property cell objects | 2154 // Old space for all global object property cell objects |
| 2164 | 2155 |
| 2165 class CellSpace : public FixedSpace { | 2156 class CellSpace : public FixedSpace { |
| 2166 public: | 2157 public: |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 | 2339 |
| 2349 private: | 2340 private: |
| 2350 LargeObjectChunk* current_; | 2341 LargeObjectChunk* current_; |
| 2351 HeapObjectCallback size_func_; | 2342 HeapObjectCallback size_func_; |
| 2352 }; | 2343 }; |
| 2353 | 2344 |
| 2354 | 2345 |
| 2355 } } // namespace v8::internal | 2346 } } // namespace v8::internal |
| 2356 | 2347 |
| 2357 #endif // V8_SPACES_H_ | 2348 #endif // V8_SPACES_H_ |
| OLD | NEW |