hotspot/src/cpu/ppc/vm/vm_version_ppc.cpp
author stefank
Tue, 04 Jul 2017 15:58:10 +0200
changeset 46619 a3919f5e8d2b
parent 46618 d503911aa948
child 46625 edefffab74e2
permissions -rw-r--r--
8178499: Remove _ptr_ and _size_ infixes from align functions Reviewed-by: rehn, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
     2
 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
     3
 * Copyright (c) 2012, 2017, SAP SE. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
    27
#include "asm/assembler.inline.hpp"
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
    28
#include "asm/macroAssembler.inline.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "compiler/disassembler.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
#include "memory/resourceArea.hpp"
46560
388aa8d67c80 8181449: Fix debug.hpp / globalDefinitions.hpp dependency inversion
kbarrett
parents: 46521
diff changeset
    31
#include "prims/jvm.h"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
#include "runtime/java.hpp"
25949
34557722059b 6424123: JVM crashes on failed 'strdup' call
zgu
parents: 25468
diff changeset
    33
#include "runtime/os.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    34
#include "runtime/stubCodeGenerator.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
#include "utilities/defaultStream.hpp"
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    36
#include "utilities/globalDefinitions.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
#include "vm_version_ppc.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    38
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    39
# include <sys/sysinfo.h>
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    40
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    41
bool VM_Version::_is_determine_features_test_running = false;
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
    42
uint64_t VM_Version::_dscr_val = 0;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    43
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    44
#define MSG(flag)   \
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    45
  if (flag && !FLAG_IS_DEFAULT(flag))                                  \
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    46
      jio_fprintf(defaultStream::error_stream(),                       \
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    47
                  "warning: -XX:+" #flag " requires -XX:+UseSIGTRAP\n" \
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    48
                  "         -XX:+" #flag " will be disabled!\n");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    49
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    50
void VM_Version::initialize() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    51
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    52
  // Test which instructions are supported and measure cache line size.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    53
  determine_features();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    54
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    55
  // If PowerArchitecturePPC64 hasn't been specified explicitly determine from features.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    56
  if (FLAG_IS_DEFAULT(PowerArchitecturePPC64)) {
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
    57
    if (VM_Version::has_lqarx()) {
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    58
      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 8);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    59
    } else if (VM_Version::has_popcntw()) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    60
      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 7);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    61
    } else if (VM_Version::has_cmpb()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    62
      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 6);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    63
    } else if (VM_Version::has_popcntb()) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    64
      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 5);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    65
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    66
      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    67
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    68
  }
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    69
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    70
  bool PowerArchitecturePPC64_ok = false;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    71
  switch (PowerArchitecturePPC64) {
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
    72
    case 8: if (!VM_Version::has_lqarx()  ) break;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    73
    case 7: if (!VM_Version::has_popcntw()) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    74
    case 6: if (!VM_Version::has_cmpb()   ) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    75
    case 5: if (!VM_Version::has_popcntb()) break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    76
    case 0: PowerArchitecturePPC64_ok = true; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    77
    default: break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    78
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    79
  guarantee(PowerArchitecturePPC64_ok, "PowerArchitecturePPC64 cannot be set to "
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
    80
            UINTX_FORMAT " on this machine", PowerArchitecturePPC64);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    81
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    82
  // Power 8: Configure Data Stream Control Register.
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
    83
  if (has_mfdscr()) {
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    84
    config_dscr();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
    85
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    86
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    87
  if (!UseSIGTRAP) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    88
    MSG(TrapBasedICMissChecks);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    89
    MSG(TrapBasedNotEntrantChecks);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    90
    MSG(TrapBasedNullChecks);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    91
    FLAG_SET_ERGO(bool, TrapBasedNotEntrantChecks, false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    92
    FLAG_SET_ERGO(bool, TrapBasedNullChecks,       false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    93
    FLAG_SET_ERGO(bool, TrapBasedICMissChecks,     false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    94
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    95
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    96
#ifdef COMPILER2
22856
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
    97
  if (!UseSIGTRAP) {
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
    98
    MSG(TrapBasedRangeChecks);
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
    99
    FLAG_SET_ERGO(bool, TrapBasedRangeChecks, false);
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
   100
  }
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
   101
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   102
  // On Power6 test for section size.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   103
  if (PowerArchitecturePPC64 == 6) {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   104
    determine_section_size();
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   105
  // TODO: PPC port } else {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   106
  // TODO: PPC port PdScheduling::power6SectorSize = 0x20;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   107
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   108
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   109
  MaxVectorSize = 8;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   110
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   111
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   112
  // Create and print feature-string.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   113
  char buf[(num_features+1) * 16]; // Max 16 chars per feature.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   114
  jio_snprintf(buf, sizeof(buf),
46521
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   115
               "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   116
               (has_fsqrt()   ? " fsqrt"   : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   117
               (has_isel()    ? " isel"    : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   118
               (has_lxarxeh() ? " lxarxeh" : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   119
               (has_cmpb()    ? " cmpb"    : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   120
               //(has_mftgpr()? " mftgpr"  : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   121
               (has_popcntb() ? " popcntb" : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   122
               (has_popcntw() ? " popcntw" : ""),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   123
               (has_fcfids()  ? " fcfids"  : ""),
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   124
               (has_vand()    ? " vand"    : ""),
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   125
               (has_lqarx()   ? " lqarx"   : ""),
37275
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   126
               (has_vcipher() ? " aes"     : ""),
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   127
               (has_vpmsumb() ? " vpmsumb" : ""),
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
   128
               (has_tcheck()  ? " tcheck"  : ""),
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   129
               (has_mfdscr()  ? " mfdscr"  : ""),
46521
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   130
               (has_vsx()     ? " vsx"     : ""),
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   131
               (has_ldbrx()   ? " ldbrx"   : ""),
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   132
               (has_stdbrx()  ? " stdbrx"  : "")
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   133
               // Make sure number of %s matches num_features!
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   134
              );
35148
5cfafc99d791 8143072: [JVMCI] Port JVMCI to AArch64
twisti
parents: 35135
diff changeset
   135
  _features_string = os::strdup(buf);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   136
  if (Verbose) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   137
    print_features();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   138
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   139
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   140
  // PPC64 supports 8-byte compare-exchange operations (see
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   141
  // Atomic::cmpxchg and StubGenerator::generate_atomic_cmpxchg_ptr)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   142
  // and 'atomic long memory ops' (see Unsafe_GetLongVolatile).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   143
  _supports_cx8 = true;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   144
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   145
  // Used by C1.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   146
  _supports_atomic_getset4 = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   147
  _supports_atomic_getadd4 = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   148
  _supports_atomic_getset8 = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   149
  _supports_atomic_getadd8 = true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   150
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   151
  UseSSE = 0; // Only on x86 and x64
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   152
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   153
  intx cache_line_size = L1_data_cache_line_size();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   154
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   155
  if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) AllocatePrefetchStyle = 1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   156
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   157
  if (AllocatePrefetchStyle == 4) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   158
    AllocatePrefetchStepSize = cache_line_size; // Need exact value.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   159
    if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) AllocatePrefetchLines = 12; // Use larger blocks by default.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   160
    if (AllocatePrefetchDistance < 0) AllocatePrefetchDistance = 2*cache_line_size; // Default is not defined?
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   162
    if (cache_line_size > AllocatePrefetchStepSize) AllocatePrefetchStepSize = cache_line_size;
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   163
    if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) AllocatePrefetchLines = 3; // Optimistic value.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   164
    if (AllocatePrefetchDistance < 0) AllocatePrefetchDistance = 3*cache_line_size; // Default is not defined?
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   166
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   167
  assert(AllocatePrefetchLines > 0, "invalid value");
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   168
  if (AllocatePrefetchLines < 1) { // Set valid value in product VM.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   169
    AllocatePrefetchLines = 1; // Conservative value.
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   170
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   171
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   172
  if (AllocatePrefetchStyle == 3 && AllocatePrefetchDistance < cache_line_size) {
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   173
    AllocatePrefetchStyle = 1; // Fall back if inappropriate.
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   174
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   175
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   176
  assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive");
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   177
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   178
  // If defined(VM_LITTLE_ENDIAN) and running on Power8 or newer hardware,
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   179
  // the implementation uses the vector instructions available with Power8.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   180
  // In all other cases, the implementation uses only generally available instructions.
31861
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
   181
  if (!UseCRC32Intrinsics) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
   182
    if (FLAG_IS_DEFAULT(UseCRC32Intrinsics)) {
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
   183
      FLAG_SET_DEFAULT(UseCRC32Intrinsics, true);
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
   184
    }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
   185
  }
7efea6fae96b 8131048: ppc: implement CRC32 intrinsic
goetz
parents: 31773
diff changeset
   186
46317
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   187
  // Implementation does not use any of the vector instructions available with Power8.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   188
  // Their exploitation is still pending (aka "work in progress").
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   189
  if (!UseCRC32CIntrinsics) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   190
    if (FLAG_IS_DEFAULT(UseCRC32CIntrinsics)) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   191
      FLAG_SET_DEFAULT(UseCRC32CIntrinsics, true);
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   192
    }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   193
  }
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   194
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   195
  // TODO: Provide implementation.
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   196
  if (UseAdler32Intrinsics) {
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   197
    warning("Adler32Intrinsics not available on this CPU.");
5f88747fe29e 8175369: [ppc] Provide intrinsic implementation for CRC32C
lucy
parents: 43428
diff changeset
   198
    FLAG_SET_DEFAULT(UseAdler32Intrinsics, false);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   199
  }
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   200
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   201
  // The AES intrinsic stubs require AES instruction support.
37275
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   202
#if defined(VM_LITTLE_ENDIAN)
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   203
  if (has_vcipher()) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   204
    if (FLAG_IS_DEFAULT(UseAES)) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   205
      UseAES = true;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   206
    }
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   207
  } else if (UseAES) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   208
    if (!FLAG_IS_DEFAULT(UseAES))
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   209
      warning("AES instructions are not available on this CPU");
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   210
    FLAG_SET_DEFAULT(UseAES, false);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   211
  }
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   212
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   213
  if (UseAES && has_vcipher()) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   214
    if (FLAG_IS_DEFAULT(UseAESIntrinsics)) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   215
      UseAESIntrinsics = true;
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   216
    }
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   217
  } else if (UseAESIntrinsics) {
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   218
    if (!FLAG_IS_DEFAULT(UseAESIntrinsics))
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   219
      warning("AES intrinsics are not available on this CPU");
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   220
    FLAG_SET_DEFAULT(UseAESIntrinsics, false);
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   221
  }
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   222
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   223
#else
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   224
  if (UseAES) {
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   225
    warning("AES instructions are not available on this CPU");
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   226
    FLAG_SET_DEFAULT(UseAES, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   227
  }
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   228
  if (UseAESIntrinsics) {
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   229
    if (!FLAG_IS_DEFAULT(UseAESIntrinsics))
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   230
      warning("AES intrinsics are not available on this CPU");
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   231
    FLAG_SET_DEFAULT(UseAESIntrinsics, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   232
  }
37275
a8858401c5f9 8152172: PPC64: Support AES intrinsics
mdoerr
parents: 36560
diff changeset
   233
#endif
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   234
35154
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35148
diff changeset
   235
  if (UseAESCTRIntrinsics) {
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35148
diff changeset
   236
    warning("AES/CTR intrinsics are not available on this CPU");
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35148
diff changeset
   237
    FLAG_SET_DEFAULT(UseAESCTRIntrinsics, false);
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35148
diff changeset
   238
  }
a9b3c1984a01 8143925: Enhancing CounterMode.crypt() for AES
kvn
parents: 35148
diff changeset
   239
31404
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 30587
diff changeset
   240
  if (UseGHASHIntrinsics) {
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 30587
diff changeset
   241
    warning("GHASH intrinsics are not available on this CPU");
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 30587
diff changeset
   242
    FLAG_SET_DEFAULT(UseGHASHIntrinsics, false);
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 30587
diff changeset
   243
  }
63e8fcd70bfc 8073108: Use x86 and SPARC CPU instructions for GHASH acceleration
ascarpino
parents: 30587
diff changeset
   244
42884
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42034
diff changeset
   245
  if (FLAG_IS_DEFAULT(UseFMA)) {
05815125c157 8171244: PPC64: Make interpreter's math entries consistent with C1 and C2 and support FMA
mdoerr
parents: 42034
diff changeset
   246
    FLAG_SET_DEFAULT(UseFMA, true);
41323
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 41321
diff changeset
   247
  }
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 41321
diff changeset
   248
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   249
  if (UseSHA) {
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   250
    warning("SHA instructions are not available on this CPU");
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   251
    FLAG_SET_DEFAULT(UseSHA, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   252
  }
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   253
  if (UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics) {
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   254
    warning("SHA intrinsics are not available on this CPU");
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   255
    FLAG_SET_DEFAULT(UseSHA1Intrinsics, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   256
    FLAG_SET_DEFAULT(UseSHA256Intrinsics, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   257
    FLAG_SET_DEFAULT(UseSHA512Intrinsics, false);
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   258
  }
31515
6aed85dadbe6 8073583: C2 support for CRC32C on SPARC
kvn
parents: 31412
diff changeset
   259
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 31515
diff changeset
   260
  if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 31515
diff changeset
   261
    UseMultiplyToLenIntrinsic = true;
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 31515
diff changeset
   262
  }
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   263
  if (FLAG_IS_DEFAULT(UseMontgomeryMultiplyIntrinsic)) {
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   264
    UseMontgomeryMultiplyIntrinsic = true;
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   265
  }
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   266
  if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   267
    UseMontgomerySquareIntrinsic = true;
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   268
  }
31773
f874931cbae7 8130653: ppc: implement MultiplyToLen intrinsic
goetz
parents: 31515
diff changeset
   269
35110
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 35085
diff changeset
   270
  if (UseVectorizedMismatchIntrinsic) {
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 35085
diff changeset
   271
    warning("UseVectorizedMismatchIntrinsic specified, but not available on this CPU.");
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 35085
diff changeset
   272
    FLAG_SET_DEFAULT(UseVectorizedMismatchIntrinsic, false);
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 35085
diff changeset
   273
  }
f19bcdf40799 8143355: Update for addition of vectorizedMismatch intrinsic for x86
kvn
parents: 35085
diff changeset
   274
35156
a06b3d7455d6 8145913: PPC64: add Montgomery multiply intrinsic
mdoerr
parents: 35154
diff changeset
   275
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   276
  // Adjust RTM (Restricted Transactional Memory) flags.
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   277
  if (UseRTMLocking) {
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   278
    // If CPU or OS are too old:
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   279
    // Can't continue because UseRTMLocking affects UseBiasedLocking flag
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   280
    // setting during arguments processing. See use_biased_locking().
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   281
    // VM_Version_init() is executed after UseBiasedLocking is used
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   282
    // in Thread::allocate().
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   283
    if (!has_tcheck()) {
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   284
      vm_exit_during_initialization("RTM instructions are not available on this CPU");
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   285
    }
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   286
    bool os_too_old = true;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   287
#ifdef AIX
41321
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   288
    // Actually, this is supported since AIX 7.1.. Unfortunately, this first
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   289
    // contained bugs, so that it can only be enabled after AIX 7.1.3.30.
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   290
    // The Java property os.version, which is used in RTM tests to decide
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   291
    // whether the feature is available, only knows major and minor versions.
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   292
    // We don't want to change this property, as user code might depend on it.
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   293
    // So the tests can not check on subversion 3.30, and we only enable RTM
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   294
    // with AIX 7.2.
463ff7705f2f 8165235: [TESTBUG] RTM tests must check OS version
goetz
parents: 40010
diff changeset
   295
    if (os::Aix::os_version() >= 0x07020000) { // At least AIX 7.2.
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   296
      os_too_old = false;
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   297
    }
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   298
#endif
40010
e32d5e545789 8161258: Simplify including platform files.
goetz
parents: 39236
diff changeset
   299
#ifdef LINUX
36560
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   300
    // At least Linux kernel 4.2, as the problematic behavior of syscalls
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   301
    // being called in the middle of a transaction has been addressed.
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   302
    // Please, refer to commit b4b56f9ecab40f3b4ef53e130c9f6663be491894
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   303
    // in Linux kernel source tree: https://goo.gl/Kc5i7A
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   304
    if (os::Linux::os_version_is_known()) {
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   305
      if (os::Linux::os_version() >= 0x040200)
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   306
        os_too_old = false;
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   307
    } else {
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   308
      vm_exit_during_initialization("RTM can not be enabled: kernel version is unknown.");
59ca2b7f6162 8150353: PPC64LE: Support RTM on linux
kvn
parents: 36303
diff changeset
   309
    }
35063
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   310
#endif
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   311
    if (os_too_old) {
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   312
      vm_exit_during_initialization("RTM is not supported on this OS version.");
cb24277be2e7 8144847: PPC64: Update Transactional Memory and Atomic::cmpxchg code
mdoerr
parents: 32581
diff changeset
   313
    }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   314
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   315
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   316
  if (UseRTMLocking) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   317
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   318
    if (!UnlockExperimentalVMOptions) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   319
      vm_exit_during_initialization("UseRTMLocking is only available as experimental option on this platform. "
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   320
                                    "It must be enabled via -XX:+UnlockExperimentalVMOptions flag.");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   321
    } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   322
      warning("UseRTMLocking is only available as experimental option on this platform.");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   323
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   324
    if (!FLAG_IS_CMDLINE(UseRTMLocking)) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   325
      // RTM locking should be used only for applications with
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   326
      // high lock contention. For now we do not use it by default.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   327
      vm_exit_during_initialization("UseRTMLocking flag should be only set on command line");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   328
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   329
    if (!is_power_of_2(RTMTotalCountIncrRate)) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   330
      warning("RTMTotalCountIncrRate must be a power of 2, resetting it to 64");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   331
      FLAG_SET_DEFAULT(RTMTotalCountIncrRate, 64);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   332
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   333
    if (RTMAbortRatio < 0 || RTMAbortRatio > 100) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   334
      warning("RTMAbortRatio must be in the range 0 to 100, resetting it to 50");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   335
      FLAG_SET_DEFAULT(RTMAbortRatio, 50);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   336
    }
43428
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42884
diff changeset
   337
    if (RTMSpinLoopCount < 0) {
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42884
diff changeset
   338
      warning("RTMSpinLoopCount must not be a negative value, resetting it to 0");
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42884
diff changeset
   339
      FLAG_SET_DEFAULT(RTMSpinLoopCount, 0);
3dccc891c216 8171266: PPC64: Add support to -XX:RTMSpinLoopCount=0
gromero
parents: 42884
diff changeset
   340
    }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   341
#else
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   342
    // Only C2 does RTM locking optimization.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   343
    // Can't continue because UseRTMLocking affects UseBiasedLocking flag
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   344
    // setting during arguments processing. See use_biased_locking().
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   345
    vm_exit_during_initialization("RTM locking optimization is not supported in this VM");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   346
#endif
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   347
  } else { // !UseRTMLocking
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   348
    if (UseRTMForStackLocks) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   349
      if (!FLAG_IS_DEFAULT(UseRTMForStackLocks)) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   350
        warning("UseRTMForStackLocks flag should be off when UseRTMLocking flag is off");
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   351
      }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   352
      FLAG_SET_DEFAULT(UseRTMForStackLocks, false);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   353
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   354
    if (UseRTMDeopt) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   355
      FLAG_SET_DEFAULT(UseRTMDeopt, false);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   356
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   357
    if (PrintPreciseRTMLockingStatistics) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   358
      FLAG_SET_DEFAULT(PrintPreciseRTMLockingStatistics, false);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   359
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   360
  }
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 25949
diff changeset
   361
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   362
  // This machine allows unaligned memory accesses
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   363
  if (FLAG_IS_DEFAULT(UseUnalignedAccesses)) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   364
    FLAG_SET_DEFAULT(UseUnalignedAccesses, true);
30209
8ea30dc99369 8026049: (bf) Intrinsify ByteBuffer.put{Int, Double, Float, ...} methods
aph
parents: 28187
diff changeset
   365
  }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   366
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   367
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   368
bool VM_Version::use_biased_locking() {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   369
#if INCLUDE_RTM_OPT
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   370
  // RTM locking is most useful when there is high lock contention and
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   371
  // low data contention. With high lock contention the lock is usually
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   372
  // inflated and biased locking is not suitable for that case.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   373
  // RTM locking code requires that biased locking is off.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   374
  // Note: we can't switch off UseBiasedLocking in get_processor_features()
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   375
  // because it is used by Thread::allocate() which is called before
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   376
  // VM_Version::initialize().
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   377
  if (UseRTMLocking && UseBiasedLocking) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   378
    if (FLAG_IS_DEFAULT(UseBiasedLocking)) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   379
      FLAG_SET_DEFAULT(UseBiasedLocking, false);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   380
    } else {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   381
      warning("Biased locking is not supported with RTM locking; ignoring UseBiasedLocking flag." );
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   382
      UseBiasedLocking = false;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   383
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   384
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   385
#endif
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   386
  return UseBiasedLocking;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   387
}
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   388
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   389
void VM_Version::print_features() {
35148
5cfafc99d791 8143072: [JVMCI] Port JVMCI to AArch64
twisti
parents: 35135
diff changeset
   390
  tty->print_cr("Version: %s L1_data_cache_line_size=%d", features_string(), L1_data_cache_line_size());
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   391
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   392
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   393
#ifdef COMPILER2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   394
// Determine section size on power6: If section size is 8 instructions,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   395
// there should be a difference between the two testloops of ~15 %. If
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   396
// no difference is detected the section is assumed to be 32 instructions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   397
void VM_Version::determine_section_size() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   398
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   399
  int unroll = 80;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   400
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   401
  const int code_size = (2* unroll * 32 + 100)*BytesPerInstWord;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   402
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   403
  // Allocate space for the code.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   404
  ResourceMark rm;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   405
  CodeBuffer cb("detect_section_size", code_size, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   406
  MacroAssembler* a = new MacroAssembler(&cb);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   407
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   408
  uint32_t *code = (uint32_t *)a->pc();
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   409
  // Emit code.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   410
  void (*test1)() = (void(*)())(void *)a->function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   411
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   412
  Label l1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   413
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   414
  a->li(R4, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   415
  a->sldi(R4, R4, 28);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   416
  a->b(l1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   417
  a->align(CodeEntryAlignment);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   418
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   419
  a->bind(l1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   420
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   421
  for (int i = 0; i < unroll; i++) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   422
    // Schleife 1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   423
    // ------- sector 0 ------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   424
    // ;; 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   425
    a->nop();                   // 1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   426
    a->fpnop0();                // 2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   427
    a->fpnop1();                // 3
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   428
    a->addi(R4,R4, -1); // 4
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   429
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   430
    // ;;  1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   431
    a->nop();                   // 5
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   432
    a->fmr(F6, F6);             // 6
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   433
    a->fmr(F7, F7);             // 7
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   434
    a->endgroup();              // 8
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   435
    // ------- sector 8 ------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   436
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   437
    // ;;  2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   438
    a->nop();                   // 9
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   439
    a->nop();                   // 10
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   440
    a->fmr(F8, F8);             // 11
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   441
    a->fmr(F9, F9);             // 12
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   442
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   443
    // ;;  3
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   444
    a->nop();                   // 13
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   445
    a->fmr(F10, F10);           // 14
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   446
    a->fmr(F11, F11);           // 15
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   447
    a->endgroup();              // 16
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   448
    // -------- sector 16 -------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   449
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   450
    // ;;  4
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   451
    a->nop();                   // 17
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   452
    a->nop();                   // 18
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   453
    a->fmr(F15, F15);           // 19
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   454
    a->fmr(F16, F16);           // 20
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   455
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   456
    // ;;  5
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   457
    a->nop();                   // 21
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   458
    a->fmr(F17, F17);           // 22
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   459
    a->fmr(F18, F18);           // 23
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   460
    a->endgroup();              // 24
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   461
    // ------- sector 24  ------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   462
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   463
    // ;;  6
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   464
    a->nop();                   // 25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   465
    a->nop();                   // 26
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   466
    a->fmr(F19, F19);           // 27
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   467
    a->fmr(F20, F20);           // 28
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   468
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   469
    // ;;  7
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   470
    a->nop();                   // 29
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   471
    a->fmr(F21, F21);           // 30
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   472
    a->fmr(F22, F22);           // 31
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   473
    a->brnop0();                // 32
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   474
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   475
    // ------- sector 32 ------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   476
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   477
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   478
  // ;; 8
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   479
  a->cmpdi(CCR0, R4, unroll);   // 33
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   480
  a->bge(CCR0, l1);             // 34
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   481
  a->blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   482
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   483
  // Emit code.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   484
  void (*test2)() = (void(*)())(void *)a->function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   485
  // uint32_t *code = (uint32_t *)a->pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   486
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   487
  Label l2;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   488
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   489
  a->li(R4, 1);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   490
  a->sldi(R4, R4, 28);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   491
  a->b(l2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   492
  a->align(CodeEntryAlignment);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   493
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   494
  a->bind(l2);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   495
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   496
  for (int i = 0; i < unroll; i++) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   497
    // Schleife 2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   498
    // ------- sector 0 ------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   499
    // ;; 0
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   500
    a->brnop0();                  // 1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   501
    a->nop();                     // 2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   502
    //a->cmpdi(CCR0, R4, unroll);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   503
    a->fpnop0();                  // 3
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   504
    a->fpnop1();                  // 4
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   505
    a->addi(R4,R4, -1);           // 5
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   506
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   507
    // ;; 1
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   508
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   509
    a->nop();                     // 6
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   510
    a->fmr(F6, F6);               // 7
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   511
    a->fmr(F7, F7);               // 8
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   512
    // ------- sector 8 ---------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   513
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   514
    // ;; 2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   515
    a->endgroup();                // 9
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   516
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   517
    // ;; 3
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   518
    a->nop();                     // 10
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   519
    a->nop();                     // 11
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   520
    a->fmr(F8, F8);               // 12
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   521
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   522
    // ;; 4
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   523
    a->fmr(F9, F9);               // 13
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   524
    a->nop();                     // 14
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   525
    a->fmr(F10, F10);             // 15
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   526
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   527
    // ;; 5
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   528
    a->fmr(F11, F11);             // 16
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   529
    // -------- sector 16 -------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   530
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   531
    // ;; 6
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   532
    a->endgroup();                // 17
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   533
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   534
    // ;; 7
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   535
    a->nop();                     // 18
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   536
    a->nop();                     // 19
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   537
    a->fmr(F15, F15);             // 20
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   538
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   539
    // ;; 8
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   540
    a->fmr(F16, F16);             // 21
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   541
    a->nop();                     // 22
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   542
    a->fmr(F17, F17);             // 23
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   543
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   544
    // ;; 9
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   545
    a->fmr(F18, F18);             // 24
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   546
    // -------- sector 24 -------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   547
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   548
    // ;; 10
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   549
    a->endgroup();                // 25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   550
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   551
    // ;; 11
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   552
    a->nop();                     // 26
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   553
    a->nop();                     // 27
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   554
    a->fmr(F19, F19);             // 28
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   555
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   556
    // ;; 12
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   557
    a->fmr(F20, F20);             // 29
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   558
    a->nop();                     // 30
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   559
    a->fmr(F21, F21);             // 31
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   560
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   561
    // ;; 13
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   562
    a->fmr(F22, F22);             // 32
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   563
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   564
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   565
  // -------- sector 32 -------------
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   566
  // ;; 14
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   567
  a->cmpdi(CCR0, R4, unroll); // 33
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   568
  a->bge(CCR0, l2);           // 34
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   569
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   570
  a->blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   571
  uint32_t *code_end = (uint32_t *)a->pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   572
  a->flush();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   573
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   574
  double loop1_seconds,loop2_seconds, rel_diff;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   575
  uint64_t start1, stop1;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   576
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   577
  start1 = os::current_thread_cpu_time(false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   578
  (*test1)();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   579
  stop1 = os::current_thread_cpu_time(false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   580
  loop1_seconds = (stop1- start1) / (1000 *1000 *1000.0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   581
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   582
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   583
  start1 = os::current_thread_cpu_time(false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   584
  (*test2)();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   585
  stop1 = os::current_thread_cpu_time(false);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   586
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   587
  loop2_seconds = (stop1 - start1) / (1000 *1000 *1000.0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   588
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   589
  rel_diff = (loop2_seconds - loop1_seconds) / loop1_seconds *100;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   590
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   591
  if (PrintAssembly) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   592
    ttyLocker ttyl;
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 24424
diff changeset
   593
    tty->print_cr("Decoding section size detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   594
    Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   595
    tty->print_cr("Time loop1 :%f", loop1_seconds);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   596
    tty->print_cr("Time loop2 :%f", loop2_seconds);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   597
    tty->print_cr("(time2 - time1) / time1 = %f %%", rel_diff);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   598
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   599
    if (rel_diff > 12.0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   600
      tty->print_cr("Section Size 8 Instructions");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   601
    } else{
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   602
      tty->print_cr("Section Size 32 Instructions or Power5");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   603
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   604
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   605
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   606
#if 0 // TODO: PPC port
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   607
  // Set sector size (if not set explicitly).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   608
  if (FLAG_IS_DEFAULT(Power6SectorSize128PPC64)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   609
    if (rel_diff > 12.0) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   610
      PdScheduling::power6SectorSize = 0x20;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   611
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   612
      PdScheduling::power6SectorSize = 0x80;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   613
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   614
  } else if (Power6SectorSize128PPC64) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   615
    PdScheduling::power6SectorSize = 0x80;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   616
  } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   617
    PdScheduling::power6SectorSize = 0x20;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   618
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   619
#endif
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   620
  if (UsePower6SchedulerPPC64) Unimplemented();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   621
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   622
#endif // COMPILER2
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   623
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   624
void VM_Version::determine_features() {
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   625
#if defined(ABI_ELFv2)
31333
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   626
  // 1 InstWord per call for the blr instruction.
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   627
  const int code_size = (num_features+1+2*1)*BytesPerInstWord;
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   628
#else
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   629
  // 7 InstWords for each call (function descriptor + blr instruction).
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   630
  const int code_size = (num_features+1+2*7)*BytesPerInstWord;
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   631
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   632
  int features = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   633
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   634
  // create test area
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   635
  enum { BUFFER_SIZE = 2*4*K }; // Needs to be >=2* max cache line size (cache line size can't exceed min page size).
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   636
  char test_area[BUFFER_SIZE];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   637
  char *mid_of_test_area = &test_area[BUFFER_SIZE>>1];
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   638
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   639
  // Allocate space for the code.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   640
  ResourceMark rm;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   641
  CodeBuffer cb("detect_cpu_features", code_size, 0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   642
  MacroAssembler* a = new MacroAssembler(&cb);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   643
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23211
diff changeset
   644
  // Must be set to true so we can generate the test code.
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23211
diff changeset
   645
  _features = VM_Version::all_features_m;
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23211
diff changeset
   646
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   647
  // Emit code.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   648
  void (*test)(address addr, uint64_t offset)=(void(*)(address addr, uint64_t offset))(void *)a->function_entry();
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   649
  uint32_t *code = (uint32_t *)a->pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   650
  // Don't use R0 in ldarx.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   651
  // Keep R3_ARG1 unmodified, it contains &field (see below).
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   652
  // Keep R4_ARG2 unmodified, it contains offset = 0 (see below).
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   653
  a->fsqrt(F3, F4);                            // code[0]  -> fsqrt_m
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   654
  a->fsqrts(F3, F4);                           // code[1]  -> fsqrts_m
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   655
  a->isel(R7, R5, R6, 0);                      // code[2]  -> isel_m
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   656
  a->ldarx_unchecked(R7, R3_ARG1, R4_ARG2, 1); // code[3]  -> lxarx_m
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   657
  a->cmpb(R7, R5, R6);                         // code[4]  -> cmpb
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   658
  a->popcntb(R7, R5);                          // code[5]  -> popcntb
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   659
  a->popcntw(R7, R5);                          // code[6]  -> popcntw
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   660
  a->fcfids(F3, F4);                           // code[7]  -> fcfids
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   661
  a->vand(VR0, VR0, VR0);                      // code[8]  -> vand
31333
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   662
  // arg0 of lqarx must be an even register, (arg1 + arg2) must be a multiple of 16
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   663
  a->lqarx_unchecked(R6, R3_ARG1, R4_ARG2, 1); // code[9]  -> lqarx_m
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   664
  a->vcipher(VR0, VR1, VR2);                   // code[10] -> vcipher
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   665
  a->vpmsumb(VR0, VR1, VR2);                   // code[11] -> vpmsumb
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   666
  a->tcheck(0);                                // code[12] -> tcheck
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
   667
  a->mfdscr(R0);                               // code[13] -> mfdscr
42034
f1e6a21095f5 8166684: PPC64: implement intrinsic code with vector instructions for Unsafe.copyMemory()
mdoerr
parents: 41323
diff changeset
   668
  a->lxvd2x(VSR0, R3_ARG1);                    // code[14] -> vsx
46521
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   669
  a->ldbrx(R7, R3_ARG1, R4_ARG2);              // code[15] -> ldbrx
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   670
  a->stdbrx(R7, R3_ARG1, R4_ARG2);             // code[16] -> stdbrx
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   671
  a->blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   672
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   673
  // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
23211
954e3a81da29 8035647: PPC64: Support for elf v2 abi.
goetz
parents: 22861
diff changeset
   674
  void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry();
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   675
  a->dcbz(R3_ARG1); // R3_ARG1 = addr
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   676
  a->blr();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   677
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   678
  uint32_t *code_end = (uint32_t *)a->pc();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   679
  a->flush();
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23211
diff changeset
   680
  _features = VM_Version::unknown_m;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   681
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   682
  // Print the detection code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   683
  if (PrintAssembly) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   684
    ttyLocker ttyl;
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 24424
diff changeset
   685
    tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   686
    Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   687
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   688
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   689
  // Measure cache line size.
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   690
  memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF.
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   691
  (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   692
  int count = 0; // count zeroed bytes
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   693
  for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   694
  guarantee(is_power_of_2(count), "cache line size needs to be a power of 2");
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32581
diff changeset
   695
  _L1_data_cache_line_size = count;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   696
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   697
  // Execute code. Illegal instructions will be replaced by 0 in the signal handler.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   698
  VM_Version::_is_determine_features_test_running = true;
31333
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   699
  // We must align the first argument to 16 bytes because of the lqarx check.
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 46618
diff changeset
   700
  (*test)(align_up(mid_of_test_area, 16), (uint64_t)0);
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   701
  VM_Version::_is_determine_features_test_running = false;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   702
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   703
  // determine which instructions are legal.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   704
  int feature_cntr = 0;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   705
  if (code[feature_cntr++]) features |= fsqrt_m;
23492
af5352f40e65 8037915: PPC64/AIX: Several smaller fixes
goetz
parents: 23211
diff changeset
   706
  if (code[feature_cntr++]) features |= fsqrts_m;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   707
  if (code[feature_cntr++]) features |= isel_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   708
  if (code[feature_cntr++]) features |= lxarxeh_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   709
  if (code[feature_cntr++]) features |= cmpb_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   710
  if (code[feature_cntr++]) features |= popcntb_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   711
  if (code[feature_cntr++]) features |= popcntw_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   712
  if (code[feature_cntr++]) features |= fcfids_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   713
  if (code[feature_cntr++]) features |= vand_m;
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   714
  if (code[feature_cntr++]) features |= lqarx_m;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   715
  if (code[feature_cntr++]) features |= vcipher_m;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   716
  if (code[feature_cntr++]) features |= vpmsumb_m;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   717
  if (code[feature_cntr++]) features |= tcheck_m;
36303
6241574f5982 8149655: PPC64: Implement CompactString intrinsics
mdoerr
parents: 35594
diff changeset
   718
  if (code[feature_cntr++]) features |= mfdscr_m;
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   719
  if (code[feature_cntr++]) features |= vsx_m;
46521
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   720
  if (code[feature_cntr++]) features |= ldbrx_m;
17e8acfe1db8 8179527: Implement intrinsic code for reverseBytes with load/store
mdoerr
parents: 46317
diff changeset
   721
  if (code[feature_cntr++]) features |= stdbrx_m;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   722
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   723
  // Print the detection code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   724
  if (PrintAssembly) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   725
    ttyLocker ttyl;
25374
d7fb2af5d53c 8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
coleenp
parents: 24424
diff changeset
   726
    tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " after execution:", p2i(code));
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   727
    Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   728
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   729
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   730
  _features = features;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   731
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   732
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   733
// Power 8: Configure Data Stream Control Register.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   734
void VM_Version::config_dscr() {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   735
  // 7 InstWords for each call (function descriptor + blr instruction).
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   736
  const int code_size = (2+2*7)*BytesPerInstWord;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   737
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   738
  // Allocate space for the code.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   739
  ResourceMark rm;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   740
  CodeBuffer cb("config_dscr", code_size, 0);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   741
  MacroAssembler* a = new MacroAssembler(&cb);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   742
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   743
  // Emit code.
31333
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   744
  uint64_t (*get_dscr)() = (uint64_t(*)())(void *)a->function_entry();
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   745
  uint32_t *code = (uint32_t *)a->pc();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   746
  a->mfdscr(R3);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   747
  a->blr();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   748
31333
12ccf8b26eb0 8080684: PPC64: Fix little-endian build after "8077838: Recent developments for ppc"
simonis
parents: 30587
diff changeset
   749
  void (*set_dscr)(long) = (void(*)(long))(void *)a->function_entry();
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   750
  a->mtdscr(R3);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   751
  a->blr();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   752
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   753
  uint32_t *code_end = (uint32_t *)a->pc();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   754
  a->flush();
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   755
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   756
  // Print the detection code.
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   757
  if (PrintAssembly) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   758
    ttyLocker ttyl;
30587
751a7698b62e 8079280: Fix format warning/error in vm_version_ppc.cpp
simonis
parents: 30303
diff changeset
   759
    tty->print_cr("Decoding dscr configuration stub at " INTPTR_FORMAT " before execution:", p2i(code));
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   760
    Disassembler::decode((u_char*)code, (u_char*)code_end, tty);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   761
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   762
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   763
  // Apply the configuration if needed.
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   764
  _dscr_val = (*get_dscr)();
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   765
  if (Verbose) {
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   766
    tty->print_cr("dscr value was 0x%lx" , _dscr_val);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   767
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   768
  bool change_requested = false;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   769
  if (DSCR_PPC64 != (uintx)-1) {
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   770
    _dscr_val = DSCR_PPC64;
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   771
    change_requested = true;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   772
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   773
  if (DSCR_DPFD_PPC64 <= 7) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   774
    uint64_t mask = 0x7;
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   775
    if ((_dscr_val & mask) != DSCR_DPFD_PPC64) {
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   776
      _dscr_val = (_dscr_val & ~mask) | (DSCR_DPFD_PPC64);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   777
      change_requested = true;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   778
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   779
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   780
  if (DSCR_URG_PPC64 <= 7) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   781
    uint64_t mask = 0x7 << 6;
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   782
    if ((_dscr_val & mask) != DSCR_DPFD_PPC64 << 6) {
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   783
      _dscr_val = (_dscr_val & ~mask) | (DSCR_URG_PPC64 << 6);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   784
      change_requested = true;
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   785
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   786
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   787
  if (change_requested) {
39236
c9d756fa846e 8154156: PPC64: improve array copy stubs by using vector instructions
mdoerr
parents: 37275
diff changeset
   788
    (*set_dscr)(_dscr_val);
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   789
    if (Verbose) {
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   790
      tty->print_cr("dscr was set to 0x%lx" , (*get_dscr)());
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   791
    }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   792
  }
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 30209
diff changeset
   793
}
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   794
35148
5cfafc99d791 8143072: [JVMCI] Port JVMCI to AArch64
twisti
parents: 35135
diff changeset
   795
static uint64_t saved_features = 0;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   796
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   797
void VM_Version::allow_all() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   798
  saved_features = _features;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   799
  _features      = all_features_m;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   800
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   801
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   802
void VM_Version::revert() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   803
  _features = saved_features;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   804
}