Path: blob/master/src/hotspot/share/runtime/keepStackGCProcessed.cpp
40951 views
/*1* Copyright (c) 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*22*/2324#include "precompiled.hpp"25#include "runtime/safepoint.hpp"26#include "runtime/stackWatermark.inline.hpp"27#include "runtime/stackWatermarkSet.inline.hpp"28#include "runtime/keepStackGCProcessed.hpp"2930KeepStackGCProcessedMark::KeepStackGCProcessedMark(JavaThread* jt) :31_active(true),32_jt(jt) {33finish_processing();34if (!Thread::current()->is_Java_thread()) {35assert(SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread(),36"must be either Java thread or VM thread in a safepoint");37_active = false;38return;39}40StackWatermark* our_watermark = StackWatermarkSet::get(JavaThread::current(), StackWatermarkKind::gc);41if (our_watermark == NULL) {42_active = false;43return;44}45StackWatermark* their_watermark = StackWatermarkSet::get(jt, StackWatermarkKind::gc);46our_watermark->link_watermark(their_watermark);47}4849KeepStackGCProcessedMark::~KeepStackGCProcessedMark() {50if (!_active) {51return;52}53StackWatermark* our_watermark = StackWatermarkSet::get(JavaThread::current(), StackWatermarkKind::gc);54our_watermark->link_watermark(NULL);55}5657void KeepStackGCProcessedMark::finish_processing() {58StackWatermarkSet::finish_processing(_jt, NULL /* context */, StackWatermarkKind::gc);59}6061#ifdef ASSERT62bool KeepStackGCProcessedMark::stack_is_kept_gc_processed(JavaThread* jt) {63if (!Thread::current()->is_Java_thread()) {64assert(SafepointSynchronize::is_at_safepoint() && Thread::current()->is_VM_thread(),65"must be either Java thread or VM thread in a safepoint");66return true;67}68StackWatermark* our_watermark = StackWatermarkSet::get(JavaThread::current(), StackWatermarkKind::gc);69if (our_watermark == nullptr) {70return true;71}72StackWatermark* their_watermark = StackWatermarkSet::get(jt, StackWatermarkKind::gc);73return our_watermark->linked_watermark() == their_watermark;74}75#endif // ASSERT767778