| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 #endif | 258 #endif |
| 259 | 259 |
| 260 | 260 |
| 261 // A queue of objects promoted during scavenge. Each object is accompanied | 261 // A queue of objects promoted during scavenge. Each object is accompanied |
| 262 // by it's size to avoid dereferencing a map pointer for scanning. | 262 // by it's size to avoid dereferencing a map pointer for scanning. |
| 263 class PromotionQueue { | 263 class PromotionQueue { |
| 264 public: | 264 public: |
| 265 PromotionQueue() : front_(NULL), rear_(NULL) { } | 265 PromotionQueue() : front_(NULL), rear_(NULL) { } |
| 266 | 266 |
| 267 void Initialize(Address start_address) { | 267 void Initialize(Address start_address) { |
| 268 // Assumes that a NewSpacePage exactly fits a number of promotion queue |
| 269 // entries (where each is a pair of intptr_t). This allows us to simplify |
| 270 // the test fpr when to switch pages. |
| 271 ASSERT((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) |
| 272 == 0); |
| 273 ASSERT(NewSpacePage::IsAtEnd(start_address)); |
| 268 front_ = rear_ = reinterpret_cast<intptr_t*>(start_address); | 274 front_ = rear_ = reinterpret_cast<intptr_t*>(start_address); |
| 269 } | 275 } |
| 270 | 276 |
| 271 bool is_empty() { return front_ <= rear_; } | 277 bool is_empty() { return front_ == rear_; } |
| 272 | 278 |
| 273 inline void insert(HeapObject* target, int size); | 279 inline void insert(HeapObject* target, int size); |
| 274 | 280 |
| 275 void remove(HeapObject** target, int* size) { | 281 void remove(HeapObject** target, int* size) { |
| 282 ASSERT(!is_empty()); |
| 283 if (NewSpacePage::IsAtStart(reinterpret_cast<Address>(front_))) { |
| 284 NewSpacePage* front_page = |
| 285 NewSpacePage::FromAddress(reinterpret_cast<Address>(front_)); |
| 286 ASSERT(!front_page->prev_page()->is_anchor()); |
| 287 front_ = |
| 288 reinterpret_cast<intptr_t*>(front_page->prev_page()->body_limit()); |
| 289 } |
| 276 *target = reinterpret_cast<HeapObject*>(*(--front_)); | 290 *target = reinterpret_cast<HeapObject*>(*(--front_)); |
| 277 *size = static_cast<int>(*(--front_)); | 291 *size = static_cast<int>(*(--front_)); |
| 278 // Assert no underflow. | 292 // Assert no underflow. |
| 279 ASSERT(front_ >= rear_); | 293 SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_), |
| 294 reinterpret_cast<Address>(front_)); |
| 280 } | 295 } |
| 281 | 296 |
| 282 private: | 297 private: |
| 283 // The front of the queue is higher in memory than the rear. | 298 // The front of the queue is higher in the memory page chain than the rear. |
| 284 intptr_t* front_; | 299 intptr_t* front_; |
| 285 intptr_t* rear_; | 300 intptr_t* rear_; |
| 286 | 301 |
| 287 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); | 302 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); |
| 288 }; | 303 }; |
| 289 | 304 |
| 290 | 305 |
| 291 typedef void (*ScavengingCallback)(Map* map, | 306 typedef void (*ScavengingCallback)(Map* map, |
| 292 HeapObject** slot, | 307 HeapObject** slot, |
| 293 HeapObject* object); | 308 HeapObject* object); |
| (...skipping 2040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2334 | 2349 |
| 2335 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2350 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2336 }; | 2351 }; |
| 2337 #endif // DEBUG || LIVE_OBJECT_LIST | 2352 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2338 | 2353 |
| 2339 } } // namespace v8::internal | 2354 } } // namespace v8::internal |
| 2340 | 2355 |
| 2341 #undef HEAP | 2356 #undef HEAP |
| 2342 | 2357 |
| 2343 #endif // V8_HEAP_H_ | 2358 #endif // V8_HEAP_H_ |
| OLD | NEW |