Mercurial > hg > graal-jvmci-8
comparison src/share/vm/memory/metachunk.cpp @ 10175:c23dbf0e8ab7
8011268: NPG: Free unused VirtualSpaceNodes
Reviewed-by: mgerdin, coleenp, johnc
author | jmasa |
---|---|
date | Fri, 01 Mar 2013 10:19:29 -0800 |
parents | e51c9860cf66 |
children | bdfbb1fb19ca |
comparison
equal
deleted
inserted
replaced
10103:07a4efc5ed14 | 10175:c23dbf0e8ab7 |
---|---|
26 #include "memory/allocation.hpp" | 26 #include "memory/allocation.hpp" |
27 #include "memory/metachunk.hpp" | 27 #include "memory/metachunk.hpp" |
28 #include "utilities/copy.hpp" | 28 #include "utilities/copy.hpp" |
29 #include "utilities/debug.hpp" | 29 #include "utilities/debug.hpp" |
30 | 30 |
31 class VirtualSpaceNode; | |
31 // | 32 // |
32 // Future modification | 33 // Future modification |
33 // | 34 // |
34 // The Metachunk can conceivable be replaced by the Chunk in | 35 // The Metachunk can conceivable be replaced by the Chunk in |
35 // allocation.hpp. Note that the latter Chunk is the space for | 36 // allocation.hpp. Note that the latter Chunk is the space for |
43 size_t Metachunk::_overhead = | 44 size_t Metachunk::_overhead = |
44 Chunk::aligned_overhead_size(sizeof(Metachunk)) / BytesPerWord; | 45 Chunk::aligned_overhead_size(sizeof(Metachunk)) / BytesPerWord; |
45 | 46 |
46 // Metachunk methods | 47 // Metachunk methods |
47 | 48 |
48 Metachunk* Metachunk::initialize(MetaWord* ptr, size_t word_size) { | 49 Metachunk::Metachunk(size_t word_size, |
49 // Set bottom, top, and end. Allow space for the Metachunk itself | 50 VirtualSpaceNode* container) : |
50 Metachunk* chunk = (Metachunk*) ptr; | 51 _word_size(word_size), |
51 | 52 _bottom(NULL), |
52 MetaWord* chunk_bottom = ptr + _overhead; | 53 _end(NULL), |
53 chunk->set_bottom(ptr); | 54 _top(NULL), |
54 chunk->set_top(chunk_bottom); | 55 _next(NULL), |
55 MetaWord* chunk_end = ptr + word_size; | 56 _prev(NULL), |
56 assert(chunk_end > chunk_bottom, "Chunk must be too small"); | 57 _container(container) |
57 chunk->set_end(chunk_end); | 58 { |
58 chunk->set_next(NULL); | 59 _bottom = (MetaWord*)this; |
59 chunk->set_prev(NULL); | 60 _top = (MetaWord*)this + _overhead; |
60 chunk->set_word_size(word_size); | 61 _end = (MetaWord*)this + word_size; |
61 #ifdef ASSERT | 62 #ifdef ASSERT |
62 size_t data_word_size = pointer_delta(chunk_end, chunk_bottom, sizeof(MetaWord)); | 63 set_is_free(false); |
63 Copy::fill_to_words((HeapWord*) chunk_bottom, data_word_size, metadata_chunk_initialize); | 64 size_t data_word_size = pointer_delta(end(), |
65 top(), | |
66 sizeof(MetaWord)); | |
67 Copy::fill_to_words((HeapWord*) top(), | |
68 data_word_size, | |
69 metadata_chunk_initialize); | |
64 #endif | 70 #endif |
65 return chunk; | |
66 } | 71 } |
67 | |
68 | 72 |
69 MetaWord* Metachunk::allocate(size_t word_size) { | 73 MetaWord* Metachunk::allocate(size_t word_size) { |
70 MetaWord* result = NULL; | 74 MetaWord* result = NULL; |
71 // If available, bump the pointer to allocate. | 75 // If available, bump the pointer to allocate. |
72 if (free_word_size() >= word_size) { | 76 if (free_word_size() >= word_size) { |