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 | |
Jakob Kummerow
2014/06/23 12:21:18
Missing #ifdef. I was wondering how this would com
| |
45 }; | 46 }; |
46 | 47 |
47 } } // namespace v8::base | 48 } } // namespace v8::base |
48 | 49 |
49 namespace { | 50 namespace { |
50 | 51 |
51 // Initialize the AtomicOps_Internalx86CPUFeatures struct. | 52 // Initialize the AtomicOps_Internalx86CPUFeatures struct. |
52 void AtomicOps_Internalx86CPUFeaturesInit() { | 53 void AtomicOps_Internalx86CPUFeaturesInit() { |
53 using v8::base::AtomicOps_Internalx86CPUFeatures; | 54 using v8::base::AtomicOps_Internalx86CPUFeatures; |
54 | 55 |
(...skipping 25 matching lines...) Expand all Loading... | |
80 // non-locked read-modify-write instruction. Rev F has this bug in | 81 // non-locked read-modify-write instruction. Rev F has this bug in |
81 // pre-release versions, but not in versions released to customers, | 82 // pre-release versions, but not in versions released to customers, |
82 // so we test only for Rev E, which is family 15, model 32..63 inclusive. | 83 // so we test only for Rev E, which is family 15, model 32..63 inclusive. |
83 if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD | 84 if (strcmp(vendor, "AuthenticAMD") == 0 && // AMD |
84 family == 15 && | 85 family == 15 && |
85 32 <= model && model <= 63) { | 86 32 <= model && model <= 63) { |
86 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; | 87 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = true; |
87 } else { | 88 } else { |
88 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; | 89 AtomicOps_Internalx86CPUFeatures.has_amd_lock_mb_bug = false; |
89 } | 90 } |
91 | |
92 #if !defined(__SSE2__) | |
93 // edx bit 26 is SSE2 which we use to tell use whether we can use mfence | |
94 AtomicOps_Internalx86CPUFeatures.has_sse2 = ((edx >> 26) & 1); | |
95 #endif | |
90 } | 96 } |
91 | 97 |
92 class AtomicOpsx86Initializer { | 98 class AtomicOpsx86Initializer { |
93 public: | 99 public: |
94 AtomicOpsx86Initializer() { | 100 AtomicOpsx86Initializer() { |
95 AtomicOps_Internalx86CPUFeaturesInit(); | 101 AtomicOps_Internalx86CPUFeaturesInit(); |
96 } | 102 } |
97 }; | 103 }; |
98 | 104 |
99 | 105 |
100 // A global to get use initialized on startup via static initialization :/ | 106 // A global to get use initialized on startup via static initialization :/ |
101 AtomicOpsx86Initializer g_initer; | 107 AtomicOpsx86Initializer g_initer; |
102 | 108 |
103 } // namespace | 109 } // namespace |
104 | 110 |
105 #endif // if x86 | 111 #endif // if x86 |
106 | 112 |
107 #endif // ifdef V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ | 113 #endif // ifdef V8_BASE_ATOMICOPS_INTERNALS_X86_GCC_H_ |
OLD | NEW |