jdk

Форк
0
/
continuationWrapper.cpp 
94 строки · 3.2 Кб
1
/*
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.
4
 *
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.
8
 *
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).
14
 *
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.
18
 *
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
21
 * questions.
22
 *
23
 */
24

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"
39

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()));
47
}
48

49
const frame ContinuationWrapper::last_frame() {
50
  stackChunkOop chunk = last_nonempty_chunk();
51
  if (chunk == nullptr) {
52
    return frame();
53
  }
54
  return StackChunkFrameStream<ChunkFrames::Mixed>(chunk).to_frame();
55
}
56

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), "");
61
      return chunk;
62
    }
63
  }
64
  return nullptr;
65
}
66

67
#ifndef PRODUCT
68
intptr_t ContinuationWrapper::hash() {
69
  return Thread::current()->is_Java_thread() ? _continuation->identity_hash() : -1;
70
}
71
#endif
72

73
#ifdef ASSERT
74
bool ContinuationWrapper::is_entry_frame(const frame& f) {
75
  return f.sp() == entrySP();
76
}
77

78
bool ContinuationWrapper::chunk_invariant() const {
79
  // only the topmost chunk can be empty
80
  if (_tail == nullptr) {
81
    return true;
82
  }
83

84
  int i = 1;
85
  for (stackChunkOop chunk = _tail->parent(); chunk != nullptr; chunk = chunk->parent()) {
86
    if (chunk->is_empty()) {
87
      assert(chunk != _tail, "");
88
      return false;
89
    }
90
    i++;
91
  }
92
  return true;
93
}
94
#endif // ASSERT
95

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.