| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 #endif | 263 #endif |
| 264 | 264 |
| 265 | 265 |
| 266 // A queue of objects promoted during scavenge. Each object is accompanied | 266 // A queue of objects promoted during scavenge. Each object is accompanied |
| 267 // by it's size to avoid dereferencing a map pointer for scanning. | 267 // by it's size to avoid dereferencing a map pointer for scanning. |
| 268 class PromotionQueue { | 268 class PromotionQueue { |
| 269 public: | 269 public: |
| 270 PromotionQueue() : front_(NULL), rear_(NULL) { } | 270 PromotionQueue() : front_(NULL), rear_(NULL) { } |
| 271 | 271 |
| 272 void Initialize(Address start_address) { | 272 void Initialize(Address start_address) { |
| 273 // Assumes that a NewSpacePage exactly fits a number of promotion queue |
| 274 // entries (where each is a pair of intptr_t). This allows us to simplify |
| 275 // the test fpr when to switch pages. |
| 276 ASSERT((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) |
| 277 == 0); |
| 278 ASSERT(NewSpacePage::at_end(start_address)); |
| 273 front_ = rear_ = reinterpret_cast<intptr_t*>(start_address); | 279 front_ = rear_ = reinterpret_cast<intptr_t*>(start_address); |
| 274 } | 280 } |
| 275 | 281 |
| 276 bool is_empty() { return front_ <= rear_; } | 282 bool is_empty() { return front_ == rear_; } |
| 277 | 283 |
| 278 inline void insert(HeapObject* target, int size); | 284 inline void insert(HeapObject* target, int size); |
| 279 | 285 |
| 280 void remove(HeapObject** target, int* size) { | 286 void remove(HeapObject** target, int* size) { |
| 287 ASSERT(!is_empty()); |
| 288 if (NewSpacePage::at_start(reinterpret_cast<Address>(front_))) { |
| 289 NewSpacePage* front_page = |
| 290 NewSpacePage::FromAddress(reinterpret_cast<Address>(front_)); |
| 291 ASSERT(!front_page->prev_page()->is_anchor()); |
| 292 front_ = |
| 293 reinterpret_cast<intptr_t*>(front_page->prev_page()->body_limit()); |
| 294 } |
| 281 *target = reinterpret_cast<HeapObject*>(*(--front_)); | 295 *target = reinterpret_cast<HeapObject*>(*(--front_)); |
| 282 *size = static_cast<int>(*(--front_)); | 296 *size = static_cast<int>(*(--front_)); |
| 283 // Assert no underflow. | 297 // Assert no underflow. |
| 284 ASSERT(front_ >= rear_); | 298 SemiSpace::AssertValidRange(reinterpret_cast<Address>(rear_), |
| 299 reinterpret_cast<Address>(front_)); |
| 285 } | 300 } |
| 286 | 301 |
| 287 private: | 302 private: |
| 288 // The front of the queue is higher in memory than the rear. | 303 // The front of the queue is higher in the memory page chain than the rear. |
| 289 intptr_t* front_; | 304 intptr_t* front_; |
| 290 intptr_t* rear_; | 305 intptr_t* rear_; |
| 291 | 306 |
| 292 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); | 307 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); |
| 293 }; | 308 }; |
| 294 | 309 |
| 295 | 310 |
| 296 typedef void (*ScavengingCallback)(Map* map, | 311 typedef void (*ScavengingCallback)(Map* map, |
| 297 HeapObject** slot, | 312 HeapObject** slot, |
| 298 HeapObject* object); | 313 HeapObject* object); |
| (...skipping 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2356 | 2371 |
| 2357 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2372 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2358 }; | 2373 }; |
| 2359 #endif // DEBUG || LIVE_OBJECT_LIST | 2374 #endif // DEBUG || LIVE_OBJECT_LIST |
| 2360 | 2375 |
| 2361 } } // namespace v8::internal | 2376 } } // namespace v8::internal |
| 2362 | 2377 |
| 2363 #undef HEAP | 2378 #undef HEAP |
| 2364 | 2379 |
| 2365 #endif // V8_HEAP_H_ | 2380 #endif // V8_HEAP_H_ |
| OLD | NEW |