1 #ifdef USE_PRAGMA_IDENT_SRC
   2 #pragma ident "@(#)vm_version_sparc.cpp 1.56 07/07/02 18:40:59 JVM"
   3 #endif
   4 /*
   5  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  
  26  */
  27 
  28 # include "incls/_precompiled.incl"
  29 # include "incls/_vm_version_sparc.cpp.incl"
  30 
  31 int VM_Version::_features = VM_Version::unknown_m;
  32 const char* VM_Version::_features_str = "";
  33 
  34 bool VM_Version::is_niagara1_plus() {
  35   // This is a placeholder until the real test is determined.
  36   return is_niagara1() &&
  37     (os::processor_count() > maximum_niagara1_processor_count());
  38 }
  39 
  40 void VM_Version::initialize() {
  41   _features = determine_features();
  42   PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes(); 
  43   PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
  44   PrefetchFieldsAhead         = prefetch_fields_ahead();
  45 
  46   // Allocation prefetch settings
  47   intx cache_line_size = L1_data_cache_line_size();
  48   if( cache_line_size > AllocatePrefetchStepSize )
  49     AllocatePrefetchStepSize = cache_line_size;
  50   if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
  51     AllocatePrefetchLines = 3; // Optimistic value
  52   assert( AllocatePrefetchLines > 0, "invalid value");
  53   if( AllocatePrefetchLines < 1 ) // set valid value in product VM
  54     AllocatePrefetchLines = 1; // Conservative value
  55 
  56   AllocatePrefetchDistance = allocate_prefetch_distance();
  57   AllocatePrefetchStyle    = allocate_prefetch_style();
  58 
  59   assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
  60 
  61   UseSSE = 0; // Only on x86 and x64
  62 
  63   _supports_cx8               = has_v9();
  64 
  65   if (is_niagara1()) {
  66     // Indirect branch is the same cost as direct
  67     if (FLAG_IS_DEFAULT(UseInlineCaches)) {
  68       UseInlineCaches         = false;
  69     }
  70 #ifdef _LP64
  71     // Single issue niagara1 is slower for CompressedOops
  72     // but niagaras after that it's fine.
  73     if (!is_niagara1_plus()) {
  74       if (FLAG_IS_DEFAULT(UseCompressedOops)) {
  75         FLAG_SET_ERGO(bool, UseCompressedOops, false);
  76       }
  77     }
  78 #endif // _LP64
  79 #ifdef COMPILER2
  80     // Indirect branch is the same cost as direct
  81     if (FLAG_IS_DEFAULT(UseJumpTables)) {
  82       UseJumpTables           = true;
  83     }
  84     // Single-issue, so entry and loop tops are
  85     // aligned on a single instruction boundary
  86     if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) {
  87       InteriorEntryAlignment  = 4;
  88     }
  89     if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
  90       OptoLoopAlignment       = 4;
  91     }
  92 #endif
  93   }
  94 
  95   char buf[512];
  96   jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s",
  97                (has_v8() ? ", has_v8" : ""),
  98                (has_v9() ? ", has_v9" : ""),
  99                (has_vis1() ? ", has_vis1" : ""),
 100                (has_vis2() ? ", has_vis2" : ""),
 101                (is_ultra3() ? ", is_ultra3" : ""),
 102                (is_sun4v() ? ", is_sun4v" : ""),
 103                (is_niagara1() ? ", is_niagara1" : ""),
 104                (!has_hardware_int_muldiv() ? ", no-muldiv" : ""),
 105                (!has_hardware_fsmuld() ? ", no-fsmuld" : ""));
 106 
 107   // buf is started with ", " or is empty
 108   _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);
 109 
 110 #ifndef PRODUCT
 111   if (PrintMiscellaneous && Verbose) { 
 112     tty->print("Allocation: ");
 113     if (AllocatePrefetchStyle <= 0) {
 114       tty->print_cr("no prefetching");
 115     } else {
 116       if (AllocatePrefetchLines > 1) {
 117         tty->print_cr("PREFETCH %d, %d lines of size %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
 118       } else {
 119         tty->print_cr("PREFETCH %d, one line", AllocatePrefetchDistance);
 120       }
 121     }
 122     if (PrefetchCopyIntervalInBytes > 0) {
 123       tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
 124     }
 125     if (PrefetchScanIntervalInBytes > 0) {
 126       tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
 127     }
 128     if (PrefetchFieldsAhead > 0) {
 129       tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
 130     }
 131   }
 132 #endif // PRODUCT
 133 }
 134 
 135 void VM_Version::print_features() {
 136   tty->print_cr("Version:%s", cpu_features());
 137 }
 138 
 139 int VM_Version::determine_features() {
 140   if (UseV8InstrsOnly) {
 141     NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-V8");)
 142     return generic_v8_m;
 143   } 
 144 
 145   int features = platform_features(unknown_m); // platform_features() is os_arch specific
 146 
 147   if (features == unknown_m) {
 148     features = generic_v9_m;
 149     warning("Cannot recognize SPARC version. Default to V9");
 150   }
 151 
 152   if (UseNiagaraInstrs) {
 153     if (is_niagara1(features)) {
 154       // Happy to accomodate...
 155     } else {
 156       NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");)
 157       features = niagara1_m;
 158     }
 159   } else {
 160     if (is_niagara1(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
 161       NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");)
 162       features &= ~niagara1_unique_m;
 163     } else {
 164       // Happy to accomodate...
 165     }
 166   }
 167 
 168   return features;
 169 }
 170 
 171 static int saved_features = 0;
 172 
 173 void VM_Version::allow_all() {
 174   saved_features = _features;
 175   _features      = all_features_m;
 176 }
 177 
 178 void VM_Version::revert() {
 179   _features = saved_features;
 180 }
 181 
 182 unsigned int VM_Version::calc_parallel_worker_threads() {
 183   unsigned int result;
 184   if (is_niagara1_plus()) {
 185     result = nof_parallel_worker_threads(5, 16, 8);
 186   } else {
 187     result = nof_parallel_worker_threads(5, 8, 8);
 188   }
 189   return result;
 190 }