OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 | 10 |
(...skipping 419 matching lines...) Loading... |
430 struct Entry* limit_; | 430 struct Entry* limit_; |
431 | 431 |
432 List<Entry>* emergency_stack_; | 432 List<Entry>* emergency_stack_; |
433 Heap* heap_; | 433 Heap* heap_; |
434 | 434 |
435 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); | 435 DISALLOW_COPY_AND_ASSIGN(PromotionQueue); |
436 }; | 436 }; |
437 | 437 |
438 class AllocationResult { | 438 class AllocationResult { |
439 public: | 439 public: |
| 440 static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) { |
| 441 return AllocationResult(space); |
| 442 } |
| 443 |
440 // Implicit constructor from Object*. | 444 // Implicit constructor from Object*. |
441 AllocationResult(Object* object) // NOLINT | 445 AllocationResult(Object* object) // NOLINT |
442 : object_(object) { | 446 : object_(object) { |
443 // AllocationResults can't return Smis, which are used to represent | 447 // AllocationResults can't return Smis, which are used to represent |
444 // failure and the space to retry in. | 448 // failure and the space to retry in. |
445 CHECK(!object->IsSmi()); | 449 CHECK(!object->IsSmi()); |
446 } | 450 } |
447 | 451 |
448 AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {} | 452 AllocationResult() : object_(Smi::FromInt(NEW_SPACE)) {} |
449 | 453 |
450 static inline AllocationResult Retry(AllocationSpace space = NEW_SPACE) { | |
451 return AllocationResult(space); | |
452 } | |
453 | |
454 inline bool IsRetry() { return object_->IsSmi(); } | 454 inline bool IsRetry() { return object_->IsSmi(); } |
| 455 inline HeapObject* ToObjectChecked(); |
| 456 inline AllocationSpace RetrySpace(); |
455 | 457 |
456 template <typename T> | 458 template <typename T> |
457 bool To(T** obj) { | 459 bool To(T** obj) { |
458 if (IsRetry()) return false; | 460 if (IsRetry()) return false; |
459 *obj = T::cast(object_); | 461 *obj = T::cast(object_); |
460 return true; | 462 return true; |
461 } | 463 } |
462 | 464 |
463 Object* ToObjectChecked() { | |
464 CHECK(!IsRetry()); | |
465 return object_; | |
466 } | |
467 | |
468 inline AllocationSpace RetrySpace(); | |
469 | |
470 private: | 465 private: |
471 explicit AllocationResult(AllocationSpace space) | 466 explicit AllocationResult(AllocationSpace space) |
472 : object_(Smi::FromInt(static_cast<int>(space))) {} | 467 : object_(Smi::FromInt(static_cast<int>(space))) {} |
473 | 468 |
474 Object* object_; | 469 Object* object_; |
475 }; | 470 }; |
476 | 471 |
477 STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize); | 472 STATIC_ASSERT(sizeof(AllocationResult) == kPointerSize); |
478 | 473 |
479 #ifdef DEBUG | 474 #ifdef DEBUG |
(...skipping 2163 matching lines...) Loading... |
2643 } | 2638 } |
2644 | 2639 |
2645 private: | 2640 private: |
2646 Heap* heap_; | 2641 Heap* heap_; |
2647 }; | 2642 }; |
2648 | 2643 |
2649 } // namespace internal | 2644 } // namespace internal |
2650 } // namespace v8 | 2645 } // namespace v8 |
2651 | 2646 |
2652 #endif // V8_HEAP_HEAP_H_ | 2647 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |