1 /*
2 * Copyright (c) 2005, 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 *
1225 static const char* space_names[last_space_id];
1226 static void print_region_ranges();
1227 static void print_dense_prefix_stats(const char* const algorithm,
1228 const SpaceId id,
1229 const bool maximum_compaction,
1230 HeapWord* const addr);
1231 static void summary_phase_msg(SpaceId dst_space_id,
1232 HeapWord* dst_beg, HeapWord* dst_end,
1233 SpaceId src_space_id,
1234 HeapWord* src_beg, HeapWord* src_end);
1235 #endif // #ifndef PRODUCT
1236
1237 #ifdef ASSERT
1238 // Sanity check the new location of a word in the heap.
1239 static inline void check_new_location(HeapWord* old_addr, HeapWord* new_addr);
1240 // Verify that all the regions have been emptied.
1241 static void verify_complete(SpaceId space_id);
1242 #endif // #ifdef ASSERT
1243 };
1244
1245 inline bool PSParallelCompact::mark_obj(oop obj) {
1246 const int obj_size = obj->size();
1247 if (mark_bitmap()->mark_obj(obj, obj_size)) {
1248 _summary_data.add_obj(obj, obj_size);
1249 return true;
1250 } else {
1251 return false;
1252 }
1253 }
1254
1255 inline bool PSParallelCompact::is_marked(oop obj) {
1256 return mark_bitmap()->is_marked(obj);
1257 }
1258
1259 inline double PSParallelCompact::normal_distribution(double density) {
1260 assert(_dwl_initialized, "uninitialized");
1261 const double squared_term = (density - _dwl_mean) / _dwl_std_dev;
1262 return _dwl_first_term * exp(-0.5 * squared_term * squared_term);
1263 }
1264
1265 inline bool
1266 PSParallelCompact::dead_space_crosses_boundary(const RegionData* region,
1267 idx_t bit)
1268 {
1269 assert(bit > 0, "cannot call this for the first bit/region");
1270 assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit),
1271 "sanity check");
1272
1273 // Dead space crosses the boundary if (1) a partial object does not extend
1274 // onto the region, (2) an object does not start at the beginning of the
1369 _source += words;
1370 _destination += words;
1371 }
1372
1373 class UpdateOnlyClosure: public ParMarkBitMapClosure {
1374 private:
1375 const PSParallelCompact::SpaceId _space_id;
1376 ObjectStartArray* const _start_array;
1377
1378 public:
1379 UpdateOnlyClosure(ParMarkBitMap* mbm,
1380 ParCompactionManager* cm,
1381 PSParallelCompact::SpaceId space_id);
1382
1383 // Update the object.
1384 virtual IterationStatus do_addr(HeapWord* addr, size_t words);
1385
1386 inline void do_addr(HeapWord* addr);
1387 };
1388
1389 class FillClosure: public ParMarkBitMapClosure
1390 {
1391 public:
1392 FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) :
1393 ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm),
1394 _start_array(PSParallelCompact::start_array(space_id))
1395 {
1396 assert(space_id == PSParallelCompact::old_space_id,
1397 "cannot use FillClosure in the young gen");
1398 }
1399
1400 virtual IterationStatus do_addr(HeapWord* addr, size_t size) {
1401 CollectedHeap::fill_with_objects(addr, size);
1402 HeapWord* const end = addr + size;
1403 do {
1404 _start_array->allocate_block(addr);
1405 addr += oop(addr)->size();
1406 } while (addr < end);
1407 return ParMarkBitMap::incomplete;
1408 }
1409
1410 private:
1411 ObjectStartArray* const _start_array;
1412 };
1413
1414 #endif // SHARE_VM_GC_PARALLEL_PSPARALLELCOMPACT_HPP
|
1 /*
2 * Copyright (c) 2005, 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 *
1225 static const char* space_names[last_space_id];
1226 static void print_region_ranges();
1227 static void print_dense_prefix_stats(const char* const algorithm,
1228 const SpaceId id,
1229 const bool maximum_compaction,
1230 HeapWord* const addr);
1231 static void summary_phase_msg(SpaceId dst_space_id,
1232 HeapWord* dst_beg, HeapWord* dst_end,
1233 SpaceId src_space_id,
1234 HeapWord* src_beg, HeapWord* src_end);
1235 #endif // #ifndef PRODUCT
1236
1237 #ifdef ASSERT
1238 // Sanity check the new location of a word in the heap.
1239 static inline void check_new_location(HeapWord* old_addr, HeapWord* new_addr);
1240 // Verify that all the regions have been emptied.
1241 static void verify_complete(SpaceId space_id);
1242 #endif // #ifdef ASSERT
1243 };
1244
1245 inline bool PSParallelCompact::is_marked(oop obj) {
1246 return mark_bitmap()->is_marked(obj);
1247 }
1248
1249 inline double PSParallelCompact::normal_distribution(double density) {
1250 assert(_dwl_initialized, "uninitialized");
1251 const double squared_term = (density - _dwl_mean) / _dwl_std_dev;
1252 return _dwl_first_term * exp(-0.5 * squared_term * squared_term);
1253 }
1254
1255 inline bool
1256 PSParallelCompact::dead_space_crosses_boundary(const RegionData* region,
1257 idx_t bit)
1258 {
1259 assert(bit > 0, "cannot call this for the first bit/region");
1260 assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit),
1261 "sanity check");
1262
1263 // Dead space crosses the boundary if (1) a partial object does not extend
1264 // onto the region, (2) an object does not start at the beginning of the
1359 _source += words;
1360 _destination += words;
1361 }
1362
1363 class UpdateOnlyClosure: public ParMarkBitMapClosure {
1364 private:
1365 const PSParallelCompact::SpaceId _space_id;
1366 ObjectStartArray* const _start_array;
1367
1368 public:
1369 UpdateOnlyClosure(ParMarkBitMap* mbm,
1370 ParCompactionManager* cm,
1371 PSParallelCompact::SpaceId space_id);
1372
1373 // Update the object.
1374 virtual IterationStatus do_addr(HeapWord* addr, size_t words);
1375
1376 inline void do_addr(HeapWord* addr);
1377 };
1378
1379 class FillClosure: public ParMarkBitMapClosure {
1380 public:
1381 FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) :
1382 ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm),
1383 _start_array(PSParallelCompact::start_array(space_id))
1384 {
1385 assert(space_id == PSParallelCompact::old_space_id,
1386 "cannot use FillClosure in the young gen");
1387 }
1388
1389 virtual IterationStatus do_addr(HeapWord* addr, size_t size);
1390
1391 private:
1392 ObjectStartArray* const _start_array;
1393 };
1394
1395 #endif // SHARE_VM_GC_PARALLEL_PSPARALLELCOMPACT_HPP
|