author | stefank |
Tue, 26 Nov 2019 10:47:46 +0100 | |
changeset 59290 | 97d13893ec3c |
parent 59247 | 56bf71d64d51 |
permissions | -rw-r--r-- |
53892 | 1 |
/* |
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. |
|
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 |
*/ |
|
23 |
||
24 |
#include "precompiled.hpp" |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
25 |
#include "gc/z/zAttachedArray.inline.hpp" |
53892 | 26 |
#include "gc/z/zLock.inline.hpp" |
27 |
#include "gc/z/zNMethodData.hpp" |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "runtime/atomic.hpp" |
|
30 |
#include "utilities/align.hpp" |
|
31 |
#include "utilities/debug.hpp" |
|
32 |
#include "utilities/growableArray.hpp" |
|
33 |
||
34 |
ZNMethodDataOops* ZNMethodDataOops::create(const GrowableArray<oop*>& immediates, bool has_non_immediates) { |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
35 |
return ::new (AttachedArray::alloc(immediates.length())) ZNMethodDataOops(immediates, has_non_immediates); |
53892 | 36 |
} |
37 |
||
38 |
void ZNMethodDataOops::destroy(ZNMethodDataOops* oops) { |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
39 |
AttachedArray::free(oops); |
53892 | 40 |
} |
41 |
||
42 |
ZNMethodDataOops::ZNMethodDataOops(const GrowableArray<oop*>& immediates, bool has_non_immediates) : |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
43 |
_immediates(immediates.length()), |
53892 | 44 |
_has_non_immediates(has_non_immediates) { |
45 |
// Save all immediate oops |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
46 |
for (size_t i = 0; i < immediates_count(); i++) { |
58237 | 47 |
immediates_begin()[i] = immediates.at(int(i)); |
53892 | 48 |
} |
49 |
} |
|
50 |
||
51 |
size_t ZNMethodDataOops::immediates_count() const { |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
52 |
return _immediates.length(); |
53892 | 53 |
} |
54 |
||
55 |
oop** ZNMethodDataOops::immediates_begin() const { |
|
54171
07943af21b96
8220596: ZGC: Convert ZNMethodData to use ZAttachedArray
pliden
parents:
53922
diff
changeset
|
56 |
return _immediates(this); |
53892 | 57 |
} |
58 |
||
59 |
oop** ZNMethodDataOops::immediates_end() const { |
|
60 |
return immediates_begin() + immediates_count(); |
|
61 |
} |
|
62 |
||
63 |
bool ZNMethodDataOops::has_non_immediates() const { |
|
64 |
return _has_non_immediates; |
|
65 |
} |
|
66 |
||
53921
a590b6107ab3
8218974: Free GC native structures in nmethod::flush
eosterlund
parents:
53892
diff
changeset
|
67 |
ZNMethodData::ZNMethodData() : |
53892 | 68 |
_lock(), |
69 |
_oops(NULL) {} |
|
70 |
||
53921
a590b6107ab3
8218974: Free GC native structures in nmethod::flush
eosterlund
parents:
53892
diff
changeset
|
71 |
ZNMethodData::~ZNMethodData() { |
53922
00fcc1ef31e8
8219638: ZGC: Free ZNMethodDataOops under a lock
eosterlund
parents:
53921
diff
changeset
|
72 |
ZNMethodDataOops::destroy(_oops); |
53921
a590b6107ab3
8218974: Free GC native structures in nmethod::flush
eosterlund
parents:
53892
diff
changeset
|
73 |
} |
a590b6107ab3
8218974: Free GC native structures in nmethod::flush
eosterlund
parents:
53892
diff
changeset
|
74 |
|
53892 | 75 |
ZReentrantLock* ZNMethodData::lock() { |
76 |
return &_lock; |
|
77 |
} |
|
78 |
||
79 |
ZNMethodDataOops* ZNMethodData::oops() const { |
|
59247
56bf71d64d51
8234562: Move OrderAccess::release_store*/load_acquire to Atomic
stefank
parents:
58237
diff
changeset
|
80 |
return Atomic::load_acquire(&_oops); |
53892 | 81 |
} |
82 |
||
83 |
ZNMethodDataOops* ZNMethodData::swap_oops(ZNMethodDataOops* new_oops) { |
|
53922
00fcc1ef31e8
8219638: ZGC: Free ZNMethodDataOops under a lock
eosterlund
parents:
53921
diff
changeset
|
84 |
ZLocker<ZReentrantLock> locker(&_lock); |
00fcc1ef31e8
8219638: ZGC: Free ZNMethodDataOops under a lock
eosterlund
parents:
53921
diff
changeset
|
85 |
ZNMethodDataOops* const old_oops = _oops; |
00fcc1ef31e8
8219638: ZGC: Free ZNMethodDataOops under a lock
eosterlund
parents:
53921
diff
changeset
|
86 |
_oops = new_oops; |
00fcc1ef31e8
8219638: ZGC: Free ZNMethodDataOops under a lock
eosterlund
parents:
53921
diff
changeset
|
87 |
return old_oops; |
53892 | 88 |
} |