hotspot/src/os/windows/vm/os_windows.hpp
author kamg
Mon, 28 Jul 2008 14:07:44 -0400
changeset 950 6112b627bb36
parent 1 489c9b5090e2
child 1421 a7ef1a3b2644
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-2006 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
// Win32_OS defines the interface to windows operating systems
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class win32 {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
 protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
  static int    _vm_page_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
  static int    _vm_allocation_granularity;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  static int    _processor_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  static int    _processor_level;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  static julong _physical_memory;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  static size_t _default_stack_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  static bool   _is_nt;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // Windows-specific interface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  static void   initialize_system_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  static void   setmode_streams();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // Processor info as provided by NT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  static int processor_type()  { return _processor_type;  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // Processor level may not be accurate on non-NT systems
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  static int processor_level() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    assert(is_nt(), "use vm_version instead");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    return _processor_level;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  static julong available_memory();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  static julong physical_memory() { return _physical_memory; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  // Generic interface:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // Trace number of created threads
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  static          intx  _os_thread_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  static volatile intx  _os_thread_count;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  // Tells whether the platform is NT or Windown95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  static bool is_nt() { return _is_nt; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  // Returns the byte size of a virtual memory page
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  static int vm_page_size() { return _vm_page_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // Returns the size in bytes of memory blocks which can be allocated.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  static int vm_allocation_granularity() { return _vm_allocation_granularity; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // Read the headers for the executable that started the current process into
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // the structure passed in (see winnt.h).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  static void read_executable_headers(PIMAGE_NT_HEADERS);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  // Default stack size for the current process.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  static size_t default_stack_size() { return _default_stack_size; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
#ifndef _WIN64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // A wrapper to install a structured exception handler for fast JNI accesors.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  static address fast_jni_accessor_wrapper(BasicType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // filter function to ignore faults on serializations page
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  static LONG WINAPI serialize_fault_filter(struct _EXCEPTION_POINTERS* e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
class PlatformEvent : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    double CachePad [4] ;   // increase odds that _Event is sole occupant of cache line
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    volatile int _Event ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    HANDLE _ParkHandle ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  public:       // TODO-FIXME: make dtor private
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    ~PlatformEvent() { guarantee (0, "invariant") ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    PlatformEvent() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
      _Event   = 0 ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      _ParkHandle = CreateEvent (NULL, false, false, NULL) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      guarantee (_ParkHandle != NULL, "invariant") ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    // Exercise caution using reset() and fired() - they may require MEMBARs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
    void reset() { _Event = 0 ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
    int  fired() { return _Event; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    void park () ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    void unpark () ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    int  park (jlong millis) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
} ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
class PlatformParker : public CHeapObj {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    HANDLE _ParkEvent ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    ~PlatformParker () { guarantee (0, "invariant") ; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    PlatformParker  () {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
      _ParkEvent = CreateEvent (NULL, true, false, NULL) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      guarantee (_ParkEvent != NULL, "invariant") ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
} ;