From a546e4a8dd2f5585133a857512ed0c4a53ac34ca Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Thu, 25 Aug 2011 10:55:44 +0000 Subject: [PATCH] Fixed bool <-> Executability confusion and improved typing a bit. Passing a value of type Executability to a function expecting a bool worked only by accident (because of the order of values in the enum). But using boolean parameters is often a bad idea, anyway, so we use Executability directly. Just another example why implicit type conversions in C++ are a bad idea... :-P Review URL: http://codereview.chromium.org/7753001 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9013 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/spaces-inl.h | 8 ++++---- src/spaces.cc | 8 +++----- src/spaces.h | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/spaces-inl.h b/src/spaces-inl.h index ca1177f..283156c 100644 --- a/src/spaces-inl.h +++ b/src/spaces-inl.h @@ -294,13 +294,13 @@ void Page::SetIsLargeObjectPage(bool is_large_object_page) { SetPageFlag(IS_NORMAL_PAGE, !is_large_object_page); } -bool Page::IsPageExecutable() { - return GetPageFlag(IS_EXECUTABLE); +Executability Page::PageExecutability() { + return GetPageFlag(IS_EXECUTABLE) ? EXECUTABLE : NOT_EXECUTABLE; } -void Page::SetIsPageExecutable(bool is_page_executable) { - SetPageFlag(IS_EXECUTABLE, is_page_executable); +void Page::SetPageExecutability(Executability executable) { + SetPageFlag(IS_EXECUTABLE, executable == EXECUTABLE); } diff --git a/src/spaces.cc b/src/spaces.cc index a782ba9..cc9038d 100644 --- a/src/spaces.cc +++ b/src/spaces.cc @@ -2762,8 +2762,7 @@ void LargeObjectSpace::TearDown() { first_chunk_ = first_chunk_->next(); LOG(heap()->isolate(), DeleteEvent("LargeObjectChunk", chunk->address())); Page* page = Page::FromAddress(RoundUp(chunk->address(), Page::kPageSize)); - Executability executable = - page->IsPageExecutable() ? EXECUTABLE : NOT_EXECUTABLE; + Executability executable = page->PageExecutability(); ObjectSpace space = kObjectSpaceLoSpace; if (executable == EXECUTABLE) space = kObjectSpaceCodeSpace; size_t size = chunk->size(); @@ -2813,7 +2812,7 @@ MaybeObject* LargeObjectSpace::AllocateRawInternal(int requested_size, // large object page. If the chunk_size happened to be written there, its // low order bit should already be clear. page->SetIsLargeObjectPage(true); - page->SetIsPageExecutable(executable); + page->SetPageExecutability(executable); page->SetRegionMarks(Page::kAllRegionsCleanMarks); return HeapObject::FromAddress(object_address); } @@ -2946,8 +2945,7 @@ void LargeObjectSpace::FreeUnmarkedObjects() { } else { Page* page = Page::FromAddress(RoundUp(current->address(), Page::kPageSize)); - Executability executable = - page->IsPageExecutable() ? EXECUTABLE : NOT_EXECUTABLE; + Executability executable = page->PageExecutability(); Address chunk_address = current->address(); size_t chunk_size = current->size(); diff --git a/src/spaces.h b/src/spaces.h index a0f4ba1..006c882 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -200,9 +200,9 @@ class Page { inline void SetIsLargeObjectPage(bool is_large_object_page); - inline bool IsPageExecutable(); + inline Executability PageExecutability(); - inline void SetIsPageExecutable(bool is_page_executable); + inline void SetPageExecutability(Executability executable); // Returns the offset of a given address to this page. INLINE(int Offset(Address a)) { -- 2.7.4