Path: blob/master/src/hotspot/os_cpu/windows_aarch64/os_windows_aarch64.cpp
40930 views
/*1* Copyright (c) 2020, Microsoft Corporation. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "jvm.h"26#include "asm/macroAssembler.hpp"27#include "classfile/vmSymbols.hpp"28#include "code/codeCache.hpp"29#include "code/icBuffer.hpp"30#include "code/vtableStubs.hpp"31#include "code/nativeInst.hpp"32#include "interpreter/interpreter.hpp"33#include "memory/allocation.inline.hpp"34#include "prims/jniFastGetField.hpp"35#include "prims/jvm_misc.hpp"36#include "runtime/arguments.hpp"37#include "runtime/frame.inline.hpp"38#include "runtime/interfaceSupport.inline.hpp"39#include "runtime/java.hpp"40#include "runtime/javaCalls.hpp"41#include "runtime/mutexLocker.hpp"42#include "runtime/osThread.hpp"43#include "runtime/sharedRuntime.hpp"44#include "runtime/stubRoutines.hpp"45#include "runtime/thread.inline.hpp"46#include "runtime/timer.hpp"47#include "unwind_windows_aarch64.hpp"48#include "utilities/debug.hpp"49#include "utilities/events.hpp"50#include "utilities/vmError.hpp"515253// put OS-includes here54# include <sys/types.h>55# include <signal.h>56# include <errno.h>57# include <stdlib.h>58# include <stdio.h>59# include <intrin.h>6061void os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& method, JavaCallArguments* args, JavaThread* thread) {62f(value, method, args, thread);63}6465PRAGMA_DISABLE_MSVC_WARNING(4172)66// Returns an estimate of the current stack pointer. Result must be guaranteed67// to point into the calling threads stack, and be no lower than the current68// stack pointer.69address os::current_stack_pointer() {70int dummy;71address sp = (address)&dummy;72return sp;73}7475address os::fetch_frame_from_context(const void* ucVoid,76intptr_t** ret_sp, intptr_t** ret_fp) {77address epc;78CONTEXT* uc = (CONTEXT*)ucVoid;7980if (uc != NULL) {81epc = (address)uc->Pc;82if (ret_sp) *ret_sp = (intptr_t*)uc->Sp;83if (ret_fp) *ret_fp = (intptr_t*)uc->Fp;84} else {85// construct empty ExtendedPC for return value checking86epc = NULL;87if (ret_sp) *ret_sp = (intptr_t *)NULL;88if (ret_fp) *ret_fp = (intptr_t *)NULL;89}90return epc;91}9293frame os::fetch_frame_from_context(const void* ucVoid) {94intptr_t* sp;95intptr_t* fp;96address epc = fetch_frame_from_context(ucVoid, &sp, &fp);97return frame(sp, fp, epc);98}99100bool os::win32::get_frame_at_stack_banging_point(JavaThread* thread,101struct _EXCEPTION_POINTERS* exceptionInfo, address pc, frame* fr) {102PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;103address addr = (address) exceptionRecord->ExceptionInformation[1];104if (Interpreter::contains(pc)) {105// interpreter performs stack banging after the fixed frame header has106// been generated while the compilers perform it before. To maintain107// semantic consistency between interpreted and compiled frames, the108// method returns the Java sender of the current frame.109*fr = os::fetch_frame_from_context((void*)exceptionInfo->ContextRecord);110if (!fr->is_first_java_frame()) {111assert(fr->safe_for_sender(thread), "Safety check");112*fr = fr->java_sender();113}114} else {115// more complex code with compiled code116assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");117CodeBlob* cb = CodeCache::find_blob(pc);118if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {119// Not sure where the pc points to, fallback to default120// stack overflow handling121return false;122} else {123// In compiled code, the stack banging is performed before LR124// has been saved in the frame. LR is live, and SP and FP125// belong to the caller.126intptr_t* fp = (intptr_t*)exceptionInfo->ContextRecord->Fp;127intptr_t* sp = (intptr_t*)exceptionInfo->ContextRecord->Sp;128address pc = (address)(exceptionInfo->ContextRecord->Lr129- NativeInstruction::instruction_size);130*fr = frame(sp, fp, pc);131if (!fr->is_java_frame()) {132assert(fr->safe_for_sender(thread), "Safety check");133assert(!fr->is_first_frame(), "Safety check");134*fr = fr->java_sender();135}136}137}138assert(fr->is_java_frame(), "Safety check");139return true;140}141142frame os::get_sender_for_C_frame(frame* fr) {143ShouldNotReachHere();144return frame();145}146147frame os::current_frame() {148return frame(); // cannot walk Windows frames this way. See os::get_native_stack149// and os::platform_print_native_stack150}151152////////////////////////////////////////////////////////////////////////////////153// thread stack154155// Minimum usable stack sizes required to get to user code. Space for156// HotSpot guard pages is added later.157158/////////////////////////////////////////////////////////////////////////////159// helper functions for fatal error handler160161void os::print_context(outputStream *st, const void *context) {162if (context == NULL) return;163164const CONTEXT* uc = (const CONTEXT*)context;165166st->print_cr("Registers:");167168st->print( "X0 =" INTPTR_FORMAT, uc->X0);169st->print(", X1 =" INTPTR_FORMAT, uc->X1);170st->print(", X2 =" INTPTR_FORMAT, uc->X2);171st->print(", X3 =" INTPTR_FORMAT, uc->X3);172st->cr();173st->print( "X4 =" INTPTR_FORMAT, uc->X4);174st->print(", X5 =" INTPTR_FORMAT, uc->X5);175st->print(", X6 =" INTPTR_FORMAT, uc->X6);176st->print(", X7 =" INTPTR_FORMAT, uc->X7);177st->cr();178st->print( "X8 =" INTPTR_FORMAT, uc->X8);179st->print(", X9 =" INTPTR_FORMAT, uc->X9);180st->print(", X10=" INTPTR_FORMAT, uc->X10);181st->print(", X11=" INTPTR_FORMAT, uc->X11);182st->cr();183st->print( "X12=" INTPTR_FORMAT, uc->X12);184st->print(", X13=" INTPTR_FORMAT, uc->X13);185st->print(", X14=" INTPTR_FORMAT, uc->X14);186st->print(", X15=" INTPTR_FORMAT, uc->X15);187st->cr();188st->print( "X16=" INTPTR_FORMAT, uc->X16);189st->print(", X17=" INTPTR_FORMAT, uc->X17);190st->print(", X18=" INTPTR_FORMAT, uc->X18);191st->print(", X19=" INTPTR_FORMAT, uc->X19);192st->cr();193st->print(", X20=" INTPTR_FORMAT, uc->X20);194st->print(", X21=" INTPTR_FORMAT, uc->X21);195st->print(", X22=" INTPTR_FORMAT, uc->X22);196st->print(", X23=" INTPTR_FORMAT, uc->X23);197st->cr();198st->print(", X24=" INTPTR_FORMAT, uc->X24);199st->print(", X25=" INTPTR_FORMAT, uc->X25);200st->print(", X26=" INTPTR_FORMAT, uc->X26);201st->print(", X27=" INTPTR_FORMAT, uc->X27);202st->print(", X28=" INTPTR_FORMAT, uc->X28);203st->cr();204st->cr();205206intptr_t *sp = (intptr_t *)uc->Sp;207st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);208print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));209st->cr();210211// Note: it may be unsafe to inspect memory near pc. For example, pc may212// point to garbage if entry point in an nmethod is corrupted. Leave213// this at the end, and hope for the best.214address pc = (address)uc->Pc;215st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);216print_hex_dump(st, pc - 32, pc + 32, sizeof(char));217st->cr();218219}220221void os::print_register_info(outputStream *st, const void *context) {222if (context == NULL) return;223224const CONTEXT* uc = (const CONTEXT*)context;225226st->print_cr("Register to memory mapping:");227st->cr();228// this is only for the "general purpose" registers229st->print(" X0="); print_location(st, uc->X0);230st->print(" X1="); print_location(st, uc->X1);231st->print(" X2="); print_location(st, uc->X2);232st->print(" X3="); print_location(st, uc->X3);233st->cr();234st->print(" X4="); print_location(st, uc->X4);235st->print(" X5="); print_location(st, uc->X5);236st->print(" X6="); print_location(st, uc->X6);237st->print(" X7="); print_location(st, uc->X7);238st->cr();239st->print(" X8="); print_location(st, uc->X8);240st->print(" X9="); print_location(st, uc->X9);241st->print("X10="); print_location(st, uc->X10);242st->print("X11="); print_location(st, uc->X11);243st->cr();244st->print("X12="); print_location(st, uc->X12);245st->print("X13="); print_location(st, uc->X13);246st->print("X14="); print_location(st, uc->X14);247st->print("X15="); print_location(st, uc->X15);248st->cr();249st->print("X16="); print_location(st, uc->X16);250st->print("X17="); print_location(st, uc->X17);251st->print("X18="); print_location(st, uc->X18);252st->print("X19="); print_location(st, uc->X19);253st->cr();254st->print("X20="); print_location(st, uc->X20);255st->print("X21="); print_location(st, uc->X21);256st->print("X22="); print_location(st, uc->X22);257st->print("X23="); print_location(st, uc->X23);258st->cr();259st->print("X24="); print_location(st, uc->X24);260st->print("X25="); print_location(st, uc->X25);261st->print("X26="); print_location(st, uc->X26);262st->print("X27="); print_location(st, uc->X27);263st->print("X28="); print_location(st, uc->X28);264265st->cr();266}267268void os::setup_fpu() {269}270271bool os::supports_sse() {272return true;273}274275#ifndef PRODUCT276void os::verify_stack_alignment() {277assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");278}279#endif280281int os::extra_bang_size_in_bytes() {282// AArch64 does not require the additional stack bang.283return 0;284}285286extern "C" {287int SpinPause() {288return 0;289}290};291292293