OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 return top_; | 1486 return top_; |
1487 } | 1487 } |
1488 | 1488 |
1489 Address* top_address() { return &top_; } | 1489 Address* top_address() { return &top_; } |
1490 | 1490 |
1491 INLINE(void set_limit(Address limit)) { | 1491 INLINE(void set_limit(Address limit)) { |
1492 limit_ = limit; | 1492 limit_ = limit; |
1493 } | 1493 } |
1494 | 1494 |
1495 INLINE(Address limit()) const { | 1495 INLINE(Address limit()) const { |
1496 SLOW_DCHECK(limit_ == NULL || | |
1497 (reinterpret_cast<intptr_t>(limit_) & kHeapObjectTagMask) == | |
1498 0); | |
1499 return limit_; | 1496 return limit_; |
1500 } | 1497 } |
1501 | 1498 |
1502 Address* limit_address() { return &limit_; } | 1499 Address* limit_address() { return &limit_; } |
1503 | 1500 |
1504 #ifdef DEBUG | 1501 #ifdef DEBUG |
1505 bool VerifyPagedAllocation() { | 1502 bool VerifyPagedAllocation() { |
1506 return (Page::FromAllocationTop(top_) == Page::FromAllocationTop(limit_)) && | 1503 return (Page::FromAllocationTop(top_) == Page::FromAllocationTop(limit_)) && |
1507 (top_ <= limit_); | 1504 (top_ <= limit_); |
1508 } | 1505 } |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2506 // Last page returned. | 2503 // Last page returned. |
2507 NewSpacePage* last_page_; | 2504 NewSpacePage* last_page_; |
2508 }; | 2505 }; |
2509 | 2506 |
2510 // ----------------------------------------------------------------------------- | 2507 // ----------------------------------------------------------------------------- |
2511 // Allows observation of inline allocation in the new space. | 2508 // Allows observation of inline allocation in the new space. |
2512 class InlineAllocationObserver { | 2509 class InlineAllocationObserver { |
2513 public: | 2510 public: |
2514 explicit InlineAllocationObserver(intptr_t step_size) | 2511 explicit InlineAllocationObserver(intptr_t step_size) |
2515 : step_size_(step_size), bytes_to_next_step_(step_size) { | 2512 : step_size_(step_size), bytes_to_next_step_(step_size) { |
2516 DCHECK(step_size >= kPointerSize && (step_size & kHeapObjectTagMask) == 0); | 2513 DCHECK(step_size >= kPointerSize); |
2517 } | 2514 } |
2518 virtual ~InlineAllocationObserver() {} | 2515 virtual ~InlineAllocationObserver() {} |
2519 | 2516 |
2520 private: | 2517 private: |
2521 intptr_t step_size() const { return step_size_; } | 2518 intptr_t step_size() const { return step_size_; } |
2522 intptr_t bytes_to_next_step() const { return bytes_to_next_step_; } | 2519 intptr_t bytes_to_next_step() const { return bytes_to_next_step_; } |
2523 | 2520 |
2524 // Pure virtual method provided by the subclasses that gets called when more | 2521 // Pure virtual method provided by the subclasses that gets called when at |
2525 // than step_size byte have been allocated. | 2522 // least step_size bytes have been allocated. |
2526 virtual void Step(int bytes_allocated) = 0; | 2523 virtual void Step(int bytes_allocated) = 0; |
2527 | 2524 |
2528 // Called each time the new space does an inline allocation step. This may be | 2525 // Called each time the new space does an inline allocation step. This may be |
2529 // more frequently than the step_size we are monitoring (e.g. when there are | 2526 // more frequently than the step_size we are monitoring (e.g. when there are |
2530 // multiple observers, or when page or space boundary is encountered.) The | 2527 // multiple observers, or when page or space boundary is encountered.) |
2531 // Step method is only called once more than step_size bytes have been | |
2532 // allocated. | |
2533 void InlineAllocationStep(int bytes_allocated) { | 2528 void InlineAllocationStep(int bytes_allocated) { |
2534 bytes_to_next_step_ -= bytes_allocated; | 2529 bytes_to_next_step_ -= bytes_allocated; |
2535 if (bytes_to_next_step_ <= 0) { | 2530 if (bytes_to_next_step_ <= 0) { |
2536 Step(static_cast<int>(step_size_ - bytes_to_next_step_)); | 2531 Step(static_cast<int>(step_size_ - bytes_to_next_step_)); |
2537 bytes_to_next_step_ = step_size_; | 2532 bytes_to_next_step_ = step_size_; |
2538 } | 2533 } |
2539 } | 2534 } |
2540 | 2535 |
2541 intptr_t step_size_; | 2536 intptr_t step_size_; |
2542 intptr_t bytes_to_next_step_; | 2537 intptr_t bytes_to_next_step_; |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3124 count = 0; | 3119 count = 0; |
3125 } | 3120 } |
3126 // Must be small, since an iteration is used for lookup. | 3121 // Must be small, since an iteration is used for lookup. |
3127 static const int kMaxComments = 64; | 3122 static const int kMaxComments = 64; |
3128 }; | 3123 }; |
3129 #endif | 3124 #endif |
3130 } // namespace internal | 3125 } // namespace internal |
3131 } // namespace v8 | 3126 } // namespace v8 |
3132 | 3127 |
3133 #endif // V8_HEAP_SPACES_H_ | 3128 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |