hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp
changeset 3912 3aaaaad1ccb0
parent 3908 24b55ad4c228
parent 3696 9e5d9b5e1049
child 5076 8b74a4b60b31
equal deleted inserted replaced
3911:a5d8d1764e94 3912:3aaaaad1ccb0
   100   GenMarkSweep::_preserved_oop_stack = NULL;
   100   GenMarkSweep::_preserved_oop_stack = NULL;
   101 
   101 
   102   GenMarkSweep::_marking_stack =
   102   GenMarkSweep::_marking_stack =
   103     new (ResourceObj::C_HEAP) GrowableArray<oop>(4000, true);
   103     new (ResourceObj::C_HEAP) GrowableArray<oop>(4000, true);
   104 
   104 
   105   size_t size = SystemDictionary::number_of_classes() * 2;
   105   int size = SystemDictionary::number_of_classes() * 2;
   106   GenMarkSweep::_revisit_klass_stack =
   106   GenMarkSweep::_revisit_klass_stack =
   107     new (ResourceObj::C_HEAP) GrowableArray<Klass*>((int)size, true);
   107     new (ResourceObj::C_HEAP) GrowableArray<Klass*>(size, true);
       
   108   // (#klass/k)^2 for k ~ 10 appears a better fit, but this will have to do
       
   109   // for now until we have a chance to work out a more optimal setting.
       
   110   GenMarkSweep::_revisit_mdo_stack =
       
   111     new (ResourceObj::C_HEAP) GrowableArray<DataLayout*>(size*2, true);
       
   112 
   108 }
   113 }
   109 
   114 
   110 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
   115 void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
   111                                     bool clear_all_softrefs) {
   116                                     bool clear_all_softrefs) {
   112   // Recursively traverse all live objects and mark them
   117   // Recursively traverse all live objects and mark them
   139   // Follow code cache roots (has to be done after system dictionary,
   144   // Follow code cache roots (has to be done after system dictionary,
   140   // assumes all live klasses are marked)
   145   // assumes all live klasses are marked)
   141   CodeCache::do_unloading(&GenMarkSweep::is_alive,
   146   CodeCache::do_unloading(&GenMarkSweep::is_alive,
   142                                    &GenMarkSweep::keep_alive,
   147                                    &GenMarkSweep::keep_alive,
   143                                    purged_class);
   148                                    purged_class);
   144            GenMarkSweep::follow_stack();
   149   GenMarkSweep::follow_stack();
   145 
   150 
   146   // Update subklass/sibling/implementor links of live klasses
   151   // Update subklass/sibling/implementor links of live klasses
   147   GenMarkSweep::follow_weak_klass_links();
   152   GenMarkSweep::follow_weak_klass_links();
   148   assert(GenMarkSweep::_marking_stack->is_empty(),
   153   assert(GenMarkSweep::_marking_stack->is_empty(),
   149          "stack should be empty by now");
   154          "stack should be empty by now");
       
   155 
       
   156   // Visit memoized MDO's and clear any unmarked weak refs
       
   157   GenMarkSweep::follow_mdo_weak_refs();
       
   158   assert(GenMarkSweep::_marking_stack->is_empty(), "just drained");
       
   159 
   150 
   160 
   151   // Visit symbol and interned string tables and delete unmarked oops
   161   // Visit symbol and interned string tables and delete unmarked oops
   152   SymbolTable::unlink(&GenMarkSweep::is_alive);
   162   SymbolTable::unlink(&GenMarkSweep::is_alive);
   153   StringTable::unlink(&GenMarkSweep::is_alive);
   163   StringTable::unlink(&GenMarkSweep::is_alive);
   154 
   164