OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "macro-assembler.h" | 9 #include "macro-assembler.h" |
10 #include "serialize.h" | 10 #include "serialize.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 // ----------------------------------------------------------------------------- | 15 // ----------------------------------------------------------------------------- |
16 // Implementation of CpuFeatures | 16 // Implementation of CpuFeatures |
17 | 17 |
18 | 18 |
19 #ifdef DEBUG | 19 #ifdef DEBUG |
20 bool CpuFeatures::initialized_ = false; | 20 bool CpuFeatures::initialized_ = false; |
21 #endif | 21 #endif |
22 uint64_t CpuFeatures::supported_ = CpuFeatures::kDefaultCpuFeatures; | 22 uint64_t CpuFeatures::supported_ = 0; |
23 uint64_t CpuFeatures::found_by_runtime_probing_only_ = 0; | 23 uint64_t CpuFeatures::found_by_runtime_probing_only_ = 0; |
24 uint64_t CpuFeatures::cross_compile_ = 0; | 24 uint64_t CpuFeatures::cross_compile_ = 0; |
25 | 25 |
26 ExternalReference ExternalReference::cpu_features() { | 26 ExternalReference ExternalReference::cpu_features() { |
27 ASSERT(CpuFeatures::initialized_); | 27 ASSERT(CpuFeatures::initialized_); |
28 return ExternalReference(&CpuFeatures::supported_); | 28 return ExternalReference(&CpuFeatures::supported_); |
29 } | 29 } |
30 | 30 |
31 | 31 |
32 void CpuFeatures::Probe(bool serializer_enabled) { | 32 void CpuFeatures::Probe(bool serializer_enabled) { |
33 ASSERT(supported_ == CpuFeatures::kDefaultCpuFeatures); | 33 ASSERT(supported_ == 0); |
34 #ifdef DEBUG | 34 #ifdef DEBUG |
35 initialized_ = true; | 35 initialized_ = true; |
36 #endif | 36 #endif |
37 supported_ = kDefaultCpuFeatures; | 37 supported_ = 0; |
38 if (serializer_enabled) { | 38 if (serializer_enabled) { |
39 supported_ |= OS::CpuFeaturesImpliedByPlatform(); | 39 supported_ |= OS::CpuFeaturesImpliedByPlatform(); |
40 return; // No features if we might serialize. | 40 return; // No features if we might serialize. |
41 } | 41 } |
42 | 42 |
43 uint64_t probed_features = 0; | 43 uint64_t probed_features = 0; |
44 CPU cpu; | 44 CPU cpu; |
45 if (cpu.has_sse41()) { | 45 if (cpu.has_sse41()) { |
46 probed_features |= static_cast<uint64_t>(1) << SSE4_1; | 46 probed_features |= static_cast<uint64_t>(1) << SSE4_1; |
47 } | 47 } |
48 if (cpu.has_sse3()) { | 48 if (cpu.has_sse3()) { |
49 probed_features |= static_cast<uint64_t>(1) << SSE3; | 49 probed_features |= static_cast<uint64_t>(1) << SSE3; |
50 } | 50 } |
51 | 51 |
52 // SSE2 must be available on every x64 CPU. | 52 // SSE2 must be available on every x64 CPU. |
53 ASSERT(cpu.has_sse2()); | 53 ASSERT(cpu.has_sse2()); |
54 | 54 |
55 // CMOV must be available on every x64 CPU. | 55 // CMOV must be available on every x64 CPU. |
56 ASSERT(cpu.has_cmov()); | 56 ASSERT(cpu.has_cmov()); |
57 probed_features |= static_cast<uint64_t>(1) << CMOV; | |
58 | 57 |
59 // SAHF is not generally available in long mode. | 58 // SAHF is not generally available in long mode. |
60 if (cpu.has_sahf()) { | 59 if (cpu.has_sahf()) { |
61 probed_features |= static_cast<uint64_t>(1) << SAHF; | 60 probed_features |= static_cast<uint64_t>(1) << SAHF; |
62 } | 61 } |
63 | 62 |
64 uint64_t platform_features = OS::CpuFeaturesImpliedByPlatform(); | 63 uint64_t platform_features = OS::CpuFeaturesImpliedByPlatform(); |
65 supported_ = probed_features | platform_features; | 64 supported_ = probed_features | platform_features; |
66 found_by_runtime_probing_only_ | 65 found_by_runtime_probing_only_ = probed_features & ~platform_features; |
67 = probed_features & ~kDefaultCpuFeatures & ~platform_features; | |
68 } | 66 } |
69 | 67 |
70 | 68 |
71 // ----------------------------------------------------------------------------- | 69 // ----------------------------------------------------------------------------- |
72 // Implementation of RelocInfo | 70 // Implementation of RelocInfo |
73 | 71 |
74 // Patch the code at the current PC with a call to the target address. | 72 // Patch the code at the current PC with a call to the target address. |
75 // Additional guard int3 instructions can be added if required. | 73 // Additional guard int3 instructions can be added if required. |
76 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) { | 74 void RelocInfo::PatchCodeWithCall(Address target, int guard_bytes) { |
77 int code_size = Assembler::kCallSequenceLength + guard_bytes; | 75 int code_size = Assembler::kCallSequenceLength + guard_bytes; |
(...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2992 | 2990 |
2993 | 2991 |
2994 bool RelocInfo::IsInConstantPool() { | 2992 bool RelocInfo::IsInConstantPool() { |
2995 return false; | 2993 return false; |
2996 } | 2994 } |
2997 | 2995 |
2998 | 2996 |
2999 } } // namespace v8::internal | 2997 } } // namespace v8::internal |
3000 | 2998 |
3001 #endif // V8_TARGET_ARCH_X64 | 2999 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |