< prev index next >

src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp

Print this page
rev 48556 : 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
Reviewed-by: stuefe
   1 /*
   2  * Copyright (c) 1997, 2017, 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.
  23  *


  93 // always looks like a C-frame according to the frame
  94 // conventions in frame_ppc.hpp.
  95 
  96 address os::Aix::ucontext_get_pc(const ucontext_t * uc) {
  97   return (address)uc->uc_mcontext.jmp_context.iar;
  98 }
  99 
 100 intptr_t* os::Aix::ucontext_get_sp(const ucontext_t * uc) {
 101   // gpr1 holds the stack pointer on aix
 102   return (intptr_t*)uc->uc_mcontext.jmp_context.gpr[1/*REG_SP*/];
 103 }
 104 
 105 intptr_t* os::Aix::ucontext_get_fp(const ucontext_t * uc) {
 106   return NULL;
 107 }
 108 
 109 void os::Aix::ucontext_set_pc(ucontext_t* uc, address new_pc) {
 110   uc->uc_mcontext.jmp_context.iar = (uint64_t) new_pc;
 111 }
 112 




 113 ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
 114                                         intptr_t** ret_sp, intptr_t** ret_fp) {
 115 
 116   ExtendedPC  epc;
 117   const ucontext_t* uc = (const ucontext_t*)ucVoid;
 118 
 119   if (uc != NULL) {
 120     epc = ExtendedPC(os::Aix::ucontext_get_pc(uc));
 121     if (ret_sp) *ret_sp = os::Aix::ucontext_get_sp(uc);
 122     if (ret_fp) *ret_fp = os::Aix::ucontext_get_fp(uc);
 123   } else {
 124     // construct empty ExtendedPC for return value checking
 125     epc = ExtendedPC(NULL);
 126     if (ret_sp) *ret_sp = (intptr_t *)NULL;
 127     if (ret_fp) *ret_fp = (intptr_t *)NULL;
 128   }
 129 
 130   return epc;
 131 }
 132 


 149     // Interpreter performs stack banging after the fixed frame header has
 150     // been generated while the compilers perform it before. To maintain
 151     // semantic consistency between interpreted and compiled frames, the
 152     // method returns the Java sender of the current frame.
 153     *fr = os::fetch_frame_from_context(uc);
 154     if (!fr->is_first_java_frame()) {
 155       assert(fr->safe_for_sender(thread), "Safety check");
 156       *fr = fr->java_sender();
 157     }
 158   } else {
 159     // More complex code with compiled code.
 160     assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
 161     CodeBlob* cb = CodeCache::find_blob(pc);
 162     if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
 163       // Not sure where the pc points to, fallback to default
 164       // stack overflow handling. In compiled code, we bang before
 165       // the frame is complete.
 166       return false;
 167     } else {
 168       intptr_t* sp = os::Aix::ucontext_get_sp(uc);
 169       *fr = frame(sp, (address)*sp);

 170       if (!fr->is_java_frame()) {
 171         assert(fr->safe_for_sender(thread), "Safety check");
 172         assert(!fr->is_first_frame(), "Safety check");
 173         *fr = fr->java_sender();
 174       }
 175     }
 176   }
 177   assert(fr->is_java_frame(), "Safety check");
 178   return true;
 179 }
 180 
 181 frame os::get_sender_for_C_frame(frame* fr) {
 182   if (*fr->sp() == NULL) {
 183     // fr is the last C frame
 184     return frame(NULL, NULL);
 185   }
 186   return frame(fr->sender_sp(), fr->sender_pc());
 187 }
 188 
 189 


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


  93 // always looks like a C-frame according to the frame
  94 // conventions in frame_ppc.hpp.
  95 
  96 address os::Aix::ucontext_get_pc(const ucontext_t * uc) {
  97   return (address)uc->uc_mcontext.jmp_context.iar;
  98 }
  99 
 100 intptr_t* os::Aix::ucontext_get_sp(const ucontext_t * uc) {
 101   // gpr1 holds the stack pointer on aix
 102   return (intptr_t*)uc->uc_mcontext.jmp_context.gpr[1/*REG_SP*/];
 103 }
 104 
 105 intptr_t* os::Aix::ucontext_get_fp(const ucontext_t * uc) {
 106   return NULL;
 107 }
 108 
 109 void os::Aix::ucontext_set_pc(ucontext_t* uc, address new_pc) {
 110   uc->uc_mcontext.jmp_context.iar = (uint64_t) new_pc;
 111 }
 112 
 113 static address ucontext_get_lr(const ucontext_t * uc) {
 114   return (address)uc->uc_mcontext.jmp_context.lr;
 115 }
 116 
 117 ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
 118                                         intptr_t** ret_sp, intptr_t** ret_fp) {
 119 
 120   ExtendedPC  epc;
 121   const ucontext_t* uc = (const ucontext_t*)ucVoid;
 122 
 123   if (uc != NULL) {
 124     epc = ExtendedPC(os::Aix::ucontext_get_pc(uc));
 125     if (ret_sp) *ret_sp = os::Aix::ucontext_get_sp(uc);
 126     if (ret_fp) *ret_fp = os::Aix::ucontext_get_fp(uc);
 127   } else {
 128     // construct empty ExtendedPC for return value checking
 129     epc = ExtendedPC(NULL);
 130     if (ret_sp) *ret_sp = (intptr_t *)NULL;
 131     if (ret_fp) *ret_fp = (intptr_t *)NULL;
 132   }
 133 
 134   return epc;
 135 }
 136 


 153     // Interpreter performs stack banging after the fixed frame header has
 154     // been generated while the compilers perform it before. To maintain
 155     // semantic consistency between interpreted and compiled frames, the
 156     // method returns the Java sender of the current frame.
 157     *fr = os::fetch_frame_from_context(uc);
 158     if (!fr->is_first_java_frame()) {
 159       assert(fr->safe_for_sender(thread), "Safety check");
 160       *fr = fr->java_sender();
 161     }
 162   } else {
 163     // More complex code with compiled code.
 164     assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
 165     CodeBlob* cb = CodeCache::find_blob(pc);
 166     if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
 167       // Not sure where the pc points to, fallback to default
 168       // stack overflow handling. In compiled code, we bang before
 169       // the frame is complete.
 170       return false;
 171     } else {
 172       intptr_t* sp = os::Aix::ucontext_get_sp(uc);
 173       address lr = ucontext_get_lr(uc);
 174       *fr = frame(sp, lr);
 175       if (!fr->is_java_frame()) {
 176         assert(fr->safe_for_sender(thread), "Safety check");
 177         assert(!fr->is_first_frame(), "Safety check");
 178         *fr = fr->java_sender();
 179       }
 180     }
 181   }
 182   assert(fr->is_java_frame(), "Safety check");
 183   return true;
 184 }
 185 
 186 frame os::get_sender_for_C_frame(frame* fr) {
 187   if (*fr->sp() == NULL) {
 188     // fr is the last C frame
 189     return frame(NULL, NULL);
 190   }
 191   return frame(fr->sender_sp(), fr->sender_pc());
 192 }
 193 
 194 


< prev index next >