| Index: src/heap/spaces.h
|
| diff --git a/src/heap/spaces.h b/src/heap/spaces.h
|
| index 29a0b66d9de1ae4ea8b4614ba970eaaa1e68eb52..eec533f9a1e01a4c470fc274c809ddde59234923 100644
|
| --- a/src/heap/spaces.h
|
| +++ b/src/heap/spaces.h
|
| @@ -2459,7 +2459,11 @@ class SemiSpace : public Space {
|
|
|
| bool AdvancePage() {
|
| Page* next_page = current_page_->next_page();
|
| - if (next_page == anchor() || pages_used_ == max_pages()) {
|
| + // We cannot expand if we reached the maximum number of pages already. Note
|
| + // that we need to account for the next page already for this check as we
|
| + // could potentially fill the whole page after advancing.
|
| + const bool reached_max_pages = (pages_used_ + 1) == max_pages();
|
| + if (next_page == anchor() || reached_max_pages) {
|
| return false;
|
| }
|
| current_page_ = next_page;
|
|
|