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 Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,101 @@ 1.4 +/* 1.5 + * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "asm/macroAssembler.hpp" 1.30 +#include "asm/macroAssembler.inline.hpp" 1.31 +#include "runtime/os.hpp" 1.32 +#include "runtime/threadLocalStorage.hpp" 1.33 + 1.34 + 1.35 +void MacroAssembler::int3() { 1.36 + emit_int8((unsigned char)0xCC); 1.37 +} 1.38 + 1.39 +#ifndef _LP64 1.40 +// The current scheme to accelerate access to the thread 1.41 +// pointer is to store the current thread in the os_exception_wrapper 1.42 +// and reference the current thread from stubs and compiled code 1.43 +// via the FS register. FS[0] contains a pointer to the structured 1.44 +// exception block which is actually a stack address. The first time 1.45 +// we call the os exception wrapper, we calculate and store the 1.46 +// offset from this exception block and use that offset here. 1.47 +// 1.48 +// The last mechanism we used was problematic in that the 1.49 +// the offset we had hard coded in the VM kept changing as Microsoft 1.50 +// evolved the OS. 1.51 +// 1.52 +// Warning: This mechanism assumes that we only attempt to get the 1.53 +// thread when we are nested below a call wrapper. 1.54 +// 1.55 +// movl reg, fs:[0] Get exeception pointer 1.56 +// movl reg, [reg + thread_ptr_offset] Load thread 1.57 +// 1.58 +void MacroAssembler::get_thread(Register thread) { 1.59 + // can't use ExternalAddress because it can't take NULL 1.60 + AddressLiteral null(0, relocInfo::none); 1.61 + 1.62 + prefix(FS_segment); 1.63 + movptr(thread, null); 1.64 + assert(ThreadLocalStorage::get_thread_ptr_offset() != 0, 1.65 + "Thread Pointer Offset has not been initialized"); 1.66 + movl(thread, Address(thread, ThreadLocalStorage::get_thread_ptr_offset())); 1.67 +} 1.68 +#else 1.69 +// call (Thread*)TlsGetValue(thread_index()); 1.70 +void MacroAssembler::get_thread(Register thread) { 1.71 + if (thread != rax) { 1.72 + push(rax); 1.73 + } 1.74 + push(rdi); 1.75 + push(rsi); 1.76 + push(rdx); 1.77 + push(rcx); 1.78 + push(r8); 1.79 + push(r9); 1.80 + push(r10); 1.81 + // XXX 1.82 + mov(r10, rsp); 1.83 + andq(rsp, -16); 1.84 + push(r10); 1.85 + push(r11); 1.86 + 1.87 + movl(c_rarg0, ThreadLocalStorage::thread_index()); 1.88 + call(RuntimeAddress((address)TlsGetValue)); 1.89 + 1.90 + pop(r11); 1.91 + pop(rsp); 1.92 + pop(r10); 1.93 + pop(r9); 1.94 + pop(r8); 1.95 + pop(rcx); 1.96 + pop(rdx); 1.97 + pop(rsi); 1.98 + pop(rdi); 1.99 + if (thread != rax) { 1.100 + mov(thread, rax); 1.101 + pop(rax); 1.102 + } 1.103 +} 1.104 +#endif