Chromium Code Reviews| Index: runtime/vm/object_set.h |
| diff --git a/runtime/vm/object_set.h b/runtime/vm/object_set.h |
| index 159a09218e60bf3eef201ec76842ca867b4e4448..f4968e608dc2626dfb3a1707d430106ccaff9cf2 100644 |
| --- a/runtime/vm/object_set.h |
| +++ b/runtime/vm/object_set.h |
| @@ -6,12 +6,28 @@ |
| #define VM_OBJECT_SET_H_ |
| #include "vm/globals.h" |
| +#include "vm/raw_object.h" |
| +#include "platform/utils.h" |
|
siva
2012/12/05 16:06:40
This order is not consistent with most other files
cshapiro
2012/12/08 03:23:08
Correct. Done.
|
| namespace dart { |
| class ObjectSet { |
| public: |
| - ObjectSet(uword start, uword end) : start_(start), end_(end) { |
| + ObjectSet() { |
| + Init(0, 0); |
| + } |
| + |
| + ObjectSet(uword start, uword end) { |
| + Init(start, end); |
| + } |
| + |
| + ~ObjectSet() { |
| + delete[] allocation_; |
| + } |
| + |
| + void Init(uword start, uword end) { |
| + start_ = start; |
| + end_ = end; |
| ASSERT(start_ <= end_); |
| size_ = SizeFor((end_ - start_) >> kWordSizeLog2); |
| allocation_ = new uword[size_]; |
| @@ -20,10 +36,6 @@ class ObjectSet { |
| Clear(); |
| } |
| - ~ObjectSet() { |
| - delete[] allocation_; |
| - } |
| - |
| bool Contains(RawObject* raw_obj) const { |
| uword raw_addr = RawObject::ToAddr(raw_obj); |
| ASSERT(raw_addr >= start_); |
| @@ -39,10 +51,30 @@ class ObjectSet { |
| ASSERT(raw_addr < end_); |
| uword i = raw_addr >> kWordSizeLog2; |
| data_[i / kBitsPerWord] |= (static_cast<uword>(1) << (i % kBitsPerWord)); |
| + min_ = Utils::Minimum(raw_addr, min_); |
| + max_ = Utils::Maximum(raw_addr, max_); |
| + } |
| + |
| + void Resize(uword start, uword end) { |
| + if (start_ != start || end_ != end) { |
| + delete[] allocation_; |
| + Init(start, end); |
| + } |
| } |
| void Clear() { |
| memset(allocation_, 0, (size_ * sizeof(allocation_[0]))); |
| + min_ = end_; |
| + max_ = start_; |
| + } |
| + |
| + void FastClear() { |
| + uword i = min_ >> kWordSizeLog2; |
| + memset(&data_[i / kBitsPerWord], |
| + 0, |
| + sizeof(uword) * SizeFor((max_ + 1 - min_) >> kWordSizeLog2)); |
| + min_ = end_; |
| + max_ = start_; |
| } |
| private: |
| @@ -66,7 +98,15 @@ class ObjectSet { |
| // Highest possible heap address, exclusive. |
| uword end_; |
| - DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectSet); |
| + // The inclusive minimum address set in this ObjectMap. |
| + // Used by FastClear |
| + uword min_; |
| + |
| + // The inclusive maximum address in this ObjectMap. |
| + // Used by FastClear |
| + uword max_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ObjectSet); |
| }; |
| } // namespace dart |