Changed card table to use less cards when heap size is limited.

The card table uses the growth limit of the heap to limit the number of
cards it makes available for use. This gives it less cards to clean up
while the heap is limited.

Change-Id: Ia6520231d4abeda9604993ba28fd7ee7729a1ecb
diff --git a/src/card_table.cc b/src/card_table.cc
index e8eec38..4b57aa1 100644
--- a/src/card_table.cc
+++ b/src/card_table.cc
@@ -45,9 +45,9 @@
  * byte is equal to GC_DIRTY_CARD. See CardTable::Init for details.
  */
 
-CardTable* CardTable::Create(const byte* heap_base, size_t heap_max_size) {
+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)) {
+  if (!bitmap->Init(heap_base, heap_max_size, growth_size)) {
     return NULL;
   } else {
     return bitmap.release();
@@ -58,7 +58,7 @@
  * Initializes the card table; must be called before any other
  * CardTable functions.
  */
-bool CardTable::Init(const byte* heap_base, size_t heap_max_size) {
+bool 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 */
@@ -68,7 +68,8 @@
     return false;
   }
   base_ = alloc_base;
-  length_ = length;
+  length_ = growth_size / GC_CARD_SIZE;
+  max_length_ = length;
   offset_ = 0;
   /* All zeros is the correct initial value; all clean. */
   CHECK_EQ(GC_CARD_CLEAN, 0);