HeapColor ParallelScavengeHeap::get_current_color(oop obj)
{
  guarantee(UseColoredSpaces, "not using colored spaces!");
  guarantee(is_in(obj), "obj not in a colored space!");

  if (is_in_young(obj)) {
    if (young_gen()->eden_space()->contains(obj)) {
      if (((MutableColoredSpace*)young_gen()->eden_space())->
          colored_spaces()->at(HC_RED)->space()->contains(obj)) {
        return HC_RED;
      }
      guarantee(((MutableColoredSpace*)young_gen()->eden_space())->
                colored_spaces()->at(HC_BLUE)->space()->contains(obj), "wtf");
      return HC_BLUE;
    } else if (young_gen()->from_space()->contains(obj)) {
      if (((MutableColoredSpace*)young_gen()->from_space())->
          colored_spaces()->at(HC_RED)->space()->contains(obj)) {
        return HC_RED;
      }
      guarantee(((MutableColoredSpace*)young_gen()->from_space())->
                colored_spaces()->at(HC_BLUE)->space()->contains(obj), "wtf");
      return HC_BLUE;
    } else {
      if (((MutableColoredSpace*)young_gen()->to_space())->
          colored_spaces()->at(HC_RED)->space()->contains(obj)) {
        return HC_RED;
      }
      guarantee(((MutableColoredSpace*)young_gen()->to_space())->
                colored_spaces()->at(HC_BLUE)->space()->contains(obj), "wtf");
      return HC_BLUE;
    }
  } else {
      if (((MutableColoredSpace*)old_gen()->object_space())->
          colored_spaces()->at(HC_RED)->space()->contains(obj)) {
        return HC_RED;
      }
      guarantee(((MutableColoredSpace*)old_gen()->object_space())->
                colored_spaces()->at(HC_BLUE)->space()->contains(obj), "wtf");
      return HC_BLUE;
  }
}
bool ParallelScavengeHeap::can_elide_initializing_store_barrier(oop new_obj) {
  // We don't need barriers for stores to objects in the
  // young gen and, a fortiori, for initializing stores to
  // objects therein.
  return is_in_young(new_obj);
}
bool ParallelScavengeHeap::is_scavengable(const void* addr) {
  return is_in_young((oop)addr);
}