author | eosterlund |
Fri, 30 Nov 2018 11:40:48 +0100 | |
changeset 52781 | 436097b038a1 |
parent 51887 | 32161fbea3fe |
permissions | -rw-r--r-- |
42055 | 1 |
/* |
51887
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
42055 | 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 |
||
25 |
#include "precompiled.hpp" |
|
26 |
#include "code/dependencyContext.hpp" |
|
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
27 |
#include "code/nmethod.hpp" |
42055 | 28 |
#include "unittest.hpp" |
29 |
||
30 |
class TestDependencyContext { |
|
31 |
public: |
|
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
32 |
nmethod _nmethods[3]; |
42055 | 33 |
|
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
34 |
nmethodBucket* volatile _dependency_context; |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
35 |
volatile uint64_t _last_cleanup; |
42055 | 36 |
|
37 |
DependencyContext dependencies() { |
|
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
38 |
DependencyContext depContext(&_dependency_context, &_last_cleanup); |
42055 | 39 |
return depContext; |
40 |
} |
|
41 |
||
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
42 |
TestDependencyContext() |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
43 |
: _dependency_context(NULL), |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
44 |
_last_cleanup(0) { |
42055 | 45 |
CodeCache_lock->lock_without_safepoint_check(); |
46 |
||
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
47 |
_nmethods[0].clear_unloading_state(); |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
48 |
_nmethods[1].clear_unloading_state(); |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
49 |
_nmethods[2].clear_unloading_state(); |
42055 | 50 |
|
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
51 |
dependencies().add_dependent_nmethod(&_nmethods[2]); |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
52 |
dependencies().add_dependent_nmethod(&_nmethods[1]); |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
53 |
dependencies().add_dependent_nmethod(&_nmethods[0]); |
42055 | 54 |
} |
55 |
||
56 |
~TestDependencyContext() { |
|
51887
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
57 |
wipe(); |
42055 | 58 |
CodeCache_lock->unlock(); |
59 |
} |
|
60 |
||
51887
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
61 |
void wipe() { |
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
62 |
DependencyContext ctx(&_dependency_context, &_last_cleanup); |
51887
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
63 |
nmethodBucket* b = ctx.dependencies(); |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
64 |
ctx.set_dependencies(NULL); |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
65 |
while (b != NULL) { |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
66 |
nmethodBucket* next = b->next(); |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
67 |
delete b; |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
68 |
b = next; |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
69 |
} |
32161fbea3fe
8210856: Move InstanceKlass DependencyContext cleaning to SystemDictionary::do_unloading()
coleenp
parents:
47216
diff
changeset
|
70 |
} |
42055 | 71 |
}; |
72 |
||
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
73 |
static void test_remove_dependent_nmethod(int id) { |
42055 | 74 |
TestDependencyContext c; |
75 |
DependencyContext depContext = c.dependencies(); |
|
76 |
||
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
77 |
nmethod* nm = &c._nmethods[id]; |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
78 |
depContext.remove_dependent_nmethod(nm); |
42055 | 79 |
|
80 |
NOT_PRODUCT(ASSERT_FALSE(depContext.is_dependent_nmethod(nm))); |
|
81 |
} |
|
82 |
||
43431
5ffa076f526d
8172098: A lot of gtests uses TEST instead of TEST_VM
kzhaldyb
parents:
42055
diff
changeset
|
83 |
TEST_VM(code, dependency_context) { |
52781
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
84 |
test_remove_dependent_nmethod(0); |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
85 |
test_remove_dependent_nmethod(1); |
436097b038a1
8213565: Crash in DependencyContext::remove_dependent_nmethod
eosterlund
parents:
51887
diff
changeset
|
86 |
test_remove_dependent_nmethod(2); |
42055 | 87 |
} |