Path: blob/master/src/hotspot/share/gc/z/zBarrierSet.cpp
40961 views
/*1* Copyright (c) 2018, 2020, 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*/2223#include "precompiled.hpp"24#include "gc/z/zBarrierSet.hpp"25#include "gc/z/zBarrierSetAssembler.hpp"26#include "gc/z/zBarrierSetNMethod.hpp"27#include "gc/z/zGlobals.hpp"28#include "gc/z/zHeap.inline.hpp"29#include "gc/z/zStackWatermark.hpp"30#include "gc/z/zThreadLocalData.hpp"31#include "runtime/thread.hpp"32#include "utilities/macros.hpp"33#ifdef COMPILER134#include "gc/z/c1/zBarrierSetC1.hpp"35#endif36#ifdef COMPILER237#include "gc/z/c2/zBarrierSetC2.hpp"38#endif3940class ZBarrierSetC1;41class ZBarrierSetC2;4243ZBarrierSet::ZBarrierSet() :44BarrierSet(make_barrier_set_assembler<ZBarrierSetAssembler>(),45make_barrier_set_c1<ZBarrierSetC1>(),46make_barrier_set_c2<ZBarrierSetC2>(),47new ZBarrierSetNMethod(),48BarrierSet::FakeRtti(BarrierSet::ZBarrierSet)) {}4950ZBarrierSetAssembler* ZBarrierSet::assembler() {51BarrierSetAssembler* const bsa = BarrierSet::barrier_set()->barrier_set_assembler();52return reinterpret_cast<ZBarrierSetAssembler*>(bsa);53}5455bool ZBarrierSet::barrier_needed(DecoratorSet decorators, BasicType type) {56assert((decorators & AS_RAW) == 0, "Unexpected decorator");57//assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Unexpected decorator");5859if (is_reference_type(type)) {60assert((decorators & (IN_HEAP | IN_NATIVE)) != 0, "Where is reference?");61// Barrier needed even when IN_NATIVE, to allow concurrent scanning.62return true;63}6465// Barrier not needed66return false;67}6869void ZBarrierSet::on_thread_create(Thread* thread) {70// Create thread local data71ZThreadLocalData::create(thread);72}7374void ZBarrierSet::on_thread_destroy(Thread* thread) {75// Destroy thread local data76ZThreadLocalData::destroy(thread);77}7879void ZBarrierSet::on_thread_attach(Thread* thread) {80// Set thread local address bad mask81ZThreadLocalData::set_address_bad_mask(thread, ZAddressBadMask);82if (thread->is_Java_thread()) {83JavaThread* const jt = thread->as_Java_thread();84StackWatermark* const watermark = new ZStackWatermark(jt);85StackWatermarkSet::add_watermark(jt, watermark);86}87}8889void ZBarrierSet::on_thread_detach(Thread* thread) {90// Flush and free any remaining mark stacks91ZHeap::heap()->mark_flush_and_free(thread);92}9394void ZBarrierSet::print_on(outputStream* st) const {95st->print_cr("ZBarrierSet");96}979899