author | naoto |
Tue, 09 Jul 2019 08:05:38 -0700 | |
changeset 55627 | 9c1885fb2a42 |
parent 55562 | 2f464d628942 |
permissions | -rw-r--r-- |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
1 |
/* |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
4 |
* |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
8 |
* |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
13 |
* accompanied this code). |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
14 |
* |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
18 |
* |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
21 |
* questions. |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
22 |
* |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
23 |
*/ |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
24 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
25 |
#include "precompiled.hpp" |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
26 |
#include "code/compiledMethod.hpp" |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
27 |
#include "code/nmethod.hpp" |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
28 |
#include "gc/shared/gcBehaviours.hpp" |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
29 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
30 |
IsUnloadingBehaviour* IsUnloadingBehaviour::_current = NULL; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
31 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
32 |
class IsCompiledMethodUnloadingOopClosure: public OopClosure { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
33 |
BoolObjectClosure *_cl; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
34 |
bool _is_unloading; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
35 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
36 |
public: |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
37 |
IsCompiledMethodUnloadingOopClosure(BoolObjectClosure* cl) |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
38 |
: _cl(cl), |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
39 |
_is_unloading(false) |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
40 |
{ } |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
41 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
42 |
virtual void do_oop(oop* p) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
43 |
if (_is_unloading) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
44 |
return; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
45 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
46 |
oop obj = *p; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
47 |
if (obj == NULL) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
48 |
return; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
49 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
50 |
if (!_cl->do_object_b(obj)) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
51 |
_is_unloading = true; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
52 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
53 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
54 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
55 |
virtual void do_oop(narrowOop* p) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
56 |
ShouldNotReachHere(); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
57 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
58 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
59 |
bool is_unloading() const { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
60 |
return _is_unloading; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
61 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
62 |
}; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
63 |
|
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
64 |
bool ClosureIsUnloadingBehaviour::is_unloading(CompiledMethod* cm) const { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
65 |
if (cm->is_nmethod()) { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
66 |
IsCompiledMethodUnloadingOopClosure cl(_cl); |
55562
2f464d628942
8219687: G1 asserts nmethod should not be unloaded during parallel code cache unloading
eosterlund
parents:
52385
diff
changeset
|
67 |
static_cast<nmethod*>(cm)->oops_do(&cl, true /* allow_dead */); |
52385
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
68 |
return cl.is_unloading(); |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
69 |
} else { |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
70 |
return false; |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
71 |
} |
5c679ec60888
8209189: Make CompiledMethod::do_unloading more concurrent
eosterlund
parents:
diff
changeset
|
72 |
} |