Reviewers: Vitaly, Mads Ager,

Description:
Don't access PagedSpace::executability after the object has been destroyed


Please review this at http://codereview.chromium.org/3344001/show

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/spaces-inl.h
  M     src/spaces.h
  M     src/spaces.cc


Index: src/spaces-inl.h
===================================================================
--- src/spaces-inl.h    (revision 5394)
+++ src/spaces-inl.h    (working copy)
@@ -303,6 +303,14 @@
// -----------------------------------------------------------------------------
 // MemoryAllocator

+void MemoryAllocator::ChunkInfo::init(Address a, size_t s, PagedSpace* o) {
+  address_ = a;
+  size_ = s;
+  owner_ = o;
+  executable_ = (o == NULL) ? NOT_EXECUTABLE : o->executable();
+}
+
+
 bool MemoryAllocator::IsValidChunk(int chunk_id) {
   if (!IsValidChunkId(chunk_id)) return false;

Index: src/spaces.cc
===================================================================
--- src/spaces.cc       (revision 5394)
+++ src/spaces.cc       (working copy)
@@ -616,7 +616,7 @@
     Counters::memory_allocated.Decrement(static_cast<int>(c.size()));
   } else {
     LOG(DeleteEvent("PagedChunk", c.address()));
-    FreeRawMemory(c.address(), c.size(), c.owner()->executable());
+    FreeRawMemory(c.address(), c.size(), c.executable());
   }
   c.init(NULL, 0, NULL);
   Push(chunk_id);
Index: src/spaces.h
===================================================================
--- src/spaces.h        (revision 5394)
+++ src/spaces.h        (working copy)
@@ -649,20 +649,23 @@
// Allocated chunk info: chunk start address, chunk size, and owning space.
   class ChunkInfo BASE_EMBEDDED {
    public:
-    ChunkInfo() : address_(NULL), size_(0), owner_(NULL) {}
-    void init(Address a, size_t s, PagedSpace* o) {
-      address_ = a;
-      size_ = s;
-      owner_ = o;
-    }
+    ChunkInfo() : address_(NULL),
+                  size_(0),
+                  owner_(NULL),
+                  executable_(NOT_EXECUTABLE) {}
+    inline void init(Address a, size_t s, PagedSpace* o);
     Address address() { return address_; }
     size_t size() { return size_; }
     PagedSpace* owner() { return owner_; }
+    // We save executability of the owner to allow using it
+    // when collecting stats after the owner has been destroyed.
+    Executability executable() const { return executable_; }

    private:
     Address address_;
     size_t size_;
     PagedSpace* owner_;
+    Executability executable_;
   };

   // Chunks_, free_chunk_ids_ and top_ act as a stack of free chunk ids.


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

Reply via email to