hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp
author mikael
Fri, 06 May 2016 13:00:21 -0700
changeset 38209 b2a58604e046
parent 38190 ff9ac612c723
child 40010 e32d5e545789
permissions -rw-r--r--
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub Reviewed-by: stuefe, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     1
/*
37430
fd743dadef12 8151939: VM_Version_init() print buffer is too small
coleenp
parents: 35201
diff changeset
     2
 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     4
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     8
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    13
 * accompanied this code).
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    14
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5403
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5403
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5403
diff changeset
    21
 * questions.
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    22
 *
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    23
 */
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    25
// no precompiled headers
14631
526804361522 8003250: SPARC: move MacroAssembler into separate file
twisti
parents: 13963
diff changeset
    26
#include "asm/macroAssembler.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    27
#include "classfile/classLoader.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    28
#include "classfile/systemDictionary.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    29
#include "classfile/vmSymbols.hpp"
34667
6b077f0ef25d 8144881: Various fixes to linux/sparc
mikael
parents: 34633
diff changeset
    30
#include "code/codeCache.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    31
#include "code/icBuffer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    32
#include "code/vtableStubs.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    33
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    34
#include "jvm_linux.h"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    35
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    36
#include "mutex_linux.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    37
#include "nativeInst_sparc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    38
#include "os_share_linux.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    39
#include "prims/jniFastGetField.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    40
#include "prims/jvm.h"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    41
#include "prims/jvm_misc.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    42
#include "runtime/arguments.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    43
#include "runtime/extendedPC.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    44
#include "runtime/frame.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    45
#include "runtime/interfaceSupport.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    46
#include "runtime/java.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    47
#include "runtime/javaCalls.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    48
#include "runtime/mutexLocker.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    49
#include "runtime/osThread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    50
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    51
#include "runtime/stubRoutines.hpp"
14583
d70ee55535f4 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 13963
diff changeset
    52
#include "runtime/thread.inline.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    53
#include "runtime/timer.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    54
#include "utilities/events.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7108
diff changeset
    55
#include "utilities/vmError.hpp"
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    56
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    57
// Linux/Sparc has rather obscure naming of registers in sigcontext
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    58
// different between 32 and 64 bits
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    59
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    60
#define SIG_PC(x) ((x)->sigc_regs.tpc)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    61
#define SIG_NPC(x) ((x)->sigc_regs.tnpc)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    62
#define SIG_REGS(x) ((x)->sigc_regs)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    63
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    64
#define SIG_PC(x) ((x)->si_regs.pc)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    65
#define SIG_NPC(x) ((x)->si_regs.npc)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    66
#define SIG_REGS(x) ((x)->si_regs)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    67
#endif
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    68
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    69
// those are to reference registers in sigcontext
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    70
enum {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    71
  CON_G0 = 0,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    72
  CON_G1,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    73
  CON_G2,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    74
  CON_G3,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    75
  CON_G4,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    76
  CON_G5,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    77
  CON_G6,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    78
  CON_G7,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    79
  CON_O0,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    80
  CON_O1,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    81
  CON_O2,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    82
  CON_O3,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    83
  CON_O4,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    84
  CON_O5,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    85
  CON_O6,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    86
  CON_O7,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    87
};
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    88
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    89
// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    90
// currently interrupted by SIGPROF.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    91
// os::Solaris::fetch_frame_from_ucontext() tries to skip nested
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    92
// signal frames. Currently we don't do that on Linux, so it's the
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    93
// same as os::fetch_frame_from_context().
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    94
ExtendedPC os::Linux::fetch_frame_from_ucontext(Thread* thread,
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
    95
                                                const ucontext_t* uc,
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    96
                                                intptr_t** ret_sp,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    97
                                                intptr_t** ret_fp) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    98
  assert(thread != NULL, "just checking");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
    99
  assert(ret_sp != NULL, "just checking");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   100
  assert(ret_fp != NULL, "just checking");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   101
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   102
  return os::fetch_frame_from_context(uc, ret_sp, ret_fp);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   103
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   104
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   105
ExtendedPC os::fetch_frame_from_context(const void* ucVoid,
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   106
                                        intptr_t** ret_sp,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   107
                                        intptr_t** ret_fp) {
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   108
  const ucontext_t* uc = (const ucontext_t*) ucVoid;
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   109
  ExtendedPC  epc;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   110
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   111
  if (uc != NULL) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   112
    epc = ExtendedPC(os::Linux::ucontext_get_pc(uc));
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   113
    if (ret_sp) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   114
      *ret_sp = os::Linux::ucontext_get_sp(uc);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   115
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   116
    if (ret_fp) {
25722
72f566374afc 8050167: linux-sparcv9: hs_err file does not show any stack information
zgu
parents: 24917
diff changeset
   117
      *ret_fp = (intptr_t*)NULL;
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   118
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   119
  } else {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   120
    // construct empty ExtendedPC for return value checking
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   121
    epc = ExtendedPC(NULL);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   122
    if (ret_sp) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   123
      *ret_sp = (intptr_t*) NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   124
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   125
    if (ret_fp) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   126
      *ret_fp = (intptr_t*) NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   127
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   128
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   129
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   130
  return epc;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   131
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   132
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   133
frame os::fetch_frame_from_context(const void* ucVoid) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   134
  intptr_t* sp;
25722
72f566374afc 8050167: linux-sparcv9: hs_err file does not show any stack information
zgu
parents: 24917
diff changeset
   135
  ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, NULL);
72f566374afc 8050167: linux-sparcv9: hs_err file does not show any stack information
zgu
parents: 24917
diff changeset
   136
  return frame(sp, frame::unpatchable, epc.pc());
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   137
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   138
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   139
frame os::get_sender_for_C_frame(frame* fr) {
25718
6281d7800e8d 8050165: linux-sparcv9: NMT detail causes assert((intptr_t*)younger_sp[FP->sp_offset_in_saved_window()] == (intptr_t*)((intptr_t)sp - STACK_BIAS)) failed: younger_sp must be valid
zgu
parents: 24917
diff changeset
   140
  return frame(fr->sender_sp(), frame::unpatchable, fr->sender_pc());
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   141
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   142
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   143
frame os::current_frame() {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   144
  intptr_t* sp = StubRoutines::Sparc::flush_callers_register_windows_func()();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   145
  frame myframe(sp, frame::unpatchable,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   146
                CAST_FROM_FN_PTR(address, os::current_frame));
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   147
  if (os::is_first_C_frame(&myframe)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   148
    // stack is not walkable
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   149
    return frame(NULL, frame::unpatchable, NULL);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   150
  } else {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   151
    return os::get_sender_for_C_frame(&myframe);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   152
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   153
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   154
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   155
address os::current_stack_pointer() {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   156
  register void *sp __asm__ ("sp");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   157
  return (address)sp;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   158
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   159
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   160
static void current_stack_region(address* bottom, size_t* size) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   161
  if (os::Linux::is_initial_thread()) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   162
    // initial thread needs special handling because pthread_getattr_np()
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   163
    // may return bogus value.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   164
    *bottom = os::Linux::initial_thread_stack_bottom();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   165
    *size = os::Linux::initial_thread_stack_size();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   166
  } else {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   167
    pthread_attr_t attr;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   168
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   169
    int rslt = pthread_getattr_np(pthread_self(), &attr);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   170
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   171
    // JVM needs to know exact stack location, abort if it fails
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   172
    if (rslt != 0) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   173
      if (rslt == ENOMEM) {
17087
f0b76c4c93a0 8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents: 15926
diff changeset
   174
        vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np");
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   175
      } else {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32080
diff changeset
   176
        fatal("pthread_getattr_np failed with errno = %d", rslt);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   177
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   178
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   179
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   180
    if (pthread_attr_getstack(&attr, (void**)bottom, size) != 0) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   181
      fatal("Can not locate current stack attributes!");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   182
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   183
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   184
    pthread_attr_destroy(&attr);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   185
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   186
  assert(os::current_stack_pointer() >= *bottom &&
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   187
         os::current_stack_pointer() < *bottom + *size, "just checking");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   188
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   189
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   190
address os::current_stack_base() {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   191
  address bottom;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   192
  size_t size;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   193
  current_stack_region(&bottom, &size);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   194
  return bottom + size;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   195
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   196
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   197
size_t os::current_stack_size() {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   198
  // stack size includes normal stack and HotSpot guard pages
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   199
  address bottom;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   200
  size_t size;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   201
  current_stack_region(&bottom, &size);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   202
  return size;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   203
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   204
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   205
char* os::non_memory_address_word() {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   206
  // Must never look like an address returned by reserve_memory,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   207
  // even in its subfields (as defined by the CPU immediate fields,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   208
  // if the CPU splits constants across multiple instructions).
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   209
  // On SPARC, 0 != %hi(any real address), because there is no
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   210
  // allocation in the first 1Kb of the virtual address space.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   211
  return (char*) 0;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   212
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   213
13859
7fe4578493fc 7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents: 11961
diff changeset
   214
void os::initialize_thread(Thread* thr) {}
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   215
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   216
void os::print_context(outputStream *st, const void *context) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   217
  if (context == NULL) return;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   218
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   219
  const ucontext_t* uc = (const ucontext_t*)context;
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   220
  sigcontext* sc = (sigcontext*)context;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   221
  st->print_cr("Registers:");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   222
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   223
  st->print_cr(" G1=" INTPTR_FORMAT " G2=" INTPTR_FORMAT
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   224
               " G3=" INTPTR_FORMAT " G4=" INTPTR_FORMAT,
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   225
               SIG_REGS(sc).u_regs[CON_G1],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   226
               SIG_REGS(sc).u_regs[CON_G2],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   227
               SIG_REGS(sc).u_regs[CON_G3],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   228
               SIG_REGS(sc).u_regs[CON_G4]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   229
  st->print_cr(" G5=" INTPTR_FORMAT " G6=" INTPTR_FORMAT
24917
bf961166fa07 8044071: Print format/argument warnings
mikael
parents: 24327
diff changeset
   230
               " G7=" INTPTR_FORMAT " Y=0x%x",
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   231
               SIG_REGS(sc).u_regs[CON_G5],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   232
               SIG_REGS(sc).u_regs[CON_G6],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   233
               SIG_REGS(sc).u_regs[CON_G7],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   234
               SIG_REGS(sc).y);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   235
  st->print_cr(" O0=" INTPTR_FORMAT " O1=" INTPTR_FORMAT
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   236
               " O2=" INTPTR_FORMAT " O3=" INTPTR_FORMAT,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   237
               SIG_REGS(sc).u_regs[CON_O0],
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   238
               SIG_REGS(sc).u_regs[CON_O1],
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   239
               SIG_REGS(sc).u_regs[CON_O2],
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   240
               SIG_REGS(sc).u_regs[CON_O3]);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   241
  st->print_cr(" O4=" INTPTR_FORMAT " O5=" INTPTR_FORMAT
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   242
               " O6=" INTPTR_FORMAT " O7=" INTPTR_FORMAT,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   243
               SIG_REGS(sc).u_regs[CON_O4],
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   244
               SIG_REGS(sc).u_regs[CON_O5],
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   245
               SIG_REGS(sc).u_regs[CON_O6],
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   246
               SIG_REGS(sc).u_regs[CON_O7]);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   247
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   248
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   249
  intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   250
  st->print_cr(" L0=" INTPTR_FORMAT " L1=" INTPTR_FORMAT
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   251
               " L2=" INTPTR_FORMAT " L3=" INTPTR_FORMAT,
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   252
               sp[L0->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   253
               sp[L1->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   254
               sp[L2->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   255
               sp[L3->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   256
  st->print_cr(" L4=" INTPTR_FORMAT " L5=" INTPTR_FORMAT
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   257
               " L6=" INTPTR_FORMAT " L7=" INTPTR_FORMAT,
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   258
               sp[L4->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   259
               sp[L5->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   260
               sp[L6->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   261
               sp[L7->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   262
  st->print_cr(" I0=" INTPTR_FORMAT " I1=" INTPTR_FORMAT
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   263
               " I2=" INTPTR_FORMAT " I3=" INTPTR_FORMAT,
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   264
               sp[I0->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   265
               sp[I1->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   266
               sp[I2->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   267
               sp[I3->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   268
  st->print_cr(" I4=" INTPTR_FORMAT " I5=" INTPTR_FORMAT
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   269
               " I6=" INTPTR_FORMAT " I7=" INTPTR_FORMAT,
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   270
               sp[I4->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   271
               sp[I5->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   272
               sp[I6->sp_offset_in_saved_window()],
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   273
               sp[I7->sp_offset_in_saved_window()]);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   274
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   275
  st->print_cr(" PC=" INTPTR_FORMAT " nPC=" INTPTR_FORMAT,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   276
               SIG_PC(sc),
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   277
               SIG_NPC(sc));
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   278
  st->cr();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   279
  st->cr();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   280
24917
bf961166fa07 8044071: Print format/argument warnings
mikael
parents: 24327
diff changeset
   281
  st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", p2i(sp));
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   282
  print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   283
  st->cr();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   284
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   285
  // Note: it may be unsafe to inspect memory near pc. For example, pc may
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   286
  // point to garbage if entry point in an nmethod is corrupted. Leave
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   287
  // this at the end, and hope for the best.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   288
  address pc = os::Linux::ucontext_get_pc(uc);
24917
bf961166fa07 8044071: Print format/argument warnings
mikael
parents: 24327
diff changeset
   289
  st->print_cr("Instructions: (pc=" INTPTR_FORMAT ")", p2i(pc));
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   290
  print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   291
}
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   292
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   293
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   294
void os::print_register_info(outputStream *st, const void *context) {
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   295
  if (context == NULL) return;
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   296
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   297
  const ucontext_t *uc = (const ucontext_t*)context;
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   298
  const sigcontext* sc = (const sigcontext*)context;
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   299
  intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   300
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   301
  st->print_cr("Register to memory mapping:");
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   302
  st->cr();
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   303
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   304
  // this is only for the "general purpose" registers
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   305
  st->print("G1="); print_location(st, SIG_REGS(sc).u_regs[CON_G1]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   306
  st->print("G2="); print_location(st, SIG_REGS(sc).u_regs[CON_G2]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   307
  st->print("G3="); print_location(st, SIG_REGS(sc).u_regs[CON_G3]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   308
  st->print("G4="); print_location(st, SIG_REGS(sc).u_regs[CON_G4]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   309
  st->print("G5="); print_location(st, SIG_REGS(sc).u_regs[CON_G5]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   310
  st->print("G6="); print_location(st, SIG_REGS(sc).u_regs[CON_G6]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   311
  st->print("G7="); print_location(st, SIG_REGS(sc).u_regs[CON_G7]);
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   312
  st->cr();
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   313
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   314
  st->print("O0="); print_location(st, SIG_REGS(sc).u_regs[CON_O0]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   315
  st->print("O1="); print_location(st, SIG_REGS(sc).u_regs[CON_O1]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   316
  st->print("O2="); print_location(st, SIG_REGS(sc).u_regs[CON_O2]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   317
  st->print("O3="); print_location(st, SIG_REGS(sc).u_regs[CON_O3]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   318
  st->print("O4="); print_location(st, SIG_REGS(sc).u_regs[CON_O4]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   319
  st->print("O5="); print_location(st, SIG_REGS(sc).u_regs[CON_O5]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   320
  st->print("O6="); print_location(st, SIG_REGS(sc).u_regs[CON_O6]);
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   321
  st->print("O7="); print_location(st, SIG_REGS(sc).u_regs[CON_O7]);
7108
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   322
  st->cr();
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   323
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   324
  st->print("L0="); print_location(st, sp[L0->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   325
  st->print("L1="); print_location(st, sp[L1->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   326
  st->print("L2="); print_location(st, sp[L2->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   327
  st->print("L3="); print_location(st, sp[L3->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   328
  st->print("L4="); print_location(st, sp[L4->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   329
  st->print("L5="); print_location(st, sp[L5->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   330
  st->print("L6="); print_location(st, sp[L6->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   331
  st->print("L7="); print_location(st, sp[L7->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   332
  st->cr();
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   333
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   334
  st->print("I0="); print_location(st, sp[I0->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   335
  st->print("I1="); print_location(st, sp[I1->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   336
  st->print("I2="); print_location(st, sp[I2->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   337
  st->print("I3="); print_location(st, sp[I3->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   338
  st->print("I4="); print_location(st, sp[I4->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   339
  st->print("I5="); print_location(st, sp[I5->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   340
  st->print("I6="); print_location(st, sp[I6->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   341
  st->print("I7="); print_location(st, sp[I7->sp_offset_in_saved_window()]);
4f87b92f3060 6970683: improvements to hs_err output
never
parents: 5547
diff changeset
   342
  st->cr();
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   343
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   344
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   345
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   346
address os::Linux::ucontext_get_pc(const ucontext_t* uc) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   347
  return (address) SIG_PC((sigcontext*)uc);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   348
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   349
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 26576
diff changeset
   350
void os::Linux::ucontext_set_pc(ucontext_t* uc, address pc) {
34667
6b077f0ef25d 8144881: Various fixes to linux/sparc
mikael
parents: 34633
diff changeset
   351
  sigcontext* ctx = (sigcontext*) uc;
6b077f0ef25d 8144881: Various fixes to linux/sparc
mikael
parents: 34633
diff changeset
   352
  SIG_PC(ctx)  = (intptr_t)pc;
6b077f0ef25d 8144881: Various fixes to linux/sparc
mikael
parents: 34633
diff changeset
   353
  SIG_NPC(ctx) = (intptr_t)(pc+4);
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 26576
diff changeset
   354
}
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 26576
diff changeset
   355
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   356
intptr_t* os::Linux::ucontext_get_sp(const ucontext_t *uc) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   357
  return (intptr_t*)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   358
    ((intptr_t)SIG_REGS((sigcontext*)uc).u_regs[CON_O6] + STACK_BIAS);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   359
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   360
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   361
// not used on Sparc
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   362
intptr_t* os::Linux::ucontext_get_fp(const ucontext_t *uc) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   363
  ShouldNotReachHere();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   364
  return NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   365
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   366
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   367
// Utility functions
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   368
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   369
inline static bool checkPrefetch(sigcontext* uc, address pc) {
18740
db44b1599483 8016697: Use stubs to implement safefetch
goetz
parents: 17087
diff changeset
   370
  if (StubRoutines::is_safefetch_fault(pc)) {
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 26576
diff changeset
   371
    os::Linux::ucontext_set_pc((ucontext_t*)uc, StubRoutines::continuation_for_safefetch_fault(pc));
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   372
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   373
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   374
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   375
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   376
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   377
inline static bool checkOverflow(sigcontext* uc,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   378
                                 address pc,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   379
                                 address addr,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   380
                                 JavaThread* thread,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   381
                                 address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   382
  // check if fault address is within thread stack
35201
996db89f378e 8139864: Improve handling of stack protection zones.
goetz
parents: 35077
diff changeset
   383
  if (thread->on_local_stack(addr)) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   384
    // stack overflow
35201
996db89f378e 8139864: Improve handling of stack protection zones.
goetz
parents: 35077
diff changeset
   385
    if (thread->in_stack_yellow_reserved_zone(addr)) {
996db89f378e 8139864: Improve handling of stack protection zones.
goetz
parents: 35077
diff changeset
   386
      thread->disable_stack_yellow_reserved_zone();
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   387
      if (thread->thread_state() == _thread_in_Java) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   388
        // Throw a stack overflow exception.  Guard pages will be reenabled
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   389
        // while unwinding the stack.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   390
        *stub =
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   391
          SharedRuntime::continuation_for_implicit_exception(thread,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   392
                                                             pc,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   393
                                                             SharedRuntime::STACK_OVERFLOW);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   394
      } else {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   395
        // Thread was in the vm or native code.  Return and try to finish.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   396
        return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   397
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   398
    } else if (thread->in_stack_red_zone(addr)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   399
      // Fatal red zone violation.  Disable the guard pages and fall through
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   400
      // to handle_unexpected_exception way down below.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   401
      thread->disable_stack_red_zone();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   402
      tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
15926
8e87d545195f 7107135: Stack guard pages are no more protected after loading a shared library with executable stack
iklam
parents: 14633
diff changeset
   403
8e87d545195f 7107135: Stack guard pages are no more protected after loading a shared library with executable stack
iklam
parents: 14633
diff changeset
   404
      // This is a likely cause, but hard to verify. Let's just print
8e87d545195f 7107135: Stack guard pages are no more protected after loading a shared library with executable stack
iklam
parents: 14633
diff changeset
   405
      // it as a hint.
8e87d545195f 7107135: Stack guard pages are no more protected after loading a shared library with executable stack
iklam
parents: 14633
diff changeset
   406
      tty->print_raw_cr("Please check if any of your loaded .so files has "
8e87d545195f 7107135: Stack guard pages are no more protected after loading a shared library with executable stack
iklam
parents: 14633
diff changeset
   407
                        "enabled executable stack (see man page execstack(8))");
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   408
    } else {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   409
      // Accessing stack address below sp may cause SEGV if current
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   410
      // thread has MAP_GROWSDOWN stack. This should only happen when
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   411
      // current thread was created by user code with MAP_GROWSDOWN flag
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   412
      // and then attached to VM. See notes in os_linux.cpp.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   413
      if (thread->osthread()->expanding_stack() == 0) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   414
        thread->osthread()->set_expanding_stack();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   415
        if (os::Linux::manually_expand_stack(thread, addr)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   416
          thread->osthread()->clear_expanding_stack();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   417
          return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   418
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   419
        thread->osthread()->clear_expanding_stack();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   420
      } else {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   421
        fatal("recursive segv. expanding stack.");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   422
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   423
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   424
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   425
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   426
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   427
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   428
inline static bool checkPollingPage(address pc, address fault, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   429
  if (fault == os::get_polling_page()) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   430
    *stub = SharedRuntime::get_poll_stub(pc);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   431
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   432
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   433
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   434
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   435
38209
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   436
inline static bool checkByteBuffer(address pc, address npc, address* stub) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   437
  // BugId 4454115: A read from a MappedByteBuffer can fault
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   438
  // here if the underlying file has been truncated.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   439
  // Do not crash the VM in such a case.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   440
  CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
38133
78b95467b9f1 8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents: 37430
diff changeset
   441
  CompiledMethod* nm = cb->as_compiled_method_or_null();
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   442
  if (nm != NULL && nm->has_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
   443
    *stub = SharedRuntime::handle_unsafe_access(thread, npc);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   444
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   445
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   446
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   447
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   448
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   449
inline static bool checkVerifyOops(address pc, address fault, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   450
  if (pc >= MacroAssembler::_verify_oop_implicit_branch[0]
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   451
      && pc <  MacroAssembler::_verify_oop_implicit_branch[1] ) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   452
    *stub     =  MacroAssembler::_verify_oop_implicit_branch[2];
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   453
    warning("fixed up memory fault in +VerifyOops at address "
24917
bf961166fa07 8044071: Print format/argument warnings
mikael
parents: 24327
diff changeset
   454
            INTPTR_FORMAT, p2i(fault));
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   455
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   456
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   457
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   458
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   459
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   460
inline static bool checkFPFault(address pc, int code,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   461
                                JavaThread* thread, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   462
  if (code == FPE_INTDIV || code == FPE_FLTDIV) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   463
    *stub =
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   464
      SharedRuntime::
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   465
      continuation_for_implicit_exception(thread,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   466
                                          pc,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   467
                                          SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   468
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   469
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   470
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   471
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   472
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   473
inline static bool checkNullPointer(address pc, intptr_t fault,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   474
                                    JavaThread* thread, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   475
  if (!MacroAssembler::needs_explicit_null_check(fault)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   476
    // Determination of interpreter/vtable stub/compiled code null
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   477
    // exception
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   478
    *stub =
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   479
      SharedRuntime::
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   480
      continuation_for_implicit_exception(thread, pc,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   481
                                          SharedRuntime::IMPLICIT_NULL);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   482
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   483
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   484
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   485
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   486
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   487
inline static bool checkFastJNIAccess(address pc, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   488
  address addr = JNI_FastGetField::find_slowcase_pc(pc);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   489
  if (addr != (address)-1) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   490
    *stub = addr;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   491
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   492
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   493
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   494
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   495
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   496
inline static bool checkSerializePage(JavaThread* thread, address addr) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   497
  return os::is_memory_serialize_page(thread, addr);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   498
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   499
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   500
inline static bool checkZombie(sigcontext* uc, address* pc, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   501
  if (nativeInstruction_at(*pc)->is_zombie()) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   502
    // zombie method (ld [%g0],%o7 instruction)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   503
    *stub = SharedRuntime::get_handle_wrong_method_stub();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   504
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   505
    // At the stub it needs to look like a call from the caller of this
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   506
    // method (not a call from the segv site).
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   507
    *pc = (address)SIG_REGS(uc).u_regs[CON_O7];
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   508
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   509
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   510
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   511
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   512
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   513
inline static bool checkICMiss(sigcontext* uc, address* pc, address* stub) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   514
#ifdef COMPILER2
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   515
  if (nativeInstruction_at(*pc)->is_ic_miss_trap()) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   516
#ifdef ASSERT
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   517
#ifdef TIERED
24327
d8d91481f76e 8042059: Various fixes to linux/sparc
mikael
parents: 22234
diff changeset
   518
    CodeBlob* cb = CodeCache::find_blob_unsafe(*pc);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   519
    assert(cb->is_compiled_by_c2(), "Wrong compiler");
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   520
#endif // TIERED
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   521
#endif // ASSERT
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   522
    // Inline cache missed and user trap "Tne G0+ST_RESERVED_FOR_USER_0+2" taken.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   523
    *stub = SharedRuntime::get_ic_miss_stub();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   524
    // At the stub it needs to look like a call from the caller of this
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   525
    // method (not a call from the segv site).
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   526
    *pc = (address)SIG_REGS(uc).u_regs[CON_O7];
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   527
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   528
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   529
#endif  // COMPILER2
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   530
  return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   531
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   532
8106
19106a0203fb 6588413: Use -fvisibility=hidden for gcc compiles
coleenp
parents: 7405
diff changeset
   533
extern "C" JNIEXPORT int
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   534
JVM_handle_linux_signal(int sig,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   535
                        siginfo_t* info,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   536
                        void* ucVoid,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   537
                        int abort_if_unrecognized) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   538
  // in fact this isn't ucontext_t* at all, but struct sigcontext*
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   539
  // but Linux porting layer uses ucontext_t, so to minimize code change
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   540
  // we cast as needed
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   541
  ucontext_t* ucFake = (ucontext_t*) ucVoid;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   542
  sigcontext* uc = (sigcontext*)ucVoid;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   543
34633
2a6c7c7b30a7 8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents: 33105
diff changeset
   544
  Thread* t = Thread::current_or_null_safe();
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   545
18943
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 17087
diff changeset
   546
  // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 17087
diff changeset
   547
  // (no destructors can be run)
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 17087
diff changeset
   548
  os::WatcherThreadCrashProtection::check_crash_protection(sig, t);
7d0ef675e808 8020701: Avoid crashes in WatcherThread
rbackman
parents: 17087
diff changeset
   549
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   550
  SignalHandlerMark shm(t);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   551
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   552
  // Note: it's not uncommon that JNI code uses signal/sigset to install
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   553
  // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   554
  // or have a SIGILL handler when detecting CPU type). When that happens,
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   555
  // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   556
  // avoid unnecessary crash when libjsig is not preloaded, try handle signals
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   557
  // that do not require siginfo/ucontext first.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   558
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   559
  if (sig == SIGPIPE || sig == SIGXFSZ) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   560
    // allow chained handler to go first
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   561
    if (os::Linux::chained_handler(sig, info, ucVoid)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   562
      return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   563
    } else {
37430
fd743dadef12 8151939: VM_Version_init() print buffer is too small
coleenp
parents: 35201
diff changeset
   564
      // Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   565
      return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   566
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   567
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   568
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   569
  JavaThread* thread = NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   570
  VMThread* vmthread = NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   571
  if (os::Linux::signal_handlers_are_installed) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   572
    if (t != NULL ){
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   573
      if(t->is_Java_thread()) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   574
        thread = (JavaThread*)t;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   575
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   576
      else if(t->is_VM_thread()){
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   577
        vmthread = (VMThread *)t;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   578
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   579
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   580
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   581
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   582
  // decide if this trap can be handled by a stub
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   583
  address stub = NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   584
  address pc = NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   585
  address npc = NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   586
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   587
  //%note os_trap_1
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   588
  if (info != NULL && uc != NULL && thread != NULL) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   589
    pc = address(SIG_PC(uc));
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   590
    npc = address(SIG_NPC(uc));
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   591
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   592
    // Check to see if we caught the safepoint code in the
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   593
    // process of write protecting the memory serialization page.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   594
    // It write enables the page immediately after protecting it
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   595
    // so we can just return to retry the write.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   596
    if ((sig == SIGSEGV) && checkSerializePage(thread, (address)info->si_addr)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   597
      // Block current thread until the memory serialize page permission restored.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   598
      os::block_on_serialize_page_trap();
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   599
      return 1;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   600
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   601
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   602
    if (checkPrefetch(uc, pc)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   603
      return 1;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   604
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   605
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   606
    // Handle ALL stack overflow variations here
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   607
    if (sig == SIGSEGV) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   608
      if (checkOverflow(uc, pc, (address)info->si_addr, thread, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   609
        return 1;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   610
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   611
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   612
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   613
    if (sig == SIGBUS &&
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   614
        thread->thread_state() == _thread_in_vm &&
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   615
        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
   616
      stub = SharedRuntime::handle_unsafe_access(thread, npc);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   617
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   618
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   619
    if (thread->thread_state() == _thread_in_Java) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   620
      do {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   621
        // Java thread running in Java code => find exception handler if any
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   622
        // a fault inside compiled code, the interpreter, or a stub
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   623
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   624
        if ((sig == SIGSEGV) && checkPollingPage(pc, (address)info->si_addr, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   625
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   626
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   627
38209
b2a58604e046 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents: 38190
diff changeset
   628
        if ((sig == SIGBUS) && checkByteBuffer(pc, npc, &stub)) {
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   629
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   630
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   631
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   632
        if ((sig == SIGSEGV || sig == SIGBUS) &&
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   633
            checkVerifyOops(pc, (address)info->si_addr, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   634
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   635
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   636
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   637
        if ((sig == SIGSEGV) && checkZombie(uc, &pc, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   638
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   639
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   640
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   641
        if ((sig == SIGILL) && checkICMiss(uc, &pc, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   642
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   643
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   644
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   645
        if ((sig == SIGFPE) && checkFPFault(pc, info->si_code, thread, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   646
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   647
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   648
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   649
        if ((sig == SIGSEGV) &&
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   650
            checkNullPointer(pc, (intptr_t)info->si_addr, thread, &stub)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   651
          break;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   652
        }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   653
      } while (0);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   654
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   655
      // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   656
      // and the heap gets shrunk before the field access.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   657
      if ((sig == SIGSEGV) || (sig == SIGBUS)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   658
        checkFastJNIAccess(pc, &stub);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   659
      }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   660
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   661
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   662
    if (stub != NULL) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   663
      // save all thread context in case we need to restore it
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   664
      thread->set_saved_exception_pc(pc);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   665
      thread->set_saved_exception_npc(npc);
29573
2d800e5d575f 8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents: 26576
diff changeset
   666
      os::Linux::ucontext_set_pc((ucontext_t*)uc, stub);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   667
      return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   668
    }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   669
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   670
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   671
  // signal-chaining
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   672
  if (os::Linux::chained_handler(sig, info, ucVoid)) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   673
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   674
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   675
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   676
  if (!abort_if_unrecognized) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   677
    // caller wants another chance, so give it to him
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   678
    return false;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   679
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   680
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   681
  if (pc == NULL && uc != NULL) {
35077
8b86440d3bf1 8145114: const-correctness for ucontext_t* reading functions
stuefe
parents: 34667
diff changeset
   682
    pc = os::Linux::ucontext_get_pc((const ucontext_t*)uc);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   683
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   684
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   685
  // unmask current signal
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   686
  sigset_t newset;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   687
  sigemptyset(&newset);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   688
  sigaddset(&newset, sig);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   689
  sigprocmask(SIG_UNBLOCK, &newset, NULL);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   690
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32080
diff changeset
   691
  VMError::report_and_die(t, sig, pc, info, ucVoid);
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   692
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   693
  ShouldNotReachHere();
34667
6b077f0ef25d 8144881: Various fixes to linux/sparc
mikael
parents: 34633
diff changeset
   694
  return false;
380
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   695
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   696
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   697
void os::Linux::init_thread_fpu_state(void) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   698
  // Nothing to do
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   699
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   700
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   701
int os::Linux::get_fpu_control_word() {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   702
  return 0;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   703
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   704
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   705
void os::Linux::set_fpu_control_word(int fpu) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   706
  // nothing
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   707
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   708
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   709
bool os::is_allocatable(size_t bytes) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   710
#ifdef _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   711
  return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   712
#else
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   713
  if (bytes < 2 * G) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   714
    return true;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   715
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   716
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   717
  char* addr = reserve_memory(bytes, NULL);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   718
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   719
  if (addr != NULL) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   720
    release_memory(addr, bytes);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   721
  }
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   722
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   723
  return addr != NULL;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   724
#endif // _LP64
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   725
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   726
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   727
///////////////////////////////////////////////////////////////////////////////
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   728
// thread stack
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   729
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   730
size_t os::Linux::min_stack_allowed  = 128 * K;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   731
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   732
// return default stack size for thr_type
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   733
size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   734
  // default stack size (compiler thread needs larger stack)
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   735
  size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   736
  return s;
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   737
}
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   738
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   739
size_t os::Linux::default_guard_size(os::ThreadType thr_type) {
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   740
  // Creating guard page is very expensive. Java thread has HotSpot
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   741
  // guard page, only enable glibc guard page for non-Java threads.
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   742
  return (thr_type == java_thread ? 0 : page_size());
ec5fd25a5edf 6693457: Open-source hotspot linux-sparc support
phh
parents:
diff changeset
   743
}
11961
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 8921
diff changeset
   744
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 8921
diff changeset
   745
#ifndef PRODUCT
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 8921
diff changeset
   746
void os::verify_stack_alignment() {
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 8921
diff changeset
   747
}
0abd4cd26e5a 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 8921
diff changeset
   748
#endif
26576
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25723
diff changeset
   749
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25723
diff changeset
   750
int os::extra_bang_size_in_bytes() {
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25723
diff changeset
   751
  // SPARC does not require the additional stack bang.
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25723
diff changeset
   752
  return 0;
a9429d24d429 8050147: StoreLoad barrier interferes with stack usages
shade
parents: 25723
diff changeset
   753
}