| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This module gets enough CPU information to optimize the | 5 // This module gets enough CPU information to optimize the |
| 6 // atomicops module on x86. | 6 // atomicops module on x86. |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 #if defined(cpuid) // initialize the struct only on x86 | 35 #if defined(cpuid) // initialize the struct only on x86 |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace base { | 38 namespace base { |
| 39 | 39 |
| 40 // Set the flags so that code will run correctly and conservatively, so even | 40 // Set the flags so that code will run correctly and conservatively, so even |
| 41 // if we haven't been initialized yet, we're probably single threaded, and our | 41 // if we haven't been initialized yet, we're probably single threaded, and our |
| 42 // default values should hopefully be pretty safe. | 42 // default values should hopefully be pretty safe. |
| 43 struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = { | 43 struct AtomicOps_x86CPUFeatureStruct AtomicOps_Internalx86CPUFeatures = { |
| 44 false, // bug can't exist before process spawns multiple threads | 44 false, // bug can't exist before process spawns multiple threads |
| 45 false, // no SSE2 | |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 } } // namespace v8::base | 47 } } // namespace v8::base |
| 49 | 48 |
| 50 namespace { | 49 namespace { |
| 51 | 50 |
| 52 // Initialize the AtomicOps_Internalx86CPUFeatures struct. | 51 // Initialize the AtomicOps_Internalx86CPUFeatures struct. |
| 53 void AtomicOps_Internalx86CPUFeaturesInit() { | 52 void AtomicOps_Internalx86CPUFeaturesInit() { |
| 54 using v8::base::AtomicOps_Internalx86CPUFeatures; | 53 using v8::base::AtomicOps_Internalx86CPUFeatures; |
| 55 | 54 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 81 // non-locked read-modify-write instruction. Rev F has this bug in | 80 // non-locked read-modify-write instruction. Rev F has this bug in |
| 82 // pre-release versions, but not in versions released to customers, | 81 // pre-release versions, but not in versions released to customers, |
| 83 // so we test only for Rev E, which is family 15, model 32..63 inclusive. | 82 // so we test only for Rev E, which is family 15, model 32..63 inclusive. |
| 84 if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD | 83 if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD |
| 85 family == 15 && | 84 family == 15 && |
| 86 32 <= model && model <= 63) { | 85 32 <= model && model <= 63) { |
| 87 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; | 86 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; |
| 88 } else { | 87 } else { |
| 89 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; | 88 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; |
| 90 } | 89 } |
| 91 | |
| 92 // edx bit 26 is SSE2 which we use to tell use whether we can use mfence | |
| 93 AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1); | |
| 94 } | 90 } |
| 95 | 91 |
| 96 class AtomicOpsx86Initializer { | 92 class AtomicOpsx86Initializer { |
| 97 public: | 93 public: |
| 98 AtomicOpsx86Initializer() { | 94 AtomicOpsx86Initializer() { |
| 99 AtomicOps_Internalx86CPUFeaturesInit(); | 95 AtomicOps_Internalx86CPUFeaturesInit(); |
| 100 } | 96 } |
| 101 }; | 97 }; |
| 102 | 98 |
| 103 | 99 |
| 104 // A global to get use initialized on startup via static initialization :/ | 100 // A global to get use initialized on startup via static initialization :/ |
| 105 AtomicOpsx86Initializer g_initer; | 101 AtomicOpsx86Initializer g_initer; |
| 106 | 102 |
| 107 } // namespace | 103 } // namespace |
| 108 | 104 |
| 109 #endif // if x86 | 105 #endif // if x86 |
| 110 | 106 |
| 111 #endif // ifdef V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ | 107 #endif // ifdef V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ |
| OLD | NEW |