Path: blob/master/src/hotspot/share/gc/shared/c1/modRefBarrierSetC1.cpp
40974 views
/*1* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc/shared/c1/modRefBarrierSetC1.hpp"26#include "utilities/macros.hpp"2728#ifdef ASSERT29#define __ gen->lir(__FILE__, __LINE__)->30#else31#define __ gen->lir()->32#endif3334void ModRefBarrierSetC1::store_at_resolved(LIRAccess& access, LIR_Opr value) {35DecoratorSet decorators = access.decorators();36bool is_array = (decorators & IS_ARRAY) != 0;37bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;3839if (access.is_oop()) {40pre_barrier(access, access.resolved_addr(),41LIR_OprFact::illegalOpr /* pre_val */, access.patch_emit_info());42}4344BarrierSetC1::store_at_resolved(access, value);4546if (access.is_oop()) {47bool precise = is_array || on_anonymous;48LIR_Opr post_addr = precise ? access.resolved_addr() : access.base().opr();49post_barrier(access, post_addr, value);50}51}5253LIR_Opr ModRefBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) {54if (access.is_oop()) {55pre_barrier(access, access.resolved_addr(),56LIR_OprFact::illegalOpr /* pre_val */, NULL);57}5859LIR_Opr result = BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value);6061if (access.is_oop()) {62post_barrier(access, access.resolved_addr(), new_value.result());63}6465return result;66}6768LIR_Opr ModRefBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) {69if (access.is_oop()) {70pre_barrier(access, access.resolved_addr(),71LIR_OprFact::illegalOpr /* pre_val */, NULL);72}7374LIR_Opr result = BarrierSetC1::atomic_xchg_at_resolved(access, value);7576if (access.is_oop()) {77post_barrier(access, access.resolved_addr(), value.result());78}7980return result;81}8283// This overrides the default to resolve the address into a register,84// assuming it will be used by a write barrier anyway.85LIR_Opr ModRefBarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) {86DecoratorSet decorators = access.decorators();87bool needs_patching = (decorators & C1_NEEDS_PATCHING) != 0;88bool is_write = (decorators & ACCESS_WRITE) != 0;89bool is_array = (decorators & IS_ARRAY) != 0;90bool on_anonymous = (decorators & ON_UNKNOWN_OOP_REF) != 0;91bool precise = is_array || on_anonymous;92resolve_in_register |= !needs_patching && is_write && access.is_oop() && precise;93return BarrierSetC1::resolve_address(access, resolve_in_register);94}959697