assembler_windows_x86.cpp revision 1472:c18cbe5936b8
1139804Simp/* 2117624Sharti * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 3117624Sharti * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4117624Sharti * 5117624Sharti * This code is free software; you can redistribute it and/or modify it 6117624Sharti * under the terms of the GNU General Public License version 2 only, as 7117624Sharti * published by the Free Software Foundation. 8117624Sharti * 9117624Sharti * This code is distributed in the hope that it will be useful, but WITHOUT 10117624Sharti * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11117624Sharti * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12117624Sharti * version 2 for more details (a copy is included in the LICENSE file that 13117624Sharti * accompanied this code). 14117624Sharti * 15117624Sharti * You should have received a copy of the GNU General Public License version 16117624Sharti * 2 along with this work; if not, write to the Free Software Foundation, 17117624Sharti * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18117624Sharti * 19117624Sharti * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20117624Sharti * or visit www.oracle.com if you need additional information or have any 21117624Sharti * questions. 22117624Sharti * 23117624Sharti */ 24117624Sharti 25117624Sharti#include "incls/_precompiled.incl" 26117624Sharti#include "incls/_assembler_windows_x86.cpp.incl" 27117624Sharti 28117624Sharti 29117624Shartivoid MacroAssembler::int3() { 30117624Sharti emit_byte(0xCC); 31117624Sharti} 32117624Sharti 33117624Sharti#ifndef _LP64 34117624Sharti// The current scheme to accelerate access to the thread 35117624Sharti// pointer is to store the current thread in the os_exception_wrapper 36117624Sharti// and reference the current thread from stubs and compiled code 37117624Sharti// via the FS register. FS[0] contains a pointer to the structured 38117624Sharti// exception block which is actually a stack address. The first time 39117624Sharti// we call the os exception wrapper, we calculate and store the 40117624Sharti// offset from this exception block and use that offset here. 41117624Sharti// 42117624Sharti// The last mechanism we used was problematic in that the 43254842Sandre// the offset we had hard coded in the VM kept changing as Microsoft 44117624Sharti// evolved the OS. 45117624Sharti// 46117624Sharti// Warning: This mechanism assumes that we only attempt to get the 47117624Sharti// thread when we are nested below a call wrapper. 48117624Sharti// 49117624Sharti// movl reg, fs:[0] Get exeception pointer 50117624Sharti// movl reg, [reg + thread_ptr_offset] Load thread 51117624Sharti// 52117624Shartivoid MacroAssembler::get_thread(Register thread) { 53117624Sharti // can't use ExternalAddress because it can't take NULL 54117624Sharti AddressLiteral null(0, relocInfo::none); 55117624Sharti 56117624Sharti prefix(FS_segment); 57117624Sharti movptr(thread, null); 58117624Sharti assert(ThreadLocalStorage::get_thread_ptr_offset() != 0, 59117624Sharti "Thread Pointer Offset has not been initialized"); 60117624Sharti movl(thread, Address(thread, ThreadLocalStorage::get_thread_ptr_offset())); 61117624Sharti} 62117624Sharti#else 63117624Sharti// call (Thread*)TlsGetValue(thread_index()); 64117624Shartivoid MacroAssembler::get_thread(Register thread) { 65117624Sharti if (thread != rax) { 66117624Sharti push(rax); 67117624Sharti } 68117624Sharti push(rdi); 69117624Sharti push(rsi); 70117624Sharti push(rdx); 71117624Sharti push(rcx); 72117624Sharti push(r8); 73117624Sharti push(r9); 74117624Sharti push(r10); 75117624Sharti // XXX 76117624Sharti mov(r10, rsp); 77117624Sharti andq(rsp, -16); 78117624Sharti push(r10); 79117624Sharti push(r11); 80117624Sharti 81117624Sharti movl(c_rarg0, ThreadLocalStorage::thread_index()); 82117624Sharti call(RuntimeAddress((address)TlsGetValue)); 83117624Sharti 84117624Sharti pop(r11); 85117624Sharti pop(rsp); 86117624Sharti pop(r10); 87117624Sharti pop(r9); 88117624Sharti pop(r8); 89117624Sharti pop(rcx); 90117624Sharti pop(rdx); 91117624Sharti pop(rsi); 92117624Sharti pop(rdi); 93117624Sharti if (thread != rax) { 94117624Sharti mov(thread, rax); 95117624Sharti pop(rax); 96117624Sharti } 97117624Sharti} 98117624Sharti#endif 99117624Sharti