1 /* 2 * Copyright (c) 1999, 2008, 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 "incls/_precompiled.incl" 26 #include "incls/_assembler_linux_x86.cpp.incl" 27 28 #ifndef _LP64 29 void MacroAssembler::int3() { 30 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); 31 } 32 33 void MacroAssembler::get_thread(Register thread) { 34 movl(thread, rsp); 35 shrl(thread, PAGE_SHIFT); 36 37 ExternalAddress tls_base((address)ThreadLocalStorage::sp_map_addr()); 38 Address index(noreg, thread, Address::times_4); 39 ArrayAddress tls(tls_base, index); 40 41 movptr(thread, tls); 42 } 43 #else 44 void MacroAssembler::int3() { 45 call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint))); 46 } 47 48 void MacroAssembler::get_thread(Register thread) { 49 // call pthread_getspecific 50 // void * pthread_getspecific(pthread_key_t key); 51 if (thread != rax) { 52 push(rax); 53 } 54 push(rdi); 55 push(rsi); 56 push(rdx); 57 push(rcx); 58 push(r8); 59 push(r9); 60 push(r10); 61 // XXX 62 mov(r10, rsp); 63 andq(rsp, -16); 64 push(r10); 65 push(r11); 66 67 movl(rdi, ThreadLocalStorage::thread_index()); 68 call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific))); 69 70 pop(r11); 71 pop(rsp); 72 pop(r10); 73 pop(r9); 74 pop(r8); 75 pop(rcx); 76 pop(rdx); 77 pop(rsi); 78 pop(rdi); 79 if (thread != rax) { 80 mov(thread, rax); 81 pop(rax); 82 } 83 } 84 #endif