Mon, 30 Jun 2014 14:58:52 -0400
8048169: Change 8037816 breaks HS build on PPC64 and CPP-Interpreter platforms
Summary: Fix the matching of format string parameter types to the actual argument types for the PPC64 and CPP-Interpreter files in the same way as 8037816 already did it for all the other files
Reviewed-by: stefank, coleenp, dholmes
goetz@6458 | 1 | /* |
drchase@6680 | 2 | * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
goetz@6515 | 3 | * Copyright 2012, 2014 SAP AG. All rights reserved. |
goetz@6458 | 4 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
goetz@6458 | 5 | * |
goetz@6458 | 6 | * This code is free software; you can redistribute it and/or modify it |
goetz@6458 | 7 | * under the terms of the GNU General Public License version 2 only, as |
goetz@6458 | 8 | * published by the Free Software Foundation. |
goetz@6458 | 9 | * |
goetz@6458 | 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
goetz@6458 | 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
goetz@6458 | 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
goetz@6458 | 13 | * version 2 for more details (a copy is included in the LICENSE file that |
goetz@6458 | 14 | * accompanied this code). |
goetz@6458 | 15 | * |
goetz@6458 | 16 | * You should have received a copy of the GNU General Public License version |
goetz@6458 | 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
goetz@6458 | 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
goetz@6458 | 19 | * |
goetz@6458 | 20 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
goetz@6458 | 21 | * or visit www.oracle.com if you need additional information or have any |
goetz@6458 | 22 | * questions. |
goetz@6458 | 23 | * |
goetz@6458 | 24 | */ |
goetz@6458 | 25 | |
goetz@6458 | 26 | #include "precompiled.hpp" |
goetz@6511 | 27 | #include "asm/assembler.inline.hpp" |
goetz@6511 | 28 | #include "asm/macroAssembler.inline.hpp" |
goetz@6458 | 29 | #include "compiler/disassembler.hpp" |
goetz@6458 | 30 | #include "memory/resourceArea.hpp" |
goetz@6458 | 31 | #include "runtime/java.hpp" |
goetz@6458 | 32 | #include "runtime/stubCodeGenerator.hpp" |
goetz@6458 | 33 | #include "utilities/defaultStream.hpp" |
goetz@6458 | 34 | #include "vm_version_ppc.hpp" |
goetz@6458 | 35 | #ifdef TARGET_OS_FAMILY_aix |
goetz@6458 | 36 | # include "os_aix.inline.hpp" |
goetz@6458 | 37 | #endif |
goetz@6458 | 38 | #ifdef TARGET_OS_FAMILY_linux |
goetz@6458 | 39 | # include "os_linux.inline.hpp" |
goetz@6458 | 40 | #endif |
goetz@6458 | 41 | |
goetz@6458 | 42 | # include <sys/sysinfo.h> |
goetz@6458 | 43 | |
goetz@6458 | 44 | int VM_Version::_features = VM_Version::unknown_m; |
goetz@6458 | 45 | int VM_Version::_measured_cache_line_size = 128; // default value |
goetz@6458 | 46 | const char* VM_Version::_features_str = ""; |
goetz@6458 | 47 | bool VM_Version::_is_determine_features_test_running = false; |
goetz@6458 | 48 | |
goetz@6458 | 49 | |
goetz@6458 | 50 | #define MSG(flag) \ |
goetz@6458 | 51 | if (flag && !FLAG_IS_DEFAULT(flag)) \ |
goetz@6458 | 52 | jio_fprintf(defaultStream::error_stream(), \ |
goetz@6458 | 53 | "warning: -XX:+" #flag " requires -XX:+UseSIGTRAP\n" \ |
goetz@6458 | 54 | " -XX:+" #flag " will be disabled!\n"); |
goetz@6458 | 55 | |
goetz@6458 | 56 | void VM_Version::initialize() { |
goetz@6458 | 57 | |
goetz@6458 | 58 | // Test which instructions are supported and measure cache line size. |
goetz@6458 | 59 | determine_features(); |
goetz@6458 | 60 | |
goetz@6458 | 61 | // If PowerArchitecturePPC64 hasn't been specified explicitly determine from features. |
goetz@6458 | 62 | if (FLAG_IS_DEFAULT(PowerArchitecturePPC64)) { |
goetz@6458 | 63 | if (VM_Version::has_popcntw()) { |
goetz@6458 | 64 | FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 7); |
goetz@6458 | 65 | } else if (VM_Version::has_cmpb()) { |
goetz@6458 | 66 | FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 6); |
goetz@6458 | 67 | } else if (VM_Version::has_popcntb()) { |
goetz@6458 | 68 | FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 5); |
goetz@6458 | 69 | } else { |
goetz@6458 | 70 | FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 0); |
goetz@6458 | 71 | } |
goetz@6458 | 72 | } |
goetz@6458 | 73 | guarantee(PowerArchitecturePPC64 == 0 || PowerArchitecturePPC64 == 5 || |
goetz@6458 | 74 | PowerArchitecturePPC64 == 6 || PowerArchitecturePPC64 == 7, |
goetz@6458 | 75 | "PowerArchitecturePPC64 should be 0, 5, 6 or 7"); |
goetz@6458 | 76 | |
goetz@6458 | 77 | if (!UseSIGTRAP) { |
goetz@6458 | 78 | MSG(TrapBasedICMissChecks); |
goetz@6458 | 79 | MSG(TrapBasedNotEntrantChecks); |
goetz@6458 | 80 | MSG(TrapBasedNullChecks); |
goetz@6458 | 81 | FLAG_SET_ERGO(bool, TrapBasedNotEntrantChecks, false); |
goetz@6458 | 82 | FLAG_SET_ERGO(bool, TrapBasedNullChecks, false); |
goetz@6458 | 83 | FLAG_SET_ERGO(bool, TrapBasedICMissChecks, false); |
goetz@6458 | 84 | } |
goetz@6458 | 85 | |
goetz@6458 | 86 | #ifdef COMPILER2 |
goetz@6490 | 87 | if (!UseSIGTRAP) { |
goetz@6490 | 88 | MSG(TrapBasedRangeChecks); |
goetz@6490 | 89 | FLAG_SET_ERGO(bool, TrapBasedRangeChecks, false); |
goetz@6490 | 90 | } |
goetz@6490 | 91 | |
goetz@6458 | 92 | // On Power6 test for section size. |
goetz@6495 | 93 | if (PowerArchitecturePPC64 == 6) { |
goetz@6458 | 94 | determine_section_size(); |
goetz@6495 | 95 | // TODO: PPC port } else { |
goetz@6458 | 96 | // TODO: PPC port PdScheduling::power6SectorSize = 0x20; |
goetz@6495 | 97 | } |
goetz@6458 | 98 | |
goetz@6458 | 99 | MaxVectorSize = 8; |
goetz@6458 | 100 | #endif |
goetz@6458 | 101 | |
goetz@6458 | 102 | // Create and print feature-string. |
goetz@6495 | 103 | char buf[(num_features+1) * 16]; // Max 16 chars per feature. |
goetz@6458 | 104 | jio_snprintf(buf, sizeof(buf), |
goetz@6458 | 105 | "ppc64%s%s%s%s%s%s%s%s", |
goetz@6458 | 106 | (has_fsqrt() ? " fsqrt" : ""), |
goetz@6458 | 107 | (has_isel() ? " isel" : ""), |
goetz@6458 | 108 | (has_lxarxeh() ? " lxarxeh" : ""), |
goetz@6458 | 109 | (has_cmpb() ? " cmpb" : ""), |
goetz@6458 | 110 | //(has_mftgpr()? " mftgpr" : ""), |
goetz@6458 | 111 | (has_popcntb() ? " popcntb" : ""), |
goetz@6458 | 112 | (has_popcntw() ? " popcntw" : ""), |
goetz@6458 | 113 | (has_fcfids() ? " fcfids" : ""), |
goetz@6458 | 114 | (has_vand() ? " vand" : "") |
goetz@6458 | 115 | // Make sure number of %s matches num_features! |
goetz@6458 | 116 | ); |
goetz@6458 | 117 | _features_str = strdup(buf); |
goetz@6458 | 118 | NOT_PRODUCT(if (Verbose) print_features();); |
goetz@6458 | 119 | |
goetz@6458 | 120 | // PPC64 supports 8-byte compare-exchange operations (see |
goetz@6458 | 121 | // Atomic::cmpxchg and StubGenerator::generate_atomic_cmpxchg_ptr) |
goetz@6458 | 122 | // and 'atomic long memory ops' (see Unsafe_GetLongVolatile). |
goetz@6458 | 123 | _supports_cx8 = true; |
goetz@6458 | 124 | |
goetz@6458 | 125 | UseSSE = 0; // Only on x86 and x64 |
goetz@6458 | 126 | |
goetz@6458 | 127 | intx cache_line_size = _measured_cache_line_size; |
goetz@6458 | 128 | |
goetz@6458 | 129 | if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) AllocatePrefetchStyle = 1; |
goetz@6458 | 130 | |
goetz@6458 | 131 | if (AllocatePrefetchStyle == 4) { |
goetz@6495 | 132 | AllocatePrefetchStepSize = cache_line_size; // Need exact value. |
goetz@6495 | 133 | if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) AllocatePrefetchLines = 12; // Use larger blocks by default. |
goetz@6495 | 134 | if (AllocatePrefetchDistance < 0) AllocatePrefetchDistance = 2*cache_line_size; // Default is not defined? |
goetz@6458 | 135 | } else { |
goetz@6458 | 136 | if (cache_line_size > AllocatePrefetchStepSize) AllocatePrefetchStepSize = cache_line_size; |
goetz@6495 | 137 | if (FLAG_IS_DEFAULT(AllocatePrefetchLines)) AllocatePrefetchLines = 3; // Optimistic value. |
goetz@6495 | 138 | if (AllocatePrefetchDistance < 0) AllocatePrefetchDistance = 3*cache_line_size; // Default is not defined? |
goetz@6458 | 139 | } |
goetz@6458 | 140 | |
goetz@6458 | 141 | assert(AllocatePrefetchLines > 0, "invalid value"); |
goetz@6458 | 142 | if (AllocatePrefetchLines < 1) // Set valid value in product VM. |
goetz@6495 | 143 | AllocatePrefetchLines = 1; // Conservative value. |
goetz@6458 | 144 | |
goetz@6458 | 145 | if (AllocatePrefetchStyle == 3 && AllocatePrefetchDistance < cache_line_size) |
goetz@6495 | 146 | AllocatePrefetchStyle = 1; // Fall back if inappropriate. |
goetz@6458 | 147 | |
goetz@6458 | 148 | assert(AllocatePrefetchStyle >= 0, "AllocatePrefetchStyle should be positive"); |
goetz@6458 | 149 | } |
goetz@6458 | 150 | |
goetz@6458 | 151 | void VM_Version::print_features() { |
drchase@6680 | 152 | tty->print_cr("Version: %s cache_line_size = %d", cpu_features(), (int) get_cache_line_size()); |
goetz@6458 | 153 | } |
goetz@6458 | 154 | |
goetz@6458 | 155 | #ifdef COMPILER2 |
goetz@6458 | 156 | // Determine section size on power6: If section size is 8 instructions, |
goetz@6458 | 157 | // there should be a difference between the two testloops of ~15 %. If |
goetz@6458 | 158 | // no difference is detected the section is assumed to be 32 instructions. |
goetz@6458 | 159 | void VM_Version::determine_section_size() { |
goetz@6458 | 160 | |
goetz@6458 | 161 | int unroll = 80; |
goetz@6458 | 162 | |
goetz@6458 | 163 | const int code_size = (2* unroll * 32 + 100)*BytesPerInstWord; |
goetz@6458 | 164 | |
goetz@6495 | 165 | // Allocate space for the code. |
goetz@6458 | 166 | ResourceMark rm; |
goetz@6458 | 167 | CodeBuffer cb("detect_section_size", code_size, 0); |
goetz@6458 | 168 | MacroAssembler* a = new MacroAssembler(&cb); |
goetz@6458 | 169 | |
goetz@6458 | 170 | uint32_t *code = (uint32_t *)a->pc(); |
goetz@6495 | 171 | // Emit code. |
goetz@6511 | 172 | void (*test1)() = (void(*)())(void *)a->function_entry(); |
goetz@6458 | 173 | |
goetz@6458 | 174 | Label l1; |
goetz@6458 | 175 | |
goetz@6458 | 176 | a->li(R4, 1); |
goetz@6458 | 177 | a->sldi(R4, R4, 28); |
goetz@6458 | 178 | a->b(l1); |
goetz@6458 | 179 | a->align(CodeEntryAlignment); |
goetz@6458 | 180 | |
goetz@6458 | 181 | a->bind(l1); |
goetz@6458 | 182 | |
goetz@6458 | 183 | for (int i = 0; i < unroll; i++) { |
goetz@6458 | 184 | // Schleife 1 |
goetz@6458 | 185 | // ------- sector 0 ------------ |
goetz@6458 | 186 | // ;; 0 |
goetz@6458 | 187 | a->nop(); // 1 |
goetz@6458 | 188 | a->fpnop0(); // 2 |
goetz@6458 | 189 | a->fpnop1(); // 3 |
goetz@6458 | 190 | a->addi(R4,R4, -1); // 4 |
goetz@6458 | 191 | |
goetz@6458 | 192 | // ;; 1 |
goetz@6458 | 193 | a->nop(); // 5 |
goetz@6495 | 194 | a->fmr(F6, F6); // 6 |
goetz@6495 | 195 | a->fmr(F7, F7); // 7 |
goetz@6458 | 196 | a->endgroup(); // 8 |
goetz@6458 | 197 | // ------- sector 8 ------------ |
goetz@6458 | 198 | |
goetz@6458 | 199 | // ;; 2 |
goetz@6458 | 200 | a->nop(); // 9 |
goetz@6458 | 201 | a->nop(); // 10 |
goetz@6495 | 202 | a->fmr(F8, F8); // 11 |
goetz@6495 | 203 | a->fmr(F9, F9); // 12 |
goetz@6458 | 204 | |
goetz@6458 | 205 | // ;; 3 |
goetz@6458 | 206 | a->nop(); // 13 |
goetz@6495 | 207 | a->fmr(F10, F10); // 14 |
goetz@6495 | 208 | a->fmr(F11, F11); // 15 |
goetz@6458 | 209 | a->endgroup(); // 16 |
goetz@6458 | 210 | // -------- sector 16 ------------- |
goetz@6458 | 211 | |
goetz@6458 | 212 | // ;; 4 |
goetz@6458 | 213 | a->nop(); // 17 |
goetz@6458 | 214 | a->nop(); // 18 |
goetz@6495 | 215 | a->fmr(F15, F15); // 19 |
goetz@6495 | 216 | a->fmr(F16, F16); // 20 |
goetz@6458 | 217 | |
goetz@6458 | 218 | // ;; 5 |
goetz@6458 | 219 | a->nop(); // 21 |
goetz@6495 | 220 | a->fmr(F17, F17); // 22 |
goetz@6495 | 221 | a->fmr(F18, F18); // 23 |
goetz@6458 | 222 | a->endgroup(); // 24 |
goetz@6458 | 223 | // ------- sector 24 ------------ |
goetz@6458 | 224 | |
goetz@6458 | 225 | // ;; 6 |
goetz@6458 | 226 | a->nop(); // 25 |
goetz@6458 | 227 | a->nop(); // 26 |
goetz@6495 | 228 | a->fmr(F19, F19); // 27 |
goetz@6495 | 229 | a->fmr(F20, F20); // 28 |
goetz@6458 | 230 | |
goetz@6458 | 231 | // ;; 7 |
goetz@6458 | 232 | a->nop(); // 29 |
goetz@6495 | 233 | a->fmr(F21, F21); // 30 |
goetz@6495 | 234 | a->fmr(F22, F22); // 31 |
goetz@6458 | 235 | a->brnop0(); // 32 |
goetz@6458 | 236 | |
goetz@6458 | 237 | // ------- sector 32 ------------ |
goetz@6458 | 238 | } |
goetz@6458 | 239 | |
goetz@6458 | 240 | // ;; 8 |
goetz@6495 | 241 | a->cmpdi(CCR0, R4, unroll); // 33 |
goetz@6495 | 242 | a->bge(CCR0, l1); // 34 |
goetz@6458 | 243 | a->blr(); |
goetz@6458 | 244 | |
goetz@6495 | 245 | // Emit code. |
goetz@6511 | 246 | void (*test2)() = (void(*)())(void *)a->function_entry(); |
goetz@6458 | 247 | // uint32_t *code = (uint32_t *)a->pc(); |
goetz@6458 | 248 | |
goetz@6458 | 249 | Label l2; |
goetz@6458 | 250 | |
goetz@6458 | 251 | a->li(R4, 1); |
goetz@6458 | 252 | a->sldi(R4, R4, 28); |
goetz@6458 | 253 | a->b(l2); |
goetz@6458 | 254 | a->align(CodeEntryAlignment); |
goetz@6458 | 255 | |
goetz@6458 | 256 | a->bind(l2); |
goetz@6458 | 257 | |
goetz@6458 | 258 | for (int i = 0; i < unroll; i++) { |
goetz@6458 | 259 | // Schleife 2 |
goetz@6458 | 260 | // ------- sector 0 ------------ |
goetz@6458 | 261 | // ;; 0 |
goetz@6458 | 262 | a->brnop0(); // 1 |
goetz@6458 | 263 | a->nop(); // 2 |
goetz@6458 | 264 | //a->cmpdi(CCR0, R4, unroll); |
goetz@6458 | 265 | a->fpnop0(); // 3 |
goetz@6458 | 266 | a->fpnop1(); // 4 |
goetz@6458 | 267 | a->addi(R4,R4, -1); // 5 |
goetz@6458 | 268 | |
goetz@6458 | 269 | // ;; 1 |
goetz@6458 | 270 | |
goetz@6458 | 271 | a->nop(); // 6 |
goetz@6458 | 272 | a->fmr(F6, F6); // 7 |
goetz@6458 | 273 | a->fmr(F7, F7); // 8 |
goetz@6458 | 274 | // ------- sector 8 --------------- |
goetz@6458 | 275 | |
goetz@6458 | 276 | // ;; 2 |
goetz@6458 | 277 | a->endgroup(); // 9 |
goetz@6458 | 278 | |
goetz@6458 | 279 | // ;; 3 |
goetz@6458 | 280 | a->nop(); // 10 |
goetz@6458 | 281 | a->nop(); // 11 |
goetz@6458 | 282 | a->fmr(F8, F8); // 12 |
goetz@6458 | 283 | |
goetz@6458 | 284 | // ;; 4 |
goetz@6458 | 285 | a->fmr(F9, F9); // 13 |
goetz@6458 | 286 | a->nop(); // 14 |
goetz@6458 | 287 | a->fmr(F10, F10); // 15 |
goetz@6458 | 288 | |
goetz@6458 | 289 | // ;; 5 |
goetz@6458 | 290 | a->fmr(F11, F11); // 16 |
goetz@6458 | 291 | // -------- sector 16 ------------- |
goetz@6458 | 292 | |
goetz@6458 | 293 | // ;; 6 |
goetz@6458 | 294 | a->endgroup(); // 17 |
goetz@6458 | 295 | |
goetz@6458 | 296 | // ;; 7 |
goetz@6458 | 297 | a->nop(); // 18 |
goetz@6458 | 298 | a->nop(); // 19 |
goetz@6458 | 299 | a->fmr(F15, F15); // 20 |
goetz@6458 | 300 | |
goetz@6458 | 301 | // ;; 8 |
goetz@6458 | 302 | a->fmr(F16, F16); // 21 |
goetz@6458 | 303 | a->nop(); // 22 |
goetz@6458 | 304 | a->fmr(F17, F17); // 23 |
goetz@6458 | 305 | |
goetz@6458 | 306 | // ;; 9 |
goetz@6458 | 307 | a->fmr(F18, F18); // 24 |
goetz@6458 | 308 | // -------- sector 24 ------------- |
goetz@6458 | 309 | |
goetz@6458 | 310 | // ;; 10 |
goetz@6458 | 311 | a->endgroup(); // 25 |
goetz@6458 | 312 | |
goetz@6458 | 313 | // ;; 11 |
goetz@6458 | 314 | a->nop(); // 26 |
goetz@6458 | 315 | a->nop(); // 27 |
goetz@6458 | 316 | a->fmr(F19, F19); // 28 |
goetz@6458 | 317 | |
goetz@6458 | 318 | // ;; 12 |
goetz@6458 | 319 | a->fmr(F20, F20); // 29 |
goetz@6458 | 320 | a->nop(); // 30 |
goetz@6458 | 321 | a->fmr(F21, F21); // 31 |
goetz@6458 | 322 | |
goetz@6458 | 323 | // ;; 13 |
goetz@6458 | 324 | a->fmr(F22, F22); // 32 |
goetz@6458 | 325 | } |
goetz@6458 | 326 | |
goetz@6458 | 327 | // -------- sector 32 ------------- |
goetz@6458 | 328 | // ;; 14 |
goetz@6458 | 329 | a->cmpdi(CCR0, R4, unroll); // 33 |
goetz@6458 | 330 | a->bge(CCR0, l2); // 34 |
goetz@6458 | 331 | |
goetz@6458 | 332 | a->blr(); |
goetz@6458 | 333 | uint32_t *code_end = (uint32_t *)a->pc(); |
goetz@6458 | 334 | a->flush(); |
goetz@6458 | 335 | |
goetz@6458 | 336 | double loop1_seconds,loop2_seconds, rel_diff; |
goetz@6458 | 337 | uint64_t start1, stop1; |
goetz@6458 | 338 | |
goetz@6458 | 339 | start1 = os::current_thread_cpu_time(false); |
goetz@6458 | 340 | (*test1)(); |
goetz@6458 | 341 | stop1 = os::current_thread_cpu_time(false); |
goetz@6458 | 342 | loop1_seconds = (stop1- start1) / (1000 *1000 *1000.0); |
goetz@6458 | 343 | |
goetz@6458 | 344 | |
goetz@6458 | 345 | start1 = os::current_thread_cpu_time(false); |
goetz@6458 | 346 | (*test2)(); |
goetz@6458 | 347 | stop1 = os::current_thread_cpu_time(false); |
goetz@6458 | 348 | |
goetz@6458 | 349 | loop2_seconds = (stop1 - start1) / (1000 *1000 *1000.0); |
goetz@6458 | 350 | |
goetz@6458 | 351 | rel_diff = (loop2_seconds - loop1_seconds) / loop1_seconds *100; |
goetz@6458 | 352 | |
goetz@6458 | 353 | if (PrintAssembly) { |
goetz@6458 | 354 | ttyLocker ttyl; |
coleenp@7358 | 355 | tty->print_cr("Decoding section size detection stub at " INTPTR_FORMAT " before execution:", p2i(code)); |
goetz@6458 | 356 | Disassembler::decode((u_char*)code, (u_char*)code_end, tty); |
goetz@6458 | 357 | tty->print_cr("Time loop1 :%f", loop1_seconds); |
goetz@6458 | 358 | tty->print_cr("Time loop2 :%f", loop2_seconds); |
goetz@6458 | 359 | tty->print_cr("(time2 - time1) / time1 = %f %%", rel_diff); |
goetz@6458 | 360 | |
goetz@6458 | 361 | if (rel_diff > 12.0) { |
goetz@6458 | 362 | tty->print_cr("Section Size 8 Instructions"); |
goetz@6458 | 363 | } else{ |
goetz@6458 | 364 | tty->print_cr("Section Size 32 Instructions or Power5"); |
goetz@6458 | 365 | } |
goetz@6458 | 366 | } |
goetz@6458 | 367 | |
goetz@6458 | 368 | #if 0 // TODO: PPC port |
goetz@6458 | 369 | // Set sector size (if not set explicitly). |
goetz@6458 | 370 | if (FLAG_IS_DEFAULT(Power6SectorSize128PPC64)) { |
goetz@6458 | 371 | if (rel_diff > 12.0) { |
goetz@6458 | 372 | PdScheduling::power6SectorSize = 0x20; |
goetz@6458 | 373 | } else { |
goetz@6458 | 374 | PdScheduling::power6SectorSize = 0x80; |
goetz@6458 | 375 | } |
goetz@6458 | 376 | } else if (Power6SectorSize128PPC64) { |
goetz@6458 | 377 | PdScheduling::power6SectorSize = 0x80; |
goetz@6458 | 378 | } else { |
goetz@6458 | 379 | PdScheduling::power6SectorSize = 0x20; |
goetz@6458 | 380 | } |
goetz@6458 | 381 | #endif |
goetz@6458 | 382 | if (UsePower6SchedulerPPC64) Unimplemented(); |
goetz@6458 | 383 | } |
goetz@6458 | 384 | #endif // COMPILER2 |
goetz@6458 | 385 | |
goetz@6458 | 386 | void VM_Version::determine_features() { |
goetz@6511 | 387 | #if defined(ABI_ELFv2) |
goetz@6511 | 388 | const int code_size = (num_features+1+2*7)*BytesPerInstWord; // TODO(asmundak): calculation is incorrect. |
goetz@6511 | 389 | #else |
goetz@6495 | 390 | // 7 InstWords for each call (function descriptor + blr instruction). |
goetz@6495 | 391 | const int code_size = (num_features+1+2*7)*BytesPerInstWord; |
goetz@6511 | 392 | #endif |
goetz@6458 | 393 | int features = 0; |
goetz@6458 | 394 | |
goetz@6458 | 395 | // create test area |
goetz@6495 | 396 | enum { BUFFER_SIZE = 2*4*K }; // Needs to be >=2* max cache line size (cache line size can't exceed min page size). |
goetz@6458 | 397 | char test_area[BUFFER_SIZE]; |
goetz@6458 | 398 | char *mid_of_test_area = &test_area[BUFFER_SIZE>>1]; |
goetz@6458 | 399 | |
goetz@6495 | 400 | // Allocate space for the code. |
goetz@6458 | 401 | ResourceMark rm; |
goetz@6458 | 402 | CodeBuffer cb("detect_cpu_features", code_size, 0); |
goetz@6458 | 403 | MacroAssembler* a = new MacroAssembler(&cb); |
goetz@6458 | 404 | |
goetz@6515 | 405 | // Must be set to true so we can generate the test code. |
goetz@6515 | 406 | _features = VM_Version::all_features_m; |
goetz@6515 | 407 | |
goetz@6495 | 408 | // Emit code. |
goetz@6511 | 409 | void (*test)(address addr, uint64_t offset)=(void(*)(address addr, uint64_t offset))(void *)a->function_entry(); |
goetz@6458 | 410 | uint32_t *code = (uint32_t *)a->pc(); |
goetz@6458 | 411 | // Don't use R0 in ldarx. |
goetz@6495 | 412 | // Keep R3_ARG1 unmodified, it contains &field (see below). |
goetz@6495 | 413 | // Keep R4_ARG2 unmodified, it contains offset = 0 (see below). |
goetz@6495 | 414 | a->fsqrt(F3, F4); // code[0] -> fsqrt_m |
goetz@6515 | 415 | a->fsqrts(F3, F4); // code[1] -> fsqrts_m |
goetz@6515 | 416 | a->isel(R7, R5, R6, 0); // code[2] -> isel_m |
goetz@6515 | 417 | a->ldarx_unchecked(R7, R3_ARG1, R4_ARG2, 1); // code[3] -> lxarx_m |
goetz@6515 | 418 | a->cmpb(R7, R5, R6); // code[4] -> bcmp |
goetz@6515 | 419 | //a->mftgpr(R7, F3); // code[5] -> mftgpr |
goetz@6515 | 420 | a->popcntb(R7, R5); // code[6] -> popcntb |
goetz@6515 | 421 | a->popcntw(R7, R5); // code[7] -> popcntw |
goetz@6515 | 422 | a->fcfids(F3, F4); // code[8] -> fcfids |
goetz@6515 | 423 | a->vand(VR0, VR0, VR0); // code[9] -> vand |
goetz@6458 | 424 | a->blr(); |
goetz@6458 | 425 | |
goetz@6495 | 426 | // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it. |
goetz@6511 | 427 | void (*zero_cacheline_func_ptr)(char*) = (void(*)(char*))(void *)a->function_entry(); |
goetz@6495 | 428 | a->dcbz(R3_ARG1); // R3_ARG1 = addr |
goetz@6458 | 429 | a->blr(); |
goetz@6458 | 430 | |
goetz@6458 | 431 | uint32_t *code_end = (uint32_t *)a->pc(); |
goetz@6458 | 432 | a->flush(); |
goetz@6515 | 433 | _features = VM_Version::unknown_m; |
goetz@6458 | 434 | |
goetz@6458 | 435 | // Print the detection code. |
goetz@6458 | 436 | if (PrintAssembly) { |
goetz@6458 | 437 | ttyLocker ttyl; |
coleenp@7358 | 438 | tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " before execution:", p2i(code)); |
goetz@6458 | 439 | Disassembler::decode((u_char*)code, (u_char*)code_end, tty); |
goetz@6458 | 440 | } |
goetz@6458 | 441 | |
goetz@6458 | 442 | // Measure cache line size. |
goetz@6495 | 443 | memset(test_area, 0xFF, BUFFER_SIZE); // Fill test area with 0xFF. |
goetz@6495 | 444 | (*zero_cacheline_func_ptr)(mid_of_test_area); // Call function which executes dcbz to the middle. |
goetz@6458 | 445 | int count = 0; // count zeroed bytes |
goetz@6458 | 446 | for (int i = 0; i < BUFFER_SIZE; i++) if (test_area[i] == 0) count++; |
goetz@6458 | 447 | guarantee(is_power_of_2(count), "cache line size needs to be a power of 2"); |
goetz@6458 | 448 | _measured_cache_line_size = count; |
goetz@6458 | 449 | |
goetz@6458 | 450 | // Execute code. Illegal instructions will be replaced by 0 in the signal handler. |
goetz@6458 | 451 | VM_Version::_is_determine_features_test_running = true; |
goetz@6458 | 452 | (*test)((address)mid_of_test_area, (uint64_t)0); |
goetz@6458 | 453 | VM_Version::_is_determine_features_test_running = false; |
goetz@6458 | 454 | |
goetz@6458 | 455 | // determine which instructions are legal. |
goetz@6458 | 456 | int feature_cntr = 0; |
goetz@6458 | 457 | if (code[feature_cntr++]) features |= fsqrt_m; |
goetz@6515 | 458 | if (code[feature_cntr++]) features |= fsqrts_m; |
goetz@6458 | 459 | if (code[feature_cntr++]) features |= isel_m; |
goetz@6458 | 460 | if (code[feature_cntr++]) features |= lxarxeh_m; |
goetz@6458 | 461 | if (code[feature_cntr++]) features |= cmpb_m; |
goetz@6458 | 462 | //if(code[feature_cntr++])features |= mftgpr_m; |
goetz@6458 | 463 | if (code[feature_cntr++]) features |= popcntb_m; |
goetz@6458 | 464 | if (code[feature_cntr++]) features |= popcntw_m; |
goetz@6458 | 465 | if (code[feature_cntr++]) features |= fcfids_m; |
goetz@6458 | 466 | if (code[feature_cntr++]) features |= vand_m; |
goetz@6458 | 467 | |
goetz@6458 | 468 | // Print the detection code. |
goetz@6458 | 469 | if (PrintAssembly) { |
goetz@6458 | 470 | ttyLocker ttyl; |
coleenp@7358 | 471 | tty->print_cr("Decoding cpu-feature detection stub at " INTPTR_FORMAT " after execution:", p2i(code)); |
goetz@6458 | 472 | Disassembler::decode((u_char*)code, (u_char*)code_end, tty); |
goetz@6458 | 473 | } |
goetz@6458 | 474 | |
goetz@6458 | 475 | _features = features; |
goetz@6458 | 476 | } |
goetz@6458 | 477 | |
goetz@6458 | 478 | |
goetz@6458 | 479 | static int saved_features = 0; |
goetz@6458 | 480 | |
goetz@6458 | 481 | void VM_Version::allow_all() { |
goetz@6458 | 482 | saved_features = _features; |
goetz@6458 | 483 | _features = all_features_m; |
goetz@6458 | 484 | } |
goetz@6458 | 485 | |
goetz@6458 | 486 | void VM_Version::revert() { |
goetz@6458 | 487 | _features = saved_features; |
goetz@6458 | 488 | } |