src/os/aix/vm/porting_aix.cpp

Print this page
rev 6239 : 8039805: Fix the signature of the global new/delete operators in allocation.cpp


   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  *
  23  */
  24 
  25 #include "asm/assembler.hpp"

  26 #include "loadlib_aix.hpp"
  27 #include "porting_aix.hpp"
  28 #include "utilities/debug.hpp"
  29 
  30 #include <demangle.h>
  31 #include <sys/debug.h>
  32 
  33 //////////////////////////////////
  34 // Provide implementation for dladdr based on LoadedLibraries pool and
  35 // traceback table scan (see getFuncName).
  36 
  37 // Search traceback table in stack,
  38 // return procedure name from trace back table.
  39 #define MAX_FUNC_SEARCH_LEN 0x10000
  40 // Any PC below this value is considered toast.
  41 #define MINIMUM_VALUE_FOR_PC ((unsigned int*)0x1024)
  42 
  43 #define PTRDIFF_BYTES(p1,p2) (((ptrdiff_t)p1) - ((ptrdiff_t)p2))
  44 
  45 // Align a pointer without having to cast.


  50 // Trace if verbose to tty.
  51 // I use these now instead of the Xtrace system because the latter is
  52 // not available at init time, hence worthless. Until we fix this, all
  53 // tracing here is done with -XX:+Verbose.
  54 #define trcVerbose(fmt, ...) { \
  55   if (Verbose) { \
  56     fprintf(stderr, fmt, ##__VA_ARGS__); \
  57     fputc('\n', stderr); fflush(stderr); \
  58   } \
  59 }
  60 #define ERRBYE(s) { trcVerbose(s); return -1; }
  61 
  62 // Unfortunately, the interface of dladdr makes the implementator
  63 // responsible for maintaining memory for function name/library
  64 // name. I guess this is because most OS's keep those values as part
  65 // of the mapped executable image ready to use. On AIX, this doesn't
  66 // work, so I have to keep the returned strings. For now, I do this in
  67 // a primitive string map. Should this turn out to be a performance
  68 // problem, a better hashmap has to be used.
  69 class fixed_strings {
  70   struct node {
  71     char* v;
  72     node* next;
  73   };
  74 
  75   node* first;
  76 
  77   public:
  78 
  79   fixed_strings() : first(0) {}
  80   ~fixed_strings() {
  81     node* n = first;
  82     while (n) {
  83       node* p = n;
  84       n = n->next;
  85       free(p->v);
  86       delete p;
  87     }
  88   }
  89 
  90   char* intern(const char* s) {




   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  *
  23  */
  24 
  25 #include "asm/assembler.hpp"
  26 #include "memory/allocation.hpp"
  27 #include "loadlib_aix.hpp"
  28 #include "porting_aix.hpp"
  29 #include "utilities/debug.hpp"
  30 
  31 #include <demangle.h>
  32 #include <sys/debug.h>
  33 
  34 //////////////////////////////////
  35 // Provide implementation for dladdr based on LoadedLibraries pool and
  36 // traceback table scan (see getFuncName).
  37 
  38 // Search traceback table in stack,
  39 // return procedure name from trace back table.
  40 #define MAX_FUNC_SEARCH_LEN 0x10000
  41 // Any PC below this value is considered toast.
  42 #define MINIMUM_VALUE_FOR_PC ((unsigned int*)0x1024)
  43 
  44 #define PTRDIFF_BYTES(p1,p2) (((ptrdiff_t)p1) - ((ptrdiff_t)p2))
  45 
  46 // Align a pointer without having to cast.


  51 // Trace if verbose to tty.
  52 // I use these now instead of the Xtrace system because the latter is
  53 // not available at init time, hence worthless. Until we fix this, all
  54 // tracing here is done with -XX:+Verbose.
  55 #define trcVerbose(fmt, ...) { \
  56   if (Verbose) { \
  57     fprintf(stderr, fmt, ##__VA_ARGS__); \
  58     fputc('\n', stderr); fflush(stderr); \
  59   } \
  60 }
  61 #define ERRBYE(s) { trcVerbose(s); return -1; }
  62 
  63 // Unfortunately, the interface of dladdr makes the implementator
  64 // responsible for maintaining memory for function name/library
  65 // name. I guess this is because most OS's keep those values as part
  66 // of the mapped executable image ready to use. On AIX, this doesn't
  67 // work, so I have to keep the returned strings. For now, I do this in
  68 // a primitive string map. Should this turn out to be a performance
  69 // problem, a better hashmap has to be used.
  70 class fixed_strings {
  71   struct node : public CHeapObj<mtInternal> {
  72     char* v;
  73     node* next;
  74   };
  75 
  76   node* first;
  77 
  78   public:
  79 
  80   fixed_strings() : first(0) {}
  81   ~fixed_strings() {
  82     node* n = first;
  83     while (n) {
  84       node* p = n;
  85       n = n->next;
  86       free(p->v);
  87       delete p;
  88     }
  89   }
  90 
  91   char* intern(const char* s) {