src/os_cpu/solaris_sparc/vm/threadLS_solaris_sparc.hpp

Thu, 21 Oct 2010 11:55:10 -0700

author
never
date
Thu, 21 Oct 2010 11:55:10 -0700
changeset 2262
1e9a9d2e6509
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6970683: improvements to hs_err output
Reviewed-by: kvn, jrose, dholmes, coleenp

     1 /*
     2  * Copyright (c) 1998, 2005, 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  */
    25 public:
    26   // Java Thread  - force inlining
    27   static inline Thread* thread() ;
    29 private:
    30   static Thread* _get_thread_cache[];  // index by [(raw_id>>9)^(raw_id>>20) % _pd_cache_size]
    31   static Thread* get_thread_via_cache_slowly(uintptr_t raw_id, int index);
    33   NOT_PRODUCT(static int _tcacheHit;)
    34   NOT_PRODUCT(static int _tcacheMiss;)
    36 public:
    38   // Print cache hit/miss statistics
    39   static void print_statistics() PRODUCT_RETURN;
    41   enum Constants {
    42     _pd_cache_size         =  256*2  // projected typical # of threads * 2
    43   };
    45   static void set_thread_in_slot (Thread *) ;
    47   static uintptr_t pd_raw_thread_id() {
    48     return _raw_thread_id();
    49   }
    51   static int pd_cache_index(uintptr_t raw_id) {
    52     // Hash function: From email from Dave:
    53     // The hash function deserves an explanation.  %g7 points to libthread's
    54     // "thread" structure.  On T1 the thread structure is allocated on the
    55     // user's stack (yes, really!) so the ">>20" handles T1 where the JVM's
    56     // stack size is usually >= 1Mb.  The ">>9" is for T2 where Roger allocates
    57     // globs of thread blocks contiguously.  The "9" has to do with the
    58     // expected size of the T2 thread structure.  If these constants are wrong
    59     // the worst thing that'll happen is that the hit rate for heavily threaded
    60     // apps won't be as good as it could be.  If you want to burn another
    61     // shift+xor you could mix together _all of the %g7 bits to form the hash,
    62     // but I think that's excessive.  Making the change above changed the
    63     // T$ miss rate on SpecJBB (on a 16X system) from about 3% to imperceptible.
    64     uintptr_t ix = (int) (((raw_id >> 9) ^ (raw_id >> 20)) % _pd_cache_size);
    65     return ix;
    66   }

mercurial