jdk

Форк
0
/
vm_version_windows_aarch64.cpp 
106 строк · 3.8 Кб
1
/*
2
 * Copyright (c) 2020, 2021, Microsoft Corporation. All rights reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.
8
 *
9
 * This code is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 * version 2 for more details (a copy is included in the LICENSE file that
13
 * accompanied this code).
14
 *
15
 * You should have received a copy of the GNU General Public License version
16
 * 2 along with this work; if not, write to the Free Software Foundation,
17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
 *
19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
 * or visit www.oracle.com if you need additional information or have any
21
 * questions.
22
 *
23
 */
24

25
#include "precompiled.hpp"
26
#include "logging/log.hpp"
27
#include "runtime/os.hpp"
28
#include "runtime/vm_version.hpp"
29

30
int VM_Version::get_current_sve_vector_length() {
31
  assert(_features & CPU_SVE, "should not call this");
32
  ShouldNotReachHere();
33
  return 0;
34
}
35

36
int VM_Version::set_and_get_current_sve_vector_length(int length) {
37
  assert(_features & CPU_SVE, "should not call this");
38
  ShouldNotReachHere();
39
  return 0;
40
}
41

42
void VM_Version::get_os_cpu_info() {
43

44
  if (IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE))   _features |= CPU_CRC32;
45
  if (IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE))  _features |= CPU_AES | CPU_SHA1 | CPU_SHA2;
46
  if (IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE))        _features |= CPU_ASIMD;
47
  // No check for CPU_PMULL, CPU_SVE, CPU_SVE2
48

49
  __int64 dczid_el0 = _ReadStatusReg(0x5807 /* ARM64_DCZID_EL0 */);
50

51
  if (!(dczid_el0 & 0x10)) {
52
    _zva_length = 4 << (dczid_el0 & 0xf);
53
  }
54

55
  {
56
    PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = nullptr;
57
    DWORD returnLength = 0;
58

59
    // See https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getlogicalprocessorinformation
60
    GetLogicalProcessorInformation(nullptr, &returnLength);
61
    assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Unexpected return from GetLogicalProcessorInformation");
62

63
    buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)os::malloc(returnLength, mtInternal);
64
    BOOL rc = GetLogicalProcessorInformation(buffer, &returnLength);
65
    assert(rc, "Unexpected return from GetLogicalProcessorInformation");
66

67
    _icache_line_size = _dcache_line_size = -1;
68
    for (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION ptr = buffer; ptr < buffer + returnLength / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); ptr++) {
69
      switch (ptr->Relationship) {
70
      case RelationCache:
71
        // Cache data is in ptr->Cache, one CACHE_DESCRIPTOR structure for each cache.
72
        PCACHE_DESCRIPTOR Cache = &ptr->Cache;
73
        if (Cache->Level == 1) {
74
            _icache_line_size = _dcache_line_size = Cache->LineSize;
75
        }
76
        break;
77
      }
78
    }
79
    os::free(buffer);
80
  }
81

82
  {
83
    char* buf = ::getenv("PROCESSOR_IDENTIFIER");
84
    if (buf && strstr(buf, "Ampere(TM)") != nullptr) {
85
      _cpu = CPU_AMCC;
86
    } else if (buf && strstr(buf, "Cavium Inc.") != nullptr) {
87
      _cpu = CPU_CAVIUM;
88
    } else {
89
      log_info(os)("VM_Version: unknown CPU model");
90
    }
91

92
    if (_cpu) {
93
      SYSTEM_INFO si;
94
      GetSystemInfo(&si);
95
      _model = si.wProcessorLevel;
96
      _variant = si.wProcessorRevision / 0xFF;
97
      _revision = si.wProcessorRevision & 0xFF;
98
    }
99
  }
100
}
101

102
void VM_Version::get_compatible_board(char *buf, int buflen) {
103
  assert(buf != nullptr, "invalid argument");
104
  assert(buflen >= 1, "invalid argument");
105
  *buf = '\0';
106
}
107

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.