Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/compiler/abstractCompiler.cpp
32285 views
//1// Copyright (c) 2007, 2013, 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//222324#include "precompiled.hpp"25#include "compiler/abstractCompiler.hpp"26#include "compiler/compileBroker.hpp"27#include "runtime/mutexLocker.hpp"2829bool AbstractCompiler::should_perform_init() {30if (_compiler_state != initialized) {31MutexLocker only_one(CompileThread_lock);3233if (_compiler_state == uninitialized) {34_compiler_state = initializing;35return true;36} else {37while (_compiler_state == initializing) {38CompileThread_lock->wait();39}40}41}42return false;43}4445bool AbstractCompiler::should_perform_shutdown() {46// Since this method can be called by multiple threads, the lock ensures atomicity of47// decrementing '_num_compiler_threads' and the following operations.48MutexLocker only_one(CompileThread_lock);49_num_compiler_threads--;50assert (CompileBroker::is_compilation_disabled_forever(), "Must be set, otherwise thread waits forever");5152// Only the last thread will perform shutdown operations53if (_num_compiler_threads == 0) {54return true;55}56return false;57}5859void AbstractCompiler::set_state(int state) {60// Ensure that ste is only set by one thread at a time61MutexLocker only_one(CompileThread_lock);62_compiler_state = state;63CompileThread_lock->notify_all();64}656667