vm_version_sparc.hpp revision 196:d1605aabd0a1
1169303Spjd/* 2169303Spjd * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 3169303Spjd * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4169303Spjd * 5169303Spjd * This code is free software; you can redistribute it and/or modify it 6169303Spjd * under the terms of the GNU General Public License version 2 only, as 7169303Spjd * published by the Free Software Foundation. 8169303Spjd * 9169303Spjd * This code is distributed in the hope that it will be useful, but WITHOUT 10169303Spjd * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11169303Spjd * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12169303Spjd * version 2 for more details (a copy is included in the LICENSE file that 13169303Spjd * accompanied this code). 14169303Spjd * 15169303Spjd * You should have received a copy of the GNU General Public License version 16169303Spjd * 2 along with this work; if not, write to the Free Software Foundation, 17169303Spjd * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18169303Spjd * 19169303Spjd * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20169303Spjd * CA 95054 USA or visit www.sun.com if you need additional information or 21169303Spjd * have any questions. 22169303Spjd * 23169303Spjd */ 24169303Spjd 25169303Spjdclass VM_Version: public Abstract_VM_Version { 26169303Spjdprotected: 27169303Spjd enum Feature_Flag { 28169303Spjd v8_instructions = 0, 29169303Spjd hardware_int_muldiv = 1, 30169303Spjd hardware_fsmuld = 2, 31169303Spjd v9_instructions = 3, 32169303Spjd vis1_instructions = 4, 33169303Spjd vis2_instructions = 5, 34169303Spjd sun4v_instructions = 6 35169303Spjd }; 36169303Spjd 37169303Spjd enum Feature_Flag_Set { 38169303Spjd unknown_m = 0, 39169303Spjd all_features_m = -1, 40169303Spjd 41169303Spjd v8_instructions_m = 1 << v8_instructions, 42169303Spjd hardware_int_muldiv_m = 1 << hardware_int_muldiv, 43169303Spjd hardware_fsmuld_m = 1 << hardware_fsmuld, 44169303Spjd v9_instructions_m = 1 << v9_instructions, 45169303Spjd vis1_instructions_m = 1 << vis1_instructions, 46169303Spjd vis2_instructions_m = 1 << vis2_instructions, 47169303Spjd sun4v_m = 1 << sun4v_instructions, 48238112Spjd 49169303Spjd generic_v8_m = v8_instructions_m | hardware_int_muldiv_m | hardware_fsmuld_m, 50169303Spjd generic_v9_m = generic_v8_m | v9_instructions_m | vis1_instructions_m, 51169303Spjd ultra3_m = generic_v9_m | vis2_instructions_m, 52169303Spjd 53169303Spjd // Temporary until we have something more accurate 54169303Spjd niagara1_unique_m = sun4v_m, 55169303Spjd niagara1_m = generic_v9_m | niagara1_unique_m 56169303Spjd }; 57169303Spjd 58169303Spjd static int _features; 59169303Spjd static const char* _features_str; 60169303Spjd 61169303Spjd static void print_features(); 62169303Spjd static int determine_features(); 63169303Spjd static int platform_features(int features); 64169303Spjd 65169303Spjd static bool is_niagara1(int features) { return (features & niagara1_m) == niagara1_m; } 66169303Spjd 67169303Spjd static int maximum_niagara1_processor_count() { return 32; } 68169303Spjd // Returns true if the platform is in the niagara line and 69169303Spjd // newer than the niagara1. 70169303Spjd static bool is_niagara1_plus(); 71169303Spjd 72169303Spjdpublic: 73169303Spjd // Initialization 74169303Spjd static void initialize(); 75169303Spjd 76169303Spjd // Instruction support 77169303Spjd static bool has_v8() { return (_features & v8_instructions_m) != 0; } 78169303Spjd static bool has_v9() { return (_features & v9_instructions_m) != 0; } 79169303Spjd static bool has_hardware_int_muldiv() { return (_features & hardware_int_muldiv_m) != 0; } 80169303Spjd static bool has_hardware_fsmuld() { return (_features & hardware_fsmuld_m) != 0; } 81169303Spjd static bool has_vis1() { return (_features & vis1_instructions_m) != 0; } 82169303Spjd static bool has_vis2() { return (_features & vis2_instructions_m) != 0; } 83169303Spjd 84169303Spjd static bool supports_compare_and_exchange() 85169303Spjd { return has_v9(); } 86169303Spjd 87169303Spjd static bool is_ultra3() { return (_features & ultra3_m) == ultra3_m; } 88169303Spjd static bool is_sun4v() { return (_features & sun4v_m) != 0; } 89169303Spjd static bool is_niagara1() { return is_niagara1(_features); } 90169303Spjd 91169303Spjd static bool has_fast_fxtof() { return has_v9() && !is_ultra3(); } 92169303Spjd 93169303Spjd static const char* cpu_features() { return _features_str; } 94169303Spjd 95169303Spjd static intx L1_data_cache_line_size() { 96169303Spjd return 64; // default prefetch block size on sparc 97185174Spjd } 98169303Spjd 99169303Spjd // Prefetch 100169303Spjd static intx prefetch_copy_interval_in_bytes() { 101169303Spjd intx interval = PrefetchCopyIntervalInBytes; 102169303Spjd return interval >= 0 ? interval : (has_v9() ? 512 : 0); 103169303Spjd } 104169303Spjd static intx prefetch_scan_interval_in_bytes() { 105169303Spjd intx interval = PrefetchScanIntervalInBytes; 106169303Spjd return interval >= 0 ? interval : (has_v9() ? 512 : 0); 107169303Spjd } 108169303Spjd static intx prefetch_fields_ahead() { 109169303Spjd intx count = PrefetchFieldsAhead; 110169303Spjd return count >= 0 ? count : (is_ultra3() ? 1 : 0); 111169303Spjd } 112169303Spjd 113169303Spjd static intx allocate_prefetch_distance() { 114169303Spjd // This method should be called before allocate_prefetch_style(). 115169303Spjd intx count = AllocatePrefetchDistance; 116 if (count < 0) { // default is not defined ? 117 count = 512; 118 } 119 return count; 120 } 121 static intx allocate_prefetch_style() { 122 assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive"); 123 // Return 0 if AllocatePrefetchDistance was not defined. 124 return AllocatePrefetchDistance > 0 ? AllocatePrefetchStyle : 0; 125 } 126 127 // Legacy 128 static bool v8_instructions_work() { return has_v8() && !has_v9(); } 129 static bool v9_instructions_work() { return has_v9(); } 130 131 // Assembler testing 132 static void allow_all(); 133 static void revert(); 134 135 // Override the Abstract_VM_Version implementation. 136 static uint page_size_count() { return is_sun4v() ? 4 : 2; } 137 138 // Calculates the number of parallel threads 139 static unsigned int calc_parallel_worker_threads(); 140}; 141