1 /*
   2  * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2013 SAP AG. 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  *
  24  */
  25 
  26 #ifndef CPU_PPC_VM_JAVAFRAMEANCHOR_PPC_HPP
  27 #define CPU_PPC_VM_JAVAFRAMEANCHOR_PPC_HPP
  28 
  29 #ifndef CC_INTERP
  30 #error "CC_INTERP must be defined on PPC64"
  31 #endif
  32 
  33 public:
  34   // Each arch must define reset, save, restore
  35   // These are used by objects that only care about:
  36   //  1 - initializing a new state (thread creation, javaCalls)
  37   //  2 - saving a current state (javaCalls)
  38   //  3 - restoring an old state (javaCalls)
  39 
  40   inline void clear(void) {
  41     // clearing _last_Java_sp must be first
  42     _last_Java_sp = NULL;
  43     // fence?
  44     OrderAccess::release();
  45     _last_Java_pc = NULL;
  46   }
  47 
  48   inline void set(intptr_t* sp, address pc) {
  49     _last_Java_pc = pc;
  50     OrderAccess::release();
  51     _last_Java_sp = sp;
  52   }
  53 
  54   void copy(JavaFrameAnchor* src) {
  55     // In order to make sure the transition state is valid for "this".
  56     // We must clear _last_Java_sp before copying the rest of the new data.
  57     //
  58     // Hack Alert: Temporary bugfix for 4717480/4721647
  59     // To act like previous version (pd_cache_state) don't NULL _last_Java_sp
  60     // unless the value is changing.
  61     if (_last_Java_sp != src->_last_Java_sp) {
  62       _last_Java_sp = NULL;
  63       OrderAccess::release();
  64     }
  65     _last_Java_pc = src->_last_Java_pc;
  66     // Must be last so profiler will always see valid frame if has_last_frame() is true.
  67     OrderAccess::release();
  68     _last_Java_sp = src->_last_Java_sp;
  69   }
  70 
  71   // Always walkable.
  72   bool walkable(void) { return true; }
  73   // Never any thing to do since we are always walkable and can find address of return addresses.
  74   void make_walkable(JavaThread* thread) { }
  75 
  76   intptr_t* last_Java_sp(void) const  { return _last_Java_sp; }
  77 
  78   address last_Java_pc(void)          { return _last_Java_pc; }
  79 
  80   void set_last_Java_sp(intptr_t* sp) { OrderAccess::release(); _last_Java_sp = sp; }
  81 
  82 #endif // CPU_PPC_VM_JAVAFRAMEANCHOR_PPC_HPP