From 5b1ba9a48ccee203b5205a1a5c480d6834c0b932 Mon Sep 17 00:00:00 2001 From: "yurys@chromium.org" Date: Wed, 1 Sep 2010 17:01:58 +0000 Subject: [PATCH] Don't access PagedSpace::executability after the object has been destroyed Review URL: http://codereview.chromium.org/3344001 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5395 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/spaces-inl.h | 8 ++++++++ src/spaces.cc | 2 +- src/spaces.h | 15 +++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/spaces-inl.h b/src/spaces-inl.h index 3b4718b..fbb2673 100644 --- a/src/spaces-inl.h +++ b/src/spaces-inl.h @@ -303,6 +303,14 @@ void Page::SetIsPageExecutable(bool is_page_executable) { // ----------------------------------------------------------------------------- // 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; diff --git a/src/spaces.cc b/src/spaces.cc index 50afd03..e734b93 100644 --- a/src/spaces.cc +++ b/src/spaces.cc @@ -616,7 +616,7 @@ void MemoryAllocator::DeleteChunk(int chunk_id) { Counters::memory_allocated.Decrement(static_cast(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); diff --git a/src/spaces.h b/src/spaces.h index 04e0c79..26bbfea 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -649,20 +649,23 @@ class MemoryAllocator : public AllStatic { // 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. -- 2.7.4