1 /*
  2  * Copyright (c) 1997, 2021, 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 #ifndef SHARE_RUNTIME_FRAME_INLINE_HPP
 26 #define SHARE_RUNTIME_FRAME_INLINE_HPP
 27 
 28 #include "runtime/frame.hpp"
 29 
 30 #include "code/compiledMethod.inline.hpp"
 31 #include "interpreter/interpreter.hpp"
 32 #include "oops/instanceStackChunkKlass.inline.hpp"
 33 #include "oops/method.hpp"
 34 #include "runtime/continuation.hpp"
 35 #include "runtime/registerMap.hpp"
 36 #include "runtime/stubRoutines.hpp"
 37 #include "utilities/macros.hpp"
 38 #ifdef ZERO
 39 # include "entryFrame_zero.hpp"
 40 # include "fakeStubFrame_zero.hpp"
 41 # include "interpreterFrame_zero.hpp"
 42 #endif
 43 
 44 #include CPU_HEADER_INLINE(frame)
 45 
 46 inline bool frame::is_entry_frame() const {
 47   return StubRoutines::returns_to_call_stub(pc());
 48 }
 49 
 50 inline bool frame::is_stub_frame() const {
 51   return StubRoutines::is_stub_code(pc()) || (_cb != NULL && _cb->is_adapter_blob());
 52 }
 53 
 54 inline bool frame::is_first_frame() const {
 55   return (is_entry_frame() && entry_frame_is_first())
 56       // Optimized entry frames are only present on certain platforms
 57       || (is_optimized_entry_frame() && optimized_entry_frame_is_first());
 58 }
 59 
 60 inline bool frame::is_optimized_entry_frame() const {
 61   return _cb != NULL && _cb->is_optimized_entry_blob();
 62 }
 63 
 64 inline bool frame::is_compiled_frame() const {
 65   if (_cb != NULL &&
 66       _cb->is_compiled() &&
 67       ((CompiledMethod*)_cb)->is_java_method()) {
 68     return true;
 69   }
 70   return false;
 71 }
 72 
 73 template <typename RegisterMapT>
 74 inline address frame::oopmapreg_to_location(VMReg reg, const RegisterMapT* reg_map) const {
 75   if (reg->is_reg()) {
 76     // If it is passed in a register, it got spilled in the stub frame.
 77     return reg_map->location(reg, sp());
 78   } else {
 79     int sp_offset_in_bytes = reg->reg2stack() * VMRegImpl::stack_slot_size;
 80     if (reg_map->in_cont()) {
 81       return (address)((intptr_t)reg_map->as_RegisterMap()->stack_chunk()->relativize_usp_offset(*this, sp_offset_in_bytes));
 82     }
 83     address usp = (address)unextended_sp();
 84     assert(reg_map->thread() == NULL || reg_map->thread()->is_in_usable_stack(usp), INTPTR_FORMAT, p2i(usp)); 
 85     return (usp + sp_offset_in_bytes);
 86   }
 87 }
 88 
 89 template <typename RegisterMapT>
 90 inline oop* frame::oopmapreg_to_oop_location(VMReg reg, const RegisterMapT* reg_map) const {
 91   return (oop*)oopmapreg_to_location(reg, reg_map);
 92 }
 93 
 94 inline CodeBlob* frame::get_cb() const {
 95   // if (_cb == NULL) _cb = CodeCache::find_blob(_pc);
 96   if (_cb == NULL) {
 97     int slot;
 98     _cb = CodeCache::find_blob_and_oopmap(_pc, slot);
 99     if (_oop_map == NULL && slot >= 0) {
100       _oop_map = _cb->oop_map_for_slot(slot, _pc);
101     }
102   }
103   return _cb;
104 }
105 
106 // inline void frame::set_cb(CodeBlob* cb) {
107 //   if (_cb == NULL) _cb = cb;
108 //   assert (_cb == cb, "");
109 //   assert (_cb->contains(_pc), "");
110 // }
111 
112 
113 #endif // SHARE_RUNTIME_FRAME_INLINE_HPP
--- EOF ---