126 Other
127 };
128
129 enum SomePublicConstants {
130 // Generations are GenGrain-aligned and have size that are multiples of
131 // GenGrain.
132 // Note: on ARM we add 1 bit for card_table_base to be properly aligned
133 // (we expect its low byte to be zero - see implementation of post_barrier)
134 LogOfGenGrain = 16 ARM32_ONLY(+1),
135 GenGrain = 1 << LogOfGenGrain
136 };
137
138 // allocate and initialize ("weak") refs processing support
139 virtual void ref_processor_init();
140 void set_ref_processor(ReferenceProcessor* rp) {
141 assert(_ref_processor == NULL, "clobbering existing _ref_processor");
142 _ref_processor = rp;
143 }
144
145 virtual Generation::Name kind() { return Generation::Other; }
146 GenerationSpec* spec();
147
148 // This properly belongs in the collector, but for now this
149 // will do.
150 virtual bool refs_discovery_is_atomic() const { return true; }
151 virtual bool refs_discovery_is_mt() const { return false; }
152
153 // Space enquiries (results in bytes)
154 virtual size_t capacity() const = 0; // The maximum number of object bytes the
155 // generation can currently hold.
156 virtual size_t used() const = 0; // The number of used bytes in the gen.
157 virtual size_t free() const = 0; // The number of free bytes in the gen.
158
159 // Support for java.lang.Runtime.maxMemory(); see CollectedHeap.
160 // Returns the total number of bytes available in a generation
161 // for the allocation of objects.
162 virtual size_t max_capacity() const;
163
164 // If this is a young generation, the maximum number of bytes that can be
165 // allocated in this generation before a GC is triggered.
166 virtual size_t capacity_before_gc() const { return 0; }
294 // Thread "thread_num" (0 <= i < ParalleGCThreads) wants to promote
295 // object "obj", whose original mark word was "m", and whose size is
296 // "word_sz". If possible, allocate space for "obj", copy obj into it
297 // (taking care to copy "m" into the mark word when done, since the mark
298 // word of "obj" may have been overwritten with a forwarding pointer, and
299 // also taking care to copy the klass pointer *last*. Returns the new
300 // object if successful, or else NULL.
301 virtual oop par_promote(int thread_num, oop obj, markOop m, size_t word_sz);
302
303 // Informs the current generation that all par_promote_alloc's in the
304 // collection have been completed; any supporting data structures can be
305 // reset. Default is to do nothing.
306 virtual void par_promote_alloc_done(int thread_num) {}
307
308 // Informs the current generation that all oop_since_save_marks_iterates
309 // performed by "thread_num" in the current collection, if any, have been
310 // completed; any supporting data structures can be reset. Default is to
311 // do nothing.
312 virtual void par_oop_since_save_marks_iterate_done(int thread_num) {}
313
314 // This generation will collect all younger generations
315 // during a full collection.
316 virtual bool full_collects_young_generation() const { return false; }
317
318 // This generation does in-place marking, meaning that mark words
319 // are mutated during the marking phase and presumably reinitialized
320 // to a canonical value after the GC. This is currently used by the
321 // biased locking implementation to determine whether additional
322 // work is required during the GC prologue and epilogue.
323 virtual bool performs_in_place_marking() const { return true; }
324
325 // Returns "true" iff collect() should subsequently be called on this
326 // this generation. See comment below.
327 // This is a generic implementation which can be overridden.
328 //
329 // Note: in the current (1.4) implementation, when genCollectedHeap's
330 // incremental_collection_will_fail flag is set, all allocations are
331 // slow path (the only fast-path place to allocate is DefNew, which
332 // will be full if the flag is set).
333 // Thus, older generations which collect younger generations should
334 // test this flag and collect if it is set.
335 virtual bool should_collect(bool full,
336 size_t word_size,
337 bool is_tlab) {
388 // that guarantees monotonically non-decreasing values provided
389 // the underlying platform provides such a source. So we still
390 // have to guard against non-monotonicity.
391 NOT_PRODUCT(
392 if (now < _time_of_last_gc) {
393 warning("time warp: " JLONG_FORMAT " to " JLONG_FORMAT, _time_of_last_gc, now);
394 }
395 )
396 return _time_of_last_gc;
397 }
398
399 virtual void update_time_of_last_gc(jlong now) {
400 _time_of_last_gc = now;
401 }
402
403 // Generations may keep statistics about collection. This method
404 // updates those statistics. current_generation is the generation
405 // that was most recently collected. This allows the generation to
406 // decide what statistics are valid to collect. For example, the
407 // generation can decide to gather the amount of promoted data if
408 // the collection of the younger generations has completed.
409 GCStats* gc_stats() const { return _gc_stats; }
410 virtual void update_gc_stats(Generation* current_generation, bool full) {}
411
412 // Mark sweep support phase2
413 virtual void prepare_for_compaction(CompactPoint* cp);
414 // Mark sweep support phase3
415 virtual void adjust_pointers();
416 // Mark sweep support phase4
417 virtual void compact();
418 virtual void post_compact() { ShouldNotReachHere(); }
419
420 // Support for CMS's rescan. In this general form we return a pointer
421 // to an abstract object that can be used, based on specific previously
422 // decided protocols, to exchange information between generations,
423 // information that may be useful for speeding up certain types of
424 // garbage collectors. A NULL value indicates to the client that
425 // no data recording is expected by the provider. The data-recorder is
426 // expected to be GC worker thread-local, with the worker index
427 // indicated by "thr_num".
428 virtual void* get_data_recorder(int thr_num) { return NULL; }
|
126 Other
127 };
128
129 enum SomePublicConstants {
130 // Generations are GenGrain-aligned and have size that are multiples of
131 // GenGrain.
132 // Note: on ARM we add 1 bit for card_table_base to be properly aligned
133 // (we expect its low byte to be zero - see implementation of post_barrier)
134 LogOfGenGrain = 16 ARM32_ONLY(+1),
135 GenGrain = 1 << LogOfGenGrain
136 };
137
138 // allocate and initialize ("weak") refs processing support
139 virtual void ref_processor_init();
140 void set_ref_processor(ReferenceProcessor* rp) {
141 assert(_ref_processor == NULL, "clobbering existing _ref_processor");
142 _ref_processor = rp;
143 }
144
145 virtual Generation::Name kind() { return Generation::Other; }
146 size_t initial_size();
147
148 // This properly belongs in the collector, but for now this
149 // will do.
150 virtual bool refs_discovery_is_atomic() const { return true; }
151 virtual bool refs_discovery_is_mt() const { return false; }
152
153 // Space enquiries (results in bytes)
154 virtual size_t capacity() const = 0; // The maximum number of object bytes the
155 // generation can currently hold.
156 virtual size_t used() const = 0; // The number of used bytes in the gen.
157 virtual size_t free() const = 0; // The number of free bytes in the gen.
158
159 // Support for java.lang.Runtime.maxMemory(); see CollectedHeap.
160 // Returns the total number of bytes available in a generation
161 // for the allocation of objects.
162 virtual size_t max_capacity() const;
163
164 // If this is a young generation, the maximum number of bytes that can be
165 // allocated in this generation before a GC is triggered.
166 virtual size_t capacity_before_gc() const { return 0; }
294 // Thread "thread_num" (0 <= i < ParalleGCThreads) wants to promote
295 // object "obj", whose original mark word was "m", and whose size is
296 // "word_sz". If possible, allocate space for "obj", copy obj into it
297 // (taking care to copy "m" into the mark word when done, since the mark
298 // word of "obj" may have been overwritten with a forwarding pointer, and
299 // also taking care to copy the klass pointer *last*. Returns the new
300 // object if successful, or else NULL.
301 virtual oop par_promote(int thread_num, oop obj, markOop m, size_t word_sz);
302
303 // Informs the current generation that all par_promote_alloc's in the
304 // collection have been completed; any supporting data structures can be
305 // reset. Default is to do nothing.
306 virtual void par_promote_alloc_done(int thread_num) {}
307
308 // Informs the current generation that all oop_since_save_marks_iterates
309 // performed by "thread_num" in the current collection, if any, have been
310 // completed; any supporting data structures can be reset. Default is to
311 // do nothing.
312 virtual void par_oop_since_save_marks_iterate_done(int thread_num) {}
313
314 // This generation does in-place marking, meaning that mark words
315 // are mutated during the marking phase and presumably reinitialized
316 // to a canonical value after the GC. This is currently used by the
317 // biased locking implementation to determine whether additional
318 // work is required during the GC prologue and epilogue.
319 virtual bool performs_in_place_marking() const { return true; }
320
321 // Returns "true" iff collect() should subsequently be called on this
322 // this generation. See comment below.
323 // This is a generic implementation which can be overridden.
324 //
325 // Note: in the current (1.4) implementation, when genCollectedHeap's
326 // incremental_collection_will_fail flag is set, all allocations are
327 // slow path (the only fast-path place to allocate is DefNew, which
328 // will be full if the flag is set).
329 // Thus, older generations which collect younger generations should
330 // test this flag and collect if it is set.
331 virtual bool should_collect(bool full,
332 size_t word_size,
333 bool is_tlab) {
384 // that guarantees monotonically non-decreasing values provided
385 // the underlying platform provides such a source. So we still
386 // have to guard against non-monotonicity.
387 NOT_PRODUCT(
388 if (now < _time_of_last_gc) {
389 warning("time warp: " JLONG_FORMAT " to " JLONG_FORMAT, _time_of_last_gc, now);
390 }
391 )
392 return _time_of_last_gc;
393 }
394
395 virtual void update_time_of_last_gc(jlong now) {
396 _time_of_last_gc = now;
397 }
398
399 // Generations may keep statistics about collection. This method
400 // updates those statistics. current_generation is the generation
401 // that was most recently collected. This allows the generation to
402 // decide what statistics are valid to collect. For example, the
403 // generation can decide to gather the amount of promoted data if
404 // the collection of the young generation has completed.
405 GCStats* gc_stats() const { return _gc_stats; }
406 virtual void update_gc_stats(Generation* current_generation, bool full) {}
407
408 // Mark sweep support phase2
409 virtual void prepare_for_compaction(CompactPoint* cp);
410 // Mark sweep support phase3
411 virtual void adjust_pointers();
412 // Mark sweep support phase4
413 virtual void compact();
414 virtual void post_compact() { ShouldNotReachHere(); }
415
416 // Support for CMS's rescan. In this general form we return a pointer
417 // to an abstract object that can be used, based on specific previously
418 // decided protocols, to exchange information between generations,
419 // information that may be useful for speeding up certain types of
420 // garbage collectors. A NULL value indicates to the client that
421 // no data recording is expected by the provider. The data-recorder is
422 // expected to be GC worker thread-local, with the worker index
423 // indicated by "thr_num".
424 virtual void* get_data_recorder(int thr_num) { return NULL; }
|