If a card table or mark stack allocation fails, dump /proc/self/maps.
Change-Id: I075d3029be52af8568ec6862a4c5f32443971861
diff --git a/src/card_table.cc b/src/card_table.cc
index 430918a..0871ed9 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 @@
*/
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 @@
}
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 a2616be..1f58507 100644
--- a/src/card_table.h
+++ b/src/card_table.h
@@ -60,7 +60,7 @@
* 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 53a342b..b61597b 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 @@
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);