hotspot/src/cpu/x86/vm/vm_version_x86.cpp
author johnc
Mon, 18 Apr 2011 16:27:16 -0700
changeset 9186 7e9f22667cfc
parent 8921 14bfe81f2a9d
child 9135 f76543993e9d
permissions -rw-r--r--
7036706: G1: Use LIR_OprDesc::as_pointer_register in code changes for 7035117 Summary: Use LIR_OprDesc::as_pointer_register() instead as_register/as_register_lo combination in the code changes for 7035117. Reviewed-by: iveresov
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
/*
8921
14bfe81f2a9d 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 8873
diff changeset
     2
 * Copyright (c) 1997, 2011, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    26
#include "assembler_x86.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    27
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    28
#include "runtime/java.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    29
#include "runtime/stubCodeGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    30
#include "vm_version_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    31
#ifdef TARGET_OS_FAMILY_linux
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    32
# include "os_linux.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    33
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    34
#ifdef TARGET_OS_FAMILY_solaris
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    35
# include "os_solaris.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    36
#endif
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    37
#ifdef TARGET_OS_FAMILY_windows
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    38
# include "os_windows.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6418
diff changeset
    39
#endif
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    40
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
int VM_Version::_cpu;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    43
int VM_Version::_model;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    44
int VM_Version::_stepping;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    45
int VM_Version::_cpuFeatures;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    46
const char*           VM_Version::_features_str = "";
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    47
VM_Version::CpuidInfo VM_Version::_cpuid_info   = { 0, };
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    48
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    49
static BufferBlob* stub_blob;
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
    50
static const int stub_size = 400;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    51
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    52
extern "C" {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    53
  typedef void (*getPsrInfo_stub_t)(void*);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    54
}
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    55
static getPsrInfo_stub_t getPsrInfo_stub = NULL;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    56
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    57
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    58
class VM_Version_StubGenerator: public StubCodeGenerator {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    59
 public:
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    60
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    61
  VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    62
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    63
  address generate_getPsrInfo() {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    64
    // Flags to test CPU type.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    65
    const uint32_t EFL_AC           = 0x40000;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    66
    const uint32_t EFL_ID           = 0x200000;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    67
    // Values for when we don't have a CPUID instruction.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    68
    const int      CPU_FAMILY_SHIFT = 8;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    69
    const uint32_t CPU_FAMILY_386   = (3 << CPU_FAMILY_SHIFT);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    70
    const uint32_t CPU_FAMILY_486   = (4 << CPU_FAMILY_SHIFT);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    71
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
    72
    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
    73
    Label ext_cpuid1, ext_cpuid5, done;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    74
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    75
    StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    76
#   define __ _masm->
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    77
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    78
    address start = __ pc();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    79
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    80
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    81
    // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    82
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    83
    // 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
    84
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    85
    __ push(rbp);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    86
#ifdef _LP64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    87
    __ mov(rbp, c_rarg0); // cpuid_info address
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    88
#else
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    89
    __ movptr(rbp, Address(rsp, 8)); // cpuid_info address
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    90
#endif
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    91
    __ push(rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    92
    __ push(rsi);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    93
    __ pushf();          // preserve rbx, and flags
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    94
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    95
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    96
    __ mov(rcx, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    97
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
    98
    // 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
    99
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   100
    __ xorl(rax, EFL_AC);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   101
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   102
    __ popf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   103
    __ pushf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   104
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   105
    __ cmpptr(rax, rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   106
    __ jccb(Assembler::notEqual, detect_486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   107
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   108
    __ movl(rax, CPU_FAMILY_386);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   109
    __ 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
   110
    __ jmp(done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   111
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
    // 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
   114
    // not support the "cpuid" instruction.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   115
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   116
    __ bind(detect_486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   117
    __ mov(rax, rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   118
    __ xorl(rax, EFL_ID);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   119
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   120
    __ popf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   121
    __ pushf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   122
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   123
    __ cmpptr(rcx, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   124
    __ jccb(Assembler::notEqual, detect_586);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   125
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   126
    __ bind(cpu486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   127
    __ movl(rax, CPU_FAMILY_486);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   128
    __ 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
   129
    __ jmp(done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   130
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   131
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   132
    // 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
   133
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   134
    __ bind(detect_586);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   135
    __ xorl(rax, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   136
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   137
    __ orl(rax, rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   138
    __ 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
   139
                                        // value of at least 1, we give up and
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   140
                                        // assume a 486
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   141
    __ 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
   142
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   143
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   144
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   145
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   146
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   147
    __ cmpl(rax, 0xa);                  // Is cpuid(0xB) supported?
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   148
    __ jccb(Assembler::belowEqual, std_cpuid4);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   149
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   150
    //
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   151
    // cpuid(0xB) Processor Topology
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   152
    //
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   153
    __ movl(rax, 0xb);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   154
    __ xorl(rcx, rcx);   // Threads level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   155
    __ cpuid();
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   156
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   157
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB0_offset())));
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   158
    __ movl(Address(rsi, 0), rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   159
    __ movl(Address(rsi, 4), rbx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   160
    __ movl(Address(rsi, 8), rcx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   161
    __ movl(Address(rsi,12), rdx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   162
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   163
    __ movl(rax, 0xb);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   164
    __ movl(rcx, 1);     // Cores level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   165
    __ cpuid();
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   166
    __ push(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   167
    __ andl(rax, 0x1f);  // Determine if valid topology level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   168
    __ orl(rax, rbx);    // eax[4:0] | ebx[0:15] == 0 indicates invalid level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   169
    __ andl(rax, 0xffff);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   170
    __ pop(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   171
    __ jccb(Assembler::equal, std_cpuid4);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   172
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   173
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB1_offset())));
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   174
    __ movl(Address(rsi, 0), rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   175
    __ movl(Address(rsi, 4), rbx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   176
    __ movl(Address(rsi, 8), rcx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   177
    __ movl(Address(rsi,12), rdx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   178
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   179
    __ movl(rax, 0xb);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   180
    __ movl(rcx, 2);     // Packages level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   181
    __ cpuid();
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   182
    __ push(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   183
    __ andl(rax, 0x1f);  // Determine if valid topology level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   184
    __ orl(rax, rbx);    // eax[4:0] | ebx[0:15] == 0 indicates invalid level
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   185
    __ andl(rax, 0xffff);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   186
    __ pop(rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   187
    __ jccb(Assembler::equal, std_cpuid4);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   188
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   189
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::tpl_cpuidB2_offset())));
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   190
    __ movl(Address(rsi, 0), rax);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   191
    __ movl(Address(rsi, 4), rbx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   192
    __ movl(Address(rsi, 8), rcx);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   193
    __ movl(Address(rsi,12), rdx);
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   194
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   195
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   196
    // cpuid(0x4) Deterministic cache params
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   197
    //
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   198
    __ bind(std_cpuid4);
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   199
    __ movl(rax, 4);
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   200
    __ 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
   201
    __ jccb(Assembler::greater, std_cpuid1);
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   202
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   203
    __ xorl(rcx, rcx);   // L1 cache
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   204
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   205
    __ push(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   206
    __ andl(rax, 0x1f);  // Determine if valid cache parameters used
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   207
    __ orl(rax, rax);    // eax[4:0] == 0 indicates invalid cache
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   208
    __ pop(rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   209
    __ jccb(Assembler::equal, std_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   210
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   211
    __ 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
   212
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   213
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   214
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   215
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   216
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   217
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   218
    // Standard cpuid(0x1)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   219
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   220
    __ bind(std_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   221
    __ movl(rax, 1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   222
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   223
    __ 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
   224
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   225
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   226
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   227
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   228
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   229
    __ movl(rax, 0x80000000);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   230
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   231
    __ cmpl(rax, 0x80000000);     // Is cpuid(0x80000001) supported?
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   232
    __ jcc(Assembler::belowEqual, done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   233
    __ cmpl(rax, 0x80000004);     // Is cpuid(0x80000005) supported?
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   234
    __ jccb(Assembler::belowEqual, ext_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   235
    __ cmpl(rax, 0x80000007);     // Is cpuid(0x80000008) supported?
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   236
    __ jccb(Assembler::belowEqual, ext_cpuid5);
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
    // Extended cpuid(0x80000008)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   239
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   240
    __ movl(rax, 0x80000008);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   241
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   242
    __ 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
   243
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   244
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   245
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   246
    __ movl(Address(rsi,12), rdx);
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
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   249
    // Extended cpuid(0x80000005)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   250
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   251
    __ bind(ext_cpuid5);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   252
    __ movl(rax, 0x80000005);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   253
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   254
    __ 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
   255
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   256
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   257
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   258
    __ movl(Address(rsi,12), rdx);
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
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   261
    // Extended cpuid(0x80000001)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   262
    //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   263
    __ bind(ext_cpuid1);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   264
    __ movl(rax, 0x80000001);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   265
    __ cpuid();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   266
    __ 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
   267
    __ movl(Address(rsi, 0), rax);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   268
    __ movl(Address(rsi, 4), rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   269
    __ movl(Address(rsi, 8), rcx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   270
    __ movl(Address(rsi,12), rdx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   271
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
    // return
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
    __ bind(done);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   276
    __ popf();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   277
    __ pop(rsi);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   278
    __ pop(rbx);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   279
    __ pop(rbp);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   280
    __ ret(0);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   281
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   282
#   undef __
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
    return start;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   285
  };
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   286
};
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   287
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   288
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   289
void VM_Version::get_processor_features() {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   290
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   291
  _cpu = 4; // 486 by default
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   292
  _model = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   293
  _stepping = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   294
  _cpuFeatures = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   295
  _logical_processors_per_package = 1;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   296
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   297
  if (!Use486InstrsOnly) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   298
    // Get raw processor info
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   299
    getPsrInfo_stub(&_cpuid_info);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   300
    assert_is_initialized();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   301
    _cpu = extended_cpu_family();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   302
    _model = extended_cpu_model();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   303
    _stepping = cpu_stepping();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   304
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   305
    if (cpu_family() > 4) { // it supports CPUID
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   306
      _cpuFeatures = feature_flags();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   307
      // Logical processors are only available on P4s and above,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   308
      // and only if hyperthreading is available.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   309
      _logical_processors_per_package = logical_processor_count();
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
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   312
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   313
  _supports_cx8 = supports_cmpxchg8();
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
#ifdef _LP64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   316
  // 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
   317
  if (!VM_Version::supports_sse2()) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   318
    vm_exit_during_initialization("Unknown x64 processor: SSE2 not supported");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   319
  }
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 2862
diff changeset
   320
  // in 64 bit the use of SSE2 is the minimum
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 2862
diff changeset
   321
  if (UseSSE < 2) UseSSE = 2;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   322
#endif
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   323
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   324
  // 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
   325
  if (!os::supports_sse())
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   326
    _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
   327
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   328
  if (UseSSE < 4) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   329
    _cpuFeatures &= ~CPU_SSE4_1;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   330
    _cpuFeatures &= ~CPU_SSE4_2;
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
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   333
  if (UseSSE < 3) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   334
    _cpuFeatures &= ~CPU_SSE3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   335
    _cpuFeatures &= ~CPU_SSSE3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   336
    _cpuFeatures &= ~CPU_SSE4A;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   337
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   338
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   339
  if (UseSSE < 2)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   340
    _cpuFeatures &= ~CPU_SSE2;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   341
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   342
  if (UseSSE < 1)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   343
    _cpuFeatures &= ~CPU_SSE;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   344
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   345
  if (logical_processors_per_package() == 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   346
    // 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
   347
    _cpuFeatures &= ~CPU_HT;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   348
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   349
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   350
  char buf[256];
2862
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   351
  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
   352
               cores_per_cpu(), threads_per_core(),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   353
               cpu_family(), _model, _stepping,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   354
               (supports_cmov() ? ", cmov" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   355
               (supports_cmpxchg8() ? ", cx8" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   356
               (supports_fxsr() ? ", fxsr" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   357
               (supports_mmx()  ? ", mmx"  : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   358
               (supports_sse()  ? ", sse"  : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   359
               (supports_sse2() ? ", sse2" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   360
               (supports_sse3() ? ", sse3" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   361
               (supports_ssse3()? ", ssse3": ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   362
               (supports_sse4_1() ? ", sse4.1" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   363
               (supports_sse4_2() ? ", sse4.2" : ""),
2255
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   364
               (supports_popcnt() ? ", popcnt" : ""),
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   365
               (supports_mmx_ext() ? ", mmxext" : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   366
               (supports_3dnow()   ? ", 3dnow"  : ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   367
               (supports_3dnow2()  ? ", 3dnowext" : ""),
2862
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   368
               (supports_lzcnt()   ? ", lzcnt": ""),
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   369
               (supports_sse4a()   ? ", sse4a": ""),
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   370
               (supports_ht() ? ", ht": ""));
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   371
  _features_str = strdup(buf);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   372
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   373
  // 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
   374
  // 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
   375
  // older Pentiums which do not support it.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   376
  if( UseSSE > 4 ) UseSSE=4;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   377
  if( UseSSE < 0 ) UseSSE=0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   378
  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
   379
    UseSSE = MIN2((intx)3,UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   380
  if( !supports_sse3() ) // Drop to 2 if no SSE3 support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   381
    UseSSE = MIN2((intx)2,UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   382
  if( !supports_sse2() ) // Drop to 1 if no SSE2 support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   383
    UseSSE = MIN2((intx)1,UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   384
  if( !supports_sse () ) // Drop to 0 if no SSE  support
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   385
    UseSSE = 0;
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
  // 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
   388
  // 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
   389
  //
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   390
  // UseXmmLoadAndClearUpper == true  --> movsd(xmm, mem)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   391
  // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   392
  // UseXmmRegToRegMoveAll == true  --> movaps(xmm, xmm), movapd(xmm, xmm).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   393
  // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm),  movsd(xmm, xmm).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   394
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   395
  if( is_amd() ) { // AMD cpus specific settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   396
    if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   397
      // Use it on new AMD cpus starting from Opteron.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   398
      UseAddressNop = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   399
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   400
    if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   401
      // Use it on new AMD cpus starting from Opteron.
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   402
      UseNewLongLShift = true;
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
    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   405
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   406
        UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   407
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   408
        UseXmmLoadAndClearUpper = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   409
      }
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
    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   412
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   413
        UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h'
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   414
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   415
        UseXmmRegToRegMoveAll = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   416
      }
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
    if( FLAG_IS_DEFAULT(UseXmmI2F) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   419
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   420
        UseXmmI2F = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   421
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   422
        UseXmmI2F = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   423
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   424
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   425
    if( FLAG_IS_DEFAULT(UseXmmI2D) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   426
      if( supports_sse4a() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   427
        UseXmmI2D = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   428
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   429
        UseXmmI2D = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   430
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   431
    }
8873
d3031147b912 7032133: Enable sse4.2 for new AMD processors
kvn
parents: 8677
diff changeset
   432
    if( FLAG_IS_DEFAULT(UseSSE42Intrinsics) ) {
d3031147b912 7032133: Enable sse4.2 for new AMD processors
kvn
parents: 8677
diff changeset
   433
      if( supports_sse4_2() && UseSSE >= 4 ) {
d3031147b912 7032133: Enable sse4.2 for new AMD processors
kvn
parents: 8677
diff changeset
   434
        UseSSE42Intrinsics = true;
d3031147b912 7032133: Enable sse4.2 for new AMD processors
kvn
parents: 8677
diff changeset
   435
      }
d3031147b912 7032133: Enable sse4.2 for new AMD processors
kvn
parents: 8677
diff changeset
   436
    }
2862
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   437
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   438
    // Use count leading zeros count instruction if available.
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   439
    if (supports_lzcnt()) {
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   440
      if (FLAG_IS_DEFAULT(UseCountLeadingZerosInstruction)) {
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   441
        UseCountLeadingZerosInstruction = true;
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   442
      }
fad636edf18f 6823354: Add intrinsics for {Integer,Long}.{numberOfLeadingZeros,numberOfTrailingZeros}()
twisti
parents: 2348
diff changeset
   443
    }
8677
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   444
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   445
    // On family 21 processors default is no sw prefetch
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   446
    if ( cpu_family() == 21 ) {
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   447
      if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   448
        AllocatePrefetchStyle = 0;
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   449
      }
45d01baba334 7028394: Newer AMD Processor Prefetch Defaults
kvn
parents: 7397
diff changeset
   450
    }
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   451
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   452
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   453
  if( is_intel() ) { // Intel cpus specific settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   454
    if( FLAG_IS_DEFAULT(UseStoreImmI16) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   455
      UseStoreImmI16 = false; // don't use it on Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   456
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   457
    if( cpu_family() == 6 || cpu_family() == 15 ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   458
      if( FLAG_IS_DEFAULT(UseAddressNop) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   459
        // Use it on all Intel cpus starting from PentiumPro
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   460
        UseAddressNop = true;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   461
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   462
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   463
    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   464
      UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   465
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   466
    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   467
      if( supports_sse3() ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   468
        UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   469
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   470
        UseXmmRegToRegMoveAll = false;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   471
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   472
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   473
    if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   474
#ifdef COMPILER2
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   475
      if( FLAG_IS_DEFAULT(MaxLoopPad) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   476
        // For new Intel cpus do the next optimization:
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   477
        // 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
   478
        // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   479
        // in current fetch line (OptoLoopAlignment) or the padding
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   480
        // is big (> MaxLoopPad).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   481
        // 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
   482
        // generated NOP instructions. 11 is the largest size of one
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   483
        // address NOP instruction '0F 1F' (see Assembler::nop(i)).
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   484
        MaxLoopPad = 11;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   485
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   486
#endif // COMPILER2
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   487
      if( FLAG_IS_DEFAULT(UseXMMForArrayCopy) ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   488
        UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   489
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   490
      if( supports_sse4_2() && supports_ht() ) { // Newest Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   491
        if( FLAG_IS_DEFAULT(UseUnalignedLoadStores) && UseXMMForArrayCopy ) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   492
          UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   493
        }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   494
      }
2348
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   495
      if( supports_sse4_2() && UseSSE >= 4 ) {
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   496
        if( FLAG_IS_DEFAULT(UseSSE42Intrinsics)) {
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   497
          UseSSE42Intrinsics = true;
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   498
        }
4e71ed4c2709 6761600: Use sse 4.2 in intrinsics
cfang
parents: 2255
diff changeset
   499
      }
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   500
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   501
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   502
2255
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   503
  // Use population count instruction if available.
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   504
  if (supports_popcnt()) {
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   505
    if (FLAG_IS_DEFAULT(UsePopCountInstruction)) {
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   506
      UsePopCountInstruction = true;
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   507
    }
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   508
  }
54abdf3e1055 6378821: bitCount() should use POPC on SPARC processors and AMD+10h
twisti
parents: 2111
diff changeset
   509
6272
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   510
#ifdef COMPILER2
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   511
  if (UseFPUForSpilling) {
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   512
    if (UseSSE < 2) {
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   513
      // Only supported with SSE2+
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   514
      FLAG_SET_DEFAULT(UseFPUForSpilling, false);
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   515
    }
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   516
  }
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   517
#endif
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   518
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   519
  assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   520
  assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   521
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   522
  // set valid Prefetch instruction
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   523
  if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   524
  if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   525
  if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   526
  if( !supports_sse() && supports_3dnow() ) ReadPrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   527
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   528
  if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   529
  if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   530
  if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   531
  if( !supports_sse() && supports_3dnow() ) AllocatePrefetchInstr = 3;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   532
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   533
  // Allocation prefetch settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   534
  intx cache_line_size = L1_data_cache_line_size();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   535
  if( cache_line_size > AllocatePrefetchStepSize )
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   536
    AllocatePrefetchStepSize = cache_line_size;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   537
  if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   538
    AllocatePrefetchLines = 3; // Optimistic value
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   539
  assert(AllocatePrefetchLines > 0, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   540
  if( AllocatePrefetchLines < 1 ) // set valid value in product VM
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   541
    AllocatePrefetchLines = 1; // Conservative value
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   542
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   543
  AllocatePrefetchDistance = allocate_prefetch_distance();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   544
  AllocatePrefetchStyle    = allocate_prefetch_style();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   545
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   546
  if( is_intel() && cpu_family() == 6 && supports_sse3() ) {
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   547
    if( AllocatePrefetchStyle == 2 ) { // watermark prefetching on Core
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   548
#ifdef _LP64
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   549
      AllocatePrefetchDistance = 384;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   550
#else
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   551
      AllocatePrefetchDistance = 320;
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   552
#endif
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   553
    }
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   554
    if( supports_sse4_2() && supports_ht() ) { // Nehalem based cpus
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   555
      AllocatePrefetchDistance = 192;
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   556
      AllocatePrefetchLines = 4;
6272
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   557
#ifdef COMPILER2
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   558
      if (AggressiveOpts && FLAG_IS_DEFAULT(UseFPUForSpilling)) {
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   559
        FLAG_SET_DEFAULT(UseFPUForSpilling, true);
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   560
      }
94a20ad0e9de 6978249: spill between cpu and fpu registers when those moves are fast
never
parents: 5902
diff changeset
   561
#endif
5902
ba0c3b725081 6964774: Adjust optimization flags setting
kvn
parents: 5547
diff changeset
   562
    }
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   563
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   564
  assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   565
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   566
#ifdef _LP64
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   567
  // Prefetch settings
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   568
  PrefetchCopyIntervalInBytes = prefetch_copy_interval_in_bytes();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   569
  PrefetchScanIntervalInBytes = prefetch_scan_interval_in_bytes();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   570
  PrefetchFieldsAhead         = prefetch_fields_ahead();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   571
#endif
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   572
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   573
#ifndef PRODUCT
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   574
  if (PrintMiscellaneous && Verbose) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   575
    tty->print_cr("Logical CPUs per core: %u",
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   576
                  logical_processors_per_package());
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   577
    tty->print_cr("UseSSE=%d",UseSSE);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   578
    tty->print("Allocation: ");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   579
    if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow()) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   580
      tty->print_cr("no prefetching");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   581
    } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   582
      if (UseSSE == 0 && supports_3dnow()) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   583
        tty->print("PREFETCHW");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   584
      } else if (UseSSE >= 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   585
        if (AllocatePrefetchInstr == 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   586
          tty->print("PREFETCHNTA");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   587
        } else if (AllocatePrefetchInstr == 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   588
          tty->print("PREFETCHT0");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   589
        } else if (AllocatePrefetchInstr == 2) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   590
          tty->print("PREFETCHT2");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   591
        } else if (AllocatePrefetchInstr == 3) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   592
          tty->print("PREFETCHW");
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
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   595
      if (AllocatePrefetchLines > 1) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   596
        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
   597
      } else {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   598
        tty->print_cr(" %d, one line", AllocatePrefetchDistance);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   599
      }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   600
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   601
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   602
    if (PrefetchCopyIntervalInBytes > 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   603
      tty->print_cr("PrefetchCopyIntervalInBytes %d", PrefetchCopyIntervalInBytes);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   604
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   605
    if (PrefetchScanIntervalInBytes > 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   606
      tty->print_cr("PrefetchScanIntervalInBytes %d", PrefetchScanIntervalInBytes);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   607
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   608
    if (PrefetchFieldsAhead > 0) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   609
      tty->print_cr("PrefetchFieldsAhead %d", PrefetchFieldsAhead);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   610
    }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   611
  }
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   612
#endif // !PRODUCT
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   613
}
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   614
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   615
void VM_Version::initialize() {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   616
  ResourceMark rm;
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   617
  // Making this stub must be FIRST use of assembler
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   618
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   619
  stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   620
  if (stub_blob == NULL) {
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   621
    vm_exit_during_initialization("Unable to allocate getPsrInfo_stub");
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   622
  }
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 6272
diff changeset
   623
  CodeBuffer c(stub_blob);
2111
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   624
  VM_Version_StubGenerator g(&c);
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   625
  getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t,
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   626
                                   g.generate_getPsrInfo());
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   627
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   628
  get_processor_features();
dab8a43dd738 6808589: Merge vm_version_x86_{32,64}.{cpp,hpp}
twisti
parents:
diff changeset
   629
}