1 /* |
1 /* |
2 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
20 * or visit www.oracle.com if you need additional information or have any |
20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 #include "precompiled.hpp" |
24 #include "precompiled.hpp" |
|
25 #include "gc/z/zForwarding.hpp" |
25 #include "gc/z/zRelocationSet.hpp" |
26 #include "gc/z/zRelocationSet.hpp" |
26 #include "memory/allocation.inline.hpp" |
27 #include "memory/allocation.hpp" |
27 |
28 |
28 ZRelocationSet::ZRelocationSet() : |
29 ZRelocationSet::ZRelocationSet() : |
29 _pages(NULL), |
30 _forwardings(NULL), |
30 _npages(0) {} |
31 _nforwardings(0) {} |
31 |
32 |
32 void ZRelocationSet::populate(const ZPage* const* group0, size_t ngroup0, |
33 void ZRelocationSet::populate(ZPage* const* group0, size_t ngroup0, |
33 const ZPage* const* group1, size_t ngroup1) { |
34 ZPage* const* group1, size_t ngroup1) { |
34 _npages = ngroup0 + ngroup1; |
35 _nforwardings = ngroup0 + ngroup1; |
35 _pages = REALLOC_C_HEAP_ARRAY(ZPage*, _pages, _npages, mtGC); |
36 _forwardings = REALLOC_C_HEAP_ARRAY(ZForwarding*, _forwardings, _nforwardings, mtGC); |
36 |
37 |
37 if (_pages != NULL) { |
38 size_t j = 0; |
38 if (group0 != NULL) { |
39 |
39 memcpy(_pages, group0, ngroup0 * sizeof(ZPage*)); |
40 // Populate group 0 |
40 } |
41 for (size_t i = 0; i < ngroup0; i++) { |
41 if (group1 != NULL) { |
42 _forwardings[j++] = ZForwarding::create(group0[i]); |
42 memcpy(_pages + ngroup0, group1, ngroup1 * sizeof(ZPage*)); |
43 } |
43 } |
44 |
|
45 // Populate group 1 |
|
46 for (size_t i = 0; i < ngroup1; i++) { |
|
47 _forwardings[j++] = ZForwarding::create(group1[i]); |
44 } |
48 } |
45 } |
49 } |
|
50 |
|
51 void ZRelocationSet::reset() { |
|
52 for (size_t i = 0; i < _nforwardings; i++) { |
|
53 ZForwarding::destroy(_forwardings[i]); |
|
54 _forwardings[i] = NULL; |
|
55 } |
|
56 } |