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