vm_version_sparc.cpp 19.2 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
22 23 24
 *
 */

25
#include "precompiled.hpp"
26
#include "asm/macroAssembler.inline.hpp"
27 28 29 30 31 32 33 34 35 36
#include "memory/resourceArea.hpp"
#include "runtime/java.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "vm_version_sparc.hpp"
#ifdef TARGET_OS_FAMILY_linux
# include "os_linux.inline.hpp"
#endif
#ifdef TARGET_OS_FAMILY_solaris
# include "os_solaris.inline.hpp"
#endif
D
duke 已提交
37 38 39

int VM_Version::_features = VM_Version::unknown_m;
const char* VM_Version::_features_str = "";
40
unsigned int VM_Version::_L2_data_cache_line_size = 0;
D
duke 已提交
41 42

void VM_Version::initialize() {
43 44 45 46

  assert(_features != VM_Version::unknown_m, "System pre-initialization is not complete.");
  guarantee(VM_Version::has_v9(), "only SPARC v9 is supported");

D
duke 已提交
47 48 49 50
  PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
  PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
  PrefetchFieldsAhead         = prefetch_fields_ahead();

51 52 53 54
  assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 1, "invalid value");
  if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
  if( AllocatePrefetchInstr > 1 ) AllocatePrefetchInstr = 0;

D
duke 已提交
55
  // Allocation prefetch settings
56
  intx cache_line_size = prefetch_data_size();
D
duke 已提交
57 58
  if( cache_line_size > AllocatePrefetchStepSize )
    AllocatePrefetchStepSize = cache_line_size;
59 60 61 62 63 64 65

  assert(AllocatePrefetchLines > 0, "invalid value");
  if( AllocatePrefetchLines < 1 )     // set valid value in product VM
    AllocatePrefetchLines = 3;
  assert(AllocateInstancePrefetchLines > 0, "invalid value");
  if( AllocateInstancePrefetchLines < 1 ) // set valid value in product VM
    AllocateInstancePrefetchLines = 1;
D
duke 已提交
66 67 68 69

  AllocatePrefetchDistance = allocate_prefetch_distance();
  AllocatePrefetchStyle    = allocate_prefetch_style();

70 71 72 73 74 75
  assert((AllocatePrefetchDistance % AllocatePrefetchStepSize) == 0 &&
         (AllocatePrefetchDistance > 0), "invalid value");
  if ((AllocatePrefetchDistance % AllocatePrefetchStepSize) != 0 ||
      (AllocatePrefetchDistance <= 0)) {
    AllocatePrefetchDistance = AllocatePrefetchStepSize;
  }
D
duke 已提交
76

77
  if (AllocatePrefetchStyle == 3 && (!has_blk_init() || cache_line_size <= 0)) {
K
kvn 已提交
78 79 80 81
    warning("BIS instructions are not available on this CPU");
    FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1);
  }

M
morris 已提交
82 83 84 85 86 87
  assert(ArraycopySrcPrefetchDistance < 4096, "invalid value");
  if (ArraycopySrcPrefetchDistance >= 4096)
    ArraycopySrcPrefetchDistance = 4064;
  assert(ArraycopyDstPrefetchDistance < 4096, "invalid value");
  if (ArraycopyDstPrefetchDistance >= 4096)
    ArraycopyDstPrefetchDistance = 4064;
88

D
duke 已提交
89 90
  UseSSE = 0; // Only on x86 and x64

91
  _supports_cx8 = has_v9();
92
  _supports_atomic_getset4 = true; // swap instruction
D
duke 已提交
93

94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
  // There are Fujitsu Sparc64 CPUs which support blk_init as well so
  // we have to take this check out of the 'is_niagara()' block below.
  if (has_blk_init()) {
    // When using CMS or G1, we cannot use memset() in BOT updates
    // because the sun4v/CMT version in libc_psr uses BIS which
    // exposes "phantom zeros" to concurrent readers. See 6948537.
    if (FLAG_IS_DEFAULT(UseMemSetInBOT) && (UseConcMarkSweepGC || UseG1GC)) {
      FLAG_SET_DEFAULT(UseMemSetInBOT, false);
    }
    // Issue a stern warning if the user has explicitly set
    // UseMemSetInBOT (it is known to cause issues), but allow
    // use for experimentation and debugging.
    if (UseConcMarkSweepGC || UseG1GC) {
      if (UseMemSetInBOT) {
        assert(!FLAG_IS_DEFAULT(UseMemSetInBOT), "Error");
        warning("Experimental flag -XX:+UseMemSetInBOT is known to cause instability"
                " on sun4v; please understand that you are using at your own risk!");
      }
    }
  }

115
  if (is_niagara()) {
D
duke 已提交
116 117
    // Indirect branch is the same cost as direct
    if (FLAG_IS_DEFAULT(UseInlineCaches)) {
118
      FLAG_SET_DEFAULT(UseInlineCaches, false);
D
duke 已提交
119
    }
120 121 122 123
    // Align loops on a single instruction boundary.
    if (FLAG_IS_DEFAULT(OptoLoopAlignment)) {
      FLAG_SET_DEFAULT(OptoLoopAlignment, 4);
    }
124
#ifdef _LP64
125 126 127
    // 32-bit oops don't make sense for the 64-bit VM on sparc
    // since the 32-bit VM has the same registers and smaller objects.
    Universe::set_narrow_oop_shift(LogMinObjAlignmentInBytes);
128
    Universe::set_narrow_klass_shift(LogKlassAlignmentInBytes);
129
#endif // _LP64
D
duke 已提交
130 131 132
#ifdef COMPILER2
    // Indirect branch is the same cost as direct
    if (FLAG_IS_DEFAULT(UseJumpTables)) {
133
      FLAG_SET_DEFAULT(UseJumpTables, true);
D
duke 已提交
134 135 136 137
    }
    // Single-issue, so entry and loop tops are
    // aligned on a single instruction boundary
    if (FLAG_IS_DEFAULT(InteriorEntryAlignment)) {
138
      FLAG_SET_DEFAULT(InteriorEntryAlignment, 4);
D
duke 已提交
139
    }
140
    if (is_niagara_plus()) {
141
      if (has_blk_init() && (cache_line_size > 0) && UseTLAB &&
142
          FLAG_IS_DEFAULT(AllocatePrefetchInstr)) {
143 144 145 146 147 148 149 150 151 152 153
        if (!has_sparc5_instr()) {
          // Use BIS instruction for TLAB allocation prefetch
          // on Niagara plus processors other than those based on CoreS4.
          FLAG_SET_DEFAULT(AllocatePrefetchInstr, 1);
        } else {
          // On CoreS4 processors use prefetch instruction
          // to avoid partial RAW issue, also use prefetch style 3.
          FLAG_SET_DEFAULT(AllocatePrefetchInstr, 0);
          if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
            FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3);
          }
154
        }
155
        if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
156
          // Use smaller prefetch distance with BIS
157 158 159
          FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64);
        }
      }
160 161 162 163 164 165 166 167 168 169
      if (is_T4()) {
        // Double number of prefetched cache lines on T4
        // since L2 cache line size is smaller (32 bytes).
        if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) {
          FLAG_SET_ERGO(intx, AllocatePrefetchLines, AllocatePrefetchLines*2);
        }
        if (FLAG_IS_DEFAULT(AllocateInstancePrefetchLines)) {
          FLAG_SET_ERGO(intx, AllocateInstancePrefetchLines, AllocateInstancePrefetchLines*2);
        }
      }
170 171 172 173
      if (AllocatePrefetchStyle != 3 && FLAG_IS_DEFAULT(AllocatePrefetchDistance)) {
        // Use different prefetch distance without BIS
        FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256);
      }
174
      if (AllocatePrefetchInstr == 1) {
175 176 177 178 179

        // Use allocation prefetch style 3 because BIS instructions
        // require aligned memory addresses.
        FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3);

180 181 182 183 184 185 186 187 188
        // Need a space at the end of TLAB for BIS since it
        // will fault when accessing memory outside of heap.

        // +1 for rounding up to next cache line, +1 to be safe
        int lines = AllocatePrefetchLines + 2;
        int step_size = AllocatePrefetchStepSize;
        int distance = AllocatePrefetchDistance;
        _reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize;
      }
D
duke 已提交
189 190 191 192
    }
#endif
  }

193 194 195
  // Use hardware population count instruction if available.
  if (has_hardware_popc()) {
    if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
196
      FLAG_SET_DEFAULT(UsePopCountInstruction, true);
197
    }
K
kvn 已提交
198 199 200 201 202 203 204 205 206 207 208 209 210
  } else if (UsePopCountInstruction) {
    warning("POPC instruction is not available on this CPU");
    FLAG_SET_DEFAULT(UsePopCountInstruction, false);
  }

  // T4 and newer Sparc cpus have new compare and branch instruction.
  if (has_cbcond()) {
    if (FLAG_IS_DEFAULT(UseCBCond)) {
      FLAG_SET_DEFAULT(UseCBCond, true);
    }
  } else if (UseCBCond) {
    warning("CBCOND instruction is not available on this CPU");
    FLAG_SET_DEFAULT(UseCBCond, false);
211 212
  }

K
kvn 已提交
213
  assert(BlockZeroingLowLimit > 0, "invalid value");
214
  if (has_block_zeroing() && cache_line_size > 0) {
K
kvn 已提交
215 216 217 218 219 220 221 222
    if (FLAG_IS_DEFAULT(UseBlockZeroing)) {
      FLAG_SET_DEFAULT(UseBlockZeroing, true);
    }
  } else if (UseBlockZeroing) {
    warning("BIS zeroing instructions are not available on this CPU");
    FLAG_SET_DEFAULT(UseBlockZeroing, false);
  }

223
  assert(BlockCopyLowLimit > 0, "invalid value");
224
  if (has_block_zeroing() && cache_line_size > 0) { // has_blk_init() && is_T4(): core's local L2 cache
225 226 227 228 229 230 231 232
    if (FLAG_IS_DEFAULT(UseBlockCopy)) {
      FLAG_SET_DEFAULT(UseBlockCopy, true);
    }
  } else if (UseBlockCopy) {
    warning("BIS instructions are not available or expensive on this CPU");
    FLAG_SET_DEFAULT(UseBlockCopy, false);
  }

233
#ifdef COMPILER2
K
kvn 已提交
234 235
  // T4 and newer Sparc cpus have fast RDPC.
  if (has_fast_rdpc() && FLAG_IS_DEFAULT(UseRDPCForConstantTableBase)) {
236
    FLAG_SET_DEFAULT(UseRDPCForConstantTableBase, true);
K
kvn 已提交
237 238
  }

239 240
  // Currently not supported anywhere.
  FLAG_SET_DEFAULT(UseFPUForSpilling, false);
241

242 243
  MaxVectorSize = 8;

244
  assert((InteriorEntryAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
245 246
#endif

247 248 249
  assert((CodeEntryAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");
  assert((OptoLoopAlignment % relocInfo::addr_unit()) == 0, "alignment is not a multiple of NOP size");

D
duke 已提交
250
  char buf[512];
251
  jio_snprintf(buf, sizeof(buf), "%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
K
kvn 已提交
252
               (has_v9() ? ", v9" : (has_v8() ? ", v8" : "")),
253
               (has_hardware_popc() ? ", popc" : ""),
K
kvn 已提交
254 255 256 257 258
               (has_vis1() ? ", vis1" : ""),
               (has_vis2() ? ", vis2" : ""),
               (has_vis3() ? ", vis3" : ""),
               (has_blk_init() ? ", blk_init" : ""),
               (has_cbcond() ? ", cbcond" : ""),
K
kvn 已提交
259
               (has_aes() ? ", aes" : ""),
260 261 262
               (has_sha1() ? ", sha1" : ""),
               (has_sha256() ? ", sha256" : ""),
               (has_sha512() ? ", sha512" : ""),
K
kvn 已提交
263
               (is_ultra3() ? ", ultra3" : ""),
264
               (has_sparc5_instr() ? ", sparc5" : ""),
K
kvn 已提交
265 266 267
               (is_sun4v() ? ", sun4v" : ""),
               (is_niagara_plus() ? ", niagara_plus" : (is_niagara() ? ", niagara" : "")),
               (is_sparc64() ? ", sparc64" : ""),
268 269
               (!has_hardware_mul32() ? ", no-mul32" : ""),
               (!has_hardware_div32() ? ", no-div32" : ""),
D
duke 已提交
270 271 272 273 274
               (!has_hardware_fsmuld() ? ", no-fsmuld" : ""));

  // buf is started with ", " or is empty
  _features_str = strdup(strlen(buf) > 2 ? buf + 2 : buf);

K
kvn 已提交
275 276 277 278 279 280 281 282 283 284 285 286
  // UseVIS is set to the smallest of what hardware supports and what
  // the command line requires.  I.e., you cannot set UseVIS to 3 on
  // older UltraSparc which do not support it.
  if (UseVIS > 3) UseVIS=3;
  if (UseVIS < 0) UseVIS=0;
  if (!has_vis3()) // Drop to 2 if no VIS3 support
    UseVIS = MIN2((intx)2,UseVIS);
  if (!has_vis2()) // Drop to 1 if no VIS2 support
    UseVIS = MIN2((intx)1,UseVIS);
  if (!has_vis1()) // Drop to 0 if no VIS1 support
    UseVIS = 0;

287
  // SPARC T4 and above should have support for AES instructions
K
kvn 已提交
288
  if (has_aes()) {
289 290 291 292 293 294
    if (FLAG_IS_DEFAULT(UseAES)) {
      FLAG_SET_DEFAULT(UseAES, true);
    }
    if (!UseAES) {
      if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) {
        warning("AES intrinsics require UseAES flag to be enabled. Intrinsics will be disabled.");
K
kvn 已提交
295
      }
296
      FLAG_SET_DEFAULT(UseAESIntrinsics, false);
K
kvn 已提交
297
    } else {
298 299 300 301 302 303 304 305 306
      // The AES intrinsic stubs require AES instruction support (of course)
      // but also require VIS3 mode or higher for instructions it use.
      if (UseVIS > 2) {
        if (FLAG_IS_DEFAULT(UseAESIntrinsics)) {
          FLAG_SET_DEFAULT(UseAESIntrinsics, true);
        }
      } else {
        if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) {
          warning("SPARC AES intrinsics require VIS3 instructions. Intrinsics will be disabled.");
K
kvn 已提交
307
        }
308 309
        FLAG_SET_DEFAULT(UseAESIntrinsics, false);
      }
K
kvn 已提交
310 311
    }
  } else if (UseAES || UseAESIntrinsics) {
312 313
    if (UseAES && !FLAG_IS_DEFAULT(UseAES)) {
      warning("AES instructions are not available on this CPU");
K
kvn 已提交
314 315
      FLAG_SET_DEFAULT(UseAES, false);
    }
316 317
    if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) {
      warning("AES intrinsics are not available on this CPU");
K
kvn 已提交
318 319 320 321
      FLAG_SET_DEFAULT(UseAESIntrinsics, false);
    }
  }

322 323 324 325 326 327 328 329 330 331 332
  // GHASH/GCM intrinsics
  if (has_vis3() && (UseVIS > 2)) {
    if (FLAG_IS_DEFAULT(UseGHASHIntrinsics)) {
      UseGHASHIntrinsics = true;
    }
  } else if (UseGHASHIntrinsics) {
    if (!FLAG_IS_DEFAULT(UseGHASHIntrinsics))
      warning("GHASH intrinsics require VIS3 insructions support. Intriniscs will be disabled");
    FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
  }

333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384
  // SHA1, SHA256, and SHA512 instructions were added to SPARC T-series at different times
  if (has_sha1() || has_sha256() || has_sha512()) {
    if (UseVIS > 0) { // SHA intrinsics use VIS1 instructions
      if (FLAG_IS_DEFAULT(UseSHA)) {
        FLAG_SET_DEFAULT(UseSHA, true);
      }
    } else {
      if (UseSHA) {
        warning("SPARC SHA intrinsics require VIS1 instruction support. Intrinsics will be disabled.");
        FLAG_SET_DEFAULT(UseSHA, false);
      }
    }
  } else if (UseSHA) {
    warning("SHA instructions are not available on this CPU");
    FLAG_SET_DEFAULT(UseSHA, false);
  }

  if (!UseSHA) {
    FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
    FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
    FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
  } else {
    if (has_sha1()) {
      if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) {
        FLAG_SET_DEFAULT(UseSHA1Intrinsics, true);
      }
    } else if (UseSHA1Intrinsics) {
      warning("SHA1 instruction is not available on this CPU.");
      FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
    }
    if (has_sha256()) {
      if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) {
        FLAG_SET_DEFAULT(UseSHA256Intrinsics, true);
      }
    } else if (UseSHA256Intrinsics) {
      warning("SHA256 instruction (for SHA-224 and SHA-256) is not available on this CPU.");
      FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
    }

    if (has_sha512()) {
      if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) {
        FLAG_SET_DEFAULT(UseSHA512Intrinsics, true);
      }
    } else if (UseSHA512Intrinsics) {
      warning("SHA512 instruction (for SHA-384 and SHA-512) is not available on this CPU.");
      FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
    }
    if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) {
      FLAG_SET_DEFAULT(UseSHA, false);
    }
  }

385 386 387 388
  if (FLAG_IS_DEFAULT(ContendedPaddingWidth) &&
    (cache_line_size > ContendedPaddingWidth))
    ContendedPaddingWidth = cache_line_size;

D
duke 已提交
389 390
#ifndef PRODUCT
  if (PrintMiscellaneous && Verbose) {
391
    tty->print_cr("L1 data cache line size: %u", L1_data_cache_line_size());
392
    tty->print_cr("L2 data cache line size: %u", L2_data_cache_line_size());
393
    tty->print("Allocation");
D
duke 已提交
394
    if (AllocatePrefetchStyle <= 0) {
395
      tty->print_cr(": no prefetching");
D
duke 已提交
396
    } else {
397 398 399 400 401 402
      tty->print(" prefetching: ");
      if (AllocatePrefetchInstr == 0) {
          tty->print("PREFETCH");
      } else if (AllocatePrefetchInstr == 1) {
          tty->print("BIS");
      }
D
duke 已提交
403
      if (AllocatePrefetchLines > 1) {
404
        tty->print_cr(" at distance %d, %d lines of %d bytes", (int) AllocatePrefetchDistance, (int) AllocatePrefetchLines, (int) AllocatePrefetchStepSize);
D
duke 已提交
405
      } else {
406
        tty->print_cr(" at distance %d, one line of %d bytes", (int) AllocatePrefetchDistance, (int) AllocatePrefetchStepSize);
D
duke 已提交
407 408 409
      }
    }
    if (PrefetchCopyIntervalInBytes > 0) {
410
      tty->print_cr("PrefetchCopyIntervalInBytes %d", (int) PrefetchCopyIntervalInBytes);
D
duke 已提交
411 412
    }
    if (PrefetchScanIntervalInBytes > 0) {
413
      tty->print_cr("PrefetchScanIntervalInBytes %d", (int) PrefetchScanIntervalInBytes);
D
duke 已提交
414 415
    }
    if (PrefetchFieldsAhead > 0) {
416
      tty->print_cr("PrefetchFieldsAhead %d", (int) PrefetchFieldsAhead);
D
duke 已提交
417
    }
418
    if (ContendedPaddingWidth > 0) {
419
      tty->print_cr("ContendedPaddingWidth %d", (int) ContendedPaddingWidth);
420
    }
D
duke 已提交
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441
  }
#endif // PRODUCT
}

void VM_Version::print_features() {
  tty->print_cr("Version:%s", cpu_features());
}

int VM_Version::determine_features() {
  if (UseV8InstrsOnly) {
    NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-V8");)
    return generic_v8_m;
  }

  int features = platform_features(unknown_m); // platform_features() is os_arch specific

  if (features == unknown_m) {
    features = generic_v9_m;
    warning("Cannot recognize SPARC version. Default to V9");
  }

442 443 444
  assert(is_T_family(features) == is_niagara(features), "Niagara should be T series");
  if (UseNiagaraInstrs) { // Force code generation for Niagara
    if (is_T_family(features)) {
D
duke 已提交
445 446 447
      // Happy to accomodate...
    } else {
      NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Niagara");)
448
      features |= T_family_m;
D
duke 已提交
449 450
    }
  } else {
451
    if (is_T_family(features) && !FLAG_IS_DEFAULT(UseNiagaraInstrs)) {
D
duke 已提交
452
      NOT_PRODUCT(if (PrintMiscellaneous && Verbose) tty->print_cr("Version is Forced-Not-Niagara");)
453
      features &= ~(T_family_m | T1_model_m);
D
duke 已提交
454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
    } else {
      // Happy to accomodate...
    }
  }

  return features;
}

static int saved_features = 0;

void VM_Version::allow_all() {
  saved_features = _features;
  _features      = all_features_m;
}

void VM_Version::revert() {
  _features = saved_features;
}
472 473 474

unsigned int VM_Version::calc_parallel_worker_threads() {
  unsigned int result;
475 476 477 478
  if (is_M_series() || is_S_series()) {
    // for now, use same gc thread calculation for M-series and S-series as for
    // niagara-plus. In future, we may want to tweak parameters for
    // nof_parallel_worker_thread
479 480
    result = nof_parallel_worker_threads(5, 16, 8);
  } else if (is_niagara_plus()) {
481 482 483 484 485 486
    result = nof_parallel_worker_threads(5, 16, 8);
  } else {
    result = nof_parallel_worker_threads(5, 8, 8);
  }
  return result;
}
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501


int VM_Version::parse_features(const char* implementation) {
  int features = unknown_m;
  // Convert to UPPER case before compare.
  char* impl = os::strdup(implementation);

  for (int i = 0; impl[i] != 0; i++)
    impl[i] = (char)toupper((uint)impl[i]);

  if (strstr(impl, "SPARC64") != NULL) {
    features |= sparc64_family_m;
  } else if (strstr(impl, "SPARC-M") != NULL) {
    // M-series SPARC is based on T-series.
    features |= (M_family_m | T_family_m);
502 503 504
  } else if (strstr(impl, "SPARC-S") != NULL) {
    // S-series SPARC is based on T-series.
    features |= (S_family_m | T_family_m);
505 506 507 508 509
  } else if (strstr(impl, "SPARC-T") != NULL) {
    features |= T_family_m;
    if (strstr(impl, "SPARC-T1") != NULL) {
      features |= T1_model_m;
    }
510 511 512
  } else if (strstr(impl, "SUN4V-CPU") != NULL) {
    // Generic or migration class LDOM
    features |= T_family_m;
513 514
  } else {
#ifndef PRODUCT
515
    warning("Failed to parse CPU implementation = '%s'", impl);
516 517 518 519 520
#endif
  }
  os::free((void*)impl);
  return features;
}