Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/gc/z/zBarrierSet.cpp
40961 views
1
/*
2
* Copyright (c) 2018, 2020, 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"
25
#include "gc/z/zBarrierSet.hpp"
26
#include "gc/z/zBarrierSetAssembler.hpp"
27
#include "gc/z/zBarrierSetNMethod.hpp"
28
#include "gc/z/zGlobals.hpp"
29
#include "gc/z/zHeap.inline.hpp"
30
#include "gc/z/zStackWatermark.hpp"
31
#include "gc/z/zThreadLocalData.hpp"
32
#include "runtime/thread.hpp"
33
#include "utilities/macros.hpp"
34
#ifdef COMPILER1
35
#include "gc/z/c1/zBarrierSetC1.hpp"
36
#endif
37
#ifdef COMPILER2
38
#include "gc/z/c2/zBarrierSetC2.hpp"
39
#endif
40
41
class ZBarrierSetC1;
42
class ZBarrierSetC2;
43
44
ZBarrierSet::ZBarrierSet() :
45
BarrierSet(make_barrier_set_assembler<ZBarrierSetAssembler>(),
46
make_barrier_set_c1<ZBarrierSetC1>(),
47
make_barrier_set_c2<ZBarrierSetC2>(),
48
new ZBarrierSetNMethod(),
49
BarrierSet::FakeRtti(BarrierSet::ZBarrierSet)) {}
50
51
ZBarrierSetAssembler* ZBarrierSet::assembler() {
52
BarrierSetAssembler* const bsa = BarrierSet::barrier_set()->barrier_set_assembler();
53
return reinterpret_cast<ZBarrierSetAssembler*>(bsa);
54
}
55
56
bool ZBarrierSet::barrier_needed(DecoratorSet decorators, BasicType type) {
57
assert((decorators & AS_RAW) == 0, "Unexpected decorator");
58
//assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Unexpected decorator");
59
60
if (is_reference_type(type)) {
61
assert((decorators & (IN_HEAP | IN_NATIVE)) != 0, "Where is reference?");
62
// Barrier needed even when IN_NATIVE, to allow concurrent scanning.
63
return true;
64
}
65
66
// Barrier not needed
67
return false;
68
}
69
70
void ZBarrierSet::on_thread_create(Thread* thread) {
71
// Create thread local data
72
ZThreadLocalData::create(thread);
73
}
74
75
void ZBarrierSet::on_thread_destroy(Thread* thread) {
76
// Destroy thread local data
77
ZThreadLocalData::destroy(thread);
78
}
79
80
void ZBarrierSet::on_thread_attach(Thread* thread) {
81
// Set thread local address bad mask
82
ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);
83
if (thread->is_Java_thread()) {
84
JavaThread* const jt = thread->as_Java_thread();
85
StackWatermark* const watermark = new ZStackWatermark(jt);
86
StackWatermarkSet::add_watermark(jt, watermark);
87
}
88
}
89
90
void ZBarrierSet::on_thread_detach(Thread* thread) {
91
// Flush and free any remaining mark stacks
92
ZHeap::heap()->mark_flush_and_free(thread);
93
}
94
95
void ZBarrierSet::print_on(outputStream* st) const {
96
st->print_cr("ZBarrierSet");
97
}
98
99