annotate src/os_cpu/windows_x86/vm/os_windows_x86.cpp @ 6842:b9a9ed0f8eeb

7197424: update copyright year to match last edit in jdk8 hotspot repository Summary: Update copyright year to 2012 for relevant files Reviewed-by: dholmes, coleenp
author mikael
date Tue, 09 Oct 2012 10:09:34 -0700
parents bf2edd3c9b0f
children 5ec0c42da025
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 6825
diff changeset
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 844
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
25 // no precompiled headers
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
26 #include "assembler_x86.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
27 #include "classfile/classLoader.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
28 #include "classfile/systemDictionary.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
29 #include "classfile/vmSymbols.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
30 #include "code/icBuffer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
31 #include "code/vtableStubs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
32 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
33 #include "jvm_windows.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
34 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
35 #include "mutex_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
36 #include "nativeInst_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
37 #include "os_share_windows.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
38 #include "prims/jniFastGetField.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
39 #include "prims/jvm.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
40 #include "prims/jvm_misc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
41 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
42 #include "runtime/extendedPC.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
43 #include "runtime/frame.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
44 #include "runtime/interfaceSupport.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
45 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
46 #include "runtime/javaCalls.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
47 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
48 #include "runtime/osThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
49 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
50 #include "runtime/stubRoutines.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
51 #include "runtime/timer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
52 #include "thread_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
53 #include "utilities/events.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
54 #include "utilities/vmError.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
55
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 # include "unwind_windows_x86.hpp"
a61af66fc99e Initial load
duke
parents:
diff changeset
57 #undef REG_SP
a61af66fc99e Initial load
duke
parents:
diff changeset
58 #undef REG_FP
a61af66fc99e Initial load
duke
parents:
diff changeset
59 #undef REG_PC
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
61 #define REG_SP Rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
62 #define REG_FP Rbp
a61af66fc99e Initial load
duke
parents:
diff changeset
63 #define REG_PC Rip
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
65 #define REG_SP Esp
a61af66fc99e Initial load
duke
parents:
diff changeset
66 #define REG_FP Ebp
a61af66fc99e Initial load
duke
parents:
diff changeset
67 #define REG_PC Eip
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // Install a win32 structured exception handler around thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
73 void os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 __try {
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 #ifndef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // We store the current thread in this wrapperthread location
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // and determine how far away this address is from the structured
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // execption pointer that FS:[0] points to. This get_thread
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // code can then get the thread pointer via FS.
a61af66fc99e Initial load
duke
parents:
diff changeset
81 //
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Warning: This routine must NEVER be inlined since we'd end up with
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // multiple offsets.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //
a61af66fc99e Initial load
duke
parents:
diff changeset
85 volatile Thread* wrapperthread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 int thread_ptr_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 __asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 lea eax, dword ptr wrapperthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 sub eax, dword ptr FS:[0H];
a61af66fc99e Initial load
duke
parents:
diff changeset
92 mov thread_ptr_offset, eax
a61af66fc99e Initial load
duke
parents:
diff changeset
93 };
a61af66fc99e Initial load
duke
parents:
diff changeset
94 ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // Verify that the offset hasn't changed since we initally captured
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // it. This might happen if we accidentally ended up with an
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // inlined version of this routine.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 int test_thread_ptr_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
102 __asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 lea eax, dword ptr wrapperthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 sub eax, dword ptr FS:[0H];
a61af66fc99e Initial load
duke
parents:
diff changeset
105 mov test_thread_ptr_offset, eax
a61af66fc99e Initial load
duke
parents:
diff changeset
106 };
a61af66fc99e Initial load
duke
parents:
diff changeset
107 assert(test_thread_ptr_offset == ThreadLocalStorage::get_thread_ptr_offset(),
a61af66fc99e Initial load
duke
parents:
diff changeset
108 "thread pointer offset from SEH changed");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
111 #endif // !AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 f(value, method, args, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 } __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // Nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // This is the language specific handler for exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // originating from dynamically generated code.
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // We call the standard structured exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // We only expect Continued Execution since we cannot unwind
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // from generated code.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 LONG HandleExceptionFromCodeCache(
a61af66fc99e Initial load
duke
parents:
diff changeset
127 IN PEXCEPTION_RECORD ExceptionRecord,
a61af66fc99e Initial load
duke
parents:
diff changeset
128 IN ULONG64 EstablisherFrame,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 IN OUT PCONTEXT ContextRecord,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 IN OUT PDISPATCHER_CONTEXT DispatcherContext) {
a61af66fc99e Initial load
duke
parents:
diff changeset
131 EXCEPTION_POINTERS ep;
a61af66fc99e Initial load
duke
parents:
diff changeset
132 LONG result;
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 ep.ExceptionRecord = ExceptionRecord;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ep.ContextRecord = ContextRecord;
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 result = topLevelExceptionFilter(&ep);
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // We better only get a CONTINUE_EXECUTION from our handler
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // since we don't have unwind information registered.
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 guarantee( result == EXCEPTION_CONTINUE_EXECUTION,
a61af66fc99e Initial load
duke
parents:
diff changeset
143 "Unexpected result from topLevelExceptionFilter");
a61af66fc99e Initial load
duke
parents:
diff changeset
144
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return(ExceptionContinueExecution);
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Structure containing the Windows Data Structures required
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // to register our Code Cache exception handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // We put these in the CodeCache since the API requires
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // all addresses in these structures are relative to the Code
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // area registered with RtlAddFunctionTable.
a61af66fc99e Initial load
duke
parents:
diff changeset
154 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
155 char ExceptionHandlerInstr[16]; // jmp HandleExceptionFromCodeCache
a61af66fc99e Initial load
duke
parents:
diff changeset
156 RUNTIME_FUNCTION rt;
a61af66fc99e Initial load
duke
parents:
diff changeset
157 UNWIND_INFO_EH_ONLY unw;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 } DynamicCodeData, *pDynamicCodeData;
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
161 //
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Register our CodeCache area with the OS so it will dispatch exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // to our topLevelExceptionFilter when we take an exception in our
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // dynamically generated code.
a61af66fc99e Initial load
duke
parents:
diff changeset
165 //
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Arguments: low and high are the address of the full reserved
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // codeCache area
a61af66fc99e Initial load
duke
parents:
diff changeset
168 //
a61af66fc99e Initial load
duke
parents:
diff changeset
169 bool os::register_code_area(char *low, char *high) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
171
a61af66fc99e Initial load
duke
parents:
diff changeset
172 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 pDynamicCodeData pDCD;
a61af66fc99e Initial load
duke
parents:
diff changeset
175 PRUNTIME_FUNCTION prt;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 PUNWIND_INFO_EH_ONLY punwind;
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // If we are using Vectored Exceptions we don't need this registration
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if (UseVectoredExceptions) return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
180
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1681
diff changeset
181 BufferBlob* blob = BufferBlob::create("CodeCache Exception Handler", sizeof(DynamicCodeData));
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1681
diff changeset
182 CodeBuffer cb(blob);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
183 MacroAssembler* masm = new MacroAssembler(&cb);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 pDCD = (pDynamicCodeData) masm->pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 masm->jump(ExternalAddress((address)&HandleExceptionFromCodeCache));
a61af66fc99e Initial load
duke
parents:
diff changeset
187 masm->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // Create an Unwind Structure specifying no unwind info
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // other than an Exception Handler
a61af66fc99e Initial load
duke
parents:
diff changeset
191 punwind = &pDCD->unw;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 punwind->Version = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 punwind->Flags = UNW_FLAG_EHANDLER;
a61af66fc99e Initial load
duke
parents:
diff changeset
194 punwind->SizeOfProlog = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 punwind->CountOfCodes = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 punwind->FrameRegister = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
197 punwind->FrameOffset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 punwind->ExceptionHandler = (char *)(&(pDCD->ExceptionHandlerInstr[0])) -
a61af66fc99e Initial load
duke
parents:
diff changeset
199 (char*)low;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 punwind->ExceptionData[0] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // This structure describes the covered dynamic code area.
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // Addresses are relative to the beginning on the code cache area
a61af66fc99e Initial load
duke
parents:
diff changeset
204 prt = &pDCD->rt;
a61af66fc99e Initial load
duke
parents:
diff changeset
205 prt->BeginAddress = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 prt->EndAddress = (ULONG)(high - low);
a61af66fc99e Initial load
duke
parents:
diff changeset
207 prt->UnwindData = ((char *)punwind - low);
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 guarantee(RtlAddFunctionTable(prt, 1, (ULONGLONG)low),
a61af66fc99e Initial load
duke
parents:
diff changeset
210 "Failed to register Dynamic Code Exception Handler with RtlAddFunctionTable");
a61af66fc99e Initial load
duke
parents:
diff changeset
211
a61af66fc99e Initial load
duke
parents:
diff changeset
212 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
213 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
214 }
a61af66fc99e Initial load
duke
parents:
diff changeset
215
6768
716e6ef4482a 7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents: 5903
diff changeset
216 void os::initialize_thread(Thread* thr) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
217 // Nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
218 }
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 // Atomics and Stub Functions
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 typedef jint xchg_func_t (jint, volatile jint*);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 typedef intptr_t xchg_ptr_func_t (intptr_t, volatile intptr_t*);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 typedef jint cmpxchg_func_t (jint, volatile jint*, jint);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 typedef jlong cmpxchg_long_func_t (jlong, volatile jlong*, jlong);
a61af66fc99e Initial load
duke
parents:
diff changeset
226 typedef jint add_func_t (jint, volatile jint*);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 typedef intptr_t add_ptr_func_t (intptr_t, volatile intptr_t*);
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
230
a61af66fc99e Initial load
duke
parents:
diff changeset
231 jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
233 xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
234
a61af66fc99e Initial load
duke
parents:
diff changeset
235 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
236 os::atomic_xchg_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
237 return (*func)(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
238 }
a61af66fc99e Initial load
duke
parents:
diff changeset
239 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
240
a61af66fc99e Initial load
duke
parents:
diff changeset
241 jint old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
243 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
244 }
a61af66fc99e Initial load
duke
parents:
diff changeset
245
a61af66fc99e Initial load
duke
parents:
diff changeset
246 intptr_t os::atomic_xchg_ptr_bootstrap(intptr_t exchange_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
248 xchg_ptr_func_t* func = CAST_TO_FN_PTR(xchg_ptr_func_t*, StubRoutines::atomic_xchg_ptr_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 os::atomic_xchg_ptr_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
252 return (*func)(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
253 }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 intptr_t old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
258 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
259 }
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
264 cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
267 os::atomic_cmpxchg_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
268 return (*func)(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 }
a61af66fc99e Initial load
duke
parents:
diff changeset
270 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
271
a61af66fc99e Initial load
duke
parents:
diff changeset
272 jint old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if (old_value == compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
274 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
275 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }
a61af66fc99e Initial load
duke
parents:
diff changeset
277 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
278
a61af66fc99e Initial load
duke
parents:
diff changeset
279 jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
281 cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
282
a61af66fc99e Initial load
duke
parents:
diff changeset
283 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
284 os::atomic_cmpxchg_long_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
285 return (*func)(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
286 }
a61af66fc99e Initial load
duke
parents:
diff changeset
287 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
288
a61af66fc99e Initial load
duke
parents:
diff changeset
289 jlong old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 if (old_value == compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
291 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
292 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
293 }
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
296
a61af66fc99e Initial load
duke
parents:
diff changeset
297 jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
298 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
299 add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
302 os::atomic_add_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
303 return (*func)(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
306
a61af66fc99e Initial load
duke
parents:
diff changeset
307 return (*dest) += add_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
308 }
a61af66fc99e Initial load
duke
parents:
diff changeset
309
a61af66fc99e Initial load
duke
parents:
diff changeset
310 intptr_t os::atomic_add_ptr_bootstrap(intptr_t add_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
311 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
312 add_ptr_func_t* func = CAST_TO_FN_PTR(add_ptr_func_t*, StubRoutines::atomic_add_ptr_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
313
a61af66fc99e Initial load
duke
parents:
diff changeset
314 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
315 os::atomic_add_ptr_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
316 return (*func)(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 }
a61af66fc99e Initial load
duke
parents:
diff changeset
318 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
319
a61af66fc99e Initial load
duke
parents:
diff changeset
320 return (*dest) += add_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
321 }
a61af66fc99e Initial load
duke
parents:
diff changeset
322
a61af66fc99e Initial load
duke
parents:
diff changeset
323 xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 xchg_ptr_func_t* os::atomic_xchg_ptr_func = os::atomic_xchg_ptr_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
326 add_func_t* os::atomic_add_func = os::atomic_add_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
327 add_ptr_func_t* os::atomic_add_ptr_func = os::atomic_add_ptr_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
332
a61af66fc99e Initial load
duke
parents:
diff changeset
333 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
a61af66fc99e Initial load
duke
parents:
diff changeset
334 intptr_t** ret_sp, intptr_t** ret_fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
335
a61af66fc99e Initial load
duke
parents:
diff changeset
336 ExtendedPC epc;
a61af66fc99e Initial load
duke
parents:
diff changeset
337 CONTEXT* uc = (CONTEXT*)ucVoid;
a61af66fc99e Initial load
duke
parents:
diff changeset
338
a61af66fc99e Initial load
duke
parents:
diff changeset
339 if (uc != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
340 epc = ExtendedPC((address)uc->REG_PC);
a61af66fc99e Initial load
duke
parents:
diff changeset
341 if (ret_sp) *ret_sp = (intptr_t*)uc->REG_SP;
a61af66fc99e Initial load
duke
parents:
diff changeset
342 if (ret_fp) *ret_fp = (intptr_t*)uc->REG_FP;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
344 // construct empty ExtendedPC for return value checking
a61af66fc99e Initial load
duke
parents:
diff changeset
345 epc = ExtendedPC(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
346 if (ret_sp) *ret_sp = (intptr_t *)NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
347 if (ret_fp) *ret_fp = (intptr_t *)NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
348 }
a61af66fc99e Initial load
duke
parents:
diff changeset
349
a61af66fc99e Initial load
duke
parents:
diff changeset
350 return epc;
a61af66fc99e Initial load
duke
parents:
diff changeset
351 }
a61af66fc99e Initial load
duke
parents:
diff changeset
352
a61af66fc99e Initial load
duke
parents:
diff changeset
353 frame os::fetch_frame_from_context(void* ucVoid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
354 intptr_t* sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
355 intptr_t* fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
356 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
357 return frame(sp, fp, epc.pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
358 }
a61af66fc99e Initial load
duke
parents:
diff changeset
359
a61af66fc99e Initial load
duke
parents:
diff changeset
360 // VC++ does not save frame pointer on stack in optimized build. It
a61af66fc99e Initial load
duke
parents:
diff changeset
361 // can be turned off by /Oy-. If we really want to walk C frames,
a61af66fc99e Initial load
duke
parents:
diff changeset
362 // we can use the StackWalk() API.
a61af66fc99e Initial load
duke
parents:
diff changeset
363 frame os::get_sender_for_C_frame(frame* fr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
364 return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
365 }
a61af66fc99e Initial load
duke
parents:
diff changeset
366
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
367 #ifndef AMD64
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
368 // Returns an estimate of the current stack pointer. Result must be guaranteed
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
369 // to point into the calling threads stack, and be no lower than the current
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
370 // stack pointer.
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
371 address os::current_stack_pointer() {
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
372 int dummy;
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
373 address sp = (address)&dummy;
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
374 return sp;
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
375 }
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
376 #else
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
377 // Returns the current stack pointer. Accurate value needed for
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
378 // os::verify_stack_alignment().
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
379 address os::current_stack_pointer() {
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
380 typedef address get_sp_func();
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
381 get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*,
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
382 StubRoutines::x86::get_previous_sp_entry());
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
383 return (*func)();
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
384 }
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
385 #endif
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
386
0
a61af66fc99e Initial load
duke
parents:
diff changeset
387
a61af66fc99e Initial load
duke
parents:
diff changeset
388 #ifndef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
389 intptr_t* _get_previous_fp() {
a61af66fc99e Initial load
duke
parents:
diff changeset
390 intptr_t **frameptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
391 __asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
392 mov frameptr, ebp
a61af66fc99e Initial load
duke
parents:
diff changeset
393 };
a61af66fc99e Initial load
duke
parents:
diff changeset
394 return *frameptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
395 }
a61af66fc99e Initial load
duke
parents:
diff changeset
396 #endif // !AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
397
a61af66fc99e Initial load
duke
parents:
diff changeset
398 frame os::current_frame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
399
a61af66fc99e Initial load
duke
parents:
diff changeset
400 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
401 // apparently _asm not supported on windows amd64
a61af66fc99e Initial load
duke
parents:
diff changeset
402 typedef intptr_t* get_fp_func ();
a61af66fc99e Initial load
duke
parents:
diff changeset
403 get_fp_func* func = CAST_TO_FN_PTR(get_fp_func*,
304
dc7f315e41f7 5108146: Merge i486 and amd64 cpu directories
never
parents: 0
diff changeset
404 StubRoutines::x86::get_previous_fp_entry());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
405 if (func == NULL) return frame(NULL, NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
406 intptr_t* fp = (*func)();
a61af66fc99e Initial load
duke
parents:
diff changeset
407 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
408 intptr_t* fp = _get_previous_fp();
a61af66fc99e Initial load
duke
parents:
diff changeset
409 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 frame myframe((intptr_t*)os::current_stack_pointer(),
a61af66fc99e Initial load
duke
parents:
diff changeset
412 (intptr_t*)fp,
a61af66fc99e Initial load
duke
parents:
diff changeset
413 CAST_FROM_FN_PTR(address, os::current_frame));
a61af66fc99e Initial load
duke
parents:
diff changeset
414 if (os::is_first_C_frame(&myframe)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
415 // stack is not walkable
a61af66fc99e Initial load
duke
parents:
diff changeset
416 return frame(NULL, NULL, NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
417 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
418 return os::get_sender_for_C_frame(&myframe);
a61af66fc99e Initial load
duke
parents:
diff changeset
419 }
a61af66fc99e Initial load
duke
parents:
diff changeset
420 }
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422 void os::print_context(outputStream *st, void *context) {
a61af66fc99e Initial load
duke
parents:
diff changeset
423 if (context == NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 CONTEXT* uc = (CONTEXT*)context;
a61af66fc99e Initial load
duke
parents:
diff changeset
426
a61af66fc99e Initial load
duke
parents:
diff changeset
427 st->print_cr("Registers:");
a61af66fc99e Initial load
duke
parents:
diff changeset
428 #ifdef AMD64
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
429 st->print( "RAX=" INTPTR_FORMAT, uc->Rax);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
430 st->print(", RBX=" INTPTR_FORMAT, uc->Rbx);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
431 st->print(", RCX=" INTPTR_FORMAT, uc->Rcx);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
432 st->print(", RDX=" INTPTR_FORMAT, uc->Rdx);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
433 st->cr();
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
434 st->print( "RSP=" INTPTR_FORMAT, uc->Rsp);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
435 st->print(", RBP=" INTPTR_FORMAT, uc->Rbp);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
436 st->print(", RSI=" INTPTR_FORMAT, uc->Rsi);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
437 st->print(", RDI=" INTPTR_FORMAT, uc->Rdi);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
438 st->cr();
1907
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
439 st->print( "R8 =" INTPTR_FORMAT, uc->R8);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
440 st->print(", R9 =" INTPTR_FORMAT, uc->R9);
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
441 st->print(", R10=" INTPTR_FORMAT, uc->R10);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
442 st->print(", R11=" INTPTR_FORMAT, uc->R11);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
443 st->cr();
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
444 st->print( "R12=" INTPTR_FORMAT, uc->R12);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
445 st->print(", R13=" INTPTR_FORMAT, uc->R13);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
446 st->print(", R14=" INTPTR_FORMAT, uc->R14);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
447 st->print(", R15=" INTPTR_FORMAT, uc->R15);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
448 st->cr();
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
449 st->print( "RIP=" INTPTR_FORMAT, uc->Rip);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
450 st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
451 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
452 st->print( "EAX=" INTPTR_FORMAT, uc->Eax);
a61af66fc99e Initial load
duke
parents:
diff changeset
453 st->print(", EBX=" INTPTR_FORMAT, uc->Ebx);
a61af66fc99e Initial load
duke
parents:
diff changeset
454 st->print(", ECX=" INTPTR_FORMAT, uc->Ecx);
a61af66fc99e Initial load
duke
parents:
diff changeset
455 st->print(", EDX=" INTPTR_FORMAT, uc->Edx);
a61af66fc99e Initial load
duke
parents:
diff changeset
456 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
457 st->print( "ESP=" INTPTR_FORMAT, uc->Esp);
a61af66fc99e Initial load
duke
parents:
diff changeset
458 st->print(", EBP=" INTPTR_FORMAT, uc->Ebp);
a61af66fc99e Initial load
duke
parents:
diff changeset
459 st->print(", ESI=" INTPTR_FORMAT, uc->Esi);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 st->print(", EDI=" INTPTR_FORMAT, uc->Edi);
a61af66fc99e Initial load
duke
parents:
diff changeset
461 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
462 st->print( "EIP=" INTPTR_FORMAT, uc->Eip);
a61af66fc99e Initial load
duke
parents:
diff changeset
463 st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags);
a61af66fc99e Initial load
duke
parents:
diff changeset
464 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
465 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
466 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
467
a61af66fc99e Initial load
duke
parents:
diff changeset
468 intptr_t *sp = (intptr_t *)uc->REG_SP;
a61af66fc99e Initial load
duke
parents:
diff changeset
469 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
470 print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
a61af66fc99e Initial load
duke
parents:
diff changeset
471 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
472
a61af66fc99e Initial load
duke
parents:
diff changeset
473 // Note: it may be unsafe to inspect memory near pc. For example, pc may
a61af66fc99e Initial load
duke
parents:
diff changeset
474 // point to garbage if entry point in an nmethod is corrupted. Leave
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // this at the end, and hope for the best.
a61af66fc99e Initial load
duke
parents:
diff changeset
476 address pc = (address)uc->REG_PC;
a61af66fc99e Initial load
duke
parents:
diff changeset
477 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
1907
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
478 print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
479 st->cr();
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
480 }
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
481
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
482
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
483 void os::print_register_info(outputStream *st, void *context) {
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
484 if (context == NULL) return;
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
485
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
486 CONTEXT* uc = (CONTEXT*)context;
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
487
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
488 st->print_cr("Register to memory mapping:");
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
489 st->cr();
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
490
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
491 // this is only for the "general purpose" registers
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
492
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
493 #ifdef AMD64
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
494 st->print("RAX="); print_location(st, uc->Rax);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
495 st->print("RBX="); print_location(st, uc->Rbx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
496 st->print("RCX="); print_location(st, uc->Rcx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
497 st->print("RDX="); print_location(st, uc->Rdx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
498 st->print("RSP="); print_location(st, uc->Rsp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
499 st->print("RBP="); print_location(st, uc->Rbp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
500 st->print("RSI="); print_location(st, uc->Rsi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
501 st->print("RDI="); print_location(st, uc->Rdi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
502 st->print("R8 ="); print_location(st, uc->R8);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
503 st->print("R9 ="); print_location(st, uc->R9);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
504 st->print("R10="); print_location(st, uc->R10);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
505 st->print("R11="); print_location(st, uc->R11);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
506 st->print("R12="); print_location(st, uc->R12);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
507 st->print("R13="); print_location(st, uc->R13);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
508 st->print("R14="); print_location(st, uc->R14);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
509 st->print("R15="); print_location(st, uc->R15);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
510 #else
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
511 st->print("EAX="); print_location(st, uc->Eax);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
512 st->print("EBX="); print_location(st, uc->Ebx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
513 st->print("ECX="); print_location(st, uc->Ecx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
514 st->print("EDX="); print_location(st, uc->Edx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
515 st->print("ESP="); print_location(st, uc->Esp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
516 st->print("EBP="); print_location(st, uc->Ebp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
517 st->print("ESI="); print_location(st, uc->Esi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
518 st->print("EDI="); print_location(st, uc->Edi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
519 #endif
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
520
0
a61af66fc99e Initial load
duke
parents:
diff changeset
521 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
522 }
a61af66fc99e Initial load
duke
parents:
diff changeset
523
a61af66fc99e Initial load
duke
parents:
diff changeset
524 extern "C" int SafeFetch32 (int * adr, int Err) {
a61af66fc99e Initial load
duke
parents:
diff changeset
525 int rv = Err ;
a61af66fc99e Initial load
duke
parents:
diff changeset
526 _try {
a61af66fc99e Initial load
duke
parents:
diff changeset
527 rv = *((volatile int *) adr) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
528 } __except(EXCEPTION_EXECUTE_HANDLER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
529 }
a61af66fc99e Initial load
duke
parents:
diff changeset
530 return rv ;
a61af66fc99e Initial load
duke
parents:
diff changeset
531 }
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 extern "C" intptr_t SafeFetchN (intptr_t * adr, intptr_t Err) {
a61af66fc99e Initial load
duke
parents:
diff changeset
534 intptr_t rv = Err ;
a61af66fc99e Initial load
duke
parents:
diff changeset
535 _try {
a61af66fc99e Initial load
duke
parents:
diff changeset
536 rv = *((volatile intptr_t *) adr) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
537 } __except(EXCEPTION_EXECUTE_HANDLER) {
a61af66fc99e Initial load
duke
parents:
diff changeset
538 }
a61af66fc99e Initial load
duke
parents:
diff changeset
539 return rv ;
a61af66fc99e Initial load
duke
parents:
diff changeset
540 }
a61af66fc99e Initial load
duke
parents:
diff changeset
541
a61af66fc99e Initial load
duke
parents:
diff changeset
542 extern "C" int SpinPause () {
a61af66fc99e Initial load
duke
parents:
diff changeset
543 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
544 return 0 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
545 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
546 // pause == rep:nop
a61af66fc99e Initial load
duke
parents:
diff changeset
547 // On systems that don't support pause a rep:nop
a61af66fc99e Initial load
duke
parents:
diff changeset
548 // is executed as a nop. The rep: prefix is ignored.
a61af66fc99e Initial load
duke
parents:
diff changeset
549 _asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
550 pause ;
a61af66fc99e Initial load
duke
parents:
diff changeset
551 };
a61af66fc99e Initial load
duke
parents:
diff changeset
552 return 1 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
553 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
554 }
a61af66fc99e Initial load
duke
parents:
diff changeset
555
a61af66fc99e Initial load
duke
parents:
diff changeset
556
a61af66fc99e Initial load
duke
parents:
diff changeset
557 void os::setup_fpu() {
a61af66fc99e Initial load
duke
parents:
diff changeset
558 #ifndef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
559 int fpu_cntrl_word = StubRoutines::fpu_cntrl_wrd_std();
a61af66fc99e Initial load
duke
parents:
diff changeset
560 __asm fldcw fpu_cntrl_word;
a61af66fc99e Initial load
duke
parents:
diff changeset
561 #endif // !AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
562 }
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
563
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
564 #ifndef PRODUCT
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
565 void os::verify_stack_alignment() {
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
566 #ifdef AMD64
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
567 assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
568 #endif
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
569 }
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
570 #endif