1 /*
2 * Copyright (c) 2001, 2013, 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 *
103 tc->link_next(NULL);
104 TreeList<Chunk_t, FreeList_t>* tl = TreeList<Chunk_t, FreeList_t>::as_TreeList(tc);
105 return tl;
106 }
107
108
109 #if INCLUDE_ALL_GCS
110 // Specialize for AdaptiveFreeList which tries to avoid
111 // splitting a chunk of a size that is under populated in favor of
112 // an over populated size. The general get_better_list() just returns
113 // the current list.
114 template <>
115 TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >*
116 TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >::get_better_list(
117 BinaryTreeDictionary<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* dictionary) {
118 // A candidate chunk has been found. If it is already under
119 // populated, get a chunk associated with the hint for this
120 // chunk.
121
122 TreeList<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* curTL = this;
123 if (surplus() <= 0) {
124 /* Use the hint to find a size with a surplus, and reset the hint. */
125 TreeList<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* hintTL = this;
126 while (hintTL->hint() != 0) {
127 assert(hintTL->hint() > hintTL->size(),
128 "hint points in the wrong direction");
129 hintTL = dictionary->find_list(hintTL->hint());
130 assert(curTL != hintTL, "Infinite loop");
131 if (hintTL == NULL ||
132 hintTL == curTL /* Should not happen but protect against it */ ) {
133 // No useful hint. Set the hint to NULL and go on.
134 curTL->set_hint(0);
135 break;
136 }
137 assert(hintTL->size() > curTL->size(), "hint is inconsistent");
138 if (hintTL->surplus() > 0) {
139 // The hint led to a list that has a surplus. Use it.
140 // Set the hint for the candidate to an overpopulated
141 // size.
142 curTL->set_hint(hintTL->size());
143 // Change the candidate.
|
1 /*
2 * Copyright (c) 2001, 2014, 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 *
103 tc->link_next(NULL);
104 TreeList<Chunk_t, FreeList_t>* tl = TreeList<Chunk_t, FreeList_t>::as_TreeList(tc);
105 return tl;
106 }
107
108
109 #if INCLUDE_ALL_GCS
110 // Specialize for AdaptiveFreeList which tries to avoid
111 // splitting a chunk of a size that is under populated in favor of
112 // an over populated size. The general get_better_list() just returns
113 // the current list.
114 template <>
115 TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >*
116 TreeList<FreeChunk, AdaptiveFreeList<FreeChunk> >::get_better_list(
117 BinaryTreeDictionary<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* dictionary) {
118 // A candidate chunk has been found. If it is already under
119 // populated, get a chunk associated with the hint for this
120 // chunk.
121
122 TreeList<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* curTL = this;
123 if (curTL->surplus() <= 0) {
124 /* Use the hint to find a size with a surplus, and reset the hint. */
125 TreeList<FreeChunk, ::AdaptiveFreeList<FreeChunk> >* hintTL = this;
126 while (hintTL->hint() != 0) {
127 assert(hintTL->hint() > hintTL->size(),
128 "hint points in the wrong direction");
129 hintTL = dictionary->find_list(hintTL->hint());
130 assert(curTL != hintTL, "Infinite loop");
131 if (hintTL == NULL ||
132 hintTL == curTL /* Should not happen but protect against it */ ) {
133 // No useful hint. Set the hint to NULL and go on.
134 curTL->set_hint(0);
135 break;
136 }
137 assert(hintTL->size() > curTL->size(), "hint is inconsistent");
138 if (hintTL->surplus() > 0) {
139 // The hint led to a list that has a surplus. Use it.
140 // Set the hint for the candidate to an overpopulated
141 // size.
142 curTL->set_hint(hintTL->size());
143 // Change the candidate.
|