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
0N/A
0N/Avoid MacroAssembler::int3() {
0N/A emit_byte(0xCC);
0N/A}
0N/A
304N/A#ifndef _LP64
0N/A// The current scheme to accelerate access to the thread
0N/A// pointer is to store the current thread in the os_exception_wrapper
0N/A// and reference the current thread from stubs and compiled code
0N/A// via the FS register. FS[0] contains a pointer to the structured
0N/A// exception block which is actually a stack address. The first time
0N/A// we call the os exception wrapper, we calculate and store the
0N/A// offset from this exception block and use that offset here.
0N/A//
0N/A// The last mechanism we used was problematic in that the
0N/A// the offset we had hard coded in the VM kept changing as Microsoft
0N/A// evolved the OS.
0N/A//
0N/A// Warning: This mechanism assumes that we only attempt to get the
0N/A// thread when we are nested below a call wrapper.
0N/A//
0N/A// movl reg, fs:[0] Get exeception pointer
0N/A// movl reg, [reg + thread_ptr_offset] Load thread
0N/A//
0N/Avoid MacroAssembler::get_thread(Register thread) {
0N/A // can't use ExternalAddress because it can't take NULL
0N/A AddressLiteral null(0, relocInfo::none);
0N/A
0N/A prefix(FS_segment);
0N/A movptr(thread, null);
0N/A assert(ThreadLocalStorage::get_thread_ptr_offset() != 0,
0N/A "Thread Pointer Offset has not been initialized");
0N/A movl(thread, Address(thread, ThreadLocalStorage::get_thread_ptr_offset()));
0N/A}
304N/A#else
304N/A// call (Thread*)TlsGetValue(thread_index());
304N/Avoid MacroAssembler::get_thread(Register thread) {
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(c_rarg0, ThreadLocalStorage::thread_index());
304N/A call(RuntimeAddress((address)TlsGetValue));
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