1 /* |
|
2 * Copyright 1999-2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
20 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
21 * have any questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 #include "incls/_precompiled.incl" |
|
26 #include "incls/_assembler_solaris_x86_32.cpp.incl" |
|
27 |
|
28 |
|
29 void MacroAssembler::int3() { |
|
30 pushl(rax); |
|
31 pushl(rdx); |
|
32 pushl(rcx); |
|
33 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); |
|
34 popl(rcx); |
|
35 popl(rdx); |
|
36 popl(rax); |
|
37 } |
|
38 |
|
39 void MacroAssembler::get_thread(Register thread) { |
|
40 |
|
41 // Try to emit a Solaris-specific fast TSD/TLS accessor. |
|
42 ThreadLocalStorage::pd_tlsAccessMode tlsMode = ThreadLocalStorage::pd_getTlsAccessMode () ; |
|
43 if (tlsMode == ThreadLocalStorage::pd_tlsAccessIndirect) { // T1 |
|
44 // Use thread as a temporary: mov r, gs:[0]; mov r, [r+tlsOffset] |
|
45 emit_byte (Assembler::GS_segment) ; |
|
46 // ExternalAddress doesn't work because it can't take NULL |
|
47 AddressLiteral null(0, relocInfo::none); |
|
48 movptr (thread, null); |
|
49 movl (thread, Address(thread, ThreadLocalStorage::pd_getTlsOffset())) ; |
|
50 return ; |
|
51 } else |
|
52 if (tlsMode == ThreadLocalStorage::pd_tlsAccessDirect) { // T2 |
|
53 // mov r, gs:[tlsOffset] |
|
54 emit_byte (Assembler::GS_segment) ; |
|
55 AddressLiteral tls((address)ThreadLocalStorage::pd_getTlsOffset(), relocInfo::none); |
|
56 movptr (thread, tls); |
|
57 return ; |
|
58 } |
|
59 |
|
60 // slow call to of thr_getspecific |
|
61 // int thr_getspecific(thread_key_t key, void **value); |
|
62 // Consider using pthread_getspecific instead. |
|
63 |
|
64 pushl(0); // allocate space for return value |
|
65 if (thread != rax) pushl(rax); // save rax, if caller still wants it |
|
66 pushl(rcx); // save caller save |
|
67 pushl(rdx); // save caller save |
|
68 if (thread != rax) { |
|
69 leal(thread, Address(rsp, 3 * sizeof(int))); // address of return value |
|
70 } else { |
|
71 leal(thread, Address(rsp, 2 * sizeof(int))); // address of return value |
|
72 } |
|
73 pushl(thread); // and pass the address |
|
74 pushl(ThreadLocalStorage::thread_index()); // the key |
|
75 call(RuntimeAddress(CAST_FROM_FN_PTR(address, thr_getspecific))); |
|
76 increment(rsp, 2 * wordSize); |
|
77 popl(rdx); |
|
78 popl(rcx); |
|
79 if (thread != rax) popl(rax); |
|
80 popl(thread); |
|
81 } |
|