Path: blob/master/src/hotspot/share/gc/shared/barrierSet.cpp
40957 views
/*1* Copyright (c) 1997, 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/barrierSet.hpp"26#include "gc/shared/barrierSetAssembler.hpp"27#include "runtime/thread.hpp"28#include "utilities/debug.hpp"29#include "utilities/macros.hpp"3031BarrierSet* BarrierSet::_barrier_set = NULL;3233void BarrierSet::set_barrier_set(BarrierSet* barrier_set) {34assert(_barrier_set == NULL, "Already initialized");35_barrier_set = barrier_set;3637// Notify barrier set of the current (main) thread. Normally the38// Thread constructor deals with this, but the main thread is39// created before we get here. Verify it isn't yet on the thread40// list, else we'd also need to call BarrierSet::on_thread_attach.41// This is the only thread that can exist at this point; the Thread42// constructor objects to other threads being created before the43// barrier set is available.44assert(Thread::current()->is_Java_thread(),45"Expected main thread to be a JavaThread");46assert(!JavaThread::current()->on_thread_list(),47"Main thread already on thread list.");48_barrier_set->on_thread_create(Thread::current());49}5051// Called from init.cpp52void gc_barrier_stubs_init() {53BarrierSet* bs = BarrierSet::barrier_set();54#ifndef ZERO55BarrierSetAssembler* bs_assembler = bs->barrier_set_assembler();56bs_assembler->barrier_stubs_init();57#endif58}596061