1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
343 // require override/definition of prepare_for_compaction().
344 // Similar dependencies exist between
345 // - adjust_obj_size and adjust_pointers()
346 // - obj_size and compact().
347 //
348 // Additionally, this also means that changes to block_size() or block_is_obj() that
349 // should be effective during the compaction operations must provide a corresponding
350 // definition of scanned_block_size/scanned_block_is_obj respectively.
351 class CompactibleSpace: public Space {
352 friend class VMStructs;
353 friend class CompactibleFreeListSpace;
354 private:
355 HeapWord* _compaction_top;
356 CompactibleSpace* _next_compaction_space;
357
358 // Auxiliary functions for scan_and_{forward,adjust_pointers,compact} support.
359 inline size_t adjust_obj_size(size_t size) const {
360 return size;
361 }
362
363 inline size_t obj_size(const HeapWord* addr) const {
364 return oop(addr)->size();
365 }
366
367 public:
368 CompactibleSpace() :
369 _compaction_top(NULL), _next_compaction_space(NULL) {}
370
371 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
372 virtual void clear(bool mangle_space);
373
374 // Used temporarily during a compaction phase to hold the value
375 // top should have when compaction is complete.
376 HeapWord* compaction_top() const { return _compaction_top; }
377
378 void set_compaction_top(HeapWord* value) {
379 assert(value == NULL || (value >= bottom() && value <= end()),
380 "should point inside space");
381 _compaction_top = value;
382 }
383
384 // Perform operations on the space needed after a compaction
385 // has been performed.
491
492 // A space in which the free area is contiguous. It therefore supports
493 // faster allocation, and compaction.
494 class ContiguousSpace: public CompactibleSpace {
495 friend class VMStructs;
496 // Allow scan_and_forward function to call (private) overrides for auxiliary functions on this class
497 template <typename SpaceType>
498 friend void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* cp);
499
500 private:
501 // Auxiliary functions for scan_and_forward support.
502 // See comments for CompactibleSpace for more information.
503 inline HeapWord* scan_limit() const {
504 return top();
505 }
506
507 inline bool scanned_block_is_obj(const HeapWord* addr) const {
508 return true; // Always true, since scan_limit is top
509 }
510
511 inline size_t scanned_block_size(const HeapWord* addr) const {
512 return oop(addr)->size();
513 }
514
515 protected:
516 HeapWord* _top;
517 HeapWord* _concurrent_iteration_safe_limit;
518 // A helper for mangling the unused area of the space in debug builds.
519 GenSpaceMangler* _mangler;
520
521 GenSpaceMangler* mangler() { return _mangler; }
522
523 // Allocation helpers (return NULL if full).
524 inline HeapWord* allocate_impl(size_t word_size);
525 inline HeapWord* par_allocate_impl(size_t word_size);
526
527 public:
528 ContiguousSpace();
529 ~ContiguousSpace();
530
531 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
532 virtual void clear(bool mangle_space);
533
|
1 /*
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
343 // require override/definition of prepare_for_compaction().
344 // Similar dependencies exist between
345 // - adjust_obj_size and adjust_pointers()
346 // - obj_size and compact().
347 //
348 // Additionally, this also means that changes to block_size() or block_is_obj() that
349 // should be effective during the compaction operations must provide a corresponding
350 // definition of scanned_block_size/scanned_block_is_obj respectively.
351 class CompactibleSpace: public Space {
352 friend class VMStructs;
353 friend class CompactibleFreeListSpace;
354 private:
355 HeapWord* _compaction_top;
356 CompactibleSpace* _next_compaction_space;
357
358 // Auxiliary functions for scan_and_{forward,adjust_pointers,compact} support.
359 inline size_t adjust_obj_size(size_t size) const {
360 return size;
361 }
362
363 inline size_t obj_size(const HeapWord* addr) const;
364
365 public:
366 CompactibleSpace() :
367 _compaction_top(NULL), _next_compaction_space(NULL) {}
368
369 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
370 virtual void clear(bool mangle_space);
371
372 // Used temporarily during a compaction phase to hold the value
373 // top should have when compaction is complete.
374 HeapWord* compaction_top() const { return _compaction_top; }
375
376 void set_compaction_top(HeapWord* value) {
377 assert(value == NULL || (value >= bottom() && value <= end()),
378 "should point inside space");
379 _compaction_top = value;
380 }
381
382 // Perform operations on the space needed after a compaction
383 // has been performed.
489
490 // A space in which the free area is contiguous. It therefore supports
491 // faster allocation, and compaction.
492 class ContiguousSpace: public CompactibleSpace {
493 friend class VMStructs;
494 // Allow scan_and_forward function to call (private) overrides for auxiliary functions on this class
495 template <typename SpaceType>
496 friend void CompactibleSpace::scan_and_forward(SpaceType* space, CompactPoint* cp);
497
498 private:
499 // Auxiliary functions for scan_and_forward support.
500 // See comments for CompactibleSpace for more information.
501 inline HeapWord* scan_limit() const {
502 return top();
503 }
504
505 inline bool scanned_block_is_obj(const HeapWord* addr) const {
506 return true; // Always true, since scan_limit is top
507 }
508
509 inline size_t scanned_block_size(const HeapWord* addr) const;
510
511 protected:
512 HeapWord* _top;
513 HeapWord* _concurrent_iteration_safe_limit;
514 // A helper for mangling the unused area of the space in debug builds.
515 GenSpaceMangler* _mangler;
516
517 GenSpaceMangler* mangler() { return _mangler; }
518
519 // Allocation helpers (return NULL if full).
520 inline HeapWord* allocate_impl(size_t word_size);
521 inline HeapWord* par_allocate_impl(size_t word_size);
522
523 public:
524 ContiguousSpace();
525 ~ContiguousSpace();
526
527 virtual void initialize(MemRegion mr, bool clear_space, bool mangle_space);
528 virtual void clear(bool mangle_space);
529
|