assembler_solaris_x86.cpp revision 3883:cd3d6a6b95d9
1/* 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25#include "precompiled.hpp" 26#include "asm/macroAssembler.hpp" 27#include "asm/macroAssembler.inline.hpp" 28#include "runtime/os.hpp" 29#include "runtime/threadLocalStorage.hpp" 30 31 32void MacroAssembler::int3() { 33 push(rax); 34 push(rdx); 35 push(rcx); 36 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); 37 pop(rcx); 38 pop(rdx); 39 pop(rax); 40} 41 42#define __ _masm-> 43#ifndef _LP64 44static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) { 45 46 // slow call to of thr_getspecific 47 // int thr_getspecific(thread_key_t key, void **value); 48 // Consider using pthread_getspecific instead. 49 50__ push(0); // allocate space for return value 51 if (thread != rax) __ push(rax); // save rax, if caller still wants it 52__ push(rcx); // save caller save 53__ push(rdx); // save caller save 54 if (thread != rax) { 55__ lea(thread, Address(rsp, 3 * sizeof(int))); // address of return value 56 } else { 57__ lea(thread, Address(rsp, 2 * sizeof(int))); // address of return value 58 } 59__ push(thread); // and pass the address 60__ push(ThreadLocalStorage::thread_index()); // the key 61__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific))); 62__ increment(rsp, 2 * wordSize); 63__ pop(rdx); 64__ pop(rcx); 65 if (thread != rax) __ pop(rax); 66__ pop(thread); 67 68} 69#else 70static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) { 71 // slow call to of thr_getspecific 72 // int thr_getspecific(thread_key_t key, void **value); 73 // Consider using pthread_getspecific instead. 74 75 if (thread != rax) { 76__ push(rax); 77 } 78__ push(0); // space for return value 79__ push(rdi); 80__ push(rsi); 81__ lea(rsi, Address(rsp, 16)); // pass return value address 82__ push(rdx); 83__ push(rcx); 84__ push(r8); 85__ push(r9); 86__ push(r10); 87 // XXX 88__ mov(r10, rsp); 89__ andptr(rsp, -16); 90__ push(r10); 91__ push(r11); 92 93__ movl(rdi, ThreadLocalStorage::thread_index()); 94__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific))); 95 96__ pop(r11); 97__ pop(rsp); 98__ pop(r10); 99__ pop(r9); 100__ pop(r8); 101__ pop(rcx); 102__ pop(rdx); 103__ pop(rsi); 104__ pop(rdi); 105__ pop(thread); // load return value 106 if (thread != rax) { 107__ pop(rax); 108 } 109} 110#endif //LP64 111 112void MacroAssembler::get_thread(Register thread) { 113 114 int segment = NOT_LP64(Assembler::GS_segment) LP64_ONLY(Assembler::FS_segment); 115 // Try to emit a Solaris-specific fast TSD/TLS accessor. 116 ThreadLocalStorage::pd_tlsAccessMode tlsMode = ThreadLocalStorage::pd_getTlsAccessMode (); 117 if (tlsMode == ThreadLocalStorage::pd_tlsAccessIndirect) { // T1 118 // Use thread as a temporary: mov r, gs:[0]; mov r, [r+tlsOffset] 119 emit_byte (segment); 120 // ExternalAddress doesn't work because it can't take NULL 121 AddressLiteral null(0, relocInfo::none); 122 movptr (thread, null); 123 movptr(thread, Address(thread, ThreadLocalStorage::pd_getTlsOffset())) ; 124 return ; 125 } else 126 if (tlsMode == ThreadLocalStorage::pd_tlsAccessDirect) { // T2 127 // mov r, gs:[tlsOffset] 128 emit_byte (segment); 129 AddressLiteral tls_off((address)ThreadLocalStorage::pd_getTlsOffset(), relocInfo::none); 130 movptr (thread, tls_off); 131 return ; 132 } 133 134 slow_call_thr_specific(this, thread); 135 136} 137