OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace v8 { | 43 namespace v8 { |
44 namespace internal { | 44 namespace internal { |
45 | 45 |
46 #ifdef DEBUG | 46 #ifdef DEBUG |
47 bool CpuFeatures::initialized_ = false; | 47 bool CpuFeatures::initialized_ = false; |
48 #endif | 48 #endif |
49 unsigned CpuFeatures::supported_ = 0; | 49 unsigned CpuFeatures::supported_ = 0; |
50 unsigned CpuFeatures::found_by_runtime_probing_ = 0; | 50 unsigned CpuFeatures::found_by_runtime_probing_ = 0; |
51 | 51 |
| 52 |
| 53 // Get the CPU features enabled by the build. For cross compilation the |
| 54 // preprocessor symbols CAN_USE_FPU_INSTRUCTIONS |
| 55 // can be defined to enable FPU instructions when building the |
| 56 // snapshot. |
| 57 static uint64_t CpuFeaturesImpliedByCompiler() { |
| 58 uint64_t answer = 0; |
| 59 #ifdef CAN_USE_FPU_INSTRUCTIONS |
| 60 answer |= 1u << FPU; |
| 61 #endif // def CAN_USE_FPU_INSTRUCTIONS |
| 62 |
| 63 #ifdef __mips__ |
| 64 // If the compiler is allowed to use FPU then we can use FPU too in our code |
| 65 // generation even when generating snapshots. This won't work for cross |
| 66 // compilation. |
| 67 #if(defined(__mips_hard_float) && __mips_hard_float != 0) |
| 68 answer |= 1u << FPU; |
| 69 #endif // defined(__mips_hard_float) && __mips_hard_float != 0 |
| 70 #endif // def __mips__ |
| 71 |
| 72 return answer; |
| 73 } |
| 74 |
| 75 |
52 void CpuFeatures::Probe() { | 76 void CpuFeatures::Probe() { |
53 ASSERT(!initialized_); | 77 ASSERT(!initialized_); |
54 #ifdef DEBUG | 78 #ifdef DEBUG |
55 initialized_ = true; | 79 initialized_ = true; |
56 #endif | 80 #endif |
| 81 |
| 82 // Get the features implied by the OS and the compiler settings. This is the |
| 83 // minimal set of features which is also allowed for generated code in the |
| 84 // snapshot. |
| 85 supported_ |= OS::CpuFeaturesImpliedByPlatform(); |
| 86 supported_ |= CpuFeaturesImpliedByCompiler(); |
| 87 |
| 88 if (Serializer::enabled()) { |
| 89 // No probing for features if we might serialize (generate snapshot). |
| 90 return; |
| 91 } |
| 92 |
57 // If the compiler is allowed to use fpu then we can use fpu too in our | 93 // If the compiler is allowed to use fpu then we can use fpu too in our |
58 // code generation. | 94 // code generation. |
59 #if !defined(__mips__) | 95 #if !defined(__mips__) |
60 // For the simulator=mips build, use FPU when FLAG_enable_fpu is enabled. | 96 // For the simulator=mips build, use FPU when FLAG_enable_fpu is enabled. |
61 if (FLAG_enable_fpu) { | 97 if (FLAG_enable_fpu) { |
62 supported_ |= 1u << FPU; | 98 supported_ |= 1u << FPU; |
63 } | 99 } |
64 #else | 100 #else |
65 if (Serializer::enabled()) { | 101 // Probe for additional features not already known to be available. |
66 supported_ |= OS::CpuFeaturesImpliedByPlatform(); | |
67 return; // No features if we might serialize. | |
68 } | |
69 | |
70 if (OS::MipsCpuHasFeature(FPU)) { | 102 if (OS::MipsCpuHasFeature(FPU)) { |
71 // This implementation also sets the FPU flags if | 103 // This implementation also sets the FPU flags if |
72 // runtime detection of FPU returns true. | 104 // runtime detection of FPU returns true. |
73 supported_ |= 1u << FPU; | 105 supported_ |= 1u << FPU; |
74 found_by_runtime_probing_ |= 1u << FPU; | 106 found_by_runtime_probing_ |= 1u << FPU; |
75 } | 107 } |
76 #endif | 108 #endif |
77 } | 109 } |
78 | 110 |
79 | 111 |
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2059 *p = LUI | rt_code | ((itarget & kHiMask) >> kLuiShift); | 2091 *p = LUI | rt_code | ((itarget & kHiMask) >> kLuiShift); |
2060 *(p+1) = ORI | rt_code | (rt_code << 5) | (itarget & kImm16Mask); | 2092 *(p+1) = ORI | rt_code | (rt_code << 5) | (itarget & kImm16Mask); |
2061 | 2093 |
2062 CPU::FlushICache(pc, 2 * sizeof(int32_t)); | 2094 CPU::FlushICache(pc, 2 * sizeof(int32_t)); |
2063 } | 2095 } |
2064 | 2096 |
2065 | 2097 |
2066 } } // namespace v8::internal | 2098 } } // namespace v8::internal |
2067 | 2099 |
2068 #endif // V8_TARGET_ARCH_MIPS | 2100 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |