annotate src/os_cpu/windows_x86/vm/os_windows_x86.cpp @ 12199:38f750491293

8022335: Native stack walk while generating hs_err does not work on Windows x64 Summary: Use WinDbg API StackWalk64() Reviewed-by: zgu, dholmes
author iklam
date Fri, 06 Sep 2013 08:42:42 -0700
parents 980532a806a5
children cefad50507d8 de6a9e811145
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
7199
cd3d6a6b95d9 8003240: x86: move MacroAssembler into separate file
twisti
parents: 6916
diff changeset
26 #include "asm/macroAssembler.hpp"
1972
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"
12199
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
32 #include "decoder_windows.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
33 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
34 #include "jvm_windows.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
35 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
36 #include "mutex_windows.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
37 #include "nativeInst_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
38 #include "os_share_windows.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
39 #include "prims/jniFastGetField.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
40 #include "prims/jvm.h"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
41 #include "prims/jvm_misc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
42 #include "runtime/arguments.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
43 #include "runtime/extendedPC.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
44 #include "runtime/frame.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
45 #include "runtime/interfaceSupport.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
46 #include "runtime/java.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
47 #include "runtime/javaCalls.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
48 #include "runtime/mutexLocker.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
49 #include "runtime/osThread.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
50 #include "runtime/sharedRuntime.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
51 #include "runtime/stubRoutines.hpp"
7180
f34d701e952e 8003935: Simplify the needed includes for using Thread::current()
stefank
parents: 6916
diff changeset
52 #include "runtime/thread.inline.hpp"
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
53 #include "runtime/timer.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
54 #include "utilities/events.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
55 #include "utilities/vmError.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1907
diff changeset
56
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 # include "unwind_windows_x86.hpp"
a61af66fc99e Initial load
duke
parents:
diff changeset
58 #undef REG_SP
a61af66fc99e Initial load
duke
parents:
diff changeset
59 #undef REG_FP
a61af66fc99e Initial load
duke
parents:
diff changeset
60 #undef REG_PC
a61af66fc99e Initial load
duke
parents:
diff changeset
61 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
62 #define REG_SP Rsp
a61af66fc99e Initial load
duke
parents:
diff changeset
63 #define REG_FP Rbp
a61af66fc99e Initial load
duke
parents:
diff changeset
64 #define REG_PC Rip
a61af66fc99e Initial load
duke
parents:
diff changeset
65 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
66 #define REG_SP Esp
a61af66fc99e Initial load
duke
parents:
diff changeset
67 #define REG_FP Ebp
a61af66fc99e Initial load
duke
parents:
diff changeset
68 #define REG_PC Eip
a61af66fc99e Initial load
duke
parents:
diff changeset
69 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Install a win32 structured exception handler around thread.
a61af66fc99e Initial load
duke
parents:
diff changeset
74 void os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 __try {
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 #ifndef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // We store the current thread in this wrapperthread location
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // and determine how far away this address is from the structured
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // execption pointer that FS:[0] points to. This get_thread
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // code can then get the thread pointer via FS.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 //
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Warning: This routine must NEVER be inlined since we'd end up with
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // multiple offsets.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 //
a61af66fc99e Initial load
duke
parents:
diff changeset
86 volatile Thread* wrapperthread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 int thread_ptr_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 __asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 lea eax, dword ptr wrapperthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 sub eax, dword ptr FS:[0H];
a61af66fc99e Initial load
duke
parents:
diff changeset
93 mov thread_ptr_offset, eax
a61af66fc99e Initial load
duke
parents:
diff changeset
94 };
a61af66fc99e Initial load
duke
parents:
diff changeset
95 ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 #ifdef ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
98 // Verify that the offset hasn't changed since we initally captured
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // it. This might happen if we accidentally ended up with an
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // inlined version of this routine.
a61af66fc99e Initial load
duke
parents:
diff changeset
101 else {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 int test_thread_ptr_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 __asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 lea eax, dword ptr wrapperthread;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 sub eax, dword ptr FS:[0H];
a61af66fc99e Initial load
duke
parents:
diff changeset
106 mov test_thread_ptr_offset, eax
a61af66fc99e Initial load
duke
parents:
diff changeset
107 };
a61af66fc99e Initial load
duke
parents:
diff changeset
108 assert(test_thread_ptr_offset == ThreadLocalStorage::get_thread_ptr_offset(),
a61af66fc99e Initial load
duke
parents:
diff changeset
109 "thread pointer offset from SEH changed");
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 #endif // ASSERT
a61af66fc99e Initial load
duke
parents:
diff changeset
112 #endif // !AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 f(value, method, args, thread);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 } __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // Nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 }
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // This is the language specific handler for exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // originating from dynamically generated code.
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // We call the standard structured exception handler
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // We only expect Continued Execution since we cannot unwind
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // from generated code.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 LONG HandleExceptionFromCodeCache(
a61af66fc99e Initial load
duke
parents:
diff changeset
128 IN PEXCEPTION_RECORD ExceptionRecord,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 IN ULONG64 EstablisherFrame,
a61af66fc99e Initial load
duke
parents:
diff changeset
130 IN OUT PCONTEXT ContextRecord,
a61af66fc99e Initial load
duke
parents:
diff changeset
131 IN OUT PDISPATCHER_CONTEXT DispatcherContext) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 EXCEPTION_POINTERS ep;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 LONG result;
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 ep.ExceptionRecord = ExceptionRecord;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 ep.ContextRecord = ContextRecord;
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 result = topLevelExceptionFilter(&ep);
a61af66fc99e Initial load
duke
parents:
diff changeset
139
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // We better only get a CONTINUE_EXECUTION from our handler
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // since we don't have unwind information registered.
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 guarantee( result == EXCEPTION_CONTINUE_EXECUTION,
a61af66fc99e Initial load
duke
parents:
diff changeset
144 "Unexpected result from topLevelExceptionFilter");
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 return(ExceptionContinueExecution);
a61af66fc99e Initial load
duke
parents:
diff changeset
147 }
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Structure containing the Windows Data Structures required
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // to register our Code Cache exception handler.
a61af66fc99e Initial load
duke
parents:
diff changeset
152 // We put these in the CodeCache since the API requires
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // all addresses in these structures are relative to the Code
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // area registered with RtlAddFunctionTable.
a61af66fc99e Initial load
duke
parents:
diff changeset
155 typedef struct {
a61af66fc99e Initial load
duke
parents:
diff changeset
156 char ExceptionHandlerInstr[16]; // jmp HandleExceptionFromCodeCache
a61af66fc99e Initial load
duke
parents:
diff changeset
157 RUNTIME_FUNCTION rt;
a61af66fc99e Initial load
duke
parents:
diff changeset
158 UNWIND_INFO_EH_ONLY unw;
a61af66fc99e Initial load
duke
parents:
diff changeset
159 } DynamicCodeData, *pDynamicCodeData;
a61af66fc99e Initial load
duke
parents:
diff changeset
160
a61af66fc99e Initial load
duke
parents:
diff changeset
161 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
162 //
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // Register our CodeCache area with the OS so it will dispatch exceptions
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // to our topLevelExceptionFilter when we take an exception in our
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // dynamically generated code.
a61af66fc99e Initial load
duke
parents:
diff changeset
166 //
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // Arguments: low and high are the address of the full reserved
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // codeCache area
a61af66fc99e Initial load
duke
parents:
diff changeset
169 //
a61af66fc99e Initial load
duke
parents:
diff changeset
170 bool os::register_code_area(char *low, char *high) {
a61af66fc99e Initial load
duke
parents:
diff changeset
171 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
172
a61af66fc99e Initial load
duke
parents:
diff changeset
173 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 pDynamicCodeData pDCD;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 PRUNTIME_FUNCTION prt;
a61af66fc99e Initial load
duke
parents:
diff changeset
177 PUNWIND_INFO_EH_ONLY punwind;
a61af66fc99e Initial load
duke
parents:
diff changeset
178
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1681
diff changeset
179 BufferBlob* blob = BufferBlob::create("CodeCache Exception Handler", sizeof(DynamicCodeData));
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1681
diff changeset
180 CodeBuffer cb(blob);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
181 MacroAssembler* masm = new MacroAssembler(&cb);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 pDCD = (pDynamicCodeData) masm->pc();
a61af66fc99e Initial load
duke
parents:
diff changeset
183
a61af66fc99e Initial load
duke
parents:
diff changeset
184 masm->jump(ExternalAddress((address)&HandleExceptionFromCodeCache));
a61af66fc99e Initial load
duke
parents:
diff changeset
185 masm->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 // Create an Unwind Structure specifying no unwind info
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // other than an Exception Handler
a61af66fc99e Initial load
duke
parents:
diff changeset
189 punwind = &pDCD->unw;
a61af66fc99e Initial load
duke
parents:
diff changeset
190 punwind->Version = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
191 punwind->Flags = UNW_FLAG_EHANDLER;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 punwind->SizeOfProlog = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 punwind->CountOfCodes = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
194 punwind->FrameRegister = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
195 punwind->FrameOffset = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
196 punwind->ExceptionHandler = (char *)(&(pDCD->ExceptionHandlerInstr[0])) -
a61af66fc99e Initial load
duke
parents:
diff changeset
197 (char*)low;
a61af66fc99e Initial load
duke
parents:
diff changeset
198 punwind->ExceptionData[0] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
199
a61af66fc99e Initial load
duke
parents:
diff changeset
200 // This structure describes the covered dynamic code area.
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Addresses are relative to the beginning on the code cache area
a61af66fc99e Initial load
duke
parents:
diff changeset
202 prt = &pDCD->rt;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 prt->BeginAddress = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 prt->EndAddress = (ULONG)(high - low);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 prt->UnwindData = ((char *)punwind - low);
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 guarantee(RtlAddFunctionTable(prt, 1, (ULONGLONG)low),
a61af66fc99e Initial load
duke
parents:
diff changeset
208 "Failed to register Dynamic Code Exception Handler with RtlAddFunctionTable");
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
6768
716e6ef4482a 7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents: 5903
diff changeset
214 void os::initialize_thread(Thread* thr) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // Nothing to do.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // Atomics and Stub Functions
a61af66fc99e Initial load
duke
parents:
diff changeset
219
a61af66fc99e Initial load
duke
parents:
diff changeset
220 typedef jint xchg_func_t (jint, volatile jint*);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 typedef intptr_t xchg_ptr_func_t (intptr_t, volatile intptr_t*);
a61af66fc99e Initial load
duke
parents:
diff changeset
222 typedef jint cmpxchg_func_t (jint, volatile jint*, jint);
a61af66fc99e Initial load
duke
parents:
diff changeset
223 typedef jlong cmpxchg_long_func_t (jlong, volatile jlong*, jlong);
a61af66fc99e Initial load
duke
parents:
diff changeset
224 typedef jint add_func_t (jint, volatile jint*);
a61af66fc99e Initial load
duke
parents:
diff changeset
225 typedef intptr_t add_ptr_func_t (intptr_t, volatile intptr_t*);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
231 xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
232
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
234 os::atomic_xchg_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 return (*func)(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
236 }
a61af66fc99e Initial load
duke
parents:
diff changeset
237 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 jint old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
241 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 intptr_t os::atomic_xchg_ptr_bootstrap(intptr_t exchange_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
246 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
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 os::atomic_xchg_ptr_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
250 return (*func)(exchange_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
251 }
a61af66fc99e Initial load
duke
parents:
diff changeset
252 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
253
a61af66fc99e Initial load
duke
parents:
diff changeset
254 intptr_t old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
256 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
257 }
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
262 cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
265 os::atomic_cmpxchg_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
266 return (*func)(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }
a61af66fc99e Initial load
duke
parents:
diff changeset
268 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 jint old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 if (old_value == compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
272 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
273 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
274 }
a61af66fc99e Initial load
duke
parents:
diff changeset
275 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
279 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
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 os::atomic_cmpxchg_long_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
283 return (*func)(exchange_value, dest, compare_value);
a61af66fc99e Initial load
duke
parents:
diff changeset
284 }
a61af66fc99e Initial load
duke
parents:
diff changeset
285 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 jlong old_value = *dest;
a61af66fc99e Initial load
duke
parents:
diff changeset
288 if (old_value == compare_value)
a61af66fc99e Initial load
duke
parents:
diff changeset
289 *dest = exchange_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
290 return old_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
291 }
a61af66fc99e Initial load
duke
parents:
diff changeset
292
a61af66fc99e Initial load
duke
parents:
diff changeset
293 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
297 add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
a61af66fc99e Initial load
duke
parents:
diff changeset
298
a61af66fc99e Initial load
duke
parents:
diff changeset
299 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
300 os::atomic_add_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 return (*func)(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
304
a61af66fc99e Initial load
duke
parents:
diff changeset
305 return (*dest) += add_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 intptr_t os::atomic_add_ptr_bootstrap(intptr_t add_value, volatile intptr_t* dest) {
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // try to use the stub:
a61af66fc99e Initial load
duke
parents:
diff changeset
310 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
311
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if (func != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 os::atomic_add_ptr_func = func;
a61af66fc99e Initial load
duke
parents:
diff changeset
314 return (*func)(add_value, dest);
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 assert(Threads::number_of_threads() == 0, "for bootstrap only");
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 return (*dest) += add_value;
a61af66fc99e Initial load
duke
parents:
diff changeset
319 }
a61af66fc99e Initial load
duke
parents:
diff changeset
320
a61af66fc99e Initial load
duke
parents:
diff changeset
321 xchg_func_t* os::atomic_xchg_func = os::atomic_xchg_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
322 xchg_ptr_func_t* os::atomic_xchg_ptr_func = os::atomic_xchg_ptr_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
323 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
324 add_func_t* os::atomic_add_func = os::atomic_add_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
325 add_ptr_func_t* os::atomic_add_ptr_func = os::atomic_add_ptr_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
326
a61af66fc99e Initial load
duke
parents:
diff changeset
327 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
328
a61af66fc99e Initial load
duke
parents:
diff changeset
329 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
a61af66fc99e Initial load
duke
parents:
diff changeset
330
12199
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
331 #ifdef AMD64
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
332 /*
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
333 * Windows/x64 does not use stack frames the way expected by Java:
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
334 * [1] in most cases, there is no frame pointer. All locals are addressed via RSP
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
335 * [2] in rare cases, when alloca() is used, a frame pointer is used, but this may
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
336 * not be RBP.
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
337 * See http://msdn.microsoft.com/en-us/library/ew5tede7.aspx
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
338 *
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
339 * So it's not possible to print the native stack using the
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
340 * while (...) {... fr = os::get_sender_for_C_frame(&fr); }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
341 * loop in vmError.cpp. We need to roll our own loop.
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
342 */
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
343 bool os::platform_print_native_stack(outputStream* st, void* context,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
344 char *buf, int buf_size)
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
345 {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
346 CONTEXT ctx;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
347 if (context != NULL) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
348 memcpy(&ctx, context, sizeof(ctx));
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
349 } else {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
350 RtlCaptureContext(&ctx);
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
351 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
352
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
353 st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)");
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
354
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
355 STACKFRAME stk;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
356 memset(&stk, 0, sizeof(stk));
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
357 stk.AddrStack.Offset = ctx.Rsp;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
358 stk.AddrStack.Mode = AddrModeFlat;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
359 stk.AddrFrame.Offset = ctx.Rbp;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
360 stk.AddrFrame.Mode = AddrModeFlat;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
361 stk.AddrPC.Offset = ctx.Rip;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
362 stk.AddrPC.Mode = AddrModeFlat;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
363
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
364 int count = 0;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
365 address lastpc = 0;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
366 while (count++ < StackPrintLimit) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
367 intptr_t* sp = (intptr_t*)stk.AddrStack.Offset;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
368 intptr_t* fp = (intptr_t*)stk.AddrFrame.Offset; // NOT necessarily the same as ctx.Rbp!
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
369 address pc = (address)stk.AddrPC.Offset;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
370
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
371 if (pc != NULL && sp != NULL && fp != NULL) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
372 if (count == 2 && lastpc == pc) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
373 // Skip it -- StackWalk64() may return the same PC
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
374 // (but different SP) on the first try.
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
375 } else {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
376 // Don't try to create a frame(sp, fp, pc) -- on WinX64, stk.AddrFrame
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
377 // may not contain what Java expects, and may cause the frame() constructor
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
378 // to crash. Let's just print out the symbolic address.
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
379 frame::print_C_frame(st, buf, buf_size, pc);
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
380 st->cr();
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
381 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
382 lastpc = pc;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
383 } else {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
384 break;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
385 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
386
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
387 PVOID p = WindowsDbgHelp::SymFunctionTableAccess64(GetCurrentProcess(), stk.AddrPC.Offset);
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
388 if (!p) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
389 // StackWalk64() can't handle this PC. Calling StackWalk64 again may cause crash.
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
390 break;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
391 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
392
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
393 BOOL result = WindowsDbgHelp::StackWalk64(
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
394 IMAGE_FILE_MACHINE_AMD64, // __in DWORD MachineType,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
395 GetCurrentProcess(), // __in HANDLE hProcess,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
396 GetCurrentThread(), // __in HANDLE hThread,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
397 &stk, // __inout LP STACKFRAME64 StackFrame,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
398 &ctx, // __inout PVOID ContextRecord,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
399 NULL, // __in_opt PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
400 WindowsDbgHelp::pfnSymFunctionTableAccess64(),
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
401 // __in_opt PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
402 WindowsDbgHelp::pfnSymGetModuleBase64(),
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
403 // __in_opt PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
404 NULL); // __in_opt PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
405
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
406 if (!result) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
407 break;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
408 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
409 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
410 if (count > StackPrintLimit) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
411 st->print_cr("...<more frames>...");
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
412 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
413 st->cr();
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
414
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
415 return true;
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
416 }
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
417 #endif // AMD64
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
418
0
a61af66fc99e Initial load
duke
parents:
diff changeset
419 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
a61af66fc99e Initial load
duke
parents:
diff changeset
420 intptr_t** ret_sp, intptr_t** ret_fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
421
a61af66fc99e Initial load
duke
parents:
diff changeset
422 ExtendedPC epc;
a61af66fc99e Initial load
duke
parents:
diff changeset
423 CONTEXT* uc = (CONTEXT*)ucVoid;
a61af66fc99e Initial load
duke
parents:
diff changeset
424
a61af66fc99e Initial load
duke
parents:
diff changeset
425 if (uc != NULL) {
a61af66fc99e Initial load
duke
parents:
diff changeset
426 epc = ExtendedPC((address)uc->REG_PC);
a61af66fc99e Initial load
duke
parents:
diff changeset
427 if (ret_sp) *ret_sp = (intptr_t*)uc->REG_SP;
a61af66fc99e Initial load
duke
parents:
diff changeset
428 if (ret_fp) *ret_fp = (intptr_t*)uc->REG_FP;
a61af66fc99e Initial load
duke
parents:
diff changeset
429 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
430 // construct empty ExtendedPC for return value checking
a61af66fc99e Initial load
duke
parents:
diff changeset
431 epc = ExtendedPC(NULL);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 if (ret_sp) *ret_sp = (intptr_t *)NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
433 if (ret_fp) *ret_fp = (intptr_t *)NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
434 }
a61af66fc99e Initial load
duke
parents:
diff changeset
435
a61af66fc99e Initial load
duke
parents:
diff changeset
436 return epc;
a61af66fc99e Initial load
duke
parents:
diff changeset
437 }
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 frame os::fetch_frame_from_context(void* ucVoid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
440 intptr_t* sp;
a61af66fc99e Initial load
duke
parents:
diff changeset
441 intptr_t* fp;
a61af66fc99e Initial load
duke
parents:
diff changeset
442 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 return frame(sp, fp, epc.pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
444 }
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 // VC++ does not save frame pointer on stack in optimized build. It
a61af66fc99e Initial load
duke
parents:
diff changeset
447 // can be turned off by /Oy-. If we really want to walk C frames,
a61af66fc99e Initial load
duke
parents:
diff changeset
448 // we can use the StackWalk() API.
a61af66fc99e Initial load
duke
parents:
diff changeset
449 frame os::get_sender_for_C_frame(frame* fr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
450 return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
a61af66fc99e Initial load
duke
parents:
diff changeset
451 }
a61af66fc99e Initial load
duke
parents:
diff changeset
452
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
453 #ifndef AMD64
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
454 // 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
455 // 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
456 // stack pointer.
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
457 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
458 int dummy;
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
459 address sp = (address)&dummy;
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
460 return sp;
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
461 }
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
462 #else
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
463 // 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
464 // os::verify_stack_alignment().
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
465 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
466 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
467 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
468 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
469 return (*func)();
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
470 }
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
471 #endif
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
472
0
a61af66fc99e Initial load
duke
parents:
diff changeset
473
a61af66fc99e Initial load
duke
parents:
diff changeset
474 #ifndef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
475 intptr_t* _get_previous_fp() {
a61af66fc99e Initial load
duke
parents:
diff changeset
476 intptr_t **frameptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
477 __asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
478 mov frameptr, ebp
a61af66fc99e Initial load
duke
parents:
diff changeset
479 };
a61af66fc99e Initial load
duke
parents:
diff changeset
480 return *frameptr;
a61af66fc99e Initial load
duke
parents:
diff changeset
481 }
a61af66fc99e Initial load
duke
parents:
diff changeset
482 #endif // !AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
483
a61af66fc99e Initial load
duke
parents:
diff changeset
484 frame os::current_frame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
485
a61af66fc99e Initial load
duke
parents:
diff changeset
486 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
487 // apparently _asm not supported on windows amd64
a61af66fc99e Initial load
duke
parents:
diff changeset
488 typedef intptr_t* get_fp_func ();
a61af66fc99e Initial load
duke
parents:
diff changeset
489 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
490 StubRoutines::x86::get_previous_fp_entry());
7987
12285410684f 8006508: Wrong frame constructor is called in os_linux_x86.cpp
dholmes
parents: 7206
diff changeset
491 if (func == NULL) return frame();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
492 intptr_t* fp = (*func)();
12199
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
493 if (fp == NULL) {
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
494 return frame();
38f750491293 8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents: 11127
diff changeset
495 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
496 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
497 intptr_t* fp = _get_previous_fp();
a61af66fc99e Initial load
duke
parents:
diff changeset
498 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
499
a61af66fc99e Initial load
duke
parents:
diff changeset
500 frame myframe((intptr_t*)os::current_stack_pointer(),
a61af66fc99e Initial load
duke
parents:
diff changeset
501 (intptr_t*)fp,
a61af66fc99e Initial load
duke
parents:
diff changeset
502 CAST_FROM_FN_PTR(address, os::current_frame));
a61af66fc99e Initial load
duke
parents:
diff changeset
503 if (os::is_first_C_frame(&myframe)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // stack is not walkable
7987
12285410684f 8006508: Wrong frame constructor is called in os_linux_x86.cpp
dholmes
parents: 7206
diff changeset
505 return frame();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
506 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 return os::get_sender_for_C_frame(&myframe);
a61af66fc99e Initial load
duke
parents:
diff changeset
508 }
a61af66fc99e Initial load
duke
parents:
diff changeset
509 }
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 void os::print_context(outputStream *st, void *context) {
a61af66fc99e Initial load
duke
parents:
diff changeset
512 if (context == NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
513
a61af66fc99e Initial load
duke
parents:
diff changeset
514 CONTEXT* uc = (CONTEXT*)context;
a61af66fc99e Initial load
duke
parents:
diff changeset
515
a61af66fc99e Initial load
duke
parents:
diff changeset
516 st->print_cr("Registers:");
a61af66fc99e Initial load
duke
parents:
diff changeset
517 #ifdef AMD64
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
518 st->print( "RAX=" INTPTR_FORMAT, uc->Rax);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
519 st->print(", RBX=" INTPTR_FORMAT, uc->Rbx);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
520 st->print(", RCX=" INTPTR_FORMAT, uc->Rcx);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
521 st->print(", RDX=" INTPTR_FORMAT, uc->Rdx);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
522 st->cr();
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
523 st->print( "RSP=" INTPTR_FORMAT, uc->Rsp);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
524 st->print(", RBP=" INTPTR_FORMAT, uc->Rbp);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
525 st->print(", RSI=" INTPTR_FORMAT, uc->Rsi);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
526 st->print(", RDI=" INTPTR_FORMAT, uc->Rdi);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
527 st->cr();
1907
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
528 st->print( "R8 =" INTPTR_FORMAT, uc->R8);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
529 st->print(", R9 =" INTPTR_FORMAT, uc->R9);
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
530 st->print(", R10=" INTPTR_FORMAT, uc->R10);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
531 st->print(", R11=" INTPTR_FORMAT, uc->R11);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
532 st->cr();
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
533 st->print( "R12=" INTPTR_FORMAT, uc->R12);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
534 st->print(", R13=" INTPTR_FORMAT, uc->R13);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
535 st->print(", R14=" INTPTR_FORMAT, uc->R14);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
536 st->print(", R15=" INTPTR_FORMAT, uc->R15);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
537 st->cr();
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
538 st->print( "RIP=" INTPTR_FORMAT, uc->Rip);
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
539 st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
540 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
541 st->print( "EAX=" INTPTR_FORMAT, uc->Eax);
a61af66fc99e Initial load
duke
parents:
diff changeset
542 st->print(", EBX=" INTPTR_FORMAT, uc->Ebx);
a61af66fc99e Initial load
duke
parents:
diff changeset
543 st->print(", ECX=" INTPTR_FORMAT, uc->Ecx);
a61af66fc99e Initial load
duke
parents:
diff changeset
544 st->print(", EDX=" INTPTR_FORMAT, uc->Edx);
a61af66fc99e Initial load
duke
parents:
diff changeset
545 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
546 st->print( "ESP=" INTPTR_FORMAT, uc->Esp);
a61af66fc99e Initial load
duke
parents:
diff changeset
547 st->print(", EBP=" INTPTR_FORMAT, uc->Ebp);
a61af66fc99e Initial load
duke
parents:
diff changeset
548 st->print(", ESI=" INTPTR_FORMAT, uc->Esi);
a61af66fc99e Initial load
duke
parents:
diff changeset
549 st->print(", EDI=" INTPTR_FORMAT, uc->Edi);
a61af66fc99e Initial load
duke
parents:
diff changeset
550 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
551 st->print( "EIP=" INTPTR_FORMAT, uc->Eip);
a61af66fc99e Initial load
duke
parents:
diff changeset
552 st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags);
a61af66fc99e Initial load
duke
parents:
diff changeset
553 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
554 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
555 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
556
a61af66fc99e Initial load
duke
parents:
diff changeset
557 intptr_t *sp = (intptr_t *)uc->REG_SP;
a61af66fc99e Initial load
duke
parents:
diff changeset
558 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp);
a61af66fc99e Initial load
duke
parents:
diff changeset
559 print_hex_dump(st, (address)sp, (address)(sp + 32), sizeof(intptr_t));
a61af66fc99e Initial load
duke
parents:
diff changeset
560 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
561
a61af66fc99e Initial load
duke
parents:
diff changeset
562 // Note: it may be unsafe to inspect memory near pc. For example, pc may
a61af66fc99e Initial load
duke
parents:
diff changeset
563 // point to garbage if entry point in an nmethod is corrupted. Leave
a61af66fc99e Initial load
duke
parents:
diff changeset
564 // this at the end, and hope for the best.
a61af66fc99e Initial load
duke
parents:
diff changeset
565 address pc = (address)uc->REG_PC;
a61af66fc99e Initial load
duke
parents:
diff changeset
566 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc);
1907
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
567 print_hex_dump(st, pc - 32, pc + 32, sizeof(char));
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
568 st->cr();
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
569 }
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
570
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
571
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
572 void os::print_register_info(outputStream *st, void *context) {
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
573 if (context == NULL) return;
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
574
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
575 CONTEXT* uc = (CONTEXT*)context;
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
576
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
577 st->print_cr("Register to memory mapping:");
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
578 st->cr();
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
579
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
580 // this is only for the "general purpose" registers
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
581
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
582 #ifdef AMD64
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
583 st->print("RAX="); print_location(st, uc->Rax);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
584 st->print("RBX="); print_location(st, uc->Rbx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
585 st->print("RCX="); print_location(st, uc->Rcx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
586 st->print("RDX="); print_location(st, uc->Rdx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
587 st->print("RSP="); print_location(st, uc->Rsp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
588 st->print("RBP="); print_location(st, uc->Rbp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
589 st->print("RSI="); print_location(st, uc->Rsi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
590 st->print("RDI="); print_location(st, uc->Rdi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
591 st->print("R8 ="); print_location(st, uc->R8);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
592 st->print("R9 ="); print_location(st, uc->R9);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
593 st->print("R10="); print_location(st, uc->R10);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
594 st->print("R11="); print_location(st, uc->R11);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
595 st->print("R12="); print_location(st, uc->R12);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
596 st->print("R13="); print_location(st, uc->R13);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
597 st->print("R14="); print_location(st, uc->R14);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
598 st->print("R15="); print_location(st, uc->R15);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
599 #else
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
600 st->print("EAX="); print_location(st, uc->Eax);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
601 st->print("EBX="); print_location(st, uc->Ebx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
602 st->print("ECX="); print_location(st, uc->Ecx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
603 st->print("EDX="); print_location(st, uc->Edx);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
604 st->print("ESP="); print_location(st, uc->Esp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
605 st->print("EBP="); print_location(st, uc->Ebp);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
606 st->print("ESI="); print_location(st, uc->Esi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
607 st->print("EDI="); print_location(st, uc->Edi);
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
608 #endif
1e9a9d2e6509 6970683: improvements to hs_err output
never
parents: 1748
diff changeset
609
0
a61af66fc99e Initial load
duke
parents:
diff changeset
610 st->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
611 }
a61af66fc99e Initial load
duke
parents:
diff changeset
612
a61af66fc99e Initial load
duke
parents:
diff changeset
613 extern "C" int SpinPause () {
a61af66fc99e Initial load
duke
parents:
diff changeset
614 #ifdef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
615 return 0 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
616 #else
a61af66fc99e Initial load
duke
parents:
diff changeset
617 // pause == rep:nop
a61af66fc99e Initial load
duke
parents:
diff changeset
618 // On systems that don't support pause a rep:nop
a61af66fc99e Initial load
duke
parents:
diff changeset
619 // is executed as a nop. The rep: prefix is ignored.
a61af66fc99e Initial load
duke
parents:
diff changeset
620 _asm {
a61af66fc99e Initial load
duke
parents:
diff changeset
621 pause ;
a61af66fc99e Initial load
duke
parents:
diff changeset
622 };
a61af66fc99e Initial load
duke
parents:
diff changeset
623 return 1 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
624 #endif // AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
625 }
a61af66fc99e Initial load
duke
parents:
diff changeset
626
a61af66fc99e Initial load
duke
parents:
diff changeset
627
a61af66fc99e Initial load
duke
parents:
diff changeset
628 void os::setup_fpu() {
a61af66fc99e Initial load
duke
parents:
diff changeset
629 #ifndef AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
630 int fpu_cntrl_word = StubRoutines::fpu_cntrl_wrd_std();
a61af66fc99e Initial load
duke
parents:
diff changeset
631 __asm fldcw fpu_cntrl_word;
a61af66fc99e Initial load
duke
parents:
diff changeset
632 #endif // !AMD64
a61af66fc99e Initial load
duke
parents:
diff changeset
633 }
5903
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
634
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
635 #ifndef PRODUCT
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
636 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
637 #ifdef AMD64
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
638 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
639 #endif
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
640 }
da4be62fb889 7147740: add assertions to check stack alignment on VM entry from generated code (x64)
roland
parents: 1980
diff changeset
641 #endif