aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@1: /* aoqi@1: * This file has been modified by Loongson Technology in 2015. These aoqi@1: * modifications are Copyright (c) 2015 Loongson Technology, and are made aoqi@1: * available on the same license terms set forth above. aoqi@1: */ aoqi@1: aoqi@0: #ifndef SHARE_VM_RUNTIME_THREADLOCALSTORAGE_HPP aoqi@0: #define SHARE_VM_RUNTIME_THREADLOCALSTORAGE_HPP aoqi@0: aoqi@0: #include "gc_implementation/shared/gcUtil.hpp" aoqi@0: #include "runtime/os.hpp" aoqi@0: #include "utilities/top.hpp" aoqi@0: aoqi@0: // Interface for thread local storage aoqi@0: aoqi@0: // Fast variant of ThreadLocalStorage::get_thread_slow aoqi@0: extern "C" Thread* get_thread(); aoqi@0: aoqi@0: // Get raw thread id: e.g., %g7 on sparc, fs or gs on x86 aoqi@0: extern "C" uintptr_t _raw_thread_id(); aoqi@0: aoqi@0: class ThreadLocalStorage : AllStatic { aoqi@0: public: aoqi@0: static void set_thread(Thread* thread); aoqi@0: static Thread* get_thread_slow(); aoqi@0: static void invalidate_all() { pd_invalidate_all(); } aoqi@0: aoqi@0: // Machine dependent stuff aoqi@0: #ifdef TARGET_OS_ARCH_linux_x86 aoqi@0: # include "threadLS_linux_x86.hpp" aoqi@0: #endif aoqi@1: #ifdef TARGET_OS_ARCH_linux_mips aoqi@1: # include "threadLS_linux_mips.hpp" aoqi@1: #endif aoqi@0: #ifdef TARGET_OS_ARCH_linux_sparc aoqi@0: # include "threadLS_linux_sparc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_linux_zero aoqi@0: # include "threadLS_linux_zero.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_solaris_x86 aoqi@0: # include "threadLS_solaris_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_solaris_sparc aoqi@0: # include "threadLS_solaris_sparc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_windows_x86 aoqi@0: # include "threadLS_windows_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_linux_arm aoqi@0: # include "threadLS_linux_arm.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_linux_ppc aoqi@0: # include "threadLS_linux_ppc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_aix_ppc aoqi@0: # include "threadLS_aix_ppc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_bsd_x86 aoqi@0: # include "threadLS_bsd_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_OS_ARCH_bsd_zero aoqi@0: # include "threadLS_bsd_zero.hpp" aoqi@0: #endif aoqi@0: aoqi@0: aoqi@0: public: aoqi@0: // Accessor aoqi@0: static inline int thread_index() { return _thread_index; } aoqi@0: static inline void set_thread_index(int index) { _thread_index = index; } aoqi@0: aoqi@0: // Initialization aoqi@0: // Called explicitly from VMThread::activate_system instead of init_globals. aoqi@0: static void init(); aoqi@0: static bool is_initialized(); aoqi@0: aoqi@0: private: aoqi@0: static int _thread_index; aoqi@0: aoqi@0: static void generate_code_for_get_thread(); aoqi@0: aoqi@0: // Processor dependent parts of set_thread and initialization aoqi@0: static void pd_set_thread(Thread* thread); aoqi@0: static void pd_init(); aoqi@0: // Invalidate any thread cacheing or optimization schemes. aoqi@0: static void pd_invalidate_all(); aoqi@0: aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_RUNTIME_THREADLOCALSTORAGE_HPP