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