annotate src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @ 20710:c5e86c5cd22e

8066964: ppc64: argument and return type profiling, fix problem with popframe Reviewed-by: roland, kvn
author goetz
date Fri, 12 Dec 2014 08:48:56 +0100
parents 71a71b0bc844
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
1 /*
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
17807
71a71b0bc844 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 14445
diff changeset
3 * Copyright 2012, 2014 SAP AG. All rights reserved.
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
5 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
6 * This code is free software; you can redistribute it and/or modify it
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
7 * under the terms of the GNU General Public License version 2 only, as
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
8 * published by the Free Software Foundation.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
9 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
10 * This code is distributed in the hope that it will be useful, but WITHOUT
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
13 * version 2 for more details (a copy is included in the LICENSE file that
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
14 * accompanied this code).
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
15 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License version
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
17 * 2 along with this work; if not, write to the Free Software Foundation,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
19 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
21 * or visit www.oracle.com if you need additional information or have any
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
22 * questions.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
23 *
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
24 */
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
25
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
26 // no precompiled headers
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
27 #include "assembler_ppc.inline.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
28 #include "classfile/classLoader.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
29 #include "classfile/systemDictionary.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
30 #include "classfile/vmSymbols.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
31 #include "code/icBuffer.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
32 #include "code/vtableStubs.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
33 #include "interpreter/interpreter.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
34 #include "jvm_aix.h"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
35 #include "memory/allocation.inline.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
36 #include "mutex_aix.inline.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
37 #include "nativeInst_ppc.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
38 #include "os_share_aix.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
39 #include "prims/jniFastGetField.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
40 #include "prims/jvm.h"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
41 #include "prims/jvm_misc.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
42 #include "runtime/arguments.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
43 #include "runtime/extendedPC.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
44 #include "runtime/frame.inline.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
45 #include "runtime/interfaceSupport.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
46 #include "runtime/java.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
47 #include "runtime/javaCalls.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
48 #include "runtime/mutexLocker.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
49 #include "runtime/osThread.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
50 #include "runtime/sharedRuntime.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
51 #include "runtime/stubRoutines.hpp"
17807
71a71b0bc844 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 14445
diff changeset
52 #include "runtime/thread.inline.hpp"
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
53 #include "runtime/timer.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
54 #include "utilities/events.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
55 #include "utilities/vmError.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
56 #ifdef COMPILER1
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
57 #include "c1/c1_Runtime1.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
58 #endif
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
59 #ifdef COMPILER2
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
60 #include "opto/runtime.hpp"
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
61 #endif
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
62
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
63 // put OS-includes here
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
64 # include <ucontext.h>
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
65
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
66 address os::current_stack_pointer() {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
67 address csp;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
68
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
69 #if !defined(USE_XLC_BUILTINS)
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
70 // inline assembly for `mr regno(csp), R1_SP':
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
71 __asm__ __volatile__ ("mr %0, 1":"=r"(csp):);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
72 #else
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
73 csp = (address) __builtin_frame_address(0);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
74 #endif
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
75
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
76 return csp;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
77 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
78
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
79 char* os::non_memory_address_word() {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
80 // Must never look like an address returned by reserve_memory,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
81 // even in its subfields (as defined by the CPU immediate fields,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
82 // if the CPU splits constants across multiple instructions).
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
83
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
84 return (char*) -1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
85 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
86
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
87 // OS specific thread initialization
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
88 //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
89 // Calculate and store the limits of the memory stack.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
90 void os::initialize_thread(Thread *thread) { }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
91
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
92 // Frame information (pc, sp, fp) retrieved via ucontext
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
93 // always looks like a C-frame according to the frame
20710
c5e86c5cd22e 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 17807
diff changeset
94 // conventions in frame_ppc.hpp.
c5e86c5cd22e 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 17807
diff changeset
95
c5e86c5cd22e 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 17807
diff changeset
96 address os::Aix::ucontext_get_pc(const ucontext_t * uc) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
97 return (address)uc->uc_mcontext.jmp_context.iar;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
98 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
99
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
100 intptr_t* os::Aix::ucontext_get_sp(ucontext_t * uc) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
101 // gpr1 holds the stack pointer on aix
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
102 return (intptr_t*)uc->uc_mcontext.jmp_context.gpr[1/*REG_SP*/];
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
103 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
104
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
105 intptr_t* os::Aix::ucontext_get_fp(ucontext_t * uc) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
106 return NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
107 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
108
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
109 void os::Aix::ucontext_set_pc(ucontext_t* uc, address new_pc) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
110 uc->uc_mcontext.jmp_context.iar = (uint64_t) new_pc;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
111 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
112
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
113 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
114 intptr_t** ret_sp, intptr_t** ret_fp) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
115
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
116 ExtendedPC epc;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
117 ucontext_t* uc = (ucontext_t*)ucVoid;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
118
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
119 if (uc != NULL) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
120 epc = ExtendedPC(os::Aix::ucontext_get_pc(uc));
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
121 if (ret_sp) *ret_sp = os::Aix::ucontext_get_sp(uc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
122 if (ret_fp) *ret_fp = os::Aix::ucontext_get_fp(uc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
123 } else {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
124 // construct empty ExtendedPC for return value checking
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
125 epc = ExtendedPC(NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
126 if (ret_sp) *ret_sp = (intptr_t *)NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
127 if (ret_fp) *ret_fp = (intptr_t *)NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
128 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
129
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
130 return epc;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
131 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
132
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
133 frame os::fetch_frame_from_context(void* ucVoid) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
134 intptr_t* sp;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
135 intptr_t* fp;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
136 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
137 // Avoid crash during crash if pc broken.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
138 if (epc.pc()) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
139 frame fr(sp, epc.pc());
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
140 return fr;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
141 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
142 frame fr(sp);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
143 return fr;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
144 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
145
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
146 frame os::get_sender_for_C_frame(frame* fr) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
147 if (*fr->sp() == NULL) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
148 // fr is the last C frame
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
149 return frame(NULL, NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
150 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
151 return frame(fr->sender_sp(), fr->sender_pc());
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
152 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
153
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
154
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
155 frame os::current_frame() {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
156 intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer());
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
157 // hack.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
158 frame topframe(csp, (address)0x8);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
159 // return sender of current topframe which hopefully has pc != NULL.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
160 return os::get_sender_for_C_frame(&topframe);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
161 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
162
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
163 // Utility functions
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
164
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
165 extern "C" JNIEXPORT int
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
166 JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrecognized) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
167
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
168 ucontext_t* uc = (ucontext_t*) ucVoid;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
169
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
170 Thread* t = ThreadLocalStorage::get_thread_slow(); // slow & steady
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
171
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
172 SignalHandlerMark shm(t);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
173
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
174 // Note: it's not uncommon that JNI code uses signal/sigset to install
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
175 // then restore certain signal handler (e.g. to temporarily block SIGPIPE,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
176 // or have a SIGILL handler when detecting CPU type). When that happens,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
177 // JVM_handle_aix_signal() might be invoked with junk info/ucVoid. To
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
178 // avoid unnecessary crash when libjsig is not preloaded, try handle signals
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
179 // that do not require siginfo/ucontext first.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
180
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
181 if (sig == SIGPIPE) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
182 if (os::Aix::chained_handler(sig, info, ucVoid)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
183 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
184 } else {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
185 if (PrintMiscellaneous && (WizardMode || Verbose)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
186 warning("Ignoring SIGPIPE - see bug 4229104");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
187 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
188 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
189 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
190 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
191
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
192 JavaThread* thread = NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
193 VMThread* vmthread = NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
194 if (os::Aix::signal_handlers_are_installed) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
195 if (t != NULL) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
196 if(t->is_Java_thread()) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
197 thread = (JavaThread*)t;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
198 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
199 else if(t->is_VM_thread()) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
200 vmthread = (VMThread *)t;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
201 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
202 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
203 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
204
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
205 // Decide if this trap can be handled by a stub.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
206 address stub = NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
207
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
208 // retrieve program counter
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
209 address const pc = uc ? os::Aix::ucontext_get_pc(uc) : NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
210
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
211 // retrieve crash address
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
212 address const addr = info ? (const address) info->si_addr : NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
213
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
214 // SafeFetch 32 handling:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
215 // - make it work if _thread is null
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
216 // - make it use the standard os::...::ucontext_get/set_pc APIs
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
217 if (uc) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
218 address const pc = os::Aix::ucontext_get_pc(uc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
219 if (pc && StubRoutines::is_safefetch_fault(pc)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
220 os::Aix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
221 return true;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
222 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
223 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
224
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
225 // Handle SIGDANGER right away. AIX would raise SIGDANGER whenever available swap
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
226 // space falls below 30%. This is only a chance for the process to gracefully abort.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
227 // We can't hope to proceed after SIGDANGER since SIGKILL tailgates.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
228 if (sig == SIGDANGER) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
229 goto report_and_die;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
230 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
231
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
232 if (info == NULL || uc == NULL || thread == NULL && vmthread == NULL) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
233 goto run_chained_handler;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
234 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
235
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
236 // If we are a java thread...
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
237 if (thread != NULL) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
238
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
239 // Handle ALL stack overflow variations here
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
240 if (sig == SIGSEGV && (addr < thread->stack_base() &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
241 addr >= thread->stack_base() - thread->stack_size())) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
242 // stack overflow
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
243 //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
244 // If we are in a yellow zone and we are inside java, we disable the yellow zone and
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
245 // throw a stack overflow exception.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
246 // If we are in native code or VM C code, we report-and-die. The original coding tried
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
247 // to continue with yellow zone disabled, but that doesn't buy us much and prevents
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
248 // hs_err_pid files.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
249 if (thread->in_stack_yellow_zone(addr)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
250 thread->disable_stack_yellow_zone();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
251 if (thread->thread_state() == _thread_in_Java) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
252 // Throw a stack overflow exception.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
253 // Guard pages will be reenabled while unwinding the stack.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
254 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
255 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
256 } else {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
257 // Thread was in the vm or native code. Return and try to finish.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
258 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
259 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
260 } else if (thread->in_stack_red_zone(addr)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
261 // Fatal red zone violation. Disable the guard pages and fall through
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
262 // to handle_unexpected_exception way down below.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
263 thread->disable_stack_red_zone();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
264 tty->print_raw_cr("An irrecoverable stack overflow has occurred.");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
265 goto report_and_die;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
266 } else {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
267 // This means a segv happened inside our stack, but not in
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
268 // the guarded zone. I'd like to know when this happens,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
269 tty->print_raw_cr("SIGSEGV happened inside stack but outside yellow and red zone.");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
270 goto report_and_die;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
271 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
272
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
273 } // end handle SIGSEGV inside stack boundaries
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
274
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
275 if (thread->thread_state() == _thread_in_Java) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
276 // Java thread running in Java code
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
277
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
278 // The following signals are used for communicating VM events:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
279 //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
280 // SIGILL: the compiler generates illegal opcodes
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
281 // at places where it wishes to interrupt the VM:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
282 // Safepoints, Unreachable Code, Entry points of Zombie methods,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
283 // This results in a SIGILL with (*pc) == inserted illegal instruction.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
284 //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
285 // (so, SIGILLs with a pc inside the zero page are real errors)
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
286 //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
287 // SIGTRAP:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
288 // The ppc trap instruction raises a SIGTRAP and is very efficient if it
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
289 // does not trap. It is used for conditional branches that are expected
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
290 // to be never taken. These are:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
291 // - zombie methods
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
292 // - IC (inline cache) misses.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
293 // - null checks leading to UncommonTraps.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
294 // - range checks leading to Uncommon Traps.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
295 // On Aix, these are especially null checks, as the ImplicitNullCheck
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
296 // optimization works only in rare cases, as the page at address 0 is only
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
297 // write protected. //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
298 // Note: !UseSIGTRAP is used to prevent SIGTRAPS altogether, to facilitate debugging.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
299 //
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
300 // SIGSEGV:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
301 // used for safe point polling:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
302 // To notify all threads that they have to reach a safe point, safe point polling is used:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
303 // All threads poll a certain mapped memory page. Normally, this page has read access.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
304 // If the VM wants to inform the threads about impending safe points, it puts this
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
305 // page to read only ("poisens" the page), and the threads then reach a safe point.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
306 // used for null checks:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
307 // If the compiler finds a store it uses it for a null check. Unfortunately this
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
308 // happens rarely. In heap based and disjoint base compressd oop modes also loads
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
309 // are used for null checks.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
310
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
311 // A VM-related SIGILL may only occur if we are not in the zero page.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
312 // On AIX, we get a SIGILL if we jump to 0x0 or to somewhere else
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
313 // in the zero page, because it is filled with 0x0. We ignore
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
314 // explicit SIGILLs in the zero page.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
315 if (sig == SIGILL && (pc < (address) 0x200)) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
316 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
317 tty->print_raw_cr("SIGILL happened inside zero page.");
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
318 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
319 goto report_and_die;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
320 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
321
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
322 // Handle signal from NativeJump::patch_verified_entry().
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
323 if (( TrapBasedNotEntrantChecks && sig == SIGTRAP && nativeInstruction_at(pc)->is_sigtrap_zombie_not_entrant()) ||
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
324 (!TrapBasedNotEntrantChecks && sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant())) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
325 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
326 tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL");
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
327 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
328 stub = SharedRuntime::get_handle_wrong_method_stub();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
329 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
330 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
331
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
332 else if (sig == SIGSEGV && os::is_poll_address(addr)) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
333 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
334 tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", pc);
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
335 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
336 stub = SharedRuntime::get_poll_stub(pc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
337 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
338 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
339
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
340 // SIGTRAP-based ic miss check in compiled code.
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
341 else if (sig == SIGTRAP && TrapBasedICMissChecks &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
342 nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
343 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
344 tty->print_cr("trap: ic_miss_check at " INTPTR_FORMAT " (SIGTRAP)", pc);
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
345 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
346 stub = SharedRuntime::get_ic_miss_stub();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
347 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
348 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
349
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
350 // SIGTRAP-based implicit null check in compiled code.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
351 else if (sig == SIGTRAP && TrapBasedNullChecks &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
352 nativeInstruction_at(pc)->is_sigtrap_null_check()) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
353 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
354 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGTRAP)", pc);
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
355 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
356 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
357 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
358 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
359
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
360 // SIGSEGV-based implicit null check in compiled code.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
361 else if (sig == SIGSEGV && ImplicitNullChecks &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
362 CodeCache::contains((void*) pc) &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
363 !MacroAssembler::needs_explicit_null_check((intptr_t) info->si_addr)) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
364 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
365 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", pc);
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
366 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
367 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
368 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
369
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
370 #ifdef COMPILER2
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
371 // SIGTRAP-based implicit range check in compiled code.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
372 else if (sig == SIGTRAP && TrapBasedRangeChecks &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
373 nativeInstruction_at(pc)->is_sigtrap_range_check()) {
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
374 if (TraceTraps) {
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
375 tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", pc);
14445
67fa91961822 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 14415
diff changeset
376 }
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
377 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
378 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
379 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
380 #endif
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
381
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
382 else if (sig == SIGFPE /* && info->si_code == FPE_INTDIV */) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
383 if (TraceTraps) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
384 tty->print_raw_cr("Fix SIGFPE handler, trying divide by zero handler.");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
385 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
386 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
387 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
388 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
389
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
390 else if (sig == SIGBUS) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
391 // BugId 4454115: A read from a MappedByteBuffer can fault here if the
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
392 // underlying file has been truncated. Do not crash the VM in such a case.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
393 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
394 nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
395 if (nm != NULL && nm->has_unsafe_access()) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
396 // We don't really need a stub here! Just set the pending exeption and
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
397 // continue at the next instruction after the faulting read. Returning
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
398 // garbage from this read is ok.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
399 thread->set_pending_unsafe_access_error();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
400 uc->uc_mcontext.jmp_context.iar = ((unsigned long)pc) + 4;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
401 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
402 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
403 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
404 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
405
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
406 else { // thread->thread_state() != _thread_in_Java
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
407 // Detect CPU features. This is only done at the very start of the VM. Later, the
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
408 // VM_Version::is_determine_features_test_running() flag should be false.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
409
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
410 if (sig == SIGILL && VM_Version::is_determine_features_test_running()) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
411 // SIGILL must be caused by VM_Version::determine_features().
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
412 *(int *)pc = 0; // patch instruction to 0 to indicate that it causes a SIGILL,
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
413 // flushing of icache is not necessary.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
414 stub = pc + 4; // continue with next instruction.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
415 goto run_stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
416 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
417 else if (thread->thread_state() == _thread_in_vm &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
418 sig == SIGBUS && thread->doing_unsafe_access()) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
419 // We don't really need a stub here! Just set the pending exeption and
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
420 // continue at the next instruction after the faulting read. Returning
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
421 // garbage from this read is ok.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
422 thread->set_pending_unsafe_access_error();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
423 uc->uc_mcontext.jmp_context.iar = ((unsigned long)pc) + 4;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
424 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
425 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
426 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
427
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
428 // Check to see if we caught the safepoint code in the
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
429 // process of write protecting the memory serialization page.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
430 // It write enables the page immediately after protecting it
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
431 // so we can just return to retry the write.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
432 if ((sig == SIGSEGV) &&
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
433 os::is_memory_serialize_page(thread, addr)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
434 // Synchronization problem in the pseudo memory barrier code (bug id 6546278)
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
435 // Block current thread until the memory serialize page permission restored.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
436 os::block_on_serialize_page_trap();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
437 return true;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
438 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
439 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
440
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
441 run_stub:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
442
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
443 // One of the above code blocks ininitalized the stub, so we want to
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
444 // delegate control to that stub.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
445 if (stub != NULL) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
446 // Save all thread context in case we need to restore it.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
447 if (thread != NULL) thread->set_saved_exception_pc(pc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
448 uc->uc_mcontext.jmp_context.iar = (unsigned long)stub;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
449 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
450 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
451
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
452 run_chained_handler:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
453
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
454 // signal-chaining
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
455 if (os::Aix::chained_handler(sig, info, ucVoid)) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
456 return 1;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
457 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
458 if (!abort_if_unrecognized) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
459 // caller wants another chance, so give it to him
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
460 return 0;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
461 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
462
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
463 report_and_die:
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
464
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
465 // Use sigthreadmask instead of sigprocmask on AIX and unmask current signal.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
466 sigset_t newset;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
467 sigemptyset(&newset);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
468 sigaddset(&newset, sig);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
469 sigthreadmask(SIG_UNBLOCK, &newset, NULL);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
470
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
471 VMError err(t, sig, pc, info, ucVoid);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
472 err.report_and_die();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
473
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
474 ShouldNotReachHere();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
475 return 0;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
476 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
477
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
478 void os::Aix::init_thread_fpu_state(void) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
479 #if !defined(USE_XLC_BUILTINS)
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
480 // Disable FP exceptions.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
481 __asm__ __volatile__ ("mtfsfi 6,0");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
482 #else
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
483 __mtfsfi(6, 0);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
484 #endif
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
485 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
486
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
487 ////////////////////////////////////////////////////////////////////////////////
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
488 // thread stack
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
489
20710
c5e86c5cd22e 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 17807
diff changeset
490 size_t os::Aix::min_stack_allowed = 128*K;
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
491
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
492 // Aix is always in floating stack mode. The stack size for a new
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
493 // thread can be set via pthread_attr_setstacksize().
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
494 bool os::Aix::supports_variable_stack_size() { return true; }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
495
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
496 // return default stack size for thr_type
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
497 size_t os::Aix::default_stack_size(os::ThreadType thr_type) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
498 // default stack size (compiler thread needs larger stack)
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
499 // Notice that the setting for compiler threads here have no impact
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
500 // because of the strange 'fallback logic' in os::create_thread().
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
501 // Better set CompilerThreadStackSize in globals_<os_cpu>.hpp if you want to
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
502 // specify a different stack size for compiler threads!
20710
c5e86c5cd22e 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 17807
diff changeset
503 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
14415
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
504 return s;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
505 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
506
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
507 size_t os::Aix::default_guard_size(os::ThreadType thr_type) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
508 return 2 * page_size();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
509 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
510
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
511 /////////////////////////////////////////////////////////////////////////////
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
512 // helper functions for fatal error handler
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
513
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
514 void os::print_context(outputStream *st, void *context) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
515 if (context == NULL) return;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
516
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
517 ucontext_t* uc = (ucontext_t*)context;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
518
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
519 st->print_cr("Registers:");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
520 st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.jmp_context.iar);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
521 st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.jmp_context.lr);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
522 st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.jmp_context.ctr);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
523 st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
524 for (int i = 0; i < 32; i++) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
525 st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.jmp_context.gpr[i]);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
526 if (i % 3 == 2) st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
527 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
528 st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
529 st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
530
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
531 intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
532 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
533 print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t));
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
534 st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
535
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
536 // Note: it may be unsafe to inspect memory near pc. For example, pc may
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
537 // point to garbage if entry point in an nmethod is corrupted. Leave
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
538 // this at the end, and hope for the best.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
539 address pc = os::Aix::ucontext_get_pc(uc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
540 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
541 print_hex_dump(st, pc - 64, pc + 64, /*instrsize=*/4);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
542 st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
543
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
544 // Try to decode the instructions.
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
545 st->print_cr("Decoded instructions: (pc=" PTR_FORMAT ")", pc);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
546 st->print("<TODO: PPC port - print_context>");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
547 // TODO: PPC port Disassembler::decode(pc, 16, 16, st);
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
548 st->cr();
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
549 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
550
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
551 void os::print_register_info(outputStream *st, void *context) {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
552 if (context == NULL) return;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
553 st->print("Not ported - print_register_info\n");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
554 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
555
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
556 extern "C" {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
557 int SpinPause() {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
558 return 0;
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
559 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
560 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
561
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
562 #ifndef PRODUCT
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
563 void os::verify_stack_alignment() {
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
564 assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
565 }
666e6ce3976c 8023038: PPC64 (part 15): Platform files for AIX/PPC64 support
simonis
parents:
diff changeset
566 #endif