assembler_solaris_x86.cpp revision 1472:c18cbe5936b8
1256641Sluigi/* 2256641Sluigi * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. 357048Sluigi * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 457048Sluigi * 557048Sluigi * This code is free software; you can redistribute it and/or modify it 6256641Sluigi * under the terms of the GNU General Public License version 2 only, as 757048Sluigi * published by the Free Software Foundation. 857048Sluigi * 957048Sluigi * This code is distributed in the hope that it will be useful, but WITHOUT 1057048Sluigi * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1157048Sluigi * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1257048Sluigi * version 2 for more details (a copy is included in the LICENSE file that 1369416Sluigi * accompanied this code). 1457048Sluigi * 1557048Sluigi * You should have received a copy of the GNU General Public License version 1657048Sluigi * 2 along with this work; if not, write to the Free Software Foundation, 1757048Sluigi * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1857048Sluigi * 1957048Sluigi * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20256641Sluigi * or visit www.oracle.com if you need additional information or have any 2157048Sluigi * questions. 2257048Sluigi * 2357048Sluigi */ 2457048Sluigi 2557048Sluigi#include "incls/_precompiled.incl" 2657048Sluigi#include "incls/_assembler_solaris_x86.cpp.incl" 2757048Sluigi 2857048Sluigi 29void MacroAssembler::int3() { 30 push(rax); 31 push(rdx); 32 push(rcx); 33 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); 34 pop(rcx); 35 pop(rdx); 36 pop(rax); 37} 38 39#define __ _masm-> 40#ifndef _LP64 41static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) { 42 43 // slow call to of thr_getspecific 44 // int thr_getspecific(thread_key_t key, void **value); 45 // Consider using pthread_getspecific instead. 46 47__ push(0); // allocate space for return value 48 if (thread != rax) __ push(rax); // save rax, if caller still wants it 49__ push(rcx); // save caller save 50__ push(rdx); // save caller save 51 if (thread != rax) { 52__ lea(thread, Address(rsp, 3 * sizeof(int))); // address of return value 53 } else { 54__ lea(thread, Address(rsp, 2 * sizeof(int))); // address of return value 55 } 56__ push(thread); // and pass the address 57__ push(ThreadLocalStorage::thread_index()); // the key 58__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific))); 59__ increment(rsp, 2 * wordSize); 60__ pop(rdx); 61__ pop(rcx); 62 if (thread != rax) __ pop(rax); 63__ pop(thread); 64 65} 66#else 67static void slow_call_thr_specific(MacroAssembler* _masm, Register thread) { 68 // slow call to of thr_getspecific 69 // int thr_getspecific(thread_key_t key, void **value); 70 // Consider using pthread_getspecific instead. 71 72 if (thread != rax) { 73__ push(rax); 74 } 75__ push(0); // space for return value 76__ push(rdi); 77__ push(rsi); 78__ lea(rsi, Address(rsp, 16)); // pass return value address 79__ push(rdx); 80__ push(rcx); 81__ push(r8); 82__ push(r9); 83__ push(r10); 84 // XXX 85__ mov(r10, rsp); 86__ andptr(rsp, -16); 87__ push(r10); 88__ push(r11); 89 90__ movl(rdi, ThreadLocalStorage::thread_index()); 91__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific))); 92 93__ pop(r11); 94__ pop(rsp); 95__ pop(r10); 96__ pop(r9); 97__ pop(r8); 98__ pop(rcx); 99__ pop(rdx); 100__ pop(rsi); 101__ pop(rdi); 102__ pop(thread); // load return value 103 if (thread != rax) { 104__ pop(rax); 105 } 106} 107#endif //LP64 108 109void MacroAssembler::get_thread(Register thread) { 110 111 int segment = NOT_LP64(Assembler::GS_segment) LP64_ONLY(Assembler::FS_segment); 112 // Try to emit a Solaris-specific fast TSD/TLS accessor. 113 ThreadLocalStorage::pd_tlsAccessMode tlsMode = ThreadLocalStorage::pd_getTlsAccessMode (); 114 if (tlsMode == ThreadLocalStorage::pd_tlsAccessIndirect) { // T1 115 // Use thread as a temporary: mov r, gs:[0]; mov r, [r+tlsOffset] 116 emit_byte (segment); 117 // ExternalAddress doesn't work because it can't take NULL 118 AddressLiteral null(0, relocInfo::none); 119 movptr (thread, null); 120 movptr(thread, Address(thread, ThreadLocalStorage::pd_getTlsOffset())) ; 121 return ; 122 } else 123 if (tlsMode == ThreadLocalStorage::pd_tlsAccessDirect) { // T2 124 // mov r, gs:[tlsOffset] 125 emit_byte (segment); 126 AddressLiteral tls_off((address)ThreadLocalStorage::pd_getTlsOffset(), relocInfo::none); 127 movptr (thread, tls_off); 128 return ; 129 } 130 131 slow_call_thr_specific(this, thread); 132 133} 134