Revision: 9013
Author:   [email protected]
Date:     Thu Aug 25 03:55:44 2011
Log:      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
http://code.google.com/p/v8/source/detail?r=9013

Modified:
 /branches/bleeding_edge/src/spaces-inl.h
 /branches/bleeding_edge/src/spaces.cc
 /branches/bleeding_edge/src/spaces.h

=======================================
--- /branches/bleeding_edge/src/spaces-inl.h    Mon Jul 11 07:03:21 2011
+++ /branches/bleeding_edge/src/spaces-inl.h    Thu Aug 25 03:55:44 2011
@@ -294,13 +294,13 @@
   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);
 }


=======================================
--- /branches/bleeding_edge/src/spaces.cc       Thu Aug  4 08:18:18 2011
+++ /branches/bleeding_edge/src/spaces.cc       Thu Aug 25 03:55:44 2011
@@ -2762,8 +2762,7 @@
     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 @@
// 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 @@
     } 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();

=======================================
--- /branches/bleeding_edge/src/spaces.h        Thu Aug 18 05:33:40 2011
+++ /branches/bleeding_edge/src/spaces.h        Thu Aug 25 03:55:44 2011
@@ -200,9 +200,9 @@

   inline void SetIsLargeObjectPage(bool is_large_object_page);

-  inline bool IsPageExecutable();
-
-  inline void SetIsPageExecutable(bool is_page_executable);
+  inline Executability PageExecutability();
+
+  inline void SetPageExecutability(Executability executable);

   // Returns the offset of a given address to this page.
   INLINE(int Offset(Address a)) {

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to