< prev index next >

src/cpu/x86/vm/frame_x86.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, 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  *


 107     }
 108 
 109     // Entry frame checks
 110     if (is_entry_frame()) {
 111       // an entry frame must have a valid fp.
 112 
 113       if (!fp_safe) return false;
 114 
 115       // Validate the JavaCallWrapper an entry frame must have
 116 
 117       address jcw = (address)entry_frame_call_wrapper();
 118 
 119       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > fp);
 120 
 121       return jcw_safe;
 122 
 123     }
 124 
 125     intptr_t* sender_sp = NULL;
 126     address   sender_pc = NULL;

 127 
 128     if (is_interpreted_frame()) {
 129       // fp must be safe
 130       if (!fp_safe) {
 131         return false;
 132       }
 133 
 134       sender_pc = (address) this->fp()[return_addr_offset];
 135       sender_sp = (intptr_t*) addr_at(sender_sp_offset);

 136 
 137     } else {
 138       // must be some sort of compiled/runtime frame
 139       // fp does not have to be safe (although it could be check for c1?)
 140 
 141       // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
 142       if (_cb->frame_size() <= 0) {
 143         return false;
 144       }
 145 
 146       sender_sp = _unextended_sp + _cb->frame_size();
 147       // On Intel the return_address is always the word on the stack
 148       sender_pc = (address) *(sender_sp-1);


 149     }
 150 
 151 
 152     // If the potential sender is the interpreter then we can do some more checking
 153     if (Interpreter::contains(sender_pc)) {
 154 
 155       // ebp is always saved in a recognizable place in any code we generate. However
 156       // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved ebp
 157       // is really a frame pointer.
 158 
 159       intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
 160       bool saved_fp_safe = ((address)saved_fp < thread->stack_base()) && (saved_fp > sender_sp);
 161 
 162       if (!saved_fp_safe) {
 163         return false;
 164       }
 165 
 166       // construct the potential sender
 167 
 168       frame sender(sender_sp, saved_fp, sender_pc);
 169 
 170       return sender.is_interpreted_frame_valid(thread);
 171 
 172     }
 173 
 174     // We must always be able to find a recognizable pc
 175     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 176     if (sender_pc == NULL ||  sender_blob == NULL) {
 177       return false;
 178     }
 179 
 180     // Could be a zombie method
 181     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 182       return false;
 183     }
 184 
 185     // Could just be some random pointer within the codeBlob
 186     if (!sender_blob->code_contains(sender_pc)) {
 187       return false;
 188     }
 189 
 190     // We should never be able to see an adapter if the current frame is something from code cache
 191     if (sender_blob->is_adapter_blob()) {
 192       return false;
 193     }
 194 
 195     // Could be the call_stub
 196     if (StubRoutines::returns_to_call_stub(sender_pc)) {
 197       intptr_t *saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
 198       bool saved_fp_safe = ((address)saved_fp < thread->stack_base()) && (saved_fp > sender_sp);
 199 
 200       if (!saved_fp_safe) {
 201         return false;
 202       }
 203 
 204       // construct the potential sender
 205 
 206       frame sender(sender_sp, saved_fp, sender_pc);
 207 
 208       // Validate the JavaCallWrapper an entry frame must have
 209       address jcw = (address)sender.entry_frame_call_wrapper();
 210 
 211       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > (address)sender.fp());
 212 
 213       return jcw_safe;
 214     }
 215 
 216     if (sender_blob->is_nmethod()) {
 217         nmethod* nm = sender_blob->as_nmethod_or_null();


   1 /*
   2  * Copyright (c) 1997, 2015, 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  *


 107     }
 108 
 109     // Entry frame checks
 110     if (is_entry_frame()) {
 111       // an entry frame must have a valid fp.
 112 
 113       if (!fp_safe) return false;
 114 
 115       // Validate the JavaCallWrapper an entry frame must have
 116 
 117       address jcw = (address)entry_frame_call_wrapper();
 118 
 119       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > fp);
 120 
 121       return jcw_safe;
 122 
 123     }
 124 
 125     intptr_t* sender_sp = NULL;
 126     address   sender_pc = NULL;
 127     intptr_t* saved_fp =  NULL;
 128 
 129     if (is_interpreted_frame()) {
 130       // fp must be safe
 131       if (!fp_safe) {
 132         return false;
 133       }
 134 
 135       sender_pc = (address) this->fp()[return_addr_offset];
 136       sender_sp = (intptr_t*) this->fp()[interpreter_frame_sender_sp_offset];
 137       saved_fp = (intptr_t*) this->fp()[link_offset];
 138 
 139     } else {
 140       // must be some sort of compiled/runtime frame
 141       // fp does not have to be safe (although it could be check for c1?)
 142 
 143       // check for a valid frame_size, otherwise we are unlikely to get a valid sender_pc
 144       if (_cb->frame_size() <= 0) {
 145         return false;
 146       }
 147 
 148       sender_sp = _unextended_sp + _cb->frame_size();
 149       // On Intel the return_address is always the word on the stack
 150       sender_pc = (address) *(sender_sp-1);
 151       // Note: frame::sender_sp_offset is only valid for compiled frame
 152       saved_fp = (intptr_t*)*(sender_sp - frame::sender_sp_offset);
 153     }
 154 
 155 
 156     // If the potential sender is the interpreter then we can do some more checking
 157     if (Interpreter::contains(sender_pc)) {
 158 
 159       // ebp is always saved in a recognizable place in any code we generate. However
 160       // only if the sender is interpreted/call_stub (c1 too?) are we certain that the saved ebp
 161       // is really a frame pointer.
 162 

 163       bool saved_fp_safe = ((address)saved_fp < thread->stack_base()) && (saved_fp > sender_sp);
 164 
 165       if (!saved_fp_safe) {
 166         return false;
 167       }
 168 
 169       // construct the potential sender
 170 
 171       frame sender(sender_sp, saved_fp, sender_pc);
 172 
 173       return sender.is_interpreted_frame_valid(thread);
 174 
 175     }
 176 
 177     // We must always be able to find a recognizable pc
 178     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 179     if (sender_pc == NULL ||  sender_blob == NULL) {
 180       return false;
 181     }
 182 
 183     // Could be a zombie method
 184     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 185       return false;
 186     }
 187 
 188     // Could just be some random pointer within the codeBlob
 189     if (!sender_blob->code_contains(sender_pc)) {
 190       return false;
 191     }
 192 
 193     // We should never be able to see an adapter if the current frame is something from code cache
 194     if (sender_blob->is_adapter_blob()) {
 195       return false;
 196     }
 197 
 198     // Could be the call_stub
 199     if (StubRoutines::returns_to_call_stub(sender_pc)) {

 200       bool saved_fp_safe = ((address)saved_fp < thread->stack_base()) && (saved_fp > sender_sp);
 201 
 202       if (!saved_fp_safe) {
 203         return false;
 204       }
 205 
 206       // construct the potential sender
 207 
 208       frame sender(sender_sp, saved_fp, sender_pc);
 209 
 210       // Validate the JavaCallWrapper an entry frame must have
 211       address jcw = (address)sender.entry_frame_call_wrapper();
 212 
 213       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > (address)sender.fp());
 214 
 215       return jcw_safe;
 216     }
 217 
 218     if (sender_blob->is_nmethod()) {
 219         nmethod* nm = sender_blob->as_nmethod_or_null();


< prev index next >