author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 57565 | 01bca26734bb |
permissions | -rw-r--r-- |
29182 | 1 |
/* |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
2 |
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
29182 | 3 |
* Copyright (c) 2014, Red Hat Inc. All rights reserved. |
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
5 |
* |
|
6 |
* This code is free software; you can redistribute it and/or modify it |
|
7 |
* under the terms of the GNU General Public License version 2 only, as |
|
8 |
* published by the Free Software Foundation. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
* |
|
24 |
*/ |
|
25 |
||
26 |
// no precompiled headers |
|
47765
b7c7428eaab9
8189610: Reconcile jvm.h and all jvm_md.h between java.base and hotspot
coleenp
parents:
47216
diff
changeset
|
27 |
#include "jvm.h" |
29182 | 28 |
#include "asm/macroAssembler.hpp" |
29 |
#include "classfile/classLoader.hpp" |
|
30 |
#include "classfile/systemDictionary.hpp" |
|
31 |
#include "classfile/vmSymbols.hpp" |
|
34667 | 32 |
#include "code/codeCache.hpp" |
29182 | 33 |
#include "code/icBuffer.hpp" |
34 |
#include "code/vtableStubs.hpp" |
|
35 |
#include "code/nativeInst.hpp" |
|
36 |
#include "interpreter/interpreter.hpp" |
|
37 |
#include "memory/allocation.inline.hpp" |
|
38 |
#include "os_share_linux.hpp" |
|
39 |
#include "prims/jniFastGetField.hpp" |
|
40 |
#include "prims/jvm_misc.hpp" |
|
41 |
#include "runtime/arguments.hpp" |
|
42 |
#include "runtime/extendedPC.hpp" |
|
43 |
#include "runtime/frame.inline.hpp" |
|
49449
ef5d5d343e2a
8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents:
47788
diff
changeset
|
44 |
#include "runtime/interfaceSupport.inline.hpp" |
29182 | 45 |
#include "runtime/java.hpp" |
46 |
#include "runtime/javaCalls.hpp" |
|
47 |
#include "runtime/mutexLocker.hpp" |
|
48 |
#include "runtime/osThread.hpp" |
|
49 |
#include "runtime/sharedRuntime.hpp" |
|
50 |
#include "runtime/stubRoutines.hpp" |
|
51 |
#include "runtime/thread.inline.hpp" |
|
52 |
#include "runtime/timer.hpp" |
|
49653
a569cb4425f3
8191101: Show register content in hs-err file on assert
stuefe
parents:
49449
diff
changeset
|
53 |
#include "utilities/debug.hpp" |
29182 | 54 |
#include "utilities/events.hpp" |
55 |
#include "utilities/vmError.hpp" |
|
56 |
||
57 |
// put OS-includes here |
|
58 |
# include <sys/types.h> |
|
59 |
# include <sys/mman.h> |
|
60 |
# include <pthread.h> |
|
61 |
# include <signal.h> |
|
62 |
# include <errno.h> |
|
63 |
# include <dlfcn.h> |
|
64 |
# include <stdlib.h> |
|
65 |
# include <stdio.h> |
|
66 |
# include <unistd.h> |
|
67 |
# include <sys/resource.h> |
|
68 |
# include <pthread.h> |
|
69 |
# include <sys/stat.h> |
|
70 |
# include <sys/time.h> |
|
71 |
# include <sys/utsname.h> |
|
72 |
# include <sys/socket.h> |
|
73 |
# include <sys/wait.h> |
|
74 |
# include <pwd.h> |
|
75 |
# include <poll.h> |
|
76 |
# include <ucontext.h> |
|
77 |
# include <fpu_control.h> |
|
78 |
||
79 |
#define REG_FP 29 |
|
43439
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
80 |
#define REG_LR 30 |
29182 | 81 |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
82 |
NOINLINE address os::current_stack_pointer() { |
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
83 |
return (address)__builtin_frame_address(0); |
29182 | 84 |
} |
85 |
||
86 |
char* os::non_memory_address_word() { |
|
87 |
// Must never look like an address returned by reserve_memory, |
|
88 |
// even in its subfields (as defined by the CPU immediate fields, |
|
89 |
// if the CPU splits constants across multiple instructions). |
|
90 |
||
91 |
return (char*) 0xffffffffffff; |
|
92 |
} |
|
93 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
94 |
address os::Linux::ucontext_get_pc(const ucontext_t * uc) { |
29182 | 95 |
return (address)uc->uc_mcontext.pc; |
96 |
} |
|
97 |
||
29679 | 98 |
void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { |
99 |
uc->uc_mcontext.pc = (intptr_t)pc; |
|
100 |
} |
|
101 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
102 |
intptr_t* os::Linux::ucontext_get_sp(const ucontext_t * uc) { |
29182 | 103 |
return (intptr_t*)uc->uc_mcontext.sp; |
104 |
} |
|
105 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
106 |
intptr_t* os::Linux::ucontext_get_fp(const ucontext_t * uc) { |
29182 | 107 |
return (intptr_t*)uc->uc_mcontext.regs[REG_FP]; |
108 |
} |
|
109 |
||
110 |
// For Forte Analyzer AsyncGetCallTrace profiling support - thread |
|
111 |
// is currently interrupted by SIGPROF. |
|
112 |
// os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal |
|
113 |
// frames. Currently we don't do that on Linux, so it's the same as |
|
114 |
// os::fetch_frame_from_context(). |
|
115 |
ExtendedPC os::Linux::fetch_frame_from_ucontext(Thread* thread, |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
116 |
const ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { |
29182 | 117 |
|
118 |
assert(thread != NULL, "just checking"); |
|
119 |
assert(ret_sp != NULL, "just checking"); |
|
120 |
assert(ret_fp != NULL, "just checking"); |
|
121 |
||
122 |
return os::fetch_frame_from_context(uc, ret_sp, ret_fp); |
|
123 |
} |
|
124 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
125 |
ExtendedPC os::fetch_frame_from_context(const void* ucVoid, |
29182 | 126 |
intptr_t** ret_sp, intptr_t** ret_fp) { |
127 |
||
128 |
ExtendedPC epc; |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
129 |
const ucontext_t* uc = (const ucontext_t*)ucVoid; |
29182 | 130 |
|
131 |
if (uc != NULL) { |
|
132 |
epc = ExtendedPC(os::Linux::ucontext_get_pc(uc)); |
|
133 |
if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc); |
|
134 |
if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc); |
|
135 |
} else { |
|
136 |
// construct empty ExtendedPC for return value checking |
|
137 |
epc = ExtendedPC(NULL); |
|
138 |
if (ret_sp) *ret_sp = (intptr_t *)NULL; |
|
139 |
if (ret_fp) *ret_fp = (intptr_t *)NULL; |
|
140 |
} |
|
141 |
||
142 |
return epc; |
|
143 |
} |
|
144 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
145 |
frame os::fetch_frame_from_context(const void* ucVoid) { |
29182 | 146 |
intptr_t* sp; |
147 |
intptr_t* fp; |
|
148 |
ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); |
|
149 |
return frame(sp, fp, epc.pc()); |
|
150 |
} |
|
151 |
||
43439
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
152 |
bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
153 |
address pc = (address) os::Linux::ucontext_get_pc(uc); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
154 |
if (Interpreter::contains(pc)) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
155 |
// interpreter performs stack banging after the fixed frame header has |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
156 |
// been generated while the compilers perform it before. To maintain |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
157 |
// semantic consistency between interpreted and compiled frames, the |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
158 |
// method returns the Java sender of the current frame. |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
159 |
*fr = os::fetch_frame_from_context(uc); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
160 |
if (!fr->is_first_java_frame()) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
161 |
assert(fr->safe_for_sender(thread), "Safety check"); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
162 |
*fr = fr->java_sender(); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
163 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
164 |
} else { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
165 |
// more complex code with compiled code |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
166 |
assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above"); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
167 |
CodeBlob* cb = CodeCache::find_blob(pc); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
168 |
if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
169 |
// Not sure where the pc points to, fallback to default |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
170 |
// stack overflow handling |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
171 |
return false; |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
172 |
} else { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
173 |
// In compiled code, the stack banging is performed before LR |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
174 |
// has been saved in the frame. LR is live, and SP and FP |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
175 |
// belong to the caller. |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
176 |
intptr_t* fp = os::Linux::ucontext_get_fp(uc); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
177 |
intptr_t* sp = os::Linux::ucontext_get_sp(uc); |
43443 | 178 |
address pc = (address)(uc->uc_mcontext.regs[REG_LR] |
43439
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
179 |
- NativeInstruction::instruction_size); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
180 |
*fr = frame(sp, fp, pc); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
181 |
if (!fr->is_java_frame()) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
182 |
assert(fr->safe_for_sender(thread), "Safety check"); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
183 |
assert(!fr->is_first_frame(), "Safety check"); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
184 |
*fr = fr->java_sender(); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
185 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
186 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
187 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
188 |
assert(fr->is_java_frame(), "Safety check"); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
189 |
return true; |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
190 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
191 |
|
29182 | 192 |
// By default, gcc always saves frame pointer rfp on this stack. This |
193 |
// may get turned off by -fomit-frame-pointer. |
|
194 |
frame os::get_sender_for_C_frame(frame* fr) { |
|
195 |
return frame(fr->link(), fr->link(), fr->sender_pc()); |
|
196 |
} |
|
197 |
||
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
198 |
NOINLINE frame os::current_frame() { |
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
199 |
intptr_t *fp = *(intptr_t **)__builtin_frame_address(0); |
29182 | 200 |
frame myframe((intptr_t*)os::current_stack_pointer(), |
201 |
(intptr_t*)fp, |
|
202 |
CAST_FROM_FN_PTR(address, os::current_frame)); |
|
203 |
if (os::is_first_C_frame(&myframe)) { |
|
204 |
// stack is not walkable |
|
205 |
return frame(); |
|
206 |
} else { |
|
207 |
return os::get_sender_for_C_frame(&myframe); |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
extern "C" JNIEXPORT int |
|
212 |
JVM_handle_linux_signal(int sig, |
|
213 |
siginfo_t* info, |
|
214 |
void* ucVoid, |
|
215 |
int abort_if_unrecognized) { |
|
216 |
ucontext_t* uc = (ucontext_t*) ucVoid; |
|
217 |
||
34633
2a6c7c7b30a7
8132510: Replace ThreadLocalStorage with compiler/language-based thread-local variables
dholmes
parents:
33105
diff
changeset
|
218 |
Thread* t = Thread::current_or_null_safe(); |
29182 | 219 |
|
220 |
// Must do this before SignalHandlerMark, if crash protection installed we will longjmp away |
|
221 |
// (no destructors can be run) |
|
46644
a5813fb66270
8183925: Decouple crash protection from watcher thread
rehn
parents:
43491
diff
changeset
|
222 |
os::ThreadCrashProtection::check_crash_protection(sig, t); |
29182 | 223 |
|
224 |
SignalHandlerMark shm(t); |
|
225 |
||
226 |
// Note: it's not uncommon that JNI code uses signal/sigset to install |
|
227 |
// then restore certain signal handler (e.g. to temporarily block SIGPIPE, |
|
228 |
// or have a SIGILL handler when detecting CPU type). When that happens, |
|
229 |
// JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To |
|
230 |
// avoid unnecessary crash when libjsig is not preloaded, try handle signals |
|
231 |
// that do not require siginfo/ucontext first. |
|
232 |
||
233 |
if (sig == SIGPIPE || sig == SIGXFSZ) { |
|
234 |
// allow chained handler to go first |
|
235 |
if (os::Linux::chained_handler(sig, info, ucVoid)) { |
|
236 |
return true; |
|
237 |
} else { |
|
37430
fd743dadef12
8151939: VM_Version_init() print buffer is too small
coleenp
parents:
35201
diff
changeset
|
238 |
// Ignoring SIGPIPE/SIGXFSZ - see bugs 4229104 or 6499219 |
29182 | 239 |
return true; |
240 |
} |
|
241 |
} |
|
242 |
||
49653
a569cb4425f3
8191101: Show register content in hs-err file on assert
stuefe
parents:
49449
diff
changeset
|
243 |
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT |
a569cb4425f3
8191101: Show register content in hs-err file on assert
stuefe
parents:
49449
diff
changeset
|
244 |
if ((sig == SIGSEGV || sig == SIGBUS) && info != NULL && info->si_addr == g_assert_poison) { |
55653
3243c42d737d
8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents:
55490
diff
changeset
|
245 |
if (handle_assert_poison_fault(ucVoid, info->si_addr)) { |
3243c42d737d
8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents:
55490
diff
changeset
|
246 |
return 1; |
3243c42d737d
8227275: Within native OOM error handling, assertions may hang the process
stuefe
parents:
55490
diff
changeset
|
247 |
} |
49653
a569cb4425f3
8191101: Show register content in hs-err file on assert
stuefe
parents:
49449
diff
changeset
|
248 |
} |
a569cb4425f3
8191101: Show register content in hs-err file on assert
stuefe
parents:
49449
diff
changeset
|
249 |
#endif |
a569cb4425f3
8191101: Show register content in hs-err file on assert
stuefe
parents:
49449
diff
changeset
|
250 |
|
29182 | 251 |
JavaThread* thread = NULL; |
252 |
VMThread* vmthread = NULL; |
|
253 |
if (os::Linux::signal_handlers_are_installed) { |
|
254 |
if (t != NULL ){ |
|
255 |
if(t->is_Java_thread()) { |
|
256 |
thread = (JavaThread*)t; |
|
257 |
} |
|
258 |
else if(t->is_VM_thread()){ |
|
259 |
vmthread = (VMThread *)t; |
|
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
/* |
|
264 |
NOTE: does not seem to work on linux. |
|
265 |
if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) { |
|
266 |
// can't decode this kind of signal |
|
267 |
info = NULL; |
|
268 |
} else { |
|
269 |
assert(sig == info->si_signo, "bad siginfo"); |
|
270 |
} |
|
271 |
*/ |
|
272 |
// decide if this trap can be handled by a stub |
|
273 |
address stub = NULL; |
|
274 |
||
275 |
address pc = NULL; |
|
276 |
||
277 |
//%note os_trap_1 |
|
278 |
if (info != NULL && uc != NULL && thread != NULL) { |
|
279 |
pc = (address) os::Linux::ucontext_get_pc(uc); |
|
280 |
||
281 |
if (StubRoutines::is_safefetch_fault(pc)) { |
|
29679 | 282 |
os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); |
29182 | 283 |
return 1; |
284 |
} |
|
285 |
||
52462
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
286 |
address addr = (address) info->si_addr; |
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
287 |
|
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
288 |
// Make sure the high order byte is sign extended, as it may be masked away by the hardware. |
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
289 |
if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) { |
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
290 |
addr = address(uintptr_t(addr) | (uintptr_t(0xFF) << 56)); |
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
291 |
} |
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
292 |
|
29182 | 293 |
// Handle ALL stack overflow variations here |
294 |
if (sig == SIGSEGV) { |
|
295 |
// check if fault address is within thread stack |
|
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
296 |
if (thread->on_local_stack(addr)) { |
29182 | 297 |
// stack overflow |
35201
996db89f378e
8139864: Improve handling of stack protection zones.
goetz
parents:
35077
diff
changeset
|
298 |
if (thread->in_stack_yellow_reserved_zone(addr)) { |
29182 | 299 |
if (thread->thread_state() == _thread_in_Java) { |
43439
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
300 |
if (thread->in_stack_reserved_zone(addr)) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
301 |
frame fr; |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
302 |
if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
303 |
assert(fr.is_java_frame(), "Must be a Java frame"); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
304 |
frame activation = |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
305 |
SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
306 |
if (activation.sp() != NULL) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
307 |
thread->disable_stack_reserved_zone(); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
308 |
if (activation.is_interpreted_frame()) { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
309 |
thread->set_reserved_stack_activation((address)( |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
310 |
activation.fp() + frame::interpreter_frame_initial_sp_offset)); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
311 |
} else { |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
312 |
thread->set_reserved_stack_activation((address)activation.unextended_sp()); |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
313 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
314 |
return 1; |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
315 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
316 |
} |
5e03c9ba74f3
8172144: AArch64: Implement "JEP 270: Reserved Stack Areas for Critical Sections"
aph
parents:
42907
diff
changeset
|
317 |
} |
29182 | 318 |
// Throw a stack overflow exception. Guard pages will be reenabled |
319 |
// while unwinding the stack. |
|
53115
b5c41404f2d1
8215879: AArch64: ReservedStackAccess may leave stack guard in inconsistent state
aph
parents:
52462
diff
changeset
|
320 |
thread->disable_stack_yellow_reserved_zone(); |
29182 | 321 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); |
322 |
} else { |
|
323 |
// Thread was in the vm or native code. Return and try to finish. |
|
53115
b5c41404f2d1
8215879: AArch64: ReservedStackAccess may leave stack guard in inconsistent state
aph
parents:
52462
diff
changeset
|
324 |
thread->disable_stack_yellow_reserved_zone(); |
29182 | 325 |
return 1; |
326 |
} |
|
327 |
} else if (thread->in_stack_red_zone(addr)) { |
|
328 |
// Fatal red zone violation. Disable the guard pages and fall through |
|
329 |
// to handle_unexpected_exception way down below. |
|
330 |
thread->disable_stack_red_zone(); |
|
331 |
tty->print_raw_cr("An irrecoverable stack overflow has occurred."); |
|
332 |
||
333 |
// This is a likely cause, but hard to verify. Let's just print |
|
334 |
// it as a hint. |
|
335 |
tty->print_raw_cr("Please check if any of your loaded .so files has " |
|
336 |
"enabled executable stack (see man page execstack(8))"); |
|
337 |
} else { |
|
338 |
// Accessing stack address below sp may cause SEGV if current |
|
339 |
// thread has MAP_GROWSDOWN stack. This should only happen when |
|
340 |
// current thread was created by user code with MAP_GROWSDOWN flag |
|
341 |
// and then attached to VM. See notes in os_linux.cpp. |
|
342 |
if (thread->osthread()->expanding_stack() == 0) { |
|
343 |
thread->osthread()->set_expanding_stack(); |
|
344 |
if (os::Linux::manually_expand_stack(thread, addr)) { |
|
345 |
thread->osthread()->clear_expanding_stack(); |
|
346 |
return 1; |
|
347 |
} |
|
348 |
thread->osthread()->clear_expanding_stack(); |
|
349 |
} else { |
|
350 |
fatal("recursive segv. expanding stack."); |
|
351 |
} |
|
352 |
} |
|
353 |
} |
|
354 |
} |
|
355 |
||
356 |
if (thread->thread_state() == _thread_in_Java) { |
|
357 |
// Java thread running in Java code => find exception handler if any |
|
358 |
// a fault inside compiled code, the interpreter, or a stub |
|
359 |
||
360 |
// Handle signal from NativeJump::patch_verified_entry(). |
|
361 |
if ((sig == SIGILL || sig == SIGTRAP) |
|
362 |
&& nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { |
|
363 |
if (TraceTraps) { |
|
364 |
tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL"); |
|
365 |
} |
|
366 |
stub = SharedRuntime::get_handle_wrong_method_stub(); |
|
367 |
} else if (sig == SIGSEGV && os::is_poll_address((address)info->si_addr)) { |
|
368 |
stub = SharedRuntime::get_poll_stub(pc); |
|
369 |
} else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) { |
|
370 |
// BugId 4454115: A read from a MappedByteBuffer can fault |
|
371 |
// here if the underlying file has been truncated. |
|
372 |
// Do not crash the VM in such a case. |
|
373 |
CodeBlob* cb = CodeCache::find_blob_unsafe(pc); |
|
38133
78b95467b9f1
8151956: Support non-continuous CodeBlobs in HotSpot
rbackman
parents:
37430
diff
changeset
|
374 |
CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
375 |
bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc)); |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
376 |
if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) { |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
377 |
address next_pc = pc + NativeCall::instruction_size; |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
378 |
if (is_unsafe_arraycopy) { |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
379 |
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc); |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
380 |
} |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
381 |
stub = SharedRuntime::handle_unsafe_access(thread, next_pc); |
29182 | 382 |
} |
383 |
} |
|
384 |
else |
|
385 |
||
386 |
if (sig == SIGFPE && |
|
387 |
(info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) { |
|
388 |
stub = |
|
389 |
SharedRuntime:: |
|
390 |
continuation_for_implicit_exception(thread, |
|
391 |
pc, |
|
392 |
SharedRuntime:: |
|
393 |
IMPLICIT_DIVIDE_BY_ZERO); |
|
394 |
} else if (sig == SIGSEGV && |
|
52462
4ad404da0088
8213199: GC abstraction for Assembler::needs_explicit_null_check()
rkennke
parents:
52460
diff
changeset
|
395 |
MacroAssembler::uses_implicit_null_check((void*)addr)) { |
29182 | 396 |
// Determination of interpreter/vtable stub/compiled code null exception |
397 |
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); |
|
398 |
} |
|
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
399 |
} else if ((thread->thread_state() == _thread_in_vm || |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
400 |
thread->thread_state() == _thread_in_native) && |
29182 | 401 |
sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ |
402 |
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
|
403 |
address next_pc = pc + NativeCall::instruction_size; |
55490
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
404 |
if (UnsafeCopyMemory::contains_pc(pc)) { |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
405 |
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc); |
3f3dc00a69a5
8191278: MappedByteBuffer bulk access memory failures are not handled gracefully
jcm
parents:
55398
diff
changeset
|
406 |
} |
38209
b2a58604e046
8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub
mikael
parents:
38190
diff
changeset
|
407 |
stub = SharedRuntime::handle_unsafe_access(thread, next_pc); |
29182 | 408 |
} |
409 |
||
410 |
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in |
|
411 |
// and the heap gets shrunk before the field access. |
|
412 |
if ((sig == SIGSEGV) || (sig == SIGBUS)) { |
|
413 |
address addr = JNI_FastGetField::find_slowcase_pc(pc); |
|
414 |
if (addr != (address)-1) { |
|
415 |
stub = addr; |
|
416 |
} |
|
417 |
} |
|
418 |
} |
|
419 |
||
420 |
if (stub != NULL) { |
|
421 |
// save all thread context in case we need to restore it |
|
422 |
if (thread != NULL) thread->set_saved_exception_pc(pc); |
|
423 |
||
29679 | 424 |
os::Linux::ucontext_set_pc(uc, stub); |
29182 | 425 |
return true; |
426 |
} |
|
427 |
||
428 |
// signal-chaining |
|
429 |
if (os::Linux::chained_handler(sig, info, ucVoid)) { |
|
430 |
return true; |
|
431 |
} |
|
432 |
||
433 |
if (!abort_if_unrecognized) { |
|
434 |
// caller wants another chance, so give it to him |
|
435 |
return false; |
|
436 |
} |
|
437 |
||
438 |
if (pc == NULL && uc != NULL) { |
|
439 |
pc = os::Linux::ucontext_get_pc(uc); |
|
440 |
} |
|
441 |
||
442 |
// unmask current signal |
|
443 |
sigset_t newset; |
|
444 |
sigemptyset(&newset); |
|
445 |
sigaddset(&newset, sig); |
|
446 |
sigprocmask(SIG_UNBLOCK, &newset, NULL); |
|
447 |
||
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
32080
diff
changeset
|
448 |
VMError::report_and_die(t, sig, pc, info, ucVoid); |
29182 | 449 |
|
450 |
ShouldNotReachHere(); |
|
451 |
return true; // Mute compiler |
|
452 |
} |
|
453 |
||
454 |
void os::Linux::init_thread_fpu_state(void) { |
|
455 |
} |
|
456 |
||
457 |
int os::Linux::get_fpu_control_word(void) { |
|
458 |
return 0; |
|
459 |
} |
|
460 |
||
461 |
void os::Linux::set_fpu_control_word(int fpu_control) { |
|
462 |
} |
|
463 |
||
464 |
// Check that the linux kernel version is 2.4 or higher since earlier |
|
465 |
// versions do not support SSE without patches. |
|
466 |
bool os::supports_sse() { |
|
467 |
return true; |
|
468 |
} |
|
469 |
||
470 |
bool os::is_allocatable(size_t bytes) { |
|
471 |
return true; |
|
472 |
} |
|
473 |
||
474 |
//////////////////////////////////////////////////////////////////////////////// |
|
475 |
// thread stack |
|
476 |
||
42906
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
42905
diff
changeset
|
477 |
// Minimum usable stack sizes required to get to user code. Space for |
1a8db9cf1407
8170655: [posix] Fix minimum stack size computations
goetz
parents:
42905
diff
changeset
|
478 |
// HotSpot guard pages is added later. |
43292 | 479 |
size_t os::Posix::_compiler_thread_min_stack_allowed = 72 * K; |
480 |
size_t os::Posix::_java_thread_min_stack_allowed = 72 * K; |
|
481 |
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 72 * K; |
|
29182 | 482 |
|
483 |
// return default stack size for thr_type |
|
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
40010
diff
changeset
|
484 |
size_t os::Posix::default_stack_size(os::ThreadType thr_type) { |
29182 | 485 |
// default stack size (compiler thread needs larger stack) |
486 |
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); |
|
487 |
return s; |
|
488 |
} |
|
489 |
||
490 |
///////////////////////////////////////////////////////////////////////////// |
|
491 |
// helper functions for fatal error handler |
|
492 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
493 |
void os::print_context(outputStream *st, const void *context) { |
29182 | 494 |
if (context == NULL) return; |
495 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
496 |
const ucontext_t *uc = (const ucontext_t*)context; |
29182 | 497 |
st->print_cr("Registers:"); |
42880
f71e11a0567d
8171129: [aarch64] hs_err logs do not print register mappings
drwhite
parents:
41070
diff
changeset
|
498 |
for (int r = 0; r < 31; r++) { |
f71e11a0567d
8171129: [aarch64] hs_err logs do not print register mappings
drwhite
parents:
41070
diff
changeset
|
499 |
st->print("R%-2d=", r); |
f71e11a0567d
8171129: [aarch64] hs_err logs do not print register mappings
drwhite
parents:
41070
diff
changeset
|
500 |
print_location(st, uc->uc_mcontext.regs[r]); |
f71e11a0567d
8171129: [aarch64] hs_err logs do not print register mappings
drwhite
parents:
41070
diff
changeset
|
501 |
} |
29182 | 502 |
st->cr(); |
503 |
||
504 |
intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); |
|
505 |
st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); |
|
506 |
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); |
|
507 |
st->cr(); |
|
508 |
||
509 |
// Note: it may be unsafe to inspect memory near pc. For example, pc may |
|
510 |
// point to garbage if entry point in an nmethod is corrupted. Leave |
|
511 |
// this at the end, and hope for the best. |
|
512 |
address pc = os::Linux::ucontext_get_pc(uc); |
|
53605
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53115
diff
changeset
|
513 |
print_instructions(st, pc, sizeof(char)); |
853c68ff2ed7
8217879: hs_err should print more instructions in hex dump
shade
parents:
53115
diff
changeset
|
514 |
st->cr(); |
29182 | 515 |
} |
516 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
517 |
void os::print_register_info(outputStream *st, const void *context) { |
29182 | 518 |
if (context == NULL) return; |
519 |
||
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
34667
diff
changeset
|
520 |
const ucontext_t *uc = (const ucontext_t*)context; |
29182 | 521 |
|
522 |
st->print_cr("Register to memory mapping:"); |
|
523 |
st->cr(); |
|
524 |
||
525 |
// this is horrendously verbose but the layout of the registers in the |
|
526 |
// context does not match how we defined our abstract Register set, so |
|
527 |
// we can't just iterate through the gregs area |
|
528 |
||
529 |
// this is only for the "general purpose" registers |
|
530 |
||
531 |
for (int r = 0; r < 31; r++) |
|
532 |
st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); |
|
533 |
st->cr(); |
|
534 |
} |
|
535 |
||
536 |
void os::setup_fpu() { |
|
537 |
} |
|
538 |
||
539 |
#ifndef PRODUCT |
|
540 |
void os::verify_stack_alignment() { |
|
541 |
assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment"); |
|
542 |
} |
|
543 |
#endif |
|
544 |
||
545 |
int os::extra_bang_size_in_bytes() { |
|
546 |
// AArch64 does not require the additional stack bang. |
|
547 |
return 0; |
|
548 |
} |
|
549 |
||
550 |
extern "C" { |
|
551 |
int SpinPause() { |
|
552 |
return 0; |
|
553 |
} |
|
554 |
||
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
555 |
void _Copy_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) { |
29182 | 556 |
if (from > to) { |
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
557 |
const jshort *end = from + count; |
29182 | 558 |
while (from < end) |
559 |
*(to++) = *(from++); |
|
560 |
} |
|
561 |
else if (from < to) { |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
562 |
const jshort *end = from; |
29182 | 563 |
from += count - 1; |
564 |
to += count - 1; |
|
565 |
while (from >= end) |
|
566 |
*(to--) = *(from--); |
|
567 |
} |
|
568 |
} |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
569 |
void _Copy_conjoint_jints_atomic(const jint* from, jint* to, size_t count) { |
29182 | 570 |
if (from > to) { |
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
571 |
const jint *end = from + count; |
29182 | 572 |
while (from < end) |
573 |
*(to++) = *(from++); |
|
574 |
} |
|
575 |
else if (from < to) { |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
576 |
const jint *end = from; |
29182 | 577 |
from += count - 1; |
578 |
to += count - 1; |
|
579 |
while (from >= end) |
|
580 |
*(to--) = *(from--); |
|
581 |
} |
|
582 |
} |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
583 |
void _Copy_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) { |
29182 | 584 |
if (from > to) { |
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
585 |
const jlong *end = from + count; |
29182 | 586 |
while (from < end) |
587 |
os::atomic_copy64(from++, to++); |
|
588 |
} |
|
589 |
else if (from < to) { |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
590 |
const jlong *end = from; |
29182 | 591 |
from += count - 1; |
592 |
to += count - 1; |
|
593 |
while (from >= end) |
|
594 |
os::atomic_copy64(from--, to--); |
|
595 |
} |
|
596 |
} |
|
597 |
||
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
598 |
void _Copy_arrayof_conjoint_bytes(const HeapWord* from, |
29182 | 599 |
HeapWord* to, |
600 |
size_t count) { |
|
601 |
memmove(to, from, count); |
|
602 |
} |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
603 |
void _Copy_arrayof_conjoint_jshorts(const HeapWord* from, |
29182 | 604 |
HeapWord* to, |
605 |
size_t count) { |
|
606 |
memmove(to, from, count * 2); |
|
607 |
} |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
608 |
void _Copy_arrayof_conjoint_jints(const HeapWord* from, |
29182 | 609 |
HeapWord* to, |
610 |
size_t count) { |
|
611 |
memmove(to, from, count * 4); |
|
612 |
} |
|
55398
e53ec3b362f4
8224851: AArch64: fix warnings and errors with Clang and GCC 8.3
ngasson
parents:
53605
diff
changeset
|
613 |
void _Copy_arrayof_conjoint_jlongs(const HeapWord* from, |
29182 | 614 |
HeapWord* to, |
615 |
size_t count) { |
|
616 |
memmove(to, from, count * 8); |
|
617 |
} |
|
618 |
}; |