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/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
| 10 #include "src/base/bits.h" |
10 #include "src/base/platform/mutex.h" | 11 #include "src/base/platform/mutex.h" |
11 #include "src/hashmap.h" | 12 #include "src/hashmap.h" |
12 #include "src/list.h" | 13 #include "src/list.h" |
13 #include "src/log.h" | 14 #include "src/log.h" |
14 #include "src/utils.h" | 15 #include "src/utils.h" |
15 | 16 |
16 namespace v8 { | 17 namespace v8 { |
17 namespace internal { | 18 namespace internal { |
18 | 19 |
19 class Isolate; | 20 class Isolate; |
(...skipping 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 // Creates a map space object with a maximum capacity. | 2614 // Creates a map space object with a maximum capacity. |
2614 MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2615 MapSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
2615 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), | 2616 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE), |
2616 max_map_space_pages_(kMaxMapPageIndex - 1) {} | 2617 max_map_space_pages_(kMaxMapPageIndex - 1) {} |
2617 | 2618 |
2618 // Given an index, returns the page address. | 2619 // Given an index, returns the page address. |
2619 // TODO(1600): this limit is artifical just to keep code compilable | 2620 // TODO(1600): this limit is artifical just to keep code compilable |
2620 static const int kMaxMapPageIndex = 1 << 16; | 2621 static const int kMaxMapPageIndex = 1 << 16; |
2621 | 2622 |
2622 virtual int RoundSizeDownToObjectAlignment(int size) { | 2623 virtual int RoundSizeDownToObjectAlignment(int size) { |
2623 if (IsPowerOf2(Map::kSize)) { | 2624 if (base::bits::IsPowerOfTwo32(Map::kSize)) { |
2624 return RoundDown(size, Map::kSize); | 2625 return RoundDown(size, Map::kSize); |
2625 } else { | 2626 } else { |
2626 return (size / Map::kSize) * Map::kSize; | 2627 return (size / Map::kSize) * Map::kSize; |
2627 } | 2628 } |
2628 } | 2629 } |
2629 | 2630 |
2630 protected: | 2631 protected: |
2631 virtual void VerifyObject(HeapObject* obj); | 2632 virtual void VerifyObject(HeapObject* obj); |
2632 | 2633 |
2633 private: | 2634 private: |
(...skipping 14 matching lines...) Expand all Loading... |
2648 // ----------------------------------------------------------------------------- | 2649 // ----------------------------------------------------------------------------- |
2649 // Old space for simple property cell objects | 2650 // Old space for simple property cell objects |
2650 | 2651 |
2651 class CellSpace : public PagedSpace { | 2652 class CellSpace : public PagedSpace { |
2652 public: | 2653 public: |
2653 // Creates a property cell space object with a maximum capacity. | 2654 // Creates a property cell space object with a maximum capacity. |
2654 CellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2655 CellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
2655 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) {} | 2656 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) {} |
2656 | 2657 |
2657 virtual int RoundSizeDownToObjectAlignment(int size) { | 2658 virtual int RoundSizeDownToObjectAlignment(int size) { |
2658 if (IsPowerOf2(Cell::kSize)) { | 2659 if (base::bits::IsPowerOfTwo32(Cell::kSize)) { |
2659 return RoundDown(size, Cell::kSize); | 2660 return RoundDown(size, Cell::kSize); |
2660 } else { | 2661 } else { |
2661 return (size / Cell::kSize) * Cell::kSize; | 2662 return (size / Cell::kSize) * Cell::kSize; |
2662 } | 2663 } |
2663 } | 2664 } |
2664 | 2665 |
2665 protected: | 2666 protected: |
2666 virtual void VerifyObject(HeapObject* obj); | 2667 virtual void VerifyObject(HeapObject* obj); |
2667 | 2668 |
2668 public: | 2669 public: |
2669 TRACK_MEMORY("CellSpace") | 2670 TRACK_MEMORY("CellSpace") |
2670 }; | 2671 }; |
2671 | 2672 |
2672 | 2673 |
2673 // ----------------------------------------------------------------------------- | 2674 // ----------------------------------------------------------------------------- |
2674 // Old space for all global object property cell objects | 2675 // Old space for all global object property cell objects |
2675 | 2676 |
2676 class PropertyCellSpace : public PagedSpace { | 2677 class PropertyCellSpace : public PagedSpace { |
2677 public: | 2678 public: |
2678 // Creates a property cell space object with a maximum capacity. | 2679 // Creates a property cell space object with a maximum capacity. |
2679 PropertyCellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) | 2680 PropertyCellSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id) |
2680 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) {} | 2681 : PagedSpace(heap, max_capacity, id, NOT_EXECUTABLE) {} |
2681 | 2682 |
2682 virtual int RoundSizeDownToObjectAlignment(int size) { | 2683 virtual int RoundSizeDownToObjectAlignment(int size) { |
2683 if (IsPowerOf2(PropertyCell::kSize)) { | 2684 if (base::bits::IsPowerOfTwo32(PropertyCell::kSize)) { |
2684 return RoundDown(size, PropertyCell::kSize); | 2685 return RoundDown(size, PropertyCell::kSize); |
2685 } else { | 2686 } else { |
2686 return (size / PropertyCell::kSize) * PropertyCell::kSize; | 2687 return (size / PropertyCell::kSize) * PropertyCell::kSize; |
2687 } | 2688 } |
2688 } | 2689 } |
2689 | 2690 |
2690 protected: | 2691 protected: |
2691 virtual void VerifyObject(HeapObject* obj); | 2692 virtual void VerifyObject(HeapObject* obj); |
2692 | 2693 |
2693 public: | 2694 public: |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2872 count = 0; | 2873 count = 0; |
2873 } | 2874 } |
2874 // Must be small, since an iteration is used for lookup. | 2875 // Must be small, since an iteration is used for lookup. |
2875 static const int kMaxComments = 64; | 2876 static const int kMaxComments = 64; |
2876 }; | 2877 }; |
2877 #endif | 2878 #endif |
2878 } | 2879 } |
2879 } // namespace v8::internal | 2880 } // namespace v8::internal |
2880 | 2881 |
2881 #endif // V8_HEAP_SPACES_H_ | 2882 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |