< prev index next >

src/hotspot/cpu/ppc/frame_ppc.cpp

Print this page


   1 /*
   2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
   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.


  38 #include "runtime/os.inline.hpp"
  39 #include "runtime/signature.hpp"
  40 #include "runtime/stubCodeGenerator.hpp"
  41 #include "runtime/stubRoutines.hpp"
  42 #ifdef COMPILER1
  43 #include "c1/c1_Runtime1.hpp"
  44 #include "runtime/vframeArray.hpp"
  45 #endif
  46 
  47 #ifdef ASSERT
  48 void RegisterMap::check_location_valid() {
  49 }
  50 #endif // ASSERT
  51 
  52 bool frame::safe_for_sender(JavaThread *thread) {
  53   bool safe = false;
  54   address sp = (address)_sp;
  55   address fp = (address)_fp;
  56   address unextended_sp = (address)_unextended_sp;
  57 
  58   // Consider stack guards when trying to determine "safe" stack pointers
  59   static size_t stack_guard_size = os::uses_stack_guard_pages() ?
  60     JavaThread::stack_red_zone_size() + JavaThread::stack_yellow_reserved_zone_size() : 0;
  61   size_t usable_stack_size = thread->stack_size() - stack_guard_size;
  62 
  63   // sp must be within the usable part of the stack (not in guards)
  64   bool sp_safe = (sp < thread->stack_base()) &&
  65                  (sp >= thread->stack_base() - usable_stack_size);
  66 
  67 
  68   if (!sp_safe) {
  69     return false;
  70   }
  71 
  72   // Unextended sp must be within the stack
  73   bool unextended_sp_safe = (unextended_sp < thread->stack_base());
  74 
  75   if (!unextended_sp_safe) {
  76     return false;
  77   }
  78 
  79   // An fp must be within the stack and above (but not equal) sp.
  80   bool fp_safe = (fp <= thread->stack_base()) &&  (fp > sp);
  81   // An interpreter fp must be within the stack and above (but not equal) sp.
  82   // Moreover, it must be at least the size of the ijava_state structure.
  83   bool fp_interp_safe = (fp <= thread->stack_base()) && (fp > sp) &&
  84     ((fp - sp) >= ijava_state_size);
  85 
  86   // We know sp/unextended_sp are safe, only fp is questionable here
  87 
  88   // If the current frame is known to the code cache then we can attempt to
  89   // to construct the sender and do some validation of it. This goes a long way
  90   // toward eliminating issues when we get in frame construction code
  91 
  92   if (_cb != NULL ){
  93     // Entry frame checks
  94     if (is_entry_frame()) {
  95       // An entry frame must have a valid fp.
  96       return fp_safe && is_entry_frame_valid(thread);
  97     }
  98 
  99     // Now check if the frame is complete and the test is
 100     // reliable. Unfortunately we can only check frame completeness for
 101     // runtime stubs and nmethods. Other generic buffer blobs are more
 102     // problematic so we just assume they are OK. Adapter blobs never have a
 103     // complete frame and are never OK


 123     // We must always be able to find a recognizable pc.
 124     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 125     if (sender_blob == NULL) {
 126       return false;
 127     }
 128 
 129     // Could be a zombie method
 130     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 131       return false;
 132     }
 133 
 134     // It should be safe to construct the sender though it might not be valid.
 135 
 136     frame sender(sender_sp, sender_pc);
 137 
 138     // Do we have a valid fp?
 139     address sender_fp = (address) sender.fp();
 140 
 141     // sender_fp must be within the stack and above (but not
 142     // equal) current frame's fp.
 143     if (sender_fp > thread->stack_base() || sender_fp <= fp) {
 144         return false;
 145     }
 146 
 147     // If the potential sender is the interpreter then we can do some more checking.
 148     if (Interpreter::contains(sender_pc)) {
 149       return sender.is_interpreted_frame_valid(thread);
 150     }
 151 
 152     // Could just be some random pointer within the codeBlob.
 153     if (!sender.cb()->code_contains(sender_pc)) {
 154       return false;
 155     }
 156 
 157     // We should never be able to see an adapter if the current frame is something from code cache.
 158     if (sender_blob->is_adapter_blob()) {
 159       return false;
 160     }
 161 
 162     if (sender.is_entry_frame()) {
 163       return sender.is_entry_frame_valid(thread);


   1 /*
   2  * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
   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.


  38 #include "runtime/os.inline.hpp"
  39 #include "runtime/signature.hpp"
  40 #include "runtime/stubCodeGenerator.hpp"
  41 #include "runtime/stubRoutines.hpp"
  42 #ifdef COMPILER1
  43 #include "c1/c1_Runtime1.hpp"
  44 #include "runtime/vframeArray.hpp"
  45 #endif
  46 
  47 #ifdef ASSERT
  48 void RegisterMap::check_location_valid() {
  49 }
  50 #endif // ASSERT
  51 
  52 bool frame::safe_for_sender(JavaThread *thread) {
  53   bool safe = false;
  54   address sp = (address)_sp;
  55   address fp = (address)_fp;
  56   address unextended_sp = (address)_unextended_sp;
  57 
  58   // consider stack guards when trying to determine "safe" stack pointers




  59   // sp must be within the usable part of the stack (not in guards)
  60   if (!thread->is_in_usable_stack(sp)) {




  61     return false;
  62   }
  63 
  64   // Unextended sp must be within the stack
  65   bool unextended_sp_safe = (unextended_sp < thread->stack_base());
  66 
  67   if (!unextended_sp_safe) {
  68     return false;
  69   }
  70 
  71   // An fp must be within the stack and above (but not equal) sp.
  72   bool fp_safe = (fp < thread->stack_base()) &&  (fp > sp);
  73   // An interpreter fp must be within the stack and above (but not equal) sp.
  74   // Moreover, it must be at least the size of the ijava_state structure.
  75   bool fp_interp_safe = (fp < thread->stack_base()) && (fp > sp) &&
  76     ((fp - sp) >= ijava_state_size);
  77 
  78   // We know sp/unextended_sp are safe, only fp is questionable here
  79 
  80   // If the current frame is known to the code cache then we can attempt to
  81   // to construct the sender and do some validation of it. This goes a long way
  82   // toward eliminating issues when we get in frame construction code
  83 
  84   if (_cb != NULL ){
  85     // Entry frame checks
  86     if (is_entry_frame()) {
  87       // An entry frame must have a valid fp.
  88       return fp_safe && is_entry_frame_valid(thread);
  89     }
  90 
  91     // Now check if the frame is complete and the test is
  92     // reliable. Unfortunately we can only check frame completeness for
  93     // runtime stubs and nmethods. Other generic buffer blobs are more
  94     // problematic so we just assume they are OK. Adapter blobs never have a
  95     // complete frame and are never OK


 115     // We must always be able to find a recognizable pc.
 116     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 117     if (sender_blob == NULL) {
 118       return false;
 119     }
 120 
 121     // Could be a zombie method
 122     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 123       return false;
 124     }
 125 
 126     // It should be safe to construct the sender though it might not be valid.
 127 
 128     frame sender(sender_sp, sender_pc);
 129 
 130     // Do we have a valid fp?
 131     address sender_fp = (address) sender.fp();
 132 
 133     // sender_fp must be within the stack and above (but not
 134     // equal) current frame's fp.
 135     if (sender_fp >= thread->stack_base() || sender_fp <= fp) {
 136         return false;
 137     }
 138 
 139     // If the potential sender is the interpreter then we can do some more checking.
 140     if (Interpreter::contains(sender_pc)) {
 141       return sender.is_interpreted_frame_valid(thread);
 142     }
 143 
 144     // Could just be some random pointer within the codeBlob.
 145     if (!sender.cb()->code_contains(sender_pc)) {
 146       return false;
 147     }
 148 
 149     // We should never be able to see an adapter if the current frame is something from code cache.
 150     if (sender_blob->is_adapter_blob()) {
 151       return false;
 152     }
 153 
 154     if (sender.is_entry_frame()) {
 155       return sender.is_entry_frame_valid(thread);


< prev index next >