Commit d0a4c900 authored by Nikolaos Papaspyrou's avatar Nikolaos Papaspyrou Committed by V8 LUCI CQ

heap: Fix bug in ReadOnlySpaceObjectIterator

ReadOnlySpaceObjectIterator did not iterate through objects, because of
a bug in the initialization of `cur_addr_` and `cur_end_`. This CL also
merges methods `Next` and `FromCurrentPage`.

Change-Id: Id56bff279216c7a5982d984d80b649bd0c915959
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3758225Reviewed-by: 's avatarOmer Katz <omerkatz@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Nikolaos Papaspyrou <nikolaos@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81668}
parent 192d8c17
......@@ -421,19 +421,14 @@ class ReadOnlySpaceObjectIterator : public ObjectIterator {
public:
ReadOnlySpaceObjectIterator(const Heap* heap, const ReadOnlySpace* space,
BasicMemoryChunk* chunk)
: cur_addr_(kNullAddress), cur_end_(kNullAddress), space_(space) {}
: cur_addr_(chunk->area_start()),
cur_end_(chunk->area_end()),
space_(space) {}
// Advance to the next object, skipping free spaces and other fillers and
// skipping the special garbage section of which there is one per space.
// Returns nullptr when the iteration has ended.
// Returns a null object when the iteration has ended.
HeapObject Next() override {
HeapObject next_obj = FromCurrentPage();
if (!next_obj.is_null()) return next_obj;
return HeapObject();
}
private:
HeapObject FromCurrentPage() {
while (cur_addr_ != cur_end_) {
if (cur_addr_ == space_->top() && cur_addr_ != space_->limit()) {
cur_addr_ = space_->limit();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment