< prev index next >

src/hotspot/cpu/s390/frame_s390.cpp

Print this page


   1 /*
   2  * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2016, 2019, 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.


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


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


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


  42 #include "c1/c1_Runtime1.hpp"
  43 #include "runtime/vframeArray.hpp"
  44 #endif
  45 
  46 // Major contributions by Aha, AS.
  47 
  48 #ifdef ASSERT
  49 void RegisterMap::check_location_valid() {
  50 }
  51 #endif // ASSERT
  52 
  53 
  54 // Profiling/safepoint support
  55 
  56 bool frame::safe_for_sender(JavaThread *thread) {
  57   bool safe = false;
  58   address sp = (address)_sp;
  59   address fp = (address)_fp;
  60   address unextended_sp = (address)_unextended_sp;
  61 
  62   // consider stack guards when trying to determine "safe" stack pointers




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




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


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


< prev index next >