| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 // Returns one past the end address of the space. | 932 // Returns one past the end address of the space. |
| 933 Address high() { return low() + capacity_; } | 933 Address high() { return low() + capacity_; } |
| 934 | 934 |
| 935 // Age mark accessors. | 935 // Age mark accessors. |
| 936 Address age_mark() { return age_mark_; } | 936 Address age_mark() { return age_mark_; } |
| 937 void set_age_mark(Address mark) { age_mark_ = mark; } | 937 void set_age_mark(Address mark) { age_mark_ = mark; } |
| 938 | 938 |
| 939 // True if the address is in the address range of this semispace (not | 939 // True if the address is in the address range of this semispace (not |
| 940 // necessarily below the allocation pointer). | 940 // necessarily below the allocation pointer). |
| 941 bool Contains(Address a) { | 941 bool Contains(Address a) { |
| 942 return (reinterpret_cast<uint32_t>(a) & address_mask_) | 942 return (reinterpret_cast<uintptr_t>(a) & address_mask_) |
| 943 == reinterpret_cast<uint32_t>(start_); | 943 == reinterpret_cast<uintptr_t>(start_); |
| 944 } | 944 } |
| 945 | 945 |
| 946 // True if the object is a heap object in the address range of this | 946 // True if the object is a heap object in the address range of this |
| 947 // semispace (not necessarily below the allocation pointer). | 947 // semispace (not necessarily below the allocation pointer). |
| 948 bool Contains(Object* o) { | 948 bool Contains(Object* o) { |
| 949 return (reinterpret_cast<uint32_t>(o) & object_mask_) == object_expected_; | 949 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
| 950 } | 950 } |
| 951 | 951 |
| 952 // The offset of an address from the beginning of the space. | 952 // The offset of an address from the beginning of the space. |
| 953 int SpaceOffsetForAddress(Address addr) { return addr - low(); } | 953 int SpaceOffsetForAddress(Address addr) { return addr - low(); } |
| 954 | 954 |
| 955 // If we don't have this here then SemiSpace will be abstract. However | 955 // If we don't have this here then SemiSpace will be abstract. However |
| 956 // it should never be called. | 956 // it should never be called. |
| 957 virtual int Size() { | 957 virtual int Size() { |
| 958 UNREACHABLE(); | 958 UNREACHABLE(); |
| 959 return 0; | 959 return 0; |
| 960 } | 960 } |
| 961 | 961 |
| 962 #ifdef DEBUG | 962 #ifdef DEBUG |
| 963 virtual void Print(); | 963 virtual void Print(); |
| 964 virtual void Verify(); | 964 virtual void Verify(); |
| 965 #endif | 965 #endif |
| 966 | 966 |
| 967 private: | 967 private: |
| 968 // The current and maximum capacity of the space. | 968 // The current and maximum capacity of the space. |
| 969 int capacity_; | 969 int capacity_; |
| 970 int maximum_capacity_; | 970 int maximum_capacity_; |
| 971 | 971 |
| 972 // The start address of the space. | 972 // The start address of the space. |
| 973 Address start_; | 973 Address start_; |
| 974 // Used to govern object promotion during mark-compact collection. | 974 // Used to govern object promotion during mark-compact collection. |
| 975 Address age_mark_; | 975 Address age_mark_; |
| 976 | 976 |
| 977 // Masks and comparison values to test for containment in this semispace. | 977 // Masks and comparison values to test for containment in this semispace. |
| 978 uint32_t address_mask_; | 978 uintptr_t address_mask_; |
| 979 uint32_t object_mask_; | 979 uintptr_t object_mask_; |
| 980 uint32_t object_expected_; | 980 uintptr_t object_expected_; |
| 981 | 981 |
| 982 public: | 982 public: |
| 983 TRACK_MEMORY("SemiSpace") | 983 TRACK_MEMORY("SemiSpace") |
| 984 }; | 984 }; |
| 985 | 985 |
| 986 | 986 |
| 987 // A SemiSpaceIterator is an ObjectIterator that iterates over the active | 987 // A SemiSpaceIterator is an ObjectIterator that iterates over the active |
| 988 // semispace of the heap's new space. It iterates over the objects in the | 988 // semispace of the heap's new space. It iterates over the objects in the |
| 989 // semispace from a given start address (defaulting to the bottom of the | 989 // semispace from a given start address (defaulting to the bottom of the |
| 990 // semispace) to the top of the semispace. New objects allocated after the | 990 // semispace) to the top of the semispace. New objects allocated after the |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 // Flip the pair of spaces. | 1056 // Flip the pair of spaces. |
| 1057 void Flip(); | 1057 void Flip(); |
| 1058 | 1058 |
| 1059 // Doubles the capacity of the semispaces. Assumes that they are not at | 1059 // Doubles the capacity of the semispaces. Assumes that they are not at |
| 1060 // their maximum capacity. Returns a flag indicating success or failure. | 1060 // their maximum capacity. Returns a flag indicating success or failure. |
| 1061 bool Double(); | 1061 bool Double(); |
| 1062 | 1062 |
| 1063 // True if the address or object lies in the address range of either | 1063 // True if the address or object lies in the address range of either |
| 1064 // semispace (not necessarily below the allocation pointer). | 1064 // semispace (not necessarily below the allocation pointer). |
| 1065 bool Contains(Address a) { | 1065 bool Contains(Address a) { |
| 1066 return (reinterpret_cast<uint32_t>(a) & address_mask_) | 1066 return (reinterpret_cast<uintptr_t>(a) & address_mask_) |
| 1067 == reinterpret_cast<uint32_t>(start_); | 1067 == reinterpret_cast<uintptr_t>(start_); |
| 1068 } | 1068 } |
| 1069 bool Contains(Object* o) { | 1069 bool Contains(Object* o) { |
| 1070 return (reinterpret_cast<uint32_t>(o) & object_mask_) == object_expected_; | 1070 return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_; |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 // Return the allocated bytes in the active semispace. | 1073 // Return the allocated bytes in the active semispace. |
| 1074 virtual int Size() { return top() - bottom(); } | 1074 virtual int Size() { return top() - bottom(); } |
| 1075 // Return the current capacity of a semispace. | 1075 // Return the current capacity of a semispace. |
| 1076 int Capacity() { return capacity_; } | 1076 int Capacity() { return capacity_; } |
| 1077 // Return the available bytes without growing in the active semispace. | 1077 // Return the available bytes without growing in the active semispace. |
| 1078 int Available() { return Capacity() - Size(); } | 1078 int Available() { return Capacity() - Size(); } |
| 1079 | 1079 |
| 1080 // Return the maximum capacity of a semispace. | 1080 // Return the maximum capacity of a semispace. |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1694 | 1694 |
| 1695 private: | 1695 private: |
| 1696 LargeObjectChunk* current_; | 1696 LargeObjectChunk* current_; |
| 1697 HeapObjectCallback size_func_; | 1697 HeapObjectCallback size_func_; |
| 1698 }; | 1698 }; |
| 1699 | 1699 |
| 1700 | 1700 |
| 1701 } } // namespace v8::internal | 1701 } } // namespace v8::internal |
| 1702 | 1702 |
| 1703 #endif // V8_SPACES_H_ | 1703 #endif // V8_SPACES_H_ |
| OLD | NEW |