Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/src/hotspot/os_cpu/bsd_aarch64/os_bsd_aarch64.cpp
64440 views
1
/*
2
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
3
* Copyright (c) 2014, Red Hat Inc. All rights reserved.
4
* Copyright (c) 2021, Azul Systems, Inc. All rights reserved.
5
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6
*
7
* This code is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License version 2 only, as
9
* published by the Free Software Foundation.
10
*
11
* This code is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
* version 2 for more details (a copy is included in the LICENSE file that
15
* accompanied this code).
16
*
17
* You should have received a copy of the GNU General Public License version
18
* 2 along with this work; if not, write to the Free Software Foundation,
19
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
*
21
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*
25
*/
26
27
// no precompiled headers
28
#include "jvm.h"
29
#include "asm/macroAssembler.hpp"
30
#include "classfile/classLoader.hpp"
31
#include "classfile/vmSymbols.hpp"
32
#include "code/codeCache.hpp"
33
#include "code/icBuffer.hpp"
34
#include "code/vtableStubs.hpp"
35
#include "interpreter/interpreter.hpp"
36
#include "logging/log.hpp"
37
#include "memory/allocation.inline.hpp"
38
#include "os_share_bsd.hpp"
39
#include "prims/jniFastGetField.hpp"
40
#include "prims/jvm_misc.hpp"
41
#include "runtime/arguments.hpp"
42
#include "runtime/frame.inline.hpp"
43
#include "runtime/interfaceSupport.inline.hpp"
44
#include "runtime/java.hpp"
45
#include "runtime/javaCalls.hpp"
46
#include "runtime/mutexLocker.hpp"
47
#include "runtime/osThread.hpp"
48
#include "runtime/safepointMechanism.hpp"
49
#include "runtime/sharedRuntime.hpp"
50
#include "runtime/stubRoutines.hpp"
51
#include "runtime/thread.inline.hpp"
52
#include "runtime/timer.hpp"
53
#include "signals_posix.hpp"
54
#include "utilities/align.hpp"
55
#include "utilities/events.hpp"
56
#include "utilities/vmError.hpp"
57
#include "tcg-apple-jit.h"
58
59
// put OS-includes here
60
# include <sys/types.h>
61
# include <sys/mman.h>
62
# include <pthread.h>
63
# include <signal.h>
64
# include <errno.h>
65
# include <dlfcn.h>
66
# include <stdlib.h>
67
# include <stdio.h>
68
# include <unistd.h>
69
# include <sys/resource.h>
70
# include <sys/stat.h>
71
# include <sys/time.h>
72
# include <sys/utsname.h>
73
# include <sys/socket.h>
74
# include <sys/wait.h>
75
# include <pwd.h>
76
# include <poll.h>
77
#ifndef __OpenBSD__
78
# include <ucontext.h>
79
#endif
80
81
#if !defined(__APPLE__) && !defined(__NetBSD__)
82
# include <pthread_np.h>
83
#endif
84
85
#define SPELL_REG_SP "sp"
86
#define SPELL_REG_FP "fp"
87
88
#ifdef __APPLE__
89
// see darwin-xnu/osfmk/mach/arm/_structs.h
90
91
// 10.5 UNIX03 member name prefixes
92
#define DU3_PREFIX(s, m) __ ## s.__ ## m
93
#endif
94
95
#define context_x uc_mcontext->DU3_PREFIX(ss,x)
96
#define context_fp uc_mcontext->DU3_PREFIX(ss,fp)
97
#define context_lr uc_mcontext->DU3_PREFIX(ss,lr)
98
#define context_sp uc_mcontext->DU3_PREFIX(ss,sp)
99
#define context_pc uc_mcontext->DU3_PREFIX(ss,pc)
100
#define context_cpsr uc_mcontext->DU3_PREFIX(ss,cpsr)
101
#define context_esr uc_mcontext->DU3_PREFIX(es,esr)
102
103
address os::current_stack_pointer() {
104
#if defined(__clang__) || defined(__llvm__)
105
void *sp;
106
__asm__("mov %0, " SPELL_REG_SP : "=r"(sp));
107
return (address) sp;
108
#else
109
register void *sp __asm__ (SPELL_REG_SP);
110
return (address) sp;
111
#endif
112
}
113
114
char* os::non_memory_address_word() {
115
// Must never look like an address returned by reserve_memory,
116
// even in its subfields (as defined by the CPU immediate fields,
117
// if the CPU splits constants across multiple instructions).
118
119
// the return value used in computation of Universe::non_oop_word(), which
120
// is loaded by cpu/aarch64 by MacroAssembler::movptr(Register, uintptr_t)
121
return (char*) 0xffffffffffff;
122
}
123
124
address os::Posix::ucontext_get_pc(const ucontext_t * uc) {
125
return (address)uc->context_pc;
126
}
127
128
void os::Posix::ucontext_set_pc(ucontext_t * uc, address pc) {
129
uc->context_pc = (intptr_t)pc ;
130
}
131
132
intptr_t* os::Bsd::ucontext_get_sp(const ucontext_t * uc) {
133
return (intptr_t*)uc->context_sp;
134
}
135
136
intptr_t* os::Bsd::ucontext_get_fp(const ucontext_t * uc) {
137
return (intptr_t*)uc->context_fp;
138
}
139
140
address os::fetch_frame_from_context(const void* ucVoid,
141
intptr_t** ret_sp, intptr_t** ret_fp) {
142
143
address epc;
144
const ucontext_t* uc = (const ucontext_t*)ucVoid;
145
146
if (uc != NULL) {
147
epc = os::Posix::ucontext_get_pc(uc);
148
if (ret_sp) *ret_sp = os::Bsd::ucontext_get_sp(uc);
149
if (ret_fp) *ret_fp = os::Bsd::ucontext_get_fp(uc);
150
} else {
151
epc = NULL;
152
if (ret_sp) *ret_sp = (intptr_t *)NULL;
153
if (ret_fp) *ret_fp = (intptr_t *)NULL;
154
}
155
156
return epc;
157
}
158
159
frame os::fetch_frame_from_context(const void* ucVoid) {
160
intptr_t* sp;
161
intptr_t* fp;
162
address epc = fetch_frame_from_context(ucVoid, &sp, &fp);
163
return frame(sp, fp, epc);
164
}
165
166
frame os::fetch_compiled_frame_from_context(const void* ucVoid) {
167
const ucontext_t* uc = (const ucontext_t*)ucVoid;
168
// In compiled code, the stack banging is performed before LR
169
// has been saved in the frame. LR is live, and SP and FP
170
// belong to the caller.
171
intptr_t* fp = os::Bsd::ucontext_get_fp(uc);
172
intptr_t* sp = os::Bsd::ucontext_get_sp(uc);
173
address pc = (address)(uc->context_lr
174
- NativeInstruction::instruction_size);
175
return frame(sp, fp, pc);
176
}
177
178
// JVM compiled with -fno-omit-frame-pointer, so RFP is saved on the stack.
179
frame os::get_sender_for_C_frame(frame* fr) {
180
return frame(fr->link(), fr->link(), fr->sender_pc());
181
}
182
183
NOINLINE frame os::current_frame() {
184
intptr_t *fp = *(intptr_t **)__builtin_frame_address(0);
185
frame myframe((intptr_t*)os::current_stack_pointer(),
186
(intptr_t*)fp,
187
CAST_FROM_FN_PTR(address, os::current_frame));
188
if (os::is_first_C_frame(&myframe)) {
189
// stack is not walkable
190
return frame();
191
} else {
192
return os::get_sender_for_C_frame(&myframe);
193
}
194
}
195
196
ATTRIBUTE_PRINTF(6, 7)
197
static void report_and_die(Thread* thread, void* context, const char* filename, int lineno, const char* message,
198
const char* detail_fmt, ...) {
199
va_list va;
200
va_start(va, detail_fmt);
201
VMError::report_and_die(thread, context, filename, lineno, message, detail_fmt, va);
202
va_end(va);
203
}
204
205
bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
206
ucontext_t* uc, JavaThread* thread) {
207
// Enable WXWrite: this function is called by the signal handler at arbitrary
208
// point of execution.
209
ThreadWXEnable wx(WXWrite, thread);
210
211
// decide if this trap can be handled by a stub
212
address stub = NULL;
213
214
address pc = NULL;
215
216
//%note os_trap_1
217
if (info != NULL && uc != NULL && thread != NULL) {
218
pc = (address) os::Posix::ucontext_get_pc(uc);
219
220
// Handle ALL stack overflow variations here
221
if (sig == SIGSEGV || sig == SIGBUS) {
222
address addr = (address) info->si_addr;
223
224
// Make sure the high order byte is sign extended, as it may be masked away by the hardware.
225
if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) {
226
addr = address(uintptr_t(addr) | (uintptr_t(0xFF) << 56));
227
}
228
229
// check if fault address is within thread stack
230
if (thread->is_in_full_stack(addr)) {
231
// stack overflow
232
if (os::Posix::handle_stack_overflow(thread, addr, pc, uc, &stub)) {
233
return true; // continue
234
}
235
}
236
}
237
238
// We test if stub is already set (by the stack overflow code
239
// above) so it is not overwritten by the code that follows. This
240
// check is not required on other platforms, because on other
241
// platforms we check for SIGSEGV only or SIGBUS only, where here
242
// we have to check for both SIGSEGV and SIGBUS.
243
if (thread->thread_state() == _thread_in_Java && stub == NULL) {
244
// Java thread running in Java code => find exception handler if any
245
// a fault inside compiled code, the interpreter, or a stub
246
247
// Handle signal from NativeJump::patch_verified_entry().
248
if ((sig == SIGILL)
249
&& nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) {
250
if (TraceTraps) {
251
tty->print_cr("trap: zombie_not_entrant");
252
}
253
stub = SharedRuntime::get_handle_wrong_method_stub();
254
} else if ((sig == SIGSEGV || sig == SIGBUS) && SafepointMechanism::is_poll_address((address)info->si_addr)) {
255
stub = SharedRuntime::get_poll_stub(pc);
256
#if defined(__APPLE__)
257
// 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
258
// 64-bit Darwin may also use a SIGBUS (seen with compressed oops).
259
// Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
260
// being called, so only do so if the implicit NULL check is not necessary.
261
} else if (sig == SIGBUS && !MacroAssembler::uses_implicit_null_check(info->si_addr)) {
262
#else
263
} else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
264
#endif
265
// BugId 4454115: A read from a MappedByteBuffer can fault
266
// here if the underlying file has been truncated.
267
// Do not crash the VM in such a case.
268
CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
269
CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
270
bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
271
if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
272
address next_pc = pc + NativeCall::instruction_size;
273
if (is_unsafe_arraycopy) {
274
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
275
}
276
stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
277
}
278
} else if (sig == SIGILL && nativeInstruction_at(pc)->is_stop()) {
279
// Pull a pointer to the error message out of the instruction
280
// stream.
281
const uint64_t *detail_msg_ptr
282
= (uint64_t*)(pc + NativeInstruction::instruction_size);
283
const char *detail_msg = (const char *)*detail_msg_ptr;
284
const char *msg = "stop";
285
if (TraceTraps) {
286
tty->print_cr("trap: %s: (SIGILL)", msg);
287
}
288
289
// End life with a fatal error, message and detail message and the context.
290
// Note: no need to do any post-processing here (e.g. signal chaining)
291
report_and_die(thread, uc, NULL, 0, msg, "%s", detail_msg);
292
ShouldNotReachHere();
293
294
} else if (sig == SIGFPE &&
295
(info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
296
stub =
297
SharedRuntime::
298
continuation_for_implicit_exception(thread,
299
pc,
300
SharedRuntime::
301
IMPLICIT_DIVIDE_BY_ZERO);
302
} else if ((sig == SIGSEGV || sig == SIGBUS) &&
303
MacroAssembler::uses_implicit_null_check(info->si_addr)) {
304
// Determination of interpreter/vtable stub/compiled code null exception
305
stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
306
}
307
} else if ((thread->thread_state() == _thread_in_vm ||
308
thread->thread_state() == _thread_in_native) &&
309
sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
310
thread->doing_unsafe_access()) {
311
address next_pc = pc + NativeCall::instruction_size;
312
if (UnsafeCopyMemory::contains_pc(pc)) {
313
next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
314
}
315
stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
316
}
317
318
// jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
319
// and the heap gets shrunk before the field access.
320
if ((sig == SIGSEGV) || (sig == SIGBUS)) {
321
address addr = JNI_FastGetField::find_slowcase_pc(pc);
322
if (addr != (address)-1) {
323
stub = addr;
324
}
325
}
326
}
327
328
if (stub != NULL) {
329
// save all thread context in case we need to restore it
330
if (thread != NULL) thread->set_saved_exception_pc(pc);
331
332
os::Posix::ucontext_set_pc(uc, stub);
333
return true;
334
}
335
336
return false; // Mute compiler
337
}
338
339
void os::Bsd::init_thread_fpu_state(void) {
340
}
341
342
bool os::is_allocatable(size_t bytes) {
343
return true;
344
}
345
346
////////////////////////////////////////////////////////////////////////////////
347
// thread stack
348
349
// Minimum usable stack sizes required to get to user code. Space for
350
// HotSpot guard pages is added later.
351
size_t os::Posix::_compiler_thread_min_stack_allowed = 72 * K;
352
size_t os::Posix::_java_thread_min_stack_allowed = 72 * K;
353
size_t os::Posix::_vm_internal_thread_min_stack_allowed = 72 * K;
354
355
// return default stack size for thr_type
356
size_t os::Posix::default_stack_size(os::ThreadType thr_type) {
357
// default stack size (compiler thread needs larger stack)
358
size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
359
return s;
360
}
361
362
static void current_stack_region(address * bottom, size_t * size) {
363
#ifdef __APPLE__
364
pthread_t self = pthread_self();
365
void *stacktop = pthread_get_stackaddr_np(self);
366
*size = pthread_get_stacksize_np(self);
367
*bottom = (address) stacktop - *size;
368
#elif defined(__OpenBSD__)
369
stack_t ss;
370
int rslt = pthread_stackseg_np(pthread_self(), &ss);
371
372
if (rslt != 0)
373
fatal("pthread_stackseg_np failed with error = %d", rslt);
374
375
*bottom = (address)((char *)ss.ss_sp - ss.ss_size);
376
*size = ss.ss_size;
377
#else
378
pthread_attr_t attr;
379
380
int rslt = pthread_attr_init(&attr);
381
382
// JVM needs to know exact stack location, abort if it fails
383
if (rslt != 0)
384
fatal("pthread_attr_init failed with error = %d", rslt);
385
386
rslt = pthread_attr_get_np(pthread_self(), &attr);
387
388
if (rslt != 0)
389
fatal("pthread_attr_get_np failed with error = %d", rslt);
390
391
if (pthread_attr_getstackaddr(&attr, (void **)bottom) != 0 ||
392
pthread_attr_getstacksize(&attr, size) != 0) {
393
fatal("Can not locate current stack attributes!");
394
}
395
396
pthread_attr_destroy(&attr);
397
#endif
398
assert(os::current_stack_pointer() >= *bottom &&
399
os::current_stack_pointer() < *bottom + *size, "just checking");
400
}
401
402
address os::current_stack_base() {
403
address bottom;
404
size_t size;
405
current_stack_region(&bottom, &size);
406
return (bottom + size);
407
}
408
409
size_t os::current_stack_size() {
410
// stack size includes normal stack and HotSpot guard pages
411
address bottom;
412
size_t size;
413
current_stack_region(&bottom, &size);
414
return size;
415
}
416
417
/////////////////////////////////////////////////////////////////////////////
418
// helper functions for fatal error handler
419
420
void os::print_context(outputStream *st, const void *context) {
421
if (context == NULL) return;
422
423
const ucontext_t *uc = (const ucontext_t*)context;
424
st->print_cr("Registers:");
425
st->print( " x0=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 0]);
426
st->print(" x1=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 1]);
427
st->print(" x2=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 2]);
428
st->print(" x3=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 3]);
429
st->cr();
430
st->print( " x4=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 4]);
431
st->print(" x5=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 5]);
432
st->print(" x6=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 6]);
433
st->print(" x7=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 7]);
434
st->cr();
435
st->print( " x8=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 8]);
436
st->print(" x9=" INTPTR_FORMAT, (intptr_t)uc->context_x[ 9]);
437
st->print(" x10=" INTPTR_FORMAT, (intptr_t)uc->context_x[10]);
438
st->print(" x11=" INTPTR_FORMAT, (intptr_t)uc->context_x[11]);
439
st->cr();
440
st->print( "x12=" INTPTR_FORMAT, (intptr_t)uc->context_x[12]);
441
st->print(" x13=" INTPTR_FORMAT, (intptr_t)uc->context_x[13]);
442
st->print(" x14=" INTPTR_FORMAT, (intptr_t)uc->context_x[14]);
443
st->print(" x15=" INTPTR_FORMAT, (intptr_t)uc->context_x[15]);
444
st->cr();
445
st->print( "x16=" INTPTR_FORMAT, (intptr_t)uc->context_x[16]);
446
st->print(" x17=" INTPTR_FORMAT, (intptr_t)uc->context_x[17]);
447
st->print(" x18=" INTPTR_FORMAT, (intptr_t)uc->context_x[18]);
448
st->print(" x19=" INTPTR_FORMAT, (intptr_t)uc->context_x[19]);
449
st->cr();
450
st->print( "x20=" INTPTR_FORMAT, (intptr_t)uc->context_x[20]);
451
st->print(" x21=" INTPTR_FORMAT, (intptr_t)uc->context_x[21]);
452
st->print(" x22=" INTPTR_FORMAT, (intptr_t)uc->context_x[22]);
453
st->print(" x23=" INTPTR_FORMAT, (intptr_t)uc->context_x[23]);
454
st->cr();
455
st->print( "x24=" INTPTR_FORMAT, (intptr_t)uc->context_x[24]);
456
st->print(" x25=" INTPTR_FORMAT, (intptr_t)uc->context_x[25]);
457
st->print(" x26=" INTPTR_FORMAT, (intptr_t)uc->context_x[26]);
458
st->print(" x27=" INTPTR_FORMAT, (intptr_t)uc->context_x[27]);
459
st->cr();
460
st->print( "x28=" INTPTR_FORMAT, (intptr_t)uc->context_x[28]);
461
st->print(" fp=" INTPTR_FORMAT, (intptr_t)uc->context_fp);
462
st->print(" lr=" INTPTR_FORMAT, (intptr_t)uc->context_lr);
463
st->print(" sp=" INTPTR_FORMAT, (intptr_t)uc->context_sp);
464
st->cr();
465
st->print( "pc=" INTPTR_FORMAT, (intptr_t)uc->context_pc);
466
st->print(" cpsr=" INTPTR_FORMAT, (intptr_t)uc->context_cpsr);
467
st->cr();
468
469
intptr_t *sp = (intptr_t *)os::Bsd::ucontext_get_sp(uc);
470
st->print_cr("Top of Stack: (sp=" INTPTR_FORMAT ")", (intptr_t)sp);
471
print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
472
st->cr();
473
474
// Note: it may be unsafe to inspect memory near pc. For example, pc may
475
// point to garbage if entry point in an nmethod is corrupted. Leave
476
// this at the end, and hope for the best.
477
address pc = os::Posix::ucontext_get_pc(uc);
478
print_instructions(st, pc, 4/*native instruction size*/);
479
st->cr();
480
}
481
482
void os::print_register_info(outputStream *st, const void *context) {
483
if (context == NULL) return;
484
485
const ucontext_t *uc = (const ucontext_t*)context;
486
487
st->print_cr("Register to memory mapping:");
488
st->cr();
489
490
// this is horrendously verbose but the layout of the registers in the
491
// context does not match how we defined our abstract Register set, so
492
// we can't just iterate through the gregs area
493
494
// this is only for the "general purpose" registers
495
496
st->print(" x0="); print_location(st, uc->context_x[ 0]);
497
st->print(" x1="); print_location(st, uc->context_x[ 1]);
498
st->print(" x2="); print_location(st, uc->context_x[ 2]);
499
st->print(" x3="); print_location(st, uc->context_x[ 3]);
500
st->print(" x4="); print_location(st, uc->context_x[ 4]);
501
st->print(" x5="); print_location(st, uc->context_x[ 5]);
502
st->print(" x6="); print_location(st, uc->context_x[ 6]);
503
st->print(" x7="); print_location(st, uc->context_x[ 7]);
504
st->print(" x8="); print_location(st, uc->context_x[ 8]);
505
st->print(" x9="); print_location(st, uc->context_x[ 9]);
506
st->print("x10="); print_location(st, uc->context_x[10]);
507
st->print("x11="); print_location(st, uc->context_x[11]);
508
st->print("x12="); print_location(st, uc->context_x[12]);
509
st->print("x13="); print_location(st, uc->context_x[13]);
510
st->print("x14="); print_location(st, uc->context_x[14]);
511
st->print("x15="); print_location(st, uc->context_x[15]);
512
st->print("x16="); print_location(st, uc->context_x[16]);
513
st->print("x17="); print_location(st, uc->context_x[17]);
514
st->print("x18="); print_location(st, uc->context_x[18]);
515
st->print("x19="); print_location(st, uc->context_x[19]);
516
st->print("x20="); print_location(st, uc->context_x[20]);
517
st->print("x21="); print_location(st, uc->context_x[21]);
518
st->print("x22="); print_location(st, uc->context_x[22]);
519
st->print("x23="); print_location(st, uc->context_x[23]);
520
st->print("x24="); print_location(st, uc->context_x[24]);
521
st->print("x25="); print_location(st, uc->context_x[25]);
522
st->print("x26="); print_location(st, uc->context_x[26]);
523
st->print("x27="); print_location(st, uc->context_x[27]);
524
st->print("x28="); print_location(st, uc->context_x[28]);
525
526
st->cr();
527
}
528
529
void os::setup_fpu() {
530
}
531
532
#ifndef PRODUCT
533
void os::verify_stack_alignment() {
534
assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
535
}
536
#endif
537
538
int os::extra_bang_size_in_bytes() {
539
// AArch64 does not require the additional stack bang.
540
return 0;
541
}
542
543
void os::current_thread_enable_wx(WXMode mode) {
544
if (os::Bsd::isRWXJITAvailable()) {
545
jit_write_protect(mode == WXExec);
546
}
547
}
548
549
extern "C" {
550
int SpinPause() {
551
return 0;
552
}
553
554
void _Copy_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
555
if (from > to) {
556
const jshort *end = from + count;
557
while (from < end)
558
*(to++) = *(from++);
559
}
560
else if (from < to) {
561
const jshort *end = from;
562
from += count - 1;
563
to += count - 1;
564
while (from >= end)
565
*(to--) = *(from--);
566
}
567
}
568
void _Copy_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
569
if (from > to) {
570
const jint *end = from + count;
571
while (from < end)
572
*(to++) = *(from++);
573
}
574
else if (from < to) {
575
const jint *end = from;
576
from += count - 1;
577
to += count - 1;
578
while (from >= end)
579
*(to--) = *(from--);
580
}
581
}
582
void _Copy_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
583
if (from > to) {
584
const jlong *end = from + count;
585
while (from < end)
586
os::atomic_copy64(from++, to++);
587
}
588
else if (from < to) {
589
const jlong *end = from;
590
from += count - 1;
591
to += count - 1;
592
while (from >= end)
593
os::atomic_copy64(from--, to--);
594
}
595
}
596
597
void _Copy_arrayof_conjoint_bytes(const HeapWord* from,
598
HeapWord* to,
599
size_t count) {
600
memmove(to, from, count);
601
}
602
void _Copy_arrayof_conjoint_jshorts(const HeapWord* from,
603
HeapWord* to,
604
size_t count) {
605
memmove(to, from, count * 2);
606
}
607
void _Copy_arrayof_conjoint_jints(const HeapWord* from,
608
HeapWord* to,
609
size_t count) {
610
memmove(to, from, count * 4);
611
}
612
void _Copy_arrayof_conjoint_jlongs(const HeapWord* from,
613
HeapWord* to,
614
size_t count) {
615
memmove(to, from, count * 8);
616
}
617
};
618
619