1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/os_cpu/windows_x86/vm/assembler_windows_x86.cpp Wed Aug 27 00:21:55 2008 -0700 1.3 @@ -0,0 +1,98 @@ 1.4 +/* 1.5 + * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "incls/_precompiled.incl" 1.29 +#include "incls/_assembler_windows_x86.cpp.incl" 1.30 + 1.31 + 1.32 +void MacroAssembler::int3() { 1.33 + emit_byte(0xCC); 1.34 +} 1.35 + 1.36 +#ifndef _LP64 1.37 +// The current scheme to accelerate access to the thread 1.38 +// pointer is to store the current thread in the os_exception_wrapper 1.39 +// and reference the current thread from stubs and compiled code 1.40 +// via the FS register. FS[0] contains a pointer to the structured 1.41 +// exception block which is actually a stack address. The first time 1.42 +// we call the os exception wrapper, we calculate and store the 1.43 +// offset from this exception block and use that offset here. 1.44 +// 1.45 +// The last mechanism we used was problematic in that the 1.46 +// the offset we had hard coded in the VM kept changing as Microsoft 1.47 +// evolved the OS. 1.48 +// 1.49 +// Warning: This mechanism assumes that we only attempt to get the 1.50 +// thread when we are nested below a call wrapper. 1.51 +// 1.52 +// movl reg, fs:[0] Get exeception pointer 1.53 +// movl reg, [reg + thread_ptr_offset] Load thread 1.54 +// 1.55 +void MacroAssembler::get_thread(Register thread) { 1.56 + // can't use ExternalAddress because it can't take NULL 1.57 + AddressLiteral null(0, relocInfo::none); 1.58 + 1.59 + prefix(FS_segment); 1.60 + movptr(thread, null); 1.61 + assert(ThreadLocalStorage::get_thread_ptr_offset() != 0, 1.62 + "Thread Pointer Offset has not been initialized"); 1.63 + movl(thread, Address(thread, ThreadLocalStorage::get_thread_ptr_offset())); 1.64 +} 1.65 +#else 1.66 +// call (Thread*)TlsGetValue(thread_index()); 1.67 +void MacroAssembler::get_thread(Register thread) { 1.68 + if (thread != rax) { 1.69 + push(rax); 1.70 + } 1.71 + push(rdi); 1.72 + push(rsi); 1.73 + push(rdx); 1.74 + push(rcx); 1.75 + push(r8); 1.76 + push(r9); 1.77 + push(r10); 1.78 + // XXX 1.79 + mov(r10, rsp); 1.80 + andq(rsp, -16); 1.81 + push(r10); 1.82 + push(r11); 1.83 + 1.84 + movl(c_rarg0, ThreadLocalStorage::thread_index()); 1.85 + call(RuntimeAddress((address)TlsGetValue)); 1.86 + 1.87 + pop(r11); 1.88 + pop(rsp); 1.89 + pop(r10); 1.90 + pop(r9); 1.91 + pop(r8); 1.92 + pop(rcx); 1.93 + pop(rdx); 1.94 + pop(rsi); 1.95 + pop(rdi); 1.96 + if (thread != rax) { 1.97 + mov(thread, rax); 1.98 + pop(rax); 1.99 + } 1.100 +} 1.101 +#endif