| 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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 | 301 |
| 302 ~SlotsBuffer() { | 302 ~SlotsBuffer() { |
| 303 } | 303 } |
| 304 | 304 |
| 305 void Add(ObjectSlot slot) { | 305 void Add(ObjectSlot slot) { |
| 306 ASSERT(0 <= idx_ && idx_ < kNumberOfElements); | 306 ASSERT(0 <= idx_ && idx_ < kNumberOfElements); |
| 307 slots_[idx_++] = slot; | 307 slots_[idx_++] = slot; |
| 308 } | 308 } |
| 309 | 309 |
| 310 enum SlotType { | 310 enum SlotType { |
| 311 NONE, | |
| 312 RELOCATED_CODE_OBJECT, | 311 RELOCATED_CODE_OBJECT, |
| 313 CODE_TARGET_SLOT, | 312 CODE_TARGET_SLOT, |
| 314 CODE_ENTRY_SLOT, | 313 CODE_ENTRY_SLOT, |
| 315 DEBUG_TARGET_SLOT, | 314 DEBUG_TARGET_SLOT, |
| 316 JS_RETURN_SLOT, | 315 JS_RETURN_SLOT, |
| 317 NUMBER_OF_SLOT_TYPES | 316 NUMBER_OF_SLOT_TYPES |
| 318 }; | 317 }; |
| 319 | 318 |
| 320 // Typed slot might be splitted between two SlotsBuffers: slot's type | 319 void UpdateSlots(Heap* heap); |
| 321 // is recorded in one buffer and type address is recorded as the first | |
| 322 // slot in the next buffer. | |
| 323 // | |
| 324 // If the first address recorded in this buffer is address of the typed | |
| 325 // slot then it's type will be passed as pending argument. | |
| 326 // | |
| 327 // If this buffer ends on slot's type and the next buffer is expected to | |
| 328 // contain address of a typed slot then the function returns that type. | |
| 329 SlotType UpdateSlots(Heap* heap, SlotType pending); | |
| 330 | 320 |
| 331 SlotsBuffer* next() { return next_; } | 321 SlotsBuffer* next() { return next_; } |
| 332 | 322 |
| 333 static int SizeOfChain(SlotsBuffer* buffer) { | 323 static int SizeOfChain(SlotsBuffer* buffer) { |
| 334 if (buffer == NULL) return 0; | 324 if (buffer == NULL) return 0; |
| 335 return static_cast<int>(buffer->idx_ + | 325 return static_cast<int>(buffer->idx_ + |
| 336 (buffer->chain_length_ - 1) * kNumberOfElements); | 326 (buffer->chain_length_ - 1) * kNumberOfElements); |
| 337 } | 327 } |
| 338 | 328 |
| 339 inline bool IsFull() { | 329 inline bool IsFull() { |
| 340 return idx_ == kNumberOfElements; | 330 return idx_ == kNumberOfElements; |
| 341 } | 331 } |
| 342 | 332 |
| 333 inline bool HasSpaceForTypedSlot() { |
| 334 return idx_ < kNumberOfElements - 1; |
| 335 } |
| 336 |
| 343 static void UpdateSlotsRecordedIn(Heap* heap, SlotsBuffer* buffer) { | 337 static void UpdateSlotsRecordedIn(Heap* heap, SlotsBuffer* buffer) { |
| 344 SlotType pending = NONE; | |
| 345 while (buffer != NULL) { | 338 while (buffer != NULL) { |
| 346 pending = buffer->UpdateSlots(heap, pending); | 339 buffer->UpdateSlots(heap); |
| 347 buffer = buffer->next(); | 340 buffer = buffer->next(); |
| 348 } | 341 } |
| 349 } | 342 } |
| 350 | 343 |
| 351 enum AdditionMode { | 344 enum AdditionMode { |
| 352 FAIL_ON_OVERFLOW, | 345 FAIL_ON_OVERFLOW, |
| 353 IGNORE_OVERFLOW | 346 IGNORE_OVERFLOW |
| 354 }; | 347 }; |
| 355 | 348 |
| 349 static bool ChainLengthThresholdReached(SlotsBuffer* buffer) { |
| 350 return buffer != NULL && buffer->chain_length_ >= kChainLengthThreshold; |
| 351 } |
| 352 |
| 356 static bool AddTo(SlotsBufferAllocator* allocator, | 353 static bool AddTo(SlotsBufferAllocator* allocator, |
| 357 SlotsBuffer** buffer_address, | 354 SlotsBuffer** buffer_address, |
| 358 ObjectSlot slot, | 355 ObjectSlot slot, |
| 359 AdditionMode mode) { | 356 AdditionMode mode) { |
| 360 SlotsBuffer* buffer = *buffer_address; | 357 SlotsBuffer* buffer = *buffer_address; |
| 361 if (buffer == NULL || buffer->IsFull()) { | 358 if (buffer == NULL || buffer->IsFull()) { |
| 362 if (mode == FAIL_ON_OVERFLOW && | 359 if (mode == FAIL_ON_OVERFLOW && ChainLengthThresholdReached(buffer)) { |
| 363 buffer != NULL && | |
| 364 buffer->chain_length_ >= kChainLengthThreshold) { | |
| 365 allocator->DeallocateChain(buffer_address); | 360 allocator->DeallocateChain(buffer_address); |
| 366 return false; | 361 return false; |
| 367 } | 362 } |
| 368 buffer = allocator->AllocateBuffer(buffer); | 363 buffer = allocator->AllocateBuffer(buffer); |
| 369 *buffer_address = buffer; | 364 *buffer_address = buffer; |
| 370 } | 365 } |
| 371 buffer->Add(slot); | 366 buffer->Add(slot); |
| 372 return true; | 367 return true; |
| 373 } | 368 } |
| 374 | 369 |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 | 755 |
| 761 List<Page*> evacuation_candidates_; | 756 List<Page*> evacuation_candidates_; |
| 762 | 757 |
| 763 friend class Heap; | 758 friend class Heap; |
| 764 }; | 759 }; |
| 765 | 760 |
| 766 | 761 |
| 767 } } // namespace v8::internal | 762 } } // namespace v8::internal |
| 768 | 763 |
| 769 #endif // V8_MARK_COMPACT_H_ | 764 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |