2
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
25
#include "precompiled.hpp"
26
#include "classfile/javaClasses.inline.hpp"
27
#include "jfr/jfrEvents.hpp"
28
#include "jfr/support/jfrThreadId.hpp"
29
#include "logging/log.hpp"
30
#include "logging/logStream.hpp"
31
#include "oops/oopsHierarchy.hpp"
32
#include "oops/stackChunkOop.inline.hpp"
33
#include "runtime/continuation.hpp"
34
#include "runtime/continuationEntry.inline.hpp"
35
#include "runtime/continuationHelper.inline.hpp"
36
#include "runtime/continuationWrapper.inline.hpp"
37
#include "runtime/javaThread.hpp"
38
#include "runtime/stackChunkFrameStream.inline.hpp"
40
ContinuationWrapper::ContinuationWrapper(const RegisterMap* map)
41
: ContinuationWrapper(map->thread(),
42
Continuation::get_continuation_entry_for_continuation(map->thread(), map->stack_chunk()->cont()),
43
map->stack_chunk()->cont()) {
44
assert(_entry == nullptr || _continuation == _entry->cont_oop(map->thread()),
45
"cont: " INTPTR_FORMAT " entry: " INTPTR_FORMAT " entry_sp: " INTPTR_FORMAT,
46
p2i( (oopDesc*)_continuation), p2i((oopDesc*)_entry->cont_oop(map->thread())), p2i(entrySP()));
49
const frame ContinuationWrapper::last_frame() {
50
stackChunkOop chunk = last_nonempty_chunk();
51
if (chunk == nullptr) {
54
return StackChunkFrameStream<ChunkFrames::Mixed>(chunk).to_frame();
57
stackChunkOop ContinuationWrapper::find_chunk_by_address(void* p) const {
58
for (stackChunkOop chunk = tail(); chunk != nullptr; chunk = chunk->parent()) {
59
if (chunk->is_in_chunk(p)) {
60
assert(chunk->is_usable_in_chunk(p), "");
68
intptr_t ContinuationWrapper::hash() {
69
return Thread::current()->is_Java_thread() ? _continuation->identity_hash() : -1;
74
bool ContinuationWrapper::is_entry_frame(const frame& f) {
75
return f.sp() == entrySP();
78
bool ContinuationWrapper::chunk_invariant() const {
79
// only the topmost chunk can be empty
80
if (_tail == nullptr) {
85
for (stackChunkOop chunk = _tail->parent(); chunk != nullptr; chunk = chunk->parent()) {
86
if (chunk->is_empty()) {
87
assert(chunk != _tail, "");