src/os_cpu/windows_x86/vm/assembler_windows_x86.cpp

Tue, 03 Aug 2010 08:13:38 -0400

author
bobv
date
Tue, 03 Aug 2010 08:13:38 -0400
changeset 2036
126ea7725993
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6953477: Increase portability and flexibility of building Hotspot
Summary: A collection of portability improvements including shared code support for PPC, ARM platforms, software floating point, cross compilation support and improvements in error crash detail.
Reviewed-by: phh, never, coleenp, dholmes

duke@435 1 /*
trims@1907 2 * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 #include "incls/_precompiled.incl"
never@739 26 #include "incls/_assembler_windows_x86.cpp.incl"
duke@435 27
duke@435 28
duke@435 29 void MacroAssembler::int3() {
duke@435 30 emit_byte(0xCC);
duke@435 31 }
duke@435 32
never@739 33 #ifndef _LP64
duke@435 34 // The current scheme to accelerate access to the thread
duke@435 35 // pointer is to store the current thread in the os_exception_wrapper
duke@435 36 // and reference the current thread from stubs and compiled code
duke@435 37 // via the FS register. FS[0] contains a pointer to the structured
duke@435 38 // exception block which is actually a stack address. The first time
duke@435 39 // we call the os exception wrapper, we calculate and store the
duke@435 40 // offset from this exception block and use that offset here.
duke@435 41 //
duke@435 42 // The last mechanism we used was problematic in that the
duke@435 43 // the offset we had hard coded in the VM kept changing as Microsoft
duke@435 44 // evolved the OS.
duke@435 45 //
duke@435 46 // Warning: This mechanism assumes that we only attempt to get the
duke@435 47 // thread when we are nested below a call wrapper.
duke@435 48 //
duke@435 49 // movl reg, fs:[0] Get exeception pointer
duke@435 50 // movl reg, [reg + thread_ptr_offset] Load thread
duke@435 51 //
duke@435 52 void MacroAssembler::get_thread(Register thread) {
duke@435 53 // can't use ExternalAddress because it can't take NULL
duke@435 54 AddressLiteral null(0, relocInfo::none);
duke@435 55
duke@435 56 prefix(FS_segment);
duke@435 57 movptr(thread, null);
duke@435 58 assert(ThreadLocalStorage::get_thread_ptr_offset() != 0,
duke@435 59 "Thread Pointer Offset has not been initialized");
duke@435 60 movl(thread, Address(thread, ThreadLocalStorage::get_thread_ptr_offset()));
duke@435 61 }
never@739 62 #else
never@739 63 // call (Thread*)TlsGetValue(thread_index());
never@739 64 void MacroAssembler::get_thread(Register thread) {
never@739 65 if (thread != rax) {
never@739 66 push(rax);
never@739 67 }
never@739 68 push(rdi);
never@739 69 push(rsi);
never@739 70 push(rdx);
never@739 71 push(rcx);
never@739 72 push(r8);
never@739 73 push(r9);
never@739 74 push(r10);
never@739 75 // XXX
never@739 76 mov(r10, rsp);
never@739 77 andq(rsp, -16);
never@739 78 push(r10);
never@739 79 push(r11);
never@739 80
never@739 81 movl(c_rarg0, ThreadLocalStorage::thread_index());
never@739 82 call(RuntimeAddress((address)TlsGetValue));
never@739 83
never@739 84 pop(r11);
never@739 85 pop(rsp);
never@739 86 pop(r10);
never@739 87 pop(r9);
never@739 88 pop(r8);
never@739 89 pop(rcx);
never@739 90 pop(rdx);
never@739 91 pop(rsi);
never@739 92 pop(rdi);
never@739 93 if (thread != rax) {
never@739 94 mov(thread, rax);
never@739 95 pop(rax);
never@739 96 }
never@739 97 }
never@739 98 #endif

mercurial