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