summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-01-13 20:12:02 -0800
committer Elliott Hughes <enh@google.com> 2012-01-13 20:12:02 -0800
commitf0605a0da70a495521e466c98255d469915a1f00 (patch)
tree99fd51cd2448794914166b6c7eef859c63b6e14f /src
parent6b3557571e798b60df995f978fa01c0ca1980dfd (diff)
If a card table or mark stack allocation fails, dump /proc/self/maps.
Change-Id: I075d3029be52af8568ec6862a4c5f32443971861
Diffstat (limited to 'src')
-rw-r--r--src/card_table.cc25
-rw-r--r--src/card_table.h2
-rw-r--r--src/mark_stack.cc8
3 files changed, 20 insertions, 15 deletions
diff --git a/src/card_table.cc b/src/card_table.cc
index 430918a8b4..0871ed92b5 100644
--- a/src/card_table.cc
+++ b/src/card_table.cc
@@ -21,6 +21,7 @@
#include "heap.h"
#include "heap_bitmap.h"
#include "logging.h"
+#include "utils.h"
namespace art {
/*
@@ -46,28 +47,27 @@ namespace art {
*/
CardTable* CardTable::Create(const byte* heap_base, size_t heap_max_size, size_t growth_size) {
- UniquePtr<CardTable> bitmap(new CardTable);
- if (!bitmap->Init(heap_base, heap_max_size, growth_size)) {
- return NULL;
- } else {
- return bitmap.release();
- }
+ CardTable* bitmap = new CardTable;
+ bitmap->Init(heap_base, heap_max_size, growth_size);
+ return bitmap;
}
/*
* Initializes the card table; must be called before any other
* CardTable functions.
*/
-bool CardTable::Init(const byte* heap_base, size_t heap_max_size, size_t growth_size) {
+void CardTable::Init(const byte* heap_base, size_t heap_max_size, size_t growth_size) {
/* Set up the card table */
size_t length = heap_max_size / GC_CARD_SIZE;
/* Allocate an extra 256 bytes to allow fixed low-byte of base */
- mem_map_.reset(
- MemMap::MapAnonymous("dalvik-card-table", NULL, length + 256, PROT_READ | PROT_WRITE));
- byte* alloc_base = mem_map_->GetAddress();
- if (alloc_base == NULL) {
- return false;
+ mem_map_.reset(MemMap::MapAnonymous("dalvik-card-table", NULL, length + 256, PROT_READ | PROT_WRITE));
+ if (mem_map_.get() == NULL) {
+ std::string maps;
+ ReadFileToString("/proc/self/maps", &maps);
+ LOG(FATAL) << "couldn't allocate card table\n" << maps;
}
+ byte* alloc_base = mem_map_->GetAddress();
+ CHECK(alloc_base != NULL);
base_ = alloc_base;
length_ = growth_size / GC_CARD_SIZE;
max_length_ = length;
@@ -82,7 +82,6 @@ bool CardTable::Init(const byte* heap_base, size_t heap_max_size, size_t growth_
}
CHECK_EQ(reinterpret_cast<int>(biased_base_) & 0xff, GC_CARD_DIRTY);
ClearCardTable();
- return true;
}
void CardTable::ClearCardTable() {
diff --git a/src/card_table.h b/src/card_table.h
index a2616be7dd..1f58507cc4 100644
--- a/src/card_table.h
+++ b/src/card_table.h
@@ -60,7 +60,7 @@ class CardTable {
* Initializes the card table; must be called before any other
* CardTable functions.
*/
- bool Init(const byte* heap_base, size_t heap_max_size, size_t growth_size);
+ void Init(const byte* heap_base, size_t heap_max_size, size_t growth_size);
/*
* Resets all of the bytes in the card table to clean.
diff --git a/src/mark_stack.cc b/src/mark_stack.cc
index 53a342b992..b61597bd2e 100644
--- a/src/mark_stack.cc
+++ b/src/mark_stack.cc
@@ -7,6 +7,7 @@
#include "UniquePtr.h"
#include "globals.h"
#include "logging.h"
+#include "utils.h"
namespace art {
@@ -19,8 +20,13 @@ MarkStack* MarkStack::Create() {
void MarkStack::Init() {
size_t length = 64 * MB;
mem_map_.reset(MemMap::MapAnonymous("dalvik-mark-stack", NULL, length, PROT_READ | PROT_WRITE));
- CHECK(mem_map_.get() != NULL) << "MemMap::Map() failed; aborting";
+ if (mem_map_.get() == NULL) {
+ std::string maps;
+ ReadFileToString("/proc/self/maps", &maps);
+ LOG(FATAL) << "couldn't allocate mark stack\n" << maps;
+ }
byte* addr = mem_map_->GetAddress();
+ CHECK(addr != NULL);
base_ = reinterpret_cast<const Object**>(addr);
limit_ = reinterpret_cast<const Object**>(addr + length);
ptr_ = reinterpret_cast<Object const**>(addr);