hotspot/src/share/vm/runtime/threadLocalStorage.hpp
author kamg
Mon, 28 Jul 2008 14:07:44 -0400
changeset 950 6112b627bb36
parent 1 489c9b5090e2
child 1217 5eb97f366a6a
permissions -rw-r--r--
6721093: -XX:AppendRatio=N not supported Summary: Add mechanism to ignore unsupported flags for a set period of time Reviewed-by: acorn, never, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2003 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// Interface for thread local storage
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// Fast variant of ThreadLocalStorage::get_thread_slow
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
extern "C" Thread*   get_thread();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// Get raw thread id: e.g., %g7 on sparc, fs or gs on x86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
extern "C" uintptr_t _raw_thread_id();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class ThreadLocalStorage : AllStatic {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  static void    set_thread(Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  static Thread* get_thread_slow();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  static void    invalidate_all() { pd_invalidate_all(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // Machine dependent stuff
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  #include "incls/_threadLS_pd.hpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // Accessor
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  static inline int  thread_index()              { return _thread_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  static inline void set_thread_index(int index) { _thread_index = index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  // Called explicitly from VMThread::activate_system instead of init_globals.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  static void init();
950
6112b627bb36 6721093: -XX:AppendRatio=N not supported
kamg
parents: 1
diff changeset
    50
  static bool is_initialized();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  static int     _thread_index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  static void    generate_code_for_get_thread();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  // Processor dependent parts of set_thread and initialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  static void pd_set_thread(Thread* thread);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  static void pd_init();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Invalidate any thread cacheing or optimization schemes.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  static void pd_invalidate_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
};