hotspot/src/os_cpu/windows_x86/vm/os_windows_x86.cpp

Print this page
rev 611 : Merge
   1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)os_windows_x86.cpp   1.32 07/09/17 09:11:33 JVM"
   3 #endif
   4 /*
   5  * Copyright 1999-2007 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  


  33 #undef REG_PC
  34 #ifdef AMD64
  35 #define REG_SP Rsp
  36 #define REG_FP Rbp
  37 #define REG_PC Rip
  38 #else
  39 #define REG_SP Esp
  40 #define REG_FP Ebp
  41 #define REG_PC Eip
  42 #endif // AMD64
  43 
  44 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  45 
  46 // Install a win32 structured exception handler around thread.
  47 void os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread) {
  48   __try {
  49 
  50 #ifndef AMD64
  51     // We store the current thread in this wrapperthread location
  52     // and determine how far away this address is from the structured
  53     // execption pointer that FS:[0] points to.  This get_thread 
  54     // code can then get the thread pointer via FS.
  55     // 
  56     // Warning:  This routine must NEVER be inlined since we'd end up with
  57     //           multiple offsets.
  58     //
  59     volatile Thread* wrapperthread = thread;
  60 
  61     if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) {
  62       int thread_ptr_offset;
  63       __asm {
  64         lea eax, dword ptr wrapperthread;
  65         sub eax, dword ptr FS:[0H];
  66         mov thread_ptr_offset, eax
  67       };
  68       ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset);
  69     }
  70 #ifdef ASSERT
  71     // Verify that the offset hasn't changed since we initally captured 
  72     // it. This might happen if we accidentally ended up with an
  73     // inlined version of this routine.


 355   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 356 }
 357 
 358 
 359 #ifndef AMD64
 360 intptr_t* _get_previous_fp() {
 361   intptr_t **frameptr;
 362   __asm {
 363     mov frameptr, ebp
 364   };
 365   return *frameptr;
 366 }
 367 #endif // !AMD64
 368 
 369 frame os::current_frame() {
 370 
 371 #ifdef AMD64
 372   // apparently _asm not supported on windows amd64
 373   typedef intptr_t*      get_fp_func           ();
 374   get_fp_func* func = CAST_TO_FN_PTR(get_fp_func*,
 375                                      StubRoutines::amd64::get_previous_fp_entry());
 376   if (func == NULL) return frame(NULL, NULL, NULL);
 377   intptr_t* fp = (*func)();
 378 #else
 379   intptr_t* fp = _get_previous_fp();
 380 #endif // AMD64
 381 
 382   frame myframe((intptr_t*)os::current_stack_pointer(), 
 383                 (intptr_t*)fp,
 384                 CAST_FROM_FN_PTR(address, os::current_frame));
 385   if (os::is_first_C_frame(&myframe)) {
 386     // stack is not walkable
 387     return frame(NULL, NULL, NULL);
 388   } else {
 389     return os::get_sender_for_C_frame(&myframe);
 390   }
 391 }
 392 
 393 void os::print_context(outputStream *st, void *context) {
 394   if (context == NULL) return;
 395 


 462 #ifdef AMD64
 463    return 0 ;
 464 #else
 465    // pause == rep:nop
 466    // On systems that don't support pause a rep:nop 
 467    // is executed as a nop.  The rep: prefix is ignored.
 468    _asm { 
 469       pause ; 
 470    };
 471    return 1 ;
 472 #endif // AMD64
 473 }
 474 
 475 
 476 void os::setup_fpu() {
 477 #ifndef AMD64
 478   int fpu_cntrl_word = StubRoutines::fpu_cntrl_wrd_std();
 479   __asm fldcw fpu_cntrl_word;
 480 #endif // !AMD64
 481 }
 482 



   1 /*
   2  * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
   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  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *


  30 #undef REG_PC
  31 #ifdef AMD64
  32 #define REG_SP Rsp
  33 #define REG_FP Rbp
  34 #define REG_PC Rip
  35 #else
  36 #define REG_SP Esp
  37 #define REG_FP Ebp
  38 #define REG_PC Eip
  39 #endif // AMD64
  40 
  41 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  42 
  43 // Install a win32 structured exception handler around thread.
  44 void os::os_exception_wrapper(java_call_t f, JavaValue* value, methodHandle* method, JavaCallArguments* args, Thread* thread) {
  45   __try {
  46 
  47 #ifndef AMD64
  48     // We store the current thread in this wrapperthread location
  49     // and determine how far away this address is from the structured
  50     // exception pointer that FS:[0] points to.  This get_thread
  51     // code can then get the thread pointer via FS.
  52     //
  53     // Warning:  This routine must NEVER be inlined since we'd end up with
  54     //           multiple offsets.
  55     //
  56     volatile Thread* wrapperthread = thread;
  57 
  58     if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) {
  59       int thread_ptr_offset;
  60       __asm {
  61         lea eax, dword ptr wrapperthread;
  62         sub eax, dword ptr FS:[0H];
  63         mov thread_ptr_offset, eax
  64       };
  65       ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset);
  66     }
  67 #ifdef ASSERT
  68     // Verify that the offset hasn't changed since we initally captured
  69     // it. This might happen if we accidentally ended up with an
  70     // inlined version of this routine.


 352   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 353 }
 354 
 355 
 356 #ifndef AMD64
 357 intptr_t* _get_previous_fp() {
 358   intptr_t **frameptr;
 359   __asm {
 360     mov frameptr, ebp
 361   };
 362   return *frameptr;
 363 }
 364 #endif // !AMD64
 365 
 366 frame os::current_frame() {
 367 
 368 #ifdef AMD64
 369   // apparently _asm not supported on windows amd64
 370   typedef intptr_t*      get_fp_func           ();
 371   get_fp_func* func = CAST_TO_FN_PTR(get_fp_func*,
 372                                      StubRoutines::x86::get_previous_fp_entry());
 373   if (func == NULL) return frame(NULL, NULL, NULL);
 374   intptr_t* fp = (*func)();
 375 #else
 376   intptr_t* fp = _get_previous_fp();
 377 #endif // AMD64
 378 
 379   frame myframe((intptr_t*)os::current_stack_pointer(),
 380                 (intptr_t*)fp,
 381                 CAST_FROM_FN_PTR(address, os::current_frame));
 382   if (os::is_first_C_frame(&myframe)) {
 383     // stack is not walkable
 384     return frame(NULL, NULL, NULL);
 385   } else {
 386     return os::get_sender_for_C_frame(&myframe);
 387   }
 388 }
 389 
 390 void os::print_context(outputStream *st, void *context) {
 391   if (context == NULL) return;
 392 


 459 #ifdef AMD64
 460    return 0 ;
 461 #else
 462    // pause == rep:nop
 463    // On systems that don't support pause a rep:nop
 464    // is executed as a nop.  The rep: prefix is ignored.
 465    _asm {
 466       pause ;
 467    };
 468    return 1 ;
 469 #endif // AMD64
 470 }
 471 
 472 
 473 void os::setup_fpu() {
 474 #ifndef AMD64
 475   int fpu_cntrl_word = StubRoutines::fpu_cntrl_wrd_std();
 476   __asm fldcw fpu_cntrl_word;
 477 #endif // !AMD64
 478 }