0N/A/*
1879N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "asm/assembler.hpp"
1879N/A#include "assembler_x86.inline.hpp"
1879N/A#include "runtime/os.hpp"
1879N/A#include "runtime/threadLocalStorage.hpp"
0N/A
304N/A#ifndef _LP64
0N/Avoid MacroAssembler::int3() {
0N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
0N/A}
0N/A
2623N/A#ifdef MINIMIZE_RAM_USAGE
2623N/A
2623N/Avoid MacroAssembler::get_thread(Register thread) {
2623N/A // call pthread_getspecific
2623N/A // void * pthread_getspecific(pthread_key_t key);
2623N/A if (thread != rax) push(rax);
2623N/A push(rcx);
2623N/A push(rdx);
2623N/A
2623N/A push(ThreadLocalStorage::thread_index());
2623N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific)));
2623N/A increment(rsp, wordSize);
2623N/A
2623N/A pop(rdx);
2623N/A pop(rcx);
2623N/A if (thread != rax) {
2623N/A mov(thread, rax);
2623N/A pop(rax);
2623N/A }
2623N/A}
2623N/A
2623N/A#else
0N/Avoid MacroAssembler::get_thread(Register thread) {
0N/A movl(thread, rsp);
0N/A shrl(thread, PAGE_SHIFT);
0N/A
0N/A ExternalAddress tls_base((address)ThreadLocalStorage::sp_map_addr());
0N/A Address index(noreg, thread, Address::times_4);
0N/A ArrayAddress tls(tls_base, index);
0N/A
0N/A movptr(thread, tls);
0N/A}
2623N/A#endif // MINIMIZE_RAM_USAGE
304N/A#else
304N/Avoid MacroAssembler::int3() {
304N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, os::breakpoint)));
304N/A}
304N/A
304N/Avoid MacroAssembler::get_thread(Register thread) {
304N/A // call pthread_getspecific
304N/A // void * pthread_getspecific(pthread_key_t key);
304N/A if (thread != rax) {
304N/A push(rax);
304N/A }
304N/A push(rdi);
304N/A push(rsi);
304N/A push(rdx);
304N/A push(rcx);
304N/A push(r8);
304N/A push(r9);
304N/A push(r10);
304N/A // XXX
304N/A mov(r10, rsp);
304N/A andq(rsp, -16);
304N/A push(r10);
304N/A push(r11);
304N/A
304N/A movl(rdi, ThreadLocalStorage::thread_index());
304N/A call(RuntimeAddress(CAST_FROM_FN_PTR(address, pthread_getspecific)));
304N/A
304N/A pop(r11);
304N/A pop(rsp);
304N/A pop(r10);
304N/A pop(r9);
304N/A pop(r8);
304N/A pop(rcx);
304N/A pop(rdx);
304N/A pop(rsi);
304N/A pop(rdi);
304N/A if (thread != rax) {
304N/A mov(thread, rax);
304N/A pop(rax);
304N/A }
304N/A}
304N/A#endif