49906
|
1 |
/*
|
|
2 |
* Copyright (c) 2018, 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 |
|
|
25 |
#include "precompiled.hpp"
|
|
26 |
#include "gc/shared/c1/modRefBarrierSetC1.hpp"
|
|
27 |
#include "utilities/macros.hpp"
|
|
28 |
|
|
29 |
#ifdef ASSERT
|
|
30 |
#define __ gen->lir(__FILE__, __LINE__)->
|
|
31 |
#else
|
|
32 |
#define __ gen->lir()->
|
|
33 |
#endif
|
|
34 |
|
|
35 |
void ModRefBarrierSetC1::store_at_resolved(LIRAccess& access, LIR_Opr value) {
|
|
36 |
DecoratorSet decorators = access.decorators();
|
|
37 |
bool on_array = (decorators & IN_HEAP_ARRAY) != 0;
|
|
38 |
bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;
|
|
39 |
|
|
40 |
if (access.is_oop()) {
|
|
41 |
pre_barrier(access, access.resolved_addr(),
|
|
42 |
LIR_OprFact::illegalOpr /* pre_val */, access.patch_emit_info());
|
|
43 |
}
|
|
44 |
|
|
45 |
BarrierSetC1::store_at_resolved(access, value);
|
|
46 |
|
|
47 |
if (access.is_oop()) {
|
|
48 |
bool precise = on_array || on_anonymous;
|
|
49 |
LIR_Opr post_addr = precise ? access.resolved_addr() : access.base().opr();
|
|
50 |
post_barrier(access, post_addr, value);
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
LIR_Opr ModRefBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) {
|
|
55 |
if (access.is_oop()) {
|
|
56 |
pre_barrier(access, access.resolved_addr(),
|
|
57 |
LIR_OprFact::illegalOpr /* pre_val */, NULL);
|
|
58 |
}
|
|
59 |
|
|
60 |
LIR_Opr result = BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);
|
|
61 |
|
|
62 |
if (access.is_oop()) {
|
|
63 |
post_barrier(access, access.resolved_addr(), new_value.result());
|
|
64 |
}
|
|
65 |
|
|
66 |
return result;
|
|
67 |
}
|
|
68 |
|
|
69 |
LIR_Opr ModRefBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {
|
|
70 |
if (access.is_oop()) {
|
|
71 |
pre_barrier(access, access.resolved_addr(),
|
|
72 |
LIR_OprFact::illegalOpr /* pre_val */, NULL);
|
|
73 |
}
|
|
74 |
|
|
75 |
LIR_Opr result = BarrierSetC1::atomic_xchg_at_resolved(access, value);
|
|
76 |
|
|
77 |
if (access.is_oop()) {
|
|
78 |
post_barrier(access, access.resolved_addr(), value.result());
|
|
79 |
}
|
|
80 |
|
|
81 |
return result;
|
|
82 |
}
|
|
83 |
|
|
84 |
// This overrides the default to resolve the address into a register,
|
|
85 |
// assuming it will be used by a write barrier anyway.
|
|
86 |
LIR_Opr ModRefBarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) {
|
|
87 |
DecoratorSet decorators = access.decorators();
|
|
88 |
bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0;
|
|
89 |
bool is_write = (decorators & C1_WRITE_ACCESS) != 0;
|
|
90 |
resolve_in_register |= !needs_patching && is_write && access.is_oop();
|
|
91 |
return BarrierSetC1::resolve_address(access, resolve_in_register);
|
|
92 |
}
|