1 /*
   2  * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2013 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_ZERO_VM_FRAME_ZERO_INLINE_HPP
  27 #define CPU_ZERO_VM_FRAME_ZERO_INLINE_HPP
  28 
  29 // Constructors
  30 
  31 inline frame::frame() {
  32   _zeroframe = NULL;
  33   _sp = NULL;
  34   _pc = NULL;
  35   _cb = NULL;
  36   _deopt_state = unknown;
  37 }
  38 
  39 inline address  frame::sender_pc()           const { ShouldNotCallThis();  }
  40 
  41 inline frame::frame(ZeroFrame* zf, intptr_t* sp) {
  42   _zeroframe = zf;
  43   _sp = sp;
  44   switch (zeroframe()->type()) {
  45   case ZeroFrame::ENTRY_FRAME:
  46     _pc = StubRoutines::call_stub_return_pc();
  47     _cb = NULL;
  48     break;
  49 
  50   case ZeroFrame::INTERPRETER_FRAME:
  51     _pc = NULL;
  52     _cb = NULL;
  53     break;
  54 
  55   case ZeroFrame::SHARK_FRAME:
  56     _pc = zero_sharkframe()->pc();
  57     _cb = CodeCache::find_blob_unsafe(pc());
  58     break;
  59 
  60   case ZeroFrame::FAKE_STUB_FRAME:
  61     _pc = NULL;
  62     _cb = NULL;
  63     break;
  64 
  65   default:
  66     ShouldNotReachHere();
  67   }
  68   _deopt_state = not_deoptimized;
  69 }
  70 
  71 // Accessors
  72 
  73 inline intptr_t* frame::sender_sp() const {
  74   return fp() + 1;
  75 }
  76 
  77 inline intptr_t* frame::real_fp() const {
  78   return fp();
  79 }
  80 
  81 inline intptr_t* frame::link() const {
  82   ShouldNotCallThis();
  83 }
  84 
  85 #ifdef CC_INTERP
  86 inline interpreterState frame::get_interpreterState() const {
  87   return zero_interpreterframe()->interpreter_state();
  88 }
  89 
  90 inline intptr_t** frame::interpreter_frame_locals_addr() const {
  91   return &(get_interpreterState()->_locals);
  92 }
  93 
  94 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
  95   return (intptr_t*) &(get_interpreterState()->_bcp);
  96 }
  97 
  98 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
  99   return &(get_interpreterState()->_constants);
 100 }
 101 
 102 inline methodOop* frame::interpreter_frame_method_addr() const {
 103   return &(get_interpreterState()->_method);
 104 }
 105 
 106 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
 107   return (intptr_t*) &(get_interpreterState()->_mdx);
 108 }
 109 
 110 inline intptr_t* frame::interpreter_frame_tos_address() const {
 111   return get_interpreterState()->_stack + 1;
 112 }
 113 #endif // CC_INTERP
 114 
 115 inline int frame::interpreter_frame_monitor_size() {
 116   return BasicObjectLock::size();
 117 }
 118 
 119 inline intptr_t* frame::interpreter_frame_expression_stack() const {
 120   intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
 121   return monitor_end - 1;
 122 }
 123 
 124 inline jint frame::interpreter_frame_expression_stack_direction() {
 125   return -1;
 126 }
 127 
 128 // Return a unique id for this frame. The id must have a value where
 129 // we can distinguish identity and younger/older relationship. NULL
 130 // represents an invalid (incomparable) frame.
 131 inline intptr_t* frame::id() const {
 132   return fp();
 133 }
 134 
 135 inline JavaCallWrapper** frame::entry_frame_call_wrapper_addr() const {
 136   return zero_entryframe()->call_wrapper();
 137 }
 138 
 139 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
 140   ShouldNotCallThis();
 141 }
 142 
 143 inline oop frame::saved_oop_result(RegisterMap* map) const {
 144   ShouldNotCallThis();
 145 }
 146 
 147 inline bool frame::is_older(intptr_t* id) const {
 148   ShouldNotCallThis();
 149 }
 150 
 151 inline intptr_t* frame::entry_frame_argument_at(int offset) const {
 152   ShouldNotCallThis();
 153 }
 154 
 155 inline intptr_t* frame::unextended_sp() const {
 156   if (zeroframe()->is_shark_frame())
 157     return zero_sharkframe()->unextended_sp();
 158   else
 159     return (intptr_t *) -1;
 160 }
 161 
 162 #endif // CPU_ZERO_VM_FRAME_ZERO_INLINE_HPP