hotspot/src/cpu/x86/vm/vm_version_x86_32.cpp
author xlu
Wed, 24 Dec 2008 13:06:09 -0800
changeset 1888 bbf498fb4354
parent 1437 d1846c1c04c4
permissions -rw-r--r--
6787106: Hotspot 32 bit build fails on platforms having different definitions for intptr_t & int32_t Summary: Avoid casting between int32_t and intptr_t specifically for MasmAssembler::movptr in 32 bit platforms. Reviewed-by: jrose, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
670
ddf3e9583f2f 6719955: Update copyright year
xdono
parents: 244
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_vm_version_x86_32.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
int VM_Version::_cpu;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
int VM_Version::_model;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
int VM_Version::_stepping;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
int VM_Version::_cpuFeatures;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
const char*           VM_Version::_features_str = "";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
VM_Version::CpuidInfo VM_Version::_cpuid_info   = { 0, };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
static BufferBlob* stub_blob;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
static const int stub_size = 300;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
extern "C" {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  typedef void (*getPsrInfo_stub_t)(void*);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
static getPsrInfo_stub_t getPsrInfo_stub = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class VM_Version_StubGenerator: public StubCodeGenerator {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  VM_Version_StubGenerator(CodeBuffer *c) : StubCodeGenerator(c) {}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  address generate_getPsrInfo() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    // Flags to test CPU type.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    const uint32_t EFL_AC           = 0x40000;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    const uint32_t EFL_ID           = 0x200000;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    // Values for when we don't have a CPUID instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    const int      CPU_FAMILY_SHIFT = 8;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    const uint32_t CPU_FAMILY_386   = (3 << CPU_FAMILY_SHIFT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    const uint32_t CPU_FAMILY_486   = (4 << CPU_FAMILY_SHIFT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    Label detect_486, cpu486, detect_586, std_cpuid1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    Label ext_cpuid1, ext_cpuid5, done;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
    StubCodeMark mark(this, "VM_Version", "getPsrInfo_stub");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
#   define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
    address start = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    //
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    70
    __ push(rbp);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    71
    __ movptr(rbp, Address(rsp, 8)); // cpuid_info address
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    72
    __ push(rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    73
    __ push(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    74
    __ pushf();          // preserve rbx, and flags
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    75
    __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    76
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    77
    __ mov(rcx, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    // if we are unable to change the AC flag, we have a 386
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    __ xorl(rax, EFL_AC);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    82
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    83
    __ popf();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    84
    __ pushf();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    85
    __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    86
    __ cmpptr(rax, rcx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    __ jccb(Assembler::notEqual, detect_486);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    __ movl(rax, CPU_FAMILY_386);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    __ jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
    // If we are unable to change the ID flag, we have a 486 which does
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    // not support the "cpuid" instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    __ bind(detect_486);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
    98
    __ mov(rax, rcx);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
    __ xorl(rax, EFL_ID);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   100
    __ push(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   101
    __ popf();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   102
    __ pushf();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   103
    __ pop(rax);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   104
    __ cmpptr(rcx, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
    __ jccb(Assembler::notEqual, detect_586);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    __ bind(cpu486);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
    __ movl(rax, CPU_FAMILY_486);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    __ movl(Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
    __ jmp(done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    // at this point, we have a chip which supports the "cpuid" instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    __ bind(detect_586);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   116
    __ xorptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    __ cpuid();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   118
    __ orptr(rax, rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    __ jcc(Assembler::equal, cpu486);   // if cpuid doesn't support an input
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
                                        // value of at least 1, we give up and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
                                        // assume a 486
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   122
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid0_offset())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    __ movl(Address(rsi, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    __ movl(Address(rsi, 4), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    __ movl(Address(rsi, 8), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    __ movl(Address(rsi,12), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    __ cmpl(rax, 3);     // Is cpuid(0x4) supported?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    __ jccb(Assembler::belowEqual, std_cpuid1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
    // cpuid(0x4) Deterministic cache params
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
    __ movl(rax, 4);     // and rcx already set to 0x0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
    __ xorl(rcx, rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    __ cpuid();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   137
    __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
    __ andl(rax, 0x1f);  // Determine if valid cache parameters used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
    __ orl(rax, rax);    // rax,[4:0] == 0 indicates invalid cache
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   140
    __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
    __ jccb(Assembler::equal, std_cpuid1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   143
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::dcp_cpuid4_offset())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
    __ movl(Address(rsi, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
    __ movl(Address(rsi, 4), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    __ movl(Address(rsi, 8), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
    __ movl(Address(rsi,12), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
    // Standard cpuid(0x1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
    __ bind(std_cpuid1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    __ movl(rax, 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
    __ cpuid();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   155
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::std_cpuid1_offset())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
    __ movl(Address(rsi, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    __ movl(Address(rsi, 4), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    __ movl(Address(rsi, 8), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    __ movl(Address(rsi,12), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    __ movl(rax, 0x80000000);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
    __ cpuid();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    __ cmpl(rax, 0x80000000);     // Is cpuid(0x80000001) supported?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    __ jcc(Assembler::belowEqual, done);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    __ cmpl(rax, 0x80000004);     // Is cpuid(0x80000005) supported?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
    __ jccb(Assembler::belowEqual, ext_cpuid1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    __ cmpl(rax, 0x80000007);     // Is cpuid(0x80000008) supported?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    __ jccb(Assembler::belowEqual, ext_cpuid5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    // Extended cpuid(0x80000008)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    __ movl(rax, 0x80000008);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    __ cpuid();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   174
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid8_offset())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    __ movl(Address(rsi, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    __ movl(Address(rsi, 4), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
    __ movl(Address(rsi, 8), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    __ movl(Address(rsi,12), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    // Extended cpuid(0x80000005)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
    __ bind(ext_cpuid5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
    __ movl(rax, 0x80000005);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
    __ cpuid();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   186
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid5_offset())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    __ movl(Address(rsi, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    __ movl(Address(rsi, 4), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    __ movl(Address(rsi, 8), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    __ movl(Address(rsi,12), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    // Extended cpuid(0x80000001)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    __ bind(ext_cpuid1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    __ movl(rax, 0x80000001);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    __ cpuid();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   198
    __ lea(rsi, Address(rbp, in_bytes(VM_Version::ext_cpuid1_offset())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    __ movl(Address(rsi, 0), rax);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    __ movl(Address(rsi, 4), rbx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    __ movl(Address(rsi, 8), rcx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    __ movl(Address(rsi,12), rdx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    // return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
    __ bind(done);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   208
    __ popf();
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   209
    __ pop(rsi);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   210
    __ pop(rbx);
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 781
diff changeset
   211
    __ pop(rbp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
    __ ret(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
#   undef __
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
    return start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
void VM_Version::get_processor_features() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  _cpu = 4; // 486 by default
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  _model = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  _stepping = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  _cpuFeatures = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  _logical_processors_per_package = 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  if (!Use486InstrsOnly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
    // Get raw processor info
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
    getPsrInfo_stub(&_cpuid_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    assert_is_initialized();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    _cpu = extended_cpu_family();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    _model = extended_cpu_model();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    _stepping = cpu_stepping();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    if (cpu_family() > 4) { // it supports CPUID
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      _cpuFeatures = feature_flags();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
      // Logical processors are only available on P4s and above,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
      // and only if hyperthreading is available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
      _logical_processors_per_package = logical_processor_count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  _supports_cx8 = supports_cmpxchg8();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // if the OS doesn't support SSE, we can't use this feature even if the HW does
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  if( !os::supports_sse())
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   245
    _cpuFeatures &= ~(CPU_SSE|CPU_SSE2|CPU_SSE3|CPU_SSSE3|CPU_SSE4A|CPU_SSE4_1|CPU_SSE4_2);
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   246
  if (UseSSE < 4) {
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   247
    _cpuFeatures &= ~CPU_SSE4_1;
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   248
    _cpuFeatures &= ~CPU_SSE4_2;
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   249
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  if (UseSSE < 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
    _cpuFeatures &= ~CPU_SSE3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    _cpuFeatures &= ~CPU_SSSE3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    _cpuFeatures &= ~CPU_SSE4A;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  if (UseSSE < 2)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
    _cpuFeatures &= ~CPU_SSE2;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  if (UseSSE < 1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    _cpuFeatures &= ~CPU_SSE;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  if (logical_processors_per_package() == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
    // HT processor could be installed on a system which doesn't support HT.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
    _cpuFeatures &= ~CPU_HT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  char buf[256];
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   266
  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",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
               cores_per_cpu(), threads_per_core(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
               cpu_family(), _model, _stepping,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
               (supports_cmov() ? ", cmov" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
               (supports_cmpxchg8() ? ", cx8" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
               (supports_fxsr() ? ", fxsr" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
               (supports_mmx()  ? ", mmx"  : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
               (supports_sse()  ? ", sse"  : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
               (supports_sse2() ? ", sse2" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
               (supports_sse3() ? ", sse3" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
               (supports_ssse3()? ", ssse3": ""),
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   277
               (supports_sse4_1() ? ", sse4.1" : ""),
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   278
               (supports_sse4_2() ? ", sse4.2" : ""),
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
               (supports_mmx_ext() ? ", mmxext" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
               (supports_3dnow()   ? ", 3dnow"  : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
               (supports_3dnow2()  ? ", 3dnowext" : ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
               (supports_sse4a()   ? ", sse4a": ""),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
               (supports_ht() ? ", ht": ""));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  _features_str = strdup(buf);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // UseSSE is set to the smaller of what hardware supports and what
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // the command line requires.  I.e., you cannot set UseSSE to 2 on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // older Pentiums which do not support it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  if( UseSSE > 4 ) UseSSE=4;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  if( UseSSE < 0 ) UseSSE=0;
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   291
  if( !supports_sse4_1() ) // Drop to 3 if no SSE4 support
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
    UseSSE = MIN2((intx)3,UseSSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  if( !supports_sse3() ) // Drop to 2 if no SSE3 support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
    UseSSE = MIN2((intx)2,UseSSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  if( !supports_sse2() ) // Drop to 1 if no SSE2 support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
    UseSSE = MIN2((intx)1,UseSSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  if( !supports_sse () ) // Drop to 0 if no SSE  support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
    UseSSE = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // On new cpus instructions which update whole XMM register should be used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // to prevent partial register stall due to dependencies on high half.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // UseXmmLoadAndClearUpper == true  --> movsd(xmm, mem)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // UseXmmLoadAndClearUpper == false --> movlpd(xmm, mem)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  // UseXmmRegToRegMoveAll == true  --> movaps(xmm, xmm), movapd(xmm, xmm).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm),  movsd(xmm, xmm).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  if( is_amd() ) { // AMD cpus specific settings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      // Use it on new AMD cpus starting from Opteron.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      UseAddressNop = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
    }
765
e0692d3d8863 6708714: Optimize long LShift on 32-bits x86
kvn
parents: 244
diff changeset
   313
    if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) {
e0692d3d8863 6708714: Optimize long LShift on 32-bits x86
kvn
parents: 244
diff changeset
   314
      // Use it on new AMD cpus starting from Opteron.
e0692d3d8863 6708714: Optimize long LShift on 32-bits x86
kvn
parents: 244
diff changeset
   315
      UseNewLongLShift = true;
e0692d3d8863 6708714: Optimize long LShift on 32-bits x86
kvn
parents: 244
diff changeset
   316
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
      if( supports_sse4a() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
        UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
        UseXmmLoadAndClearUpper = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
      if( supports_sse4a() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
        UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        UseXmmRegToRegMoveAll = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    }
244
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   331
    if( FLAG_IS_DEFAULT(UseXmmI2F) ) {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   332
      if( supports_sse4a() ) {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   333
        UseXmmI2F = true;
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   334
      } else {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   335
        UseXmmI2F = false;
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   336
      }
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   337
    }
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   338
    if( FLAG_IS_DEFAULT(UseXmmI2D) ) {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   339
      if( supports_sse4a() ) {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   340
        UseXmmI2D = true;
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   341
      } else {
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   342
        UseXmmI2D = false;
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   343
      }
c8ad6f221400 6662967: Optimize I2D conversion on new x86
kvn
parents: 1
diff changeset
   344
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  if( is_intel() ) { // Intel cpus specific settings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    if( FLAG_IS_DEFAULT(UseStoreImmI16) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
      UseStoreImmI16 = false; // don't use it on Intel cpus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    if( cpu_family() == 6 || cpu_family() == 15 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      if( FLAG_IS_DEFAULT(UseAddressNop) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
        // Use it on all Intel cpus starting from PentiumPro
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
        UseAddressNop = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
      UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
      if( supports_sse3() ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
        UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
        UseXmmRegToRegMoveAll = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
    if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
#ifdef COMPILER2
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
      if( FLAG_IS_DEFAULT(MaxLoopPad) ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
        // For new Intel cpus do the next optimization:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
        // don't align the beginning of a loop if there are enough instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
        // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
        // in current fetch line (OptoLoopAlignment) or the padding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
        // is big (> MaxLoopPad).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
        // Set MaxLoopPad to 11 for new Intel cpus to reduce number of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
        // generated NOP instructions. 11 is the largest size of one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
        // address NOP instruction '0F 1F' (see Assembler::nop(i)).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
        MaxLoopPad = 11;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
#endif // COMPILER2
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   381
      if( FLAG_IS_DEFAULT(UseXMMForArrayCopy) ) {
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   382
        UseXMMForArrayCopy = true; // use SSE2 movq on new Intel cpus
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   383
      }
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   384
      if( supports_sse4_2() && supports_ht() ) { // Newest Intel cpus
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   385
        if( FLAG_IS_DEFAULT(UseUnalignedLoadStores) && UseXMMForArrayCopy ) {
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   386
          UseUnalignedLoadStores = true; // use movdqu on newest Intel cpus
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   387
        }
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   388
      }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  assert(0 <= ReadPrefetchInstr && ReadPrefetchInstr <= 3, "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  assert(0 <= AllocatePrefetchInstr && AllocatePrefetchInstr <= 3, "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  // set valid Prefetch instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  if( ReadPrefetchInstr < 0 ) ReadPrefetchInstr = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  if( ReadPrefetchInstr > 3 ) ReadPrefetchInstr = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  if( ReadPrefetchInstr == 3 && !supports_3dnow() ) ReadPrefetchInstr = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  if( !supports_sse() && supports_3dnow() ) ReadPrefetchInstr = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  if( AllocatePrefetchInstr < 0 ) AllocatePrefetchInstr = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  if( AllocatePrefetchInstr > 3 ) AllocatePrefetchInstr = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  if( AllocatePrefetchInstr == 3 && !supports_3dnow() ) AllocatePrefetchInstr=0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  if( !supports_sse() && supports_3dnow() ) AllocatePrefetchInstr = 3;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // Allocation prefetch settings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  intx cache_line_size = L1_data_cache_line_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  if( cache_line_size > AllocatePrefetchStepSize )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
    AllocatePrefetchStepSize = cache_line_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  if( FLAG_IS_DEFAULT(AllocatePrefetchLines) )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    AllocatePrefetchLines = 3; // Optimistic value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  assert(AllocatePrefetchLines > 0, "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  if( AllocatePrefetchLines < 1 ) // set valid value in product VM
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    AllocatePrefetchLines = 1; // Conservative value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  AllocatePrefetchDistance = allocate_prefetch_distance();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  AllocatePrefetchStyle    = allocate_prefetch_style();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  if( AllocatePrefetchStyle == 2 && is_intel() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
      cpu_family() == 6 && supports_sse3() ) { // watermark prefetching on Core
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    AllocatePrefetchDistance = 320;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  assert(AllocatePrefetchDistance % AllocatePrefetchStepSize == 0, "invalid value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  if (PrintMiscellaneous && Verbose) {
1437
d1846c1c04c4 6532536: Optimize arraycopy stubs for Intel cpus
kvn
parents: 1066
diff changeset
   427
    tty->print_cr("Logical CPUs per core: %u",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
                  logical_processors_per_package());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
    tty->print_cr("UseSSE=%d",UseSSE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    tty->print("Allocation: ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    if (AllocatePrefetchStyle <= 0 || UseSSE == 0 && !supports_3dnow()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      tty->print_cr("no prefetching");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
      if (UseSSE == 0 && supports_3dnow()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
        tty->print("PREFETCHW");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
      } else if (UseSSE >= 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
        if (AllocatePrefetchInstr == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
          tty->print("PREFETCHNTA");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
        } else if (AllocatePrefetchInstr == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
          tty->print("PREFETCHT0");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
        } else if (AllocatePrefetchInstr == 2) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
          tty->print("PREFETCHT2");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
        } else if (AllocatePrefetchInstr == 3) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
          tty->print("PREFETCHW");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      if (AllocatePrefetchLines > 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
        tty->print_cr(" %d, %d lines with step %d bytes", AllocatePrefetchDistance, AllocatePrefetchLines, AllocatePrefetchStepSize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
        tty->print_cr(" %d, one line", AllocatePrefetchDistance);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
#endif // !PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
void VM_Version::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Making this stub must be FIRST use of assembler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  stub_blob = BufferBlob::create("getPsrInfo_stub", stub_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  if (stub_blob == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    vm_exit_during_initialization("Unable to allocate getPsrInfo_stub");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  CodeBuffer c(stub_blob->instructions_begin(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
               stub_blob->instructions_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  VM_Version_StubGenerator g(&c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  getPsrInfo_stub = CAST_TO_FN_PTR(getPsrInfo_stub_t,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
                                   g.generate_getPsrInfo());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  get_processor_features();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
}