Chromium Code Reviews| Index: src/global-handles.cc |
| diff --git a/src/global-handles.cc b/src/global-handles.cc |
| index 88ebe31647dc954fa21f0f5deca99dbf2ccc819b..61d03ddab53a6492eaeebcc38bebbba179ecf651 100644 |
| --- a/src/global-handles.cc |
| +++ b/src/global-handles.cc |
| @@ -1018,4 +1018,69 @@ void GlobalHandles::ComputeObjectGroupsAndImplicitReferences() { |
| } |
| +EternalHandles::EternalHandles() : size_(0) { |
| + for (unsigned i = 0; i < ARRAY_SIZE(indexed_handles_); i++) { |
| + indexed_handles_[i] = kInvalidIndex; |
| + } |
| +} |
| + |
| + |
| +EternalHandles::~EternalHandles() { |
| + for (int i = 0; i < blocks_.length(); i++) delete blocks_[i]; |
| +} |
| + |
| + |
| +void EternalHandles::IterateAllRoots(ObjectVisitor* visitor) { |
| + int limit = size_; |
| + for (int i = 0; i < blocks_.length(); i++) { |
| + ASSERT(limit > 0); |
| + Object** block = blocks_[i]; |
| + visitor->VisitPointers(block, block + Min(limit, kSize)); |
| + limit -= kSize; |
| + } |
| +} |
| + |
| + |
| +void EternalHandles::IterateNewSpaceRoots(ObjectVisitor* visitor) { |
| + for (int i = 0; i < new_space_indices_.length(); i++) { |
| + visitor->VisitPointer(Get(new_space_indices_[i])); |
| + } |
| +} |
| + |
| + |
| +void EternalHandles::PostGarbageCollectionProcessing(Heap* heap) { |
| + int last = 0; |
| + for (int i = 0; i < new_space_indices_.length(); i++) { |
| + int index = new_space_indices_[i]; |
| + if (heap->InNewSpace(*Get(index))) { |
| + new_space_indices_[last++] = index; |
| + } |
| + } |
| + new_space_indices_.Rewind(last); |
| +} |
| + |
| + |
| +int EternalHandles::Create(Isolate* isolate, Object* object) { |
| + if (object == NULL) return kInvalidIndex; |
| + ASSERT_NE(isolate->heap()->the_hole_value(), object); |
| + int block = size_ >> kShift; |
| + int offset = size_ & kMask; |
| + // need to resize |
| + if (offset == 0) { |
| + Object** next_block = new Object*[kSize]; |
| + Object* the_hole = isolate->heap()->the_hole_value(); |
| + for (int i = 0; i < kSize; i++) { |
|
Michael Starzinger
2013/08/01 13:26:11
Use MemsetPointer() instead of the loop.
|
| + next_block[i] = the_hole; |
| + } |
| + blocks_.Add(next_block); |
| + } |
| + ASSERT_EQ(isolate->heap()->the_hole_value(), blocks_[block][offset]); |
| + blocks_[block][offset] = object; |
| + if (isolate->heap()->InNewSpace(object)) { |
| + new_space_indices_.Add(size_); |
| + } |
| + return size_++; |
| +} |
| + |
| + |
| } } // namespace v8::internal |