src/share/vm/runtime/thread.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2014, 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  *


 590   TLAB_FIELD_OFFSET(top)
 591   TLAB_FIELD_OFFSET(pf_top)
 592   TLAB_FIELD_OFFSET(size)                   // desired_size
 593   TLAB_FIELD_OFFSET(refill_waste_limit)
 594   TLAB_FIELD_OFFSET(number_of_refills)
 595   TLAB_FIELD_OFFSET(fast_refill_waste)
 596   TLAB_FIELD_OFFSET(slow_allocations)
 597 
 598 #undef TLAB_FIELD_OFFSET
 599 
 600   static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes); }
 601 
 602  public:
 603   volatile intptr_t _Stalled;
 604   volatile int _TypeTag;
 605   ParkEvent * _ParkEvent;                     // for synchronized()
 606   ParkEvent * _SleepEvent;                    // for Thread.sleep
 607   ParkEvent * _MutexEvent;                    // for native internal Mutex/Monitor
 608   ParkEvent * _MuxEvent;                      // for low-level muxAcquire-muxRelease
 609   int NativeSyncRecursion;                    // diagnostic

 610 
 611   volatile int _OnTrap;                       // Resume-at IP delta
 612   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
 613   jint _hashStateX;                           // thread-specific hashCode generator state
 614   jint _hashStateY;
 615   jint _hashStateZ;
 616   void * _schedctl;
 617 
 618 
 619   volatile jint rng[4];                      // RNG for spin loop

 620 
 621   // Low-level leaf-lock primitives used to implement synchronization
 622   // and native monitor-mutex infrastructure.
 623   // Not for general synchronization use.
 624   static void SpinAcquire(volatile int * Lock, const char * Name);
 625   static void SpinRelease(volatile int * Lock);
 626   static void muxAcquire(volatile intptr_t * Lock, const char * Name);
 627   static void muxAcquireW(volatile intptr_t * Lock, ParkEvent * ev);
 628   static void muxRelease(volatile intptr_t * Lock);
 629 };
 630 
 631 // Inline implementation of Thread::current()
 632 // Thread::current is "hot" it's called > 128K times in the 1st 500 msecs of
 633 // startup.
 634 // ThreadLocalStorage::thread is warm -- it's called > 16K times in the same
 635 // period.   This is inlined in thread_<os_family>.inline.hpp.
 636 
 637 inline Thread* Thread::current() {
 638 #ifdef ASSERT
 639   // This function is very high traffic. Define PARANOID to enable expensive


   1 /*
   2  * Copyright (c) 1997, 2015, 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  *


 590   TLAB_FIELD_OFFSET(top)
 591   TLAB_FIELD_OFFSET(pf_top)
 592   TLAB_FIELD_OFFSET(size)                   // desired_size
 593   TLAB_FIELD_OFFSET(refill_waste_limit)
 594   TLAB_FIELD_OFFSET(number_of_refills)
 595   TLAB_FIELD_OFFSET(fast_refill_waste)
 596   TLAB_FIELD_OFFSET(slow_allocations)
 597 
 598 #undef TLAB_FIELD_OFFSET
 599 
 600   static ByteSize allocated_bytes_offset()       { return byte_offset_of(Thread, _allocated_bytes); }
 601 
 602  public:
 603   volatile intptr_t _Stalled;
 604   volatile int _TypeTag;
 605   ParkEvent * _ParkEvent;                     // for synchronized()
 606   ParkEvent * _SleepEvent;                    // for Thread.sleep
 607   ParkEvent * _MutexEvent;                    // for native internal Mutex/Monitor
 608   ParkEvent * _MuxEvent;                      // for low-level muxAcquire-muxRelease
 609   int NativeSyncRecursion;                    // diagnostic
 610   Thread * volatile _TSelf;                   // allows xchg T,T->TSelf style MFENCE replacement
 611 
 612   volatile int _OnTrap;                       // Resume-at IP delta
 613   jint _hashStateW;                           // Marsaglia Shift-XOR thread-local RNG
 614   jint _hashStateX;                           // thread-specific hashCode generator state
 615   jint _hashStateY;
 616   jint _hashStateZ;
 617   void * _schedctl;
 618 
 619 
 620   volatile jint rng[4];                      // RNG for spin loop
 621   static ByteSize TSelf_offset()                 { return byte_offset_of(Thread, _TSelf); }
 622 
 623   // Low-level leaf-lock primitives used to implement synchronization
 624   // and native monitor-mutex infrastructure.
 625   // Not for general synchronization use.
 626   static void SpinAcquire(volatile int * Lock, const char * Name);
 627   static void SpinRelease(volatile int * Lock);
 628   static void muxAcquire(volatile intptr_t * Lock, const char * Name);
 629   static void muxAcquireW(volatile intptr_t * Lock, ParkEvent * ev);
 630   static void muxRelease(volatile intptr_t * Lock);
 631 };
 632 
 633 // Inline implementation of Thread::current()
 634 // Thread::current is "hot" it's called > 128K times in the 1st 500 msecs of
 635 // startup.
 636 // ThreadLocalStorage::thread is warm -- it's called > 16K times in the same
 637 // period.   This is inlined in thread_<os_family>.inline.hpp.
 638 
 639 inline Thread* Thread::current() {
 640 #ifdef ASSERT
 641   // This function is very high traffic. Define PARANOID to enable expensive