vm_version_arm.hpp revision 12422:98fe046473c9
1/* 2 * Copyright (c) 2008, 2014, Oracle and/or its affiliates. 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#ifndef CPU_ARM_VM_VM_VERSION_ARM_HPP 26#define CPU_ARM_VM_VM_VERSION_ARM_HPP 27 28#include "runtime/globals_extension.hpp" 29#include "runtime/vm_version.hpp" 30 31class VM_Version: public Abstract_VM_Version { 32 friend class JVMCIVMStructs; 33 34 static bool _has_simd; 35 36 protected: 37 // Are we done with vm version initialization 38 static bool _is_initialized; 39 40 public: 41 static void initialize(); 42 static bool is_initialized() { return _is_initialized; } 43 44#ifdef AARCH64 45 46 public: 47 static bool supports_ldrex() { return true; } 48 static bool supports_ldrexd() { return true; } 49 static bool supports_movw() { return true; } 50 51 // Override Abstract_VM_Version implementation 52 static bool use_biased_locking(); 53 54 static bool has_simd() { return _has_simd; } 55 static bool has_vfp() { return has_simd(); } 56 static bool simd_math_is_compliant() { return true; } 57 58 static bool prefer_moves_over_load_literal() { return true; } 59 60#else 61 62 protected: 63 enum Feature_Flag { 64 vfp = 0, 65 vfp3_32 = 1, 66 simd = 2, 67 }; 68 69 enum Feature_Flag_Set { 70 unknown_m = 0, 71 all_features_m = -1, 72 73 vfp_m = 1 << vfp, 74 vfp3_32_m = 1 << vfp3_32, 75 simd_m = 1 << simd, 76 }; 77 78 // The value stored by "STR PC, [addr]" instruction can be either 79 // (address of this instruction + 8) or (address of this instruction + 12) 80 // depending on hardware implementation. 81 // This adjustment is calculated in runtime. 82 static int _stored_pc_adjustment; 83 84 // ARM architecture version: 5 = ARMv5, 6 = ARMv6, 7 = ARMv7 etc. 85 static int _arm_arch; 86 87 // linux kernel atomic helper function version info 88 // __kuser_cmpxchg() if version >= 2 89 // __kuser_cmpxchg64() if version >= 5 90 static int _kuser_helper_version; 91 92#define KUSER_HELPER_VERSION_ADDR 0xffff0ffc 93#define KUSER_VERSION_CMPXCHG32 2 94#define KUSER_VERSION_CMPXCHG64 5 95 96 // Read additional info using OS-specific interfaces 97 static void get_os_cpu_info(); 98 99 public: 100 static void early_initialize(); 101 102 static int arm_arch() { return _arm_arch; } 103 static int stored_pc_adjustment() { return _stored_pc_adjustment; } 104 static bool supports_rev() { return _arm_arch >= 6; } 105 static bool supports_ldrex() { return _arm_arch >= 6; } 106 static bool supports_movw() { return _arm_arch >= 7; } 107 static bool supports_ldrexd() { return _arm_arch >= 7; } 108 static bool supports_compare_and_exchange() { return true; } 109 static bool supports_kuser_cmpxchg32() { return _kuser_helper_version >= KUSER_VERSION_CMPXCHG32; } 110 static bool supports_kuser_cmpxchg64() { return _kuser_helper_version >= KUSER_VERSION_CMPXCHG64; } 111 // Override Abstract_VM_Version implementation 112 static bool use_biased_locking(); 113 static const char* vm_info_string(); 114 115 static bool has_vfp() { return (_features & vfp_m) != 0; } 116 static bool has_vfp3_32() { return (_features & vfp3_32_m) != 0; } 117 static bool has_simd() { return (_features & simd_m) != 0; } 118 119 static bool simd_math_is_compliant() { return false; } 120 121 static bool prefer_moves_over_load_literal() { return supports_movw(); } 122 123 friend class VM_Version_StubGenerator; 124 125#endif // AARCH64 126}; 127 128#endif // CPU_ARM_VM_VM_VERSION_ARM_HPP 129