src/hotspot/os_cpu/linux_ppc/os_linux_ppc.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 57594 61c2e3e7315d
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
54717
b39365cebb73 8223395: PPC64: Improve comments in the JVM signal handler to match ISA text
gromero
parents: 54283
diff changeset
     2
 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
b39365cebb73 8223395: PPC64: Improve comments in the JVM signal handler to match ISA text
gromero
parents: 54283
diff changeset
     3
 * Copyright (c) 2012, 2019 SAP SE. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
31388
40814c7eba5c 8129607: Incorrect GPL header
coleenp
parents: 30304
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
// no precompiled headers
47765
b7c7428eaab9 8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents: 47216
diff changeset
    27
#include "jvm.h"
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
    28
#include "asm/assembler.inline.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "classfile/classLoader.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
#include "classfile/systemDictionary.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    31
#include "classfile/vmSymbols.hpp"
34667
6b077f0ef25d 8144881: Various fixes to linux/sparc
mikael
parents: 34633
diff changeset
    32
#include "code/codeCache.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
#include "code/icBuffer.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    34
#include "code/vtableStubs.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
#include "interpreter/interpreter.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    36
#include "memory/allocation.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
#include "nativeInst_ppc.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    38
#include "os_share_linux.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    39
#include "prims/jniFastGetField.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    40
#include "prims/jvm_misc.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    41
#include "runtime/arguments.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    42
#include "runtime/extendedPC.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    43
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 48821
diff changeset
    44
#include "runtime/interfaceSupport.inline.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    45
#include "runtime/java.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    46
#include "runtime/javaCalls.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    47
#include "runtime/mutexLocker.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    48
#include "runtime/osThread.hpp"
48506
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47765
diff changeset
    49
#include "runtime/safepointMechanism.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    50
#include "runtime/sharedRuntime.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    51
#include "runtime/stubRoutines.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    52
#include "runtime/thread.inline.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    53
#include "runtime/timer.hpp"
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
    54
#include "utilities/debug.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    55
#include "utilities/events.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    56
#include "utilities/vmError.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    57
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    58
// put OS-includes here
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    59
# include <sys/types.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    60
# include <sys/mman.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    61
# include <pthread.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    62
# include <signal.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    63
# include <errno.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    64
# include <dlfcn.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    65
# include <stdlib.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    66
# include <stdio.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    67
# include <unistd.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    68
# include <sys/resource.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    69
# include <pthread.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    70
# include <sys/stat.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    71
# include <sys/time.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    72
# include <sys/utsname.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    73
# include <sys/socket.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    74
# include <sys/wait.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    75
# include <pwd.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    76
# include <poll.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    77
# include <ucontext.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    78
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    79
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    80
address os::current_stack_pointer() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    81
  intptr_t* csp;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    82
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    83
  // inline assembly `mr regno(csp), R1_SP':
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    84
  __asm__ __volatile__ ("mr %0, 1":"=r"(csp):);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    85
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    86
  return (address) csp;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    87
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    88
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    89
char* os::non_memory_address_word() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    90
  // Must never look like an address returned by reserve_memory,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    91
  // even in its subfields (as defined by the CPU immediate fields,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    92
  // if the CPU splits constants across multiple instructions).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    93
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    94
  return (char*) -1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    95
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    96
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    97
// Frame information (pc, sp, fp) retrieved via ucontext
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    98
// always looks like a C-frame according to the frame
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    99
// conventions in frame_ppc64.hpp.
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   100
address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   101
  // On powerpc64, ucontext_t is not selfcontained but contains
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   102
  // a pointer to an optional substructure (mcontext_t.regs) containing the volatile
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   103
  // registers - NIP, among others.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   104
  // This substructure may or may not be there depending where uc came from:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   105
  // - if uc was handed over as the argument to a sigaction handler, a pointer to the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   106
  //   substructure was provided by the kernel when calling the signal handler, and
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   107
  //   regs->nip can be accessed.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   108
  // - if uc was filled by getcontext(), it is undefined - getcontext() does not fill
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   109
  //   it because the volatile registers are not needed to make setcontext() work.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   110
  //   Hopefully it was zero'd out beforehand.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   111
  guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_get_pc in sigaction context");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   112
  return (address)uc->uc_mcontext.regs->nip;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   113
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   114
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   115
// modify PC in ucontext.
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   116
// Note: Only use this for an ucontext handed down to a signal handler. See comment
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   117
// in ucontext_get_pc.
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   118
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   119
  guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context");
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   120
  uc->uc_mcontext.regs->nip = (unsigned long)pc;
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   121
}
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   122
48821
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 48506
diff changeset
   123
static address ucontext_get_lr(const ucontext_t * uc) {
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 48506
diff changeset
   124
  return (address)uc->uc_mcontext.regs->link;
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 48506
diff changeset
   125
}
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 48506
diff changeset
   126
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   127
intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   128
  return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   129
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   130
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   131
intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   132
  return NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   133
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   134
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   135
static unsigned long ucontext_get_trap(const ucontext_t * uc) {
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   136
  return uc->uc_mcontext.regs->trap;
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   137
}
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   138
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   139
ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   140
                    intptr_t** ret_sp, intptr_t** ret_fp) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   141
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   142
  ExtendedPC  epc;
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   143
  const ucontext_t* uc = (const ucontext_t*)ucVoid;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   144
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   145
  if (uc != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   146
    epc = ExtendedPC(os::Linux::ucontext_get_pc(uc));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   147
    if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   148
    if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   149
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   150
    // construct empty ExtendedPC for return value checking
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   151
    epc = ExtendedPC(NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   152
    if (ret_sp) *ret_sp = (intptr_t *)NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   153
    if (ret_fp) *ret_fp = (intptr_t *)NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   154
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   155
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   156
  return epc;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   157
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   158
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   159
frame os::fetch_frame_from_context(const void* ucVoid) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   160
  intptr_t* sp;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
  intptr_t* fp;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   162
  ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   163
  return frame(sp, epc.pc());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   164
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   166
bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   167
  address pc = (address) os::Linux::ucontext_get_pc(uc);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   168
  if (Interpreter::contains(pc)) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   169
    // Interpreter performs stack banging after the fixed frame header has
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   170
    // been generated while the compilers perform it before. To maintain
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   171
    // semantic consistency between interpreted and compiled frames, the
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   172
    // method returns the Java sender of the current frame.
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   173
    *fr = os::fetch_frame_from_context(uc);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   174
    if (!fr->is_first_java_frame()) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   175
      assert(fr->safe_for_sender(thread), "Safety check");
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   176
      *fr = fr->java_sender();
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   177
    }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   178
  } else {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   179
    // More complex code with compiled code.
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   180
    assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   181
    CodeBlob* cb = CodeCache::find_blob(pc);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   182
    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   183
      // Not sure where the pc points to, fallback to default
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   184
      // stack overflow handling. In compiled code, we bang before
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   185
      // the frame is complete.
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   186
      return false;
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   187
    } else {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   188
      intptr_t* sp = os::Linux::ucontext_get_sp(uc);
48821
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 48506
diff changeset
   189
      address lr = ucontext_get_lr(uc);
8250a10cf60f 8196401: PPC64+s390: get_frame_at_stack_banging_point uses wrong PC
mdoerr
parents: 48506
diff changeset
   190
      *fr = frame(sp, lr);
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   191
      if (!fr->is_java_frame()) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   192
        assert(fr->safe_for_sender(thread), "Safety check");
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   193
        assert(!fr->is_first_frame(), "Safety check");
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   194
        *fr = fr->java_sender();
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   195
      }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   196
    }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   197
  }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   198
  assert(fr->is_java_frame(), "Safety check");
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   199
  return true;
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   200
}
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   201
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   202
frame os::get_sender_for_C_frame(frame* fr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   203
  if (*fr->sp() == 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   204
    // fr is the last C frame
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   205
    return frame(NULL, NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   206
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   207
  return frame(fr->sender_sp(), fr->sender_pc());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   208
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   209
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   210
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   211
frame os::current_frame() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   212
  intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer());
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   213
  // hack.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   214
  frame topframe(csp, (address)0x8);
41086
06b10263e509 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents: 41070
diff changeset
   215
  // Return sender of sender of current topframe which hopefully
06b10263e509 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents: 41070
diff changeset
   216
  // both have pc != NULL.
06b10263e509 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents: 41070
diff changeset
   217
  frame tmp = os::get_sender_for_C_frame(&topframe);
06b10263e509 8165315: [ppc] Port "8133749: NMT detail stack trace cleanup"
goetz
parents: 41070
diff changeset
   218
  return os::get_sender_for_C_frame(&tmp);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   219
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   220
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   221
// Utility functions
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   222
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   223
extern "C" JNIEXPORT int
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   224
JVM_handle_linux_signal(int sig,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   225
                        siginfo_t* info,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   226
                        void* ucVoid,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   227
                        int abort_if_unrecognized) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   228
  ucontext_t* uc = (ucontext_t*) ucVoid;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   229
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 33105
diff changeset
   230
  Thread* t = Thread::current_or_null_safe();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   231
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   232
  SignalHandlerMark shm(t);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   233
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   234
  // Note: it's not uncommon that JNI code uses signal/sigset to install
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   235
  // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   236
  // or have a SIGILL handler when detecting CPU type). When that happens,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   237
  // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   238
  // avoid unnecessary crash when libjsig is not preloaded, try handle signals
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   239
  // that do not require siginfo/ucontext first.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   240
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   241
  if (sig == SIGPIPE) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   242
    if (os::Linux::chained_handler(sig, info, ucVoid)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   243
      return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   244
    } else {
37430
fd743dadef12 8151939: VM_Version_init() print buffer is too small
coleenp
parents: 35594
diff changeset
   245
      // Ignoring SIGPIPE - see bugs 4229104
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   246
      return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   247
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   248
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   249
40366
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   250
  // Make the signal handler transaction-aware by checking the existence of a
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   251
  // second (transactional) context with MSR TS bits active. If the signal is
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   252
  // caught during a transaction, then just return to the HTM abort handler.
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   253
  // Please refer to Linux kernel document powerpc/transactional_memory.txt,
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   254
  // section "Signals".
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   255
  if (uc && uc->uc_link) {
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   256
    ucontext_t* second_uc = uc->uc_link;
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   257
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   258
    // MSR TS bits are 29 and 30 (Power ISA, v2.07B, Book III-S, pp. 857-858,
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   259
    // 3.2.1 "Machine State Register"), however note that ISA notation for bit
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   260
    // numbering is MSB 0, so for normal bit numbering (LSB 0) they come to be
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   261
    // bits 33 and 34. It's not related to endianness, just a notation matter.
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   262
    if (second_uc->uc_mcontext.regs->msr & 0x600000000) {
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   263
      if (TraceTraps) {
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   264
        tty->print_cr("caught signal in transaction, "
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   265
                        "ignoring to jump to abort handler");
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   266
      }
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   267
      // Return control to the HTM abort handler.
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   268
      return true;
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   269
    }
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   270
  }
f0e255676d72 8162369: PPC64: Wrong ucontext used after SIGTRAP while in HTM critical section
mdoerr
parents: 40010
diff changeset
   271
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   272
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   273
  if ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison) {
55653
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55490
diff changeset
   274
    if (handle_assert_poison_fault(ucVoid, info->si_addr)) {
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55490
diff changeset
   275
      return 1;
3243c42d737d 8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents: 55490
diff changeset
   276
    }
49653
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   277
  }
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   278
#endif
a569cb4425f3 8191101: Show register content in hs-err file on assert
stuefe
parents: 49449
diff changeset
   279
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   280
  JavaThread* thread = NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   281
  VMThread* vmthread = NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   282
  if (os::Linux::signal_handlers_are_installed) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   283
    if (t != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   284
      if(t->is_Java_thread()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   285
        thread = (JavaThread*)t;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   286
      } else if(t->is_VM_thread()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   287
        vmthread = (VMThread *)t;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   288
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   289
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   290
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   291
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   292
  // Moved SafeFetch32 handling outside thread!=NULL conditional block to make
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   293
  // it work if no associated JavaThread object exists.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   294
  if (uc) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   295
    address const pc = os::Linux::ucontext_get_pc(uc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   296
    if (pc && StubRoutines::is_safefetch_fault(pc)) {
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   297
      os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   298
      return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   299
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   300
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   301
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   302
  // decide if this trap can be handled by a stub
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   303
  address stub = NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   304
  address pc   = NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   305
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   306
  if (info != NULL && uc != NULL && thread != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   307
    pc = (address) os::Linux::ucontext_get_pc(uc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   308
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   309
    // Handle ALL stack overflow variations here
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   310
    if (sig == SIGSEGV) {
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   311
      // si_addr may not be valid due to a bug in the linux-ppc64 kernel (see
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   312
      // comment below). Use get_stack_bang_address instead of si_addr.
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   313
      // If SIGSEGV is caused due to a branch to an invalid address an
54717
b39365cebb73 8223395: PPC64: Improve comments in the JVM signal handler to match ISA text
gromero
parents: 54283
diff changeset
   314
      // "Instruction Storage Interrupt" is generated and 'pc' (NIP) already
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   315
      // contains the invalid address. Otherwise, the SIGSEGV is caused due to
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   316
      // load/store instruction trying to load/store from/to an invalid address
54717
b39365cebb73 8223395: PPC64: Improve comments in the JVM signal handler to match ISA text
gromero
parents: 54283
diff changeset
   317
      // and causing a "Data Storage Interrupt", so we inspect the intruction
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   318
      // in order to extract the faulty data addresss.
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   319
      address addr;
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   320
      if ((ucontext_get_trap(uc) & 0x0F00 /* no IRQ reply bits */) == 0x0400) {
54717
b39365cebb73 8223395: PPC64: Improve comments in the JVM signal handler to match ISA text
gromero
parents: 54283
diff changeset
   321
        // Instruction Storage Interrupt (ISI)
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   322
        addr = pc;
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   323
      } else {
54717
b39365cebb73 8223395: PPC64: Improve comments in the JVM signal handler to match ISA text
gromero
parents: 54283
diff changeset
   324
        // Data Storage Interrupt (DSI), i.e. 0x0300: extract faulty data address
54283
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   325
        addr = ((NativeInstruction*)pc)->get_stack_bang_address(uc);
e61065c08924 8220794: PPC64: Fix signal handler for SIGSEGV on branch to illegal address
gromero
parents: 53605
diff changeset
   326
      }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   327
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   328
      // Check if fault address is within thread stack.
35201
996db89f378e 8139864: Improve handling of stack protection zones.
goetz
parents: 35077
diff changeset
   329
      if (thread->on_local_stack(addr)) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   330
        // stack overflow
35201
996db89f378e 8139864: Improve handling of stack protection zones.
goetz
parents: 35077
diff changeset
   331
        if (thread->in_stack_yellow_reserved_zone(addr)) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   332
          if (thread->thread_state() == _thread_in_Java) {
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   333
            if (thread->in_stack_reserved_zone(addr)) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   334
              frame fr;
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   335
              if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   336
                assert(fr.is_java_frame(), "Must be a Javac frame");
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   337
                frame activation =
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   338
                  SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   339
                if (activation.sp() != NULL) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   340
                  thread->disable_stack_reserved_zone();
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   341
                  if (activation.is_interpreted_frame()) {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   342
                    thread->set_reserved_stack_activation((address)activation.fp());
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   343
                  } else {
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   344
                    thread->set_reserved_stack_activation((address)activation.unextended_sp());
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   345
                  }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   346
                  return 1;
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   347
                }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   348
              }
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   349
            }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   350
            // Throw a stack overflow exception.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   351
            // Guard pages will be reenabled while unwinding the stack.
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   352
            thread->disable_stack_yellow_reserved_zone();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   353
            stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   354
          } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   355
            // Thread was in the vm or native code. Return and try to finish.
38931
3cf28d630349 8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents: 38209
diff changeset
   356
            thread->disable_stack_yellow_reserved_zone();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   357
            return 1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   358
          }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   359
        } else if (thread->in_stack_red_zone(addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   360
          // Fatal red zone violation.  Disable the guard pages and fall through
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   361
          // to handle_unexpected_exception way down below.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   362
          thread->disable_stack_red_zone();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   363
          tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   364
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   365
          // This is a likely cause, but hard to verify. Let's just print
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   366
          // it as a hint.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   367
          tty->print_raw_cr("Please check if any of your loaded .so files has "
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   368
                            "enabled executable stack (see man page execstack(8))");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   369
        } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   370
          // Accessing stack address below sp may cause SEGV if current
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   371
          // thread has MAP_GROWSDOWN stack. This should only happen when
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   372
          // current thread was created by user code with MAP_GROWSDOWN flag
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   373
          // and then attached to VM. See notes in os_linux.cpp.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   374
          if (thread->osthread()->expanding_stack() == 0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   375
             thread->osthread()->set_expanding_stack();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   376
             if (os::Linux::manually_expand_stack(thread, addr)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   377
               thread->osthread()->clear_expanding_stack();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   378
               return 1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   379
             }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   380
             thread->osthread()->clear_expanding_stack();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   381
          } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   382
             fatal("recursive segv. expanding stack.");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   383
          }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   384
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   385
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   386
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   387
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   388
    if (thread->thread_state() == _thread_in_Java) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   389
      // Java thread running in Java code => find exception handler if any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   390
      // a fault inside compiled code, the interpreter, or a stub
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   391
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   392
      // A VM-related SIGILL may only occur if we are not in the zero page.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   393
      // On AIX, we get a SIGILL if we jump to 0x0 or to somewhere else
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   394
      // in the zero page, because it is filled with 0x0. We ignore
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   395
      // explicit SIGILLs in the zero page.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   396
      if (sig == SIGILL && (pc < (address) 0x200)) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   397
        if (TraceTraps) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   398
          tty->print_raw_cr("SIGILL happened inside zero page.");
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   399
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   400
        goto report_and_die;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   401
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   402
30304
94f13c5f0f5d 8078482: ppc: pass thread to throw_AbstractMethodError
goetz
parents: 29573
diff changeset
   403
      CodeBlob *cb = NULL;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   404
      // Handle signal from NativeJump::patch_verified_entry().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   405
      if (( TrapBasedNotEntrantChecks && sig == SIGTRAP && nativeInstruction_at(pc)->is_sigtrap_zombie_not_entrant()) ||
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   406
          (!TrapBasedNotEntrantChecks && sig == SIGILL  && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant())) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   407
        if (TraceTraps) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   408
          tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL");
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   409
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   410
        stub = SharedRuntime::get_handle_wrong_method_stub();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   411
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   412
48506
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47765
diff changeset
   413
      else if (sig == ((SafepointMechanism::uses_thread_local_poll() && USE_POLL_BIT_ONLY) ? SIGTRAP : SIGSEGV) &&
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   414
               // A linux-ppc64 kernel before 2.6.6 doesn't set si_addr on some segfaults
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   415
               // in 64bit mode (cf. http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.6),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   416
               // especially when we try to read from the safepoint polling page. So the check
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   417
               //   (address)info->si_addr == os::get_standard_polling_page()
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   418
               // doesn't work for us. We use:
30304
94f13c5f0f5d 8078482: ppc: pass thread to throw_AbstractMethodError
goetz
parents: 29573
diff changeset
   419
               ((NativeInstruction*)pc)->is_safepoint_poll() &&
94f13c5f0f5d 8078482: ppc: pass thread to throw_AbstractMethodError
goetz
parents: 29573
diff changeset
   420
               CodeCache::contains((void*) pc) &&
94f13c5f0f5d 8078482: ppc: pass thread to throw_AbstractMethodError
goetz
parents: 29573
diff changeset
   421
               ((cb = CodeCache::find_blob(pc)) != NULL) &&
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37430
diff changeset
   422
               cb->is_compiled()) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   423
        if (TraceTraps) {
48506
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47765
diff changeset
   424
          tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (%s)", p2i(pc),
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47765
diff changeset
   425
                        (SafepointMechanism::uses_thread_local_poll() && USE_POLL_BIT_ONLY) ? "SIGTRAP" : "SIGSEGV");
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   426
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   427
        stub = SharedRuntime::get_poll_stub(pc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   428
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   429
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   430
      // SIGTRAP-based ic miss check in compiled code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   431
      else if (sig == SIGTRAP && TrapBasedICMissChecks &&
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   432
               nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   433
        if (TraceTraps) {
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 22861
diff changeset
   434
          tty->print_cr("trap: ic_miss_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   435
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   436
        stub = SharedRuntime::get_ic_miss_stub();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   437
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   438
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   439
      // SIGTRAP-based implicit null check in compiled code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   440
      else if (sig == SIGTRAP && TrapBasedNullChecks &&
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   441
               nativeInstruction_at(pc)->is_sigtrap_null_check()) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   442
        if (TraceTraps) {
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 22861
diff changeset
   443
          tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   444
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   445
        stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   446
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   447
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   448
      // SIGSEGV-based implicit null check in compiled code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   449
      else if (sig == SIGSEGV && ImplicitNullChecks &&
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   450
               CodeCache::contains((void*) pc) &&
52462
4ad404da0088 8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents: 52460
diff changeset
   451
               MacroAssembler::uses_implicit_null_check(info->si_addr)) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   452
        if (TraceTraps) {
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 22861
diff changeset
   453
          tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   454
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   455
        stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   456
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   457
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   458
#ifdef COMPILER2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   459
      // SIGTRAP-based implicit range check in compiled code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   460
      else if (sig == SIGTRAP && TrapBasedRangeChecks &&
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   461
               nativeInstruction_at(pc)->is_sigtrap_range_check()) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   462
        if (TraceTraps) {
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 22861
diff changeset
   463
          tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22824
diff changeset
   464
        }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   465
        stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   466
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   467
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   468
      else if (sig == SIGBUS) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   469
        // BugId 4454115: A read from a MappedByteBuffer can fault here if the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   470
        // underlying file has been truncated. Do not crash the VM in such a case.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   471
        CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37430
diff changeset
   472
        CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   473
        bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   474
        if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
38209
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   475
          address next_pc = pc + 4;
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   476
          if (is_unsafe_arraycopy) {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   477
            next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   478
          }
38209
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   479
          next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   480
          os::Linux::ucontext_set_pc(uc, next_pc);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   481
          return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   482
        }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   483
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   484
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   485
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   486
    else { // thread->thread_state() != _thread_in_Java
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   487
      if (sig == SIGILL && VM_Version::is_determine_features_test_running()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   488
        // SIGILL must be caused by VM_Version::determine_features().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   489
        *(int *)pc = 0; // patch instruction to 0 to indicate that it causes a SIGILL,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   490
                        // flushing of icache is not necessary.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   491
        stub = pc + 4;  // continue with next instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   492
      }
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   493
      else if ((thread->thread_state() == _thread_in_vm ||
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   494
                thread->thread_state() == _thread_in_native) &&
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   495
               sig == SIGBUS && thread->doing_unsafe_access()) {
38209
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   496
        address next_pc = pc + 4;
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   497
        if (UnsafeCopyMemory::contains_pc(pc)) {
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   498
          next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   499
        }
38209
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   500
        next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
55490
3f3dc00a69a5 8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents: 54717
diff changeset
   501
        os::Linux::ucontext_set_pc(uc, next_pc);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   502
        return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   503
      }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   504
    }
57594
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   505
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   506
    // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   507
    // and the heap gets shrunk before the field access.
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   508
    if ((sig == SIGSEGV) || (sig == SIGBUS)) {
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   509
      address addr = JNI_FastGetField::find_slowcase_pc(pc);
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   510
      if (addr != (address)-1) {
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   511
        stub = addr;
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   512
      }
61c2e3e7315d 8228743: [PPC64, s390] Implement FastJNIAccessors
mdoerr
parents: 55653
diff changeset
   513
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   514
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   515
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   516
  if (stub != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   517
    // Save all thread context in case we need to restore it.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   518
    if (thread != NULL) thread->set_saved_exception_pc(pc);
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 28187
diff changeset
   519
    os::Linux::ucontext_set_pc(uc, stub);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   520
    return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   521
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   522
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   523
  // signal-chaining
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   524
  if (os::Linux::chained_handler(sig, info, ucVoid)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   525
    return true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   526
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   527
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   528
  if (!abort_if_unrecognized) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   529
    // caller wants another chance, so give it to him
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   530
    return false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   531
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   532
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   533
  if (pc == NULL && uc != NULL) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   534
    pc = os::Linux::ucontext_get_pc(uc);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   535
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   536
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   537
report_and_die:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   538
  // unmask current signal
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   539
  sigset_t newset;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   540
  sigemptyset(&newset);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   541
  sigaddset(&newset, sig);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   542
  sigprocmask(SIG_UNBLOCK, &newset, NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   543
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32080
diff changeset
   544
  VMError::report_and_die(t, sig, pc, info, ucVoid);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   545
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   546
  ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   547
  return false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   548
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   549
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   550
void os::Linux::init_thread_fpu_state(void) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   551
  // Disable FP exceptions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   552
  __asm__ __volatile__ ("mtfsfi 6,0");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   553
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   554
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   555
int os::Linux::get_fpu_control_word(void) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   556
  // x86 has problems with FPU precision after pthread_cond_timedwait().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   557
  // nothing to do on ppc64.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   558
  return 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   559
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   560
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   561
void os::Linux::set_fpu_control_word(int fpu_control) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   562
  // x86 has problems with FPU precision after pthread_cond_timedwait().
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   563
  // nothing to do on ppc64.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   564
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   565
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   566
////////////////////////////////////////////////////////////////////////////////
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   567
// thread stack
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   568
42906
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   569
// Minimum usable stack sizes required to get to user code. Space for
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   570
// HotSpot guard pages is added later.
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   571
size_t os::Posix::_compiler_thread_min_stack_allowed = 64 * K;
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   572
size_t os::Posix::_java_thread_min_stack_allowed = 64 * K;
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   573
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 64 * K;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   574
42906
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   575
// Return default stack size for thr_type.
41070
496463b4e206 8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents: 40366
diff changeset
   576
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
42906
1a8db9cf1407 8170655: [posix] Fix minimum stack size computations
goetz
parents: 42905
diff changeset
   577
  // Default stack size (compiler thread needs larger stack).
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   578
  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   579
  return s;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   580
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   581
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   582
/////////////////////////////////////////////////////////////////////////////
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   583
// helper functions for fatal error handler
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   584
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   585
void os::print_context(outputStream *st, const void *context) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   586
  if (context == NULL) return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   587
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   588
  const ucontext_t* uc = (const ucontext_t*)context;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   589
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   590
  st->print_cr("Registers:");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   591
  st->print("pc =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->nip);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   592
  st->print("lr =" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->link);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   593
  st->print("ctr=" INTPTR_FORMAT "  ", uc->uc_mcontext.regs->ctr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   594
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   595
  for (int i = 0; i < 32; i++) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   596
    st->print("r%-2d=" INTPTR_FORMAT "  ", i, uc->uc_mcontext.regs->gpr[i]);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   597
    if (i % 3 == 2) st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   598
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   599
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   600
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   601
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   602
  intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 22861
diff changeset
   603
  st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   604
  print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   605
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   606
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   607
  // Note: it may be unsafe to inspect memory near pc. For example, pc may
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   608
  // point to garbage if entry point in an nmethod is corrupted. Leave
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   609
  // this at the end, and hope for the best.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   610
  address pc = os::Linux::ucontext_get_pc(uc);
53605
853c68ff2ed7 8217879: hs_err should print more instructions in hex dump
shade
parents: 52462
diff changeset
   611
  print_instructions(st, pc, /*instrsize=*/4);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   612
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   613
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   614
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   615
void os::print_register_info(outputStream *st, const void *context) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   616
  if (context == NULL) return;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   617
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   618
  const ucontext_t *uc = (const ucontext_t*)context;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   619
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   620
  st->print_cr("Register to memory mapping:");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   621
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   622
51139
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   623
  st->print("pc ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->nip);
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   624
  st->print("lr ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->link);
c95334202a14 8207342: error occurred during error reporting (printing register info)
mdoerr
parents: 49653
diff changeset
   625
  st->print("ctr ="); print_location(st, (intptr_t)uc->uc_mcontext.regs->ctr);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   626
  for (int i = 0; i < 32; i++) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   627
    st->print("r%-2d=", i);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   628
    print_location(st, uc->uc_mcontext.regs->gpr[i]);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   629
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   630
  st->cr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   631
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   632
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   633
extern "C" {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   634
  int SpinPause() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   635
    return 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   636
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   637
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   638
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   639
#ifndef PRODUCT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   640
void os::verify_stack_alignment() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   641
  assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   642
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   643
#endif
26576
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25374
diff changeset
   644
26582
b17d77706e6f 8057780: Fix ppc build after "8050147: StoreLoad barrier interferes with stack usages
simonis
parents: 26576
diff changeset
   645
int os::extra_bang_size_in_bytes() {
26576
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25374
diff changeset
   646
  // PPC does not require the additional stack bang.
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25374
diff changeset
   647
  return 0;
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25374
diff changeset
   648
}