1 /*
   2  * Copyright 2003-2007 Sun Microsystems, Inc.  All Rights Reserved.
   3  * Copyright 2007, 2008, 2009 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  21  * CA 95054 USA or visit www.sun.com if you need additional information or
  22  * have any questions.
  23  *
  24  */
  25 
  26 // Constructors
  27 
  28 inline frame::frame() {
  29   _sp = NULL;
  30   _fp = NULL;
  31   _pc = NULL;
  32   _cb = NULL;
  33   _deopt_state = unknown;
  34 }
  35 
  36 inline frame::frame(intptr_t* sp, intptr_t* fp) {
  37   _sp = sp;
  38   _fp = fp;
  39   switch (zeroframe()->type()) {
  40   case ZeroFrame::ENTRY_FRAME:
  41     _pc = StubRoutines::call_stub_return_pc();
  42     _cb = NULL;
  43     break;
  44 
  45   case ZeroFrame::INTERPRETER_FRAME:
  46     _pc = NULL;
  47     _cb = NULL;
  48     break;
  49 
  50   case ZeroFrame::SHARK_FRAME:
  51     _pc = zero_sharkframe()->pc();
  52     _cb = CodeCache::find_blob_unsafe(pc());
  53     break;
  54 
  55   case ZeroFrame::FAKE_STUB_FRAME:
  56     _pc = NULL;
  57     _cb = NULL;
  58     break;
  59 
  60   default:
  61     ShouldNotReachHere();
  62   }
  63   _deopt_state = not_deoptimized;
  64 }
  65 
  66 // Accessors
  67 
  68 inline intptr_t* frame::sender_sp() const {
  69   return (intptr_t *) zeroframe()->next();
  70 }
  71 
  72 inline intptr_t* frame::link() const {
  73   ShouldNotCallThis();
  74 }
  75 
  76 #ifdef CC_INTERP
  77 inline interpreterState frame::get_interpreterState() const {
  78   return zero_interpreterframe()->interpreter_state();
  79 }
  80 
  81 inline intptr_t** frame::interpreter_frame_locals_addr() const {
  82   return &(get_interpreterState()->_locals);
  83 }
  84 
  85 inline intptr_t* frame::interpreter_frame_bcx_addr() const {
  86   return (intptr_t*) &(get_interpreterState()->_bcp);
  87 }
  88 
  89 inline constantPoolCacheOop* frame::interpreter_frame_cache_addr() const {
  90   return &(get_interpreterState()->_constants);
  91 }
  92 
  93 inline methodOop* frame::interpreter_frame_method_addr() const {
  94   return &(get_interpreterState()->_method);
  95 }
  96 
  97 inline intptr_t* frame::interpreter_frame_mdx_addr() const {
  98   return (intptr_t*) &(get_interpreterState()->_mdx);
  99 }
 100 
 101 inline intptr_t* frame::interpreter_frame_tos_address() const {
 102   return get_interpreterState()->_stack + 1;
 103 }
 104 #endif // CC_INTERP
 105 
 106 inline int frame::interpreter_frame_monitor_size() {
 107   return BasicObjectLock::size();
 108 }
 109 
 110 inline intptr_t* frame::interpreter_frame_expression_stack() const {
 111   intptr_t* monitor_end = (intptr_t*) interpreter_frame_monitor_end();
 112   return monitor_end - 1;
 113 }
 114 
 115 inline jint frame::interpreter_frame_expression_stack_direction() {
 116   return -1;
 117 }
 118 
 119 // Return a unique id for this frame. The id must have a value where
 120 // we can distinguish identity and younger/older relationship. NULL
 121 // represents an invalid (incomparable) frame.
 122 inline intptr_t* frame::id() const {
 123   return sp();
 124 }
 125 
 126 inline JavaCallWrapper* frame::entry_frame_call_wrapper() const {
 127   return zero_entryframe()->call_wrapper();
 128 }
 129 
 130 inline void frame::set_saved_oop_result(RegisterMap* map, oop obj) {
 131   ShouldNotCallThis();
 132 }
 133 
 134 inline oop frame::saved_oop_result(RegisterMap* map) const {
 135   ShouldNotCallThis();
 136 }
 137 
 138 inline bool frame::is_older(intptr_t* id) const {
 139   ShouldNotCallThis();
 140 }
 141 
 142 inline intptr_t* frame::entry_frame_argument_at(int offset) const {
 143   ShouldNotCallThis();
 144 }
 145 
 146 inline intptr_t* frame::unextended_sp() const {
 147   if (zeroframe()->is_shark_frame())
 148     return zero_sharkframe()->unextended_sp();
 149   else
 150     return (intptr_t *) -1;
 151 }