hotspot/src/cpu/x86/vm/vm_version_x86.cpp
author iveresov
Fri, 03 Sep 2010 17:51:07 -0700
changeset 6453 970dc585ab63
parent 6418 6671edbd230e
child 7397 5b173b4ca846
permissions -rw-r--r--
6953144: Tiered compilation Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation. Reviewed-by: kvn, never, phh, twisti
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     1
/*
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates.  All Rights Reserved.
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     4
 *
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     8
 *
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    13
 * accompanied this code).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    14
 *
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4430
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4430
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4430
diff changeset
    21
 * questions.
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    22
 *
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    23
 */
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    24
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    26
# include "incls/_vm_version_x86.cpp.incl"
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    27
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    28
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    29
int VM_Version::_cpu;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    30
int VM_Version::_model;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    31
int VM_Version::_stepping;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    32
int VM_Version::_cpuFeatures;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    33
const char*           VM_Version::_features_str = "";
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    34
VM_Version::CpuidInfo VM_Version::_cpuid_info   = { 0, };
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    35
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    36
static BufferBlob* stub_blob;
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
    37
static const int stub_size = 400;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    38
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    39
extern "C" {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    40
  typedef void (*getPsrInfo_stub_t)(void*);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    41
}
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    42
static getPsrInfo_stub_t getPsrInfo_stub = NULL;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    43
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    44
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    45
class VM_Version_StubGenerator: public StubCodeGenerator {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    46
 public:
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    47
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    48
  VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    49
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    50
  address generate_getPsrInfo() {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    51
    // Flags to test CPU type.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    52
    const uint32_t EFL_AC           = 0x40000;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    53
    const uint32_t EFL_ID           = 0x200000;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    54
    // Values for when we don't have a CPUID instruction.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    55
    const int      CPU_FAMILY_SHIFT = 8;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    56
    const uint32_t CPU_FAMILY_386   = (3 << CPU_FAMILY_SHIFT);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    57
    const uint32_t CPU_FAMILY_486   = (4 << CPU_FAMILY_SHIFT);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    58
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
    59
    Label detect_486, cpu486, detect_586, std_cpuid1, std_cpuid4;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    60
    Label ext_cpuid1, ext_cpuid5, done;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    61
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    62
    StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    63
#   define __ _masm->
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    65
    address start = __ pc();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    66
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    67
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    68
    // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    69
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    70
    // LP64: rcx and rdx are first and second argument registers on windows
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    71
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    72
    __ push(rbp);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    73
#ifdef _LP64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    74
    __ mov(rbp, c_rarg0); // cpuid_info address
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    75
#else
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    76
    __ movptr(rbp, Address(rsp, 8)); // cpuid_info address
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    77
#endif
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    78
    __ push(rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    79
    __ push(rsi);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    80
    __ pushf();          // preserve rbx, and flags
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    81
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    82
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    83
    __ mov(rcx, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    84
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    85
    // if we are unable to change the AC flag, we have a 386
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    86
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    87
    __ xorl(rax, EFL_AC);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    88
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    89
    __ popf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    90
    __ pushf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    91
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    92
    __ cmpptr(rax, rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    93
    __ jccb(Assembler::notEqual, detect_486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    94
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    95
    __ movl(rax, CPU_FAMILY_386);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    96
    __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    97
    __ jmp(done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    98
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    99
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   100
    // If we are unable to change the ID flag, we have a 486 which does
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   101
    // not support the "cpuid" instruction.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   102
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   103
    __ bind(detect_486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   104
    __ mov(rax, rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   105
    __ xorl(rax, EFL_ID);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   106
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   107
    __ popf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   108
    __ pushf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   109
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   110
    __ cmpptr(rcx, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   111
    __ jccb(Assembler::notEqual, detect_586);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   112
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   113
    __ bind(cpu486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   114
    __ movl(rax, CPU_FAMILY_486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   115
    __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   116
    __ jmp(done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   117
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   118
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   119
    // At this point, we have a chip which supports the "cpuid" instruction
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   120
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   121
    __ bind(detect_586);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   122
    __ xorl(rax, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   123
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   124
    __ orl(rax, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   125
    __ jcc(Assembler::equal, cpu486);   // if cpuid doesn't support an input
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   126
                                        // value of at least 1, we give up and
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   127
                                        // assume a 486
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   128
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset())));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   129
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   130
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   131
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   132
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   133
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   134
    __ cmpl(rax, 0xa);                  // Is cpuid(0xB) supported?
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   135
    __ jccb(Assembler::belowEqual, std_cpuid4);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   136
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   137
    //
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   138
    // cpuid(0xB) Processor Topology
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   139
    //
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   140
    __ movl(rax, 0xb);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   141
    __ xorl(rcx, rcx);   // Threads level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   142
    __ cpuid();
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   143
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   144
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB0_offset())));
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   145
    __ movl(Address(rsi, 0), rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   146
    __ movl(Address(rsi, 4), rbx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   147
    __ movl(Address(rsi, 8), rcx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   148
    __ movl(Address(rsi,12), rdx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   149
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   150
    __ movl(rax, 0xb);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   151
    __ movl(rcx, 1);     // Cores level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   152
    __ cpuid();
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   153
    __ push(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   154
    __ andl(rax, 0x1f);  // Determine if valid topology level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   155
    __ orl(rax, rbx);    // eax[4:0] | ebx[0:15] == 0 indicates invalid level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   156
    __ andl(rax, 0xffff);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   157
    __ pop(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   158
    __ jccb(Assembler::equal, std_cpuid4);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   159
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   160
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB1_offset())));
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   161
    __ movl(Address(rsi, 0), rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   162
    __ movl(Address(rsi, 4), rbx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   163
    __ movl(Address(rsi, 8), rcx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   164
    __ movl(Address(rsi,12), rdx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   165
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   166
    __ movl(rax, 0xb);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   167
    __ movl(rcx, 2);     // Packages level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   168
    __ cpuid();
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   169
    __ push(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   170
    __ andl(rax, 0x1f);  // Determine if valid topology level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   171
    __ orl(rax, rbx);    // eax[4:0] | ebx[0:15] == 0 indicates invalid level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   172
    __ andl(rax, 0xffff);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   173
    __ pop(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   174
    __ jccb(Assembler::equal, std_cpuid4);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   175
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   176
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB2_offset())));
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   177
    __ movl(Address(rsi, 0), rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   178
    __ movl(Address(rsi, 4), rbx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   179
    __ movl(Address(rsi, 8), rcx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   180
    __ movl(Address(rsi,12), rdx);
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   181
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   182
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   183
    // cpuid(0x4) Deterministic cache params
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   184
    //
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   185
    __ bind(std_cpuid4);
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   186
    __ movl(rax, 4);
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   187
    __ cmpl(rax, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset()))); // Is cpuid(0x4) supported?
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   188
    __ jccb(Assembler::greater, std_cpuid1);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   189
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   190
    __ xorl(rcx, rcx);   // L1 cache
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   191
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   192
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   193
    __ andl(rax, 0x1f);  // Determine if valid cache parameters used
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   194
    __ orl(rax, rax);    // eax[4:0] == 0 indicates invalid cache
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   195
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   196
    __ jccb(Assembler::equal, std_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   197
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   198
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset())));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   199
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   200
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   201
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   202
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   203
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   204
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   205
    // Standard cpuid(0x1)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   206
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   207
    __ bind(std_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   208
    __ movl(rax, 1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   209
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   210
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   211
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   212
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   213
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   214
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   215
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   216
    __ movl(rax, 0x80000000);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   217
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   218
    __ cmpl(rax, 0x80000000);     // Is cpuid(0x80000001) supported?
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   219
    __ jcc(Assembler::belowEqual, done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   220
    __ cmpl(rax, 0x80000004);     // Is cpuid(0x80000005) supported?
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   221
    __ jccb(Assembler::belowEqual, ext_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   222
    __ cmpl(rax, 0x80000007);     // Is cpuid(0x80000008) supported?
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   223
    __ jccb(Assembler::belowEqual, ext_cpuid5);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   224
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   225
    // Extended cpuid(0x80000008)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   226
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   227
    __ movl(rax, 0x80000008);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   228
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   229
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset())));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   230
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   231
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   232
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   233
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   234
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   235
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   236
    // Extended cpuid(0x80000005)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   237
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   238
    __ bind(ext_cpuid5);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   239
    __ movl(rax, 0x80000005);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   240
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   241
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset())));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   242
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   243
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   244
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   245
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   246
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   247
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   248
    // Extended cpuid(0x80000001)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   249
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   250
    __ bind(ext_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   251
    __ movl(rax, 0x80000001);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   252
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   253
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset())));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   254
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   255
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   256
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   257
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   258
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   259
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   260
    // return
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   261
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   262
    __ bind(done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   263
    __ popf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   264
    __ pop(rsi);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   265
    __ pop(rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   266
    __ pop(rbp);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   267
    __ ret(0);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   268
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   269
#   undef __
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   270
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   271
    return start;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   272
  };
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   273
};
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   274
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   275
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   276
void VM_Version::get_processor_features() {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   277
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   278
  _cpu = 4; // 486 by default
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   279
  _model = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   280
  _stepping = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   281
  _cpuFeatures = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   282
  _logical_processors_per_package = 1;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   283
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   284
  if (!Use486InstrsOnly) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   285
    // Get raw processor info
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   286
    getPsrInfo_stub(&_cpuid_info);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   287
    assert_is_initialized();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   288
    _cpu = extended_cpu_family();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   289
    _model = extended_cpu_model();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   290
    _stepping = cpu_stepping();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   291
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   292
    if (cpu_family() > 4) { // it supports CPUID
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   293
      _cpuFeatures = feature_flags();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   294
      // Logical processors are only available on P4s and above,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   295
      // and only if hyperthreading is available.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   296
      _logical_processors_per_package = logical_processor_count();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   297
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   298
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   299
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   300
  _supports_cx8 = supports_cmpxchg8();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   301
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   302
#ifdef _LP64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   303
  // OS should support SSE for x64 and hardware should support at least SSE2.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   304
  if (!VM_Version::supports_sse2()) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   305
    vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   306
  }
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 2862
diff changeset
   307
  // in 64 bit the use of SSE2 is the minimum
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 2862
diff changeset
   308
  if (UseSSE < 2) UseSSE = 2;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   309
#endif
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   310
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   311
  // If the OS doesn't support SSE, we can't use this feature even if the HW does
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   312
  if (!os::supports_sse())
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   313
    _cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   314
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   315
  if (UseSSE < 4) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   316
    _cpuFeatures &= ~CPU_SSE4_1;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   317
    _cpuFeatures &= ~CPU_SSE4_2;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   318
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   319
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   320
  if (UseSSE < 3) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   321
    _cpuFeatures &= ~CPU_SSE3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   322
    _cpuFeatures &= ~CPU_SSSE3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   323
    _cpuFeatures &= ~CPU_SSE4A;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   324
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   325
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   326
  if (UseSSE < 2)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   327
    _cpuFeatures &= ~CPU_SSE2;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   328
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   329
  if (UseSSE < 1)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   330
    _cpuFeatures &= ~CPU_SSE;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   331
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   332
  if (logical_processors_per_package() == 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   333
    // HT processor could be installed on a system which doesn't support HT.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   334
    _cpuFeatures &= ~CPU_HT;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   335
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   336
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   337
  char buf[256];
2862
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   338
  jio_snprintf(buf, sizeof(buf), "(%u cores per cpu, %u threads per core) family %d model %d stepping %d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   339
               cores_per_cpu(), threads_per_core(),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   340
               cpu_family(), _model, _stepping,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   341
               (supports_cmov() ? ", cmov" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   342
               (supports_cmpxchg8() ? ", cx8" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   343
               (supports_fxsr() ? ", fxsr" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   344
               (supports_mmx()  ? ", mmx"  : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   345
               (supports_sse()  ? ", sse"  : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   346
               (supports_sse2() ? ", sse2" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   347
               (supports_sse3() ? ", sse3" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   348
               (supports_ssse3()? ", ssse3": ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   349
               (supports_sse4_1() ? ", sse4.1" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   350
               (supports_sse4_2() ? ", sse4.2" : ""),
2255
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   351
               (supports_popcnt() ? ", popcnt" : ""),
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   352
               (supports_mmx_ext() ? ", mmxext" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   353
               (supports_3dnow()   ? ", 3dnow"  : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   354
               (supports_3dnow2()  ? ", 3dnowext" : ""),
2862
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   355
               (supports_lzcnt()   ? ", lzcnt": ""),
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   356
               (supports_sse4a()   ? ", sse4a": ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   357
               (supports_ht() ? ", ht": ""));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   358
  _features_str = strdup(buf);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   359
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   360
  // UseSSE is set to the smaller of what hardware supports and what
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   361
  // the command line requires.  I.e., you cannot set UseSSE to 2 on
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   362
  // older Pentiums which do not support it.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   363
  if( UseSSE > 4 ) UseSSE=4;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   364
  if( UseSSE < 0 ) UseSSE=0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   365
  if( !supports_sse4_1() ) // Drop to 3 if no SSE4 support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   366
    UseSSE = MIN2((intx)3,UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   367
  if( !supports_sse3() ) // Drop to 2 if no SSE3 support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   368
    UseSSE = MIN2((intx)2,UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   369
  if( !supports_sse2() ) // Drop to 1 if no SSE2 support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   370
    UseSSE = MIN2((intx)1,UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   371
  if( !supports_sse () ) // Drop to 0 if no SSE  support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   372
    UseSSE = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   373
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   374
  // On new cpus instructions which update whole XMM register should be used
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   375
  // to prevent partial register stall due to dependencies on high half.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   376
  //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   377
  // UseXmmLoadAndClearUpper == true  --> movsd(xmm, mem)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   378
  // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   379
  // UseXmmRegToRegMoveAll == true  --> movaps(xmm, xmm), movapd(xmm, xmm).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   380
  // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm),  movsd(xmm, xmm).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   381
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   382
  if( is_amd() ) { // AMD cpus specific settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   383
    if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   384
      // Use it on new AMD cpus starting from Opteron.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   385
      UseAddressNop = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   386
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   387
    if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   388
      // Use it on new AMD cpus starting from Opteron.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   389
      UseNewLongLShift = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   390
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   391
    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   392
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   393
        UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   394
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   395
        UseXmmLoadAndClearUpper = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   396
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   397
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   398
    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   399
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   400
        UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h'
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   401
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   402
        UseXmmRegToRegMoveAll = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   403
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   404
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   405
    if( FLAG_IS_DEFAULT(UseXmmI2F) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   406
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   407
        UseXmmI2F = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   408
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   409
        UseXmmI2F = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   410
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   411
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   412
    if( FLAG_IS_DEFAULT(UseXmmI2D) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   413
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   414
        UseXmmI2D = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   415
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   416
        UseXmmI2D = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   417
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   418
    }
2862
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   419
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   420
    // Use count leading zeros count instruction if available.
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   421
    if (supports_lzcnt()) {
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   422
      if (FLAG_IS_DEFAULT(UseCountLeadingZerosInstruction)) {
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   423
        UseCountLeadingZerosInstruction = true;
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   424
      }
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   425
    }
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   426
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   427
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   428
  if( is_intel() ) { // Intel cpus specific settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   429
    if( FLAG_IS_DEFAULT(UseStoreImmI16) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   430
      UseStoreImmI16 = false; // don't use it on Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   431
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   432
    if( cpu_family() == 6 || cpu_family() == 15 ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   433
      if( FLAG_IS_DEFAULT(UseAddressNop) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   434
        // Use it on all Intel cpus starting from PentiumPro
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   435
        UseAddressNop = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   436
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   437
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   438
    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   439
      UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   440
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   441
    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   442
      if( supports_sse3() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   443
        UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   444
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   445
        UseXmmRegToRegMoveAll = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   446
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   447
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   448
    if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   449
#ifdef COMPILER2
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   450
      if( FLAG_IS_DEFAULT(MaxLoopPad) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   451
        // For new Intel cpus do the next optimization:
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   452
        // don't align the beginning of a loop if there are enough instructions
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   453
        // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   454
        // in current fetch line (OptoLoopAlignment) or the padding
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   455
        // is big (> MaxLoopPad).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   456
        // Set MaxLoopPad to 11 for new Intel cpus to reduce number of
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   457
        // generated NOP instructions. 11 is the largest size of one
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   458
        // address NOP instruction '0F 1F' (see Assembler::nop(i)).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   459
        MaxLoopPad = 11;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   460
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   461
#endif // COMPILER2
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   462
      if( FLAG_IS_DEFAULT(UseXMMForArrayCopy) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   463
        UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   464
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   465
      if( supports_sse4_2() && supports_ht() ) { // Newest Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   466
        if( FLAG_IS_DEFAULT(UseUnalignedLoadStores) && UseXMMForArrayCopy ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   467
          UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   468
        }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   469
      }
2348
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   470
      if( supports_sse4_2() && UseSSE >= 4 ) {
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   471
        if( FLAG_IS_DEFAULT(UseSSE42Intrinsics)) {
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   472
          UseSSE42Intrinsics = true;
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   473
        }
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   474
      }
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   475
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   476
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   477
2255
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   478
  // Use population count instruction if available.
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   479
  if (supports_popcnt()) {
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   480
    if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   481
      UsePopCountInstruction = true;
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   482
    }
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   483
  }
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   484
6272
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   485
#ifdef COMPILER2
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   486
  if (UseFPUForSpilling) {
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   487
    if (UseSSE < 2) {
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   488
      // Only supported with SSE2+
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   489
      FLAG_SET_DEFAULT(UseFPUForSpilling, false);
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   490
    }
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   491
  }
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   492
#endif
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   493
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   494
  assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   495
  assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   496
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   497
  // set valid Prefetch instruction
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   498
  if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   499
  if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   500
  if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   501
  if( !supports_sse() && supports_3dnow() ) ReadPrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   502
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   503
  if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   504
  if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   505
  if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   506
  if( !supports_sse() && supports_3dnow() ) AllocatePrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   507
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   508
  // Allocation prefetch settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   509
  intx cache_line_size = L1_data_cache_line_size();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   510
  if( cache_line_size > AllocatePrefetchStepSize )
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   511
    AllocatePrefetchStepSize = cache_line_size;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   512
  if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   513
    AllocatePrefetchLines = 3; // Optimistic value
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   514
  assert(AllocatePrefetchLines > 0, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   515
  if( AllocatePrefetchLines < 1 ) // set valid value in product VM
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   516
    AllocatePrefetchLines = 1; // Conservative value
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   517
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   518
  AllocatePrefetchDistance = allocate_prefetch_distance();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   519
  AllocatePrefetchStyle    = allocate_prefetch_style();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   520
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   521
  if( is_intel() && cpu_family() == 6 && supports_sse3() ) {
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   522
    if( AllocatePrefetchStyle == 2 ) { // watermark prefetching on Core
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   523
#ifdef _LP64
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   524
      AllocatePrefetchDistance = 384;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   525
#else
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   526
      AllocatePrefetchDistance = 320;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   527
#endif
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   528
    }
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   529
    if( supports_sse4_2() && supports_ht() ) { // Nehalem based cpus
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   530
      AllocatePrefetchDistance = 192;
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   531
      AllocatePrefetchLines = 4;
6272
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   532
#ifdef COMPILER2
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   533
      if (AggressiveOpts && FLAG_IS_DEFAULT(UseFPUForSpilling)) {
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   534
        FLAG_SET_DEFAULT(UseFPUForSpilling, true);
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   535
      }
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   536
#endif
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   537
    }
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   538
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   539
  assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   540
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   541
#ifdef _LP64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   542
  // Prefetch settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   543
  PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   544
  PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   545
  PrefetchFieldsAhead         = prefetch_fields_ahead();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   546
#endif
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   547
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   548
#ifndef PRODUCT
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   549
  if (PrintMiscellaneous && Verbose) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   550
    tty->print_cr("Logical CPUs per core: %u",
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   551
                  logical_processors_per_package());
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   552
    tty->print_cr("UseSSE=%d",UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   553
    tty->print("Allocation: ");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   554
    if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow()) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   555
      tty->print_cr("no prefetching");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   556
    } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   557
      if (UseSSE == 0 && supports_3dnow()) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   558
        tty->print("PREFETCHW");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   559
      } else if (UseSSE >= 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   560
        if (AllocatePrefetchInstr == 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   561
          tty->print("PREFETCHNTA");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   562
        } else if (AllocatePrefetchInstr == 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   563
          tty->print("PREFETCHT0");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   564
        } else if (AllocatePrefetchInstr == 2) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   565
          tty->print("PREFETCHT2");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   566
        } else if (AllocatePrefetchInstr == 3) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   567
          tty->print("PREFETCHW");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   568
        }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   569
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   570
      if (AllocatePrefetchLines > 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   571
        tty->print_cr(" %d, %d lines with step %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   572
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   573
        tty->print_cr(" %d, one line", AllocatePrefetchDistance);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   574
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   575
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   576
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   577
    if (PrefetchCopyIntervalInBytes > 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   578
      tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   579
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   580
    if (PrefetchScanIntervalInBytes > 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   581
      tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   582
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   583
    if (PrefetchFieldsAhead > 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   584
      tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   585
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   586
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   587
#endif // !PRODUCT
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   588
}
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   589
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   590
void VM_Version::initialize() {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   591
  ResourceMark rm;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   592
  // Making this stub must be FIRST use of assembler
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   593
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   594
  stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   595
  if (stub_blob == NULL) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   596
    vm_exit_during_initialization("Unable to allocate getPsrInfo_stub");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   597
  }
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 6272
diff changeset
   598
  CodeBuffer c(stub_blob);
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   599
  VM_Version_StubGenerator g(&c);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   600
  getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   601
                                   g.generate_getPsrInfo());
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   602
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   603
  get_processor_features();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   604
}