Simplified CPU/CpuFeatures a bit.

This is a necessary intermediate step to disentangle the startup.

In the long run CPU and CpuFeatures should probably be merged,
and Serializer::enabled usage should be radically reduced, but
we're not there yet.

BUG=359977
LOG=y
R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/258993002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21001 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 574cfbcc
...@@ -48,7 +48,6 @@ namespace internal { ...@@ -48,7 +48,6 @@ namespace internal {
#ifdef DEBUG #ifdef DEBUG
bool CpuFeatures::initialized_ = false; bool CpuFeatures::initialized_ = false;
#endif #endif
bool CpuFeatures::hint_creating_snapshot_ = false;
unsigned CpuFeatures::supported_ = 0; unsigned CpuFeatures::supported_ = 0;
unsigned CpuFeatures::found_by_runtime_probing_only_ = 0; unsigned CpuFeatures::found_by_runtime_probing_only_ = 0;
unsigned CpuFeatures::cross_compile_ = 0; unsigned CpuFeatures::cross_compile_ = 0;
...@@ -101,22 +100,6 @@ const char* DwVfpRegister::AllocationIndexToString(int index) { ...@@ -101,22 +100,6 @@ const char* DwVfpRegister::AllocationIndexToString(int index) {
} }
void CpuFeatures::SetHintCreatingSnapshot() {
hint_creating_snapshot_ = true;
}
void CpuFeatures::ProbeWithoutIsolate() {
Probe(hint_creating_snapshot_);
}
void CpuFeatures::Probe() {
// The Serializer can only be queried after isolate initialization.
Probe(Serializer::enabled());
}
void CpuFeatures::Probe(bool serializer_enabled) { void CpuFeatures::Probe(bool serializer_enabled) {
uint64_t standard_features = static_cast<unsigned>( uint64_t standard_features = static_cast<unsigned>(
OS::CpuFeaturesImpliedByPlatform()) | CpuFeaturesImpliedByCompiler(); OS::CpuFeaturesImpliedByPlatform()) | CpuFeaturesImpliedByCompiler();
...@@ -133,8 +116,6 @@ void CpuFeatures::Probe(bool serializer_enabled) { ...@@ -133,8 +116,6 @@ void CpuFeatures::Probe(bool serializer_enabled) {
if (serializer_enabled) { if (serializer_enabled) {
// No probing for features if we might serialize (generate snapshot). // No probing for features if we might serialize (generate snapshot).
printf(" ");
PrintFeatures();
return; return;
} }
......
...@@ -56,12 +56,7 @@ class CpuFeatures : public AllStatic { ...@@ -56,12 +56,7 @@ class CpuFeatures : public AllStatic {
public: public:
// Detect features of the target CPU. Set safe defaults if the serializer // Detect features of the target CPU. Set safe defaults if the serializer
// is enabled (snapshots must be portable). // is enabled (snapshots must be portable).
static void Probe(); static void Probe(bool serializer_enabled);
// A special case for printing target and features, which we want to do
// before initializing the isolate
static void SetHintCreatingSnapshot();
static void ProbeWithoutIsolate();
// Display target use when compiling. // Display target use when compiling.
static void PrintTarget(); static void PrintTarget();
...@@ -98,10 +93,9 @@ class CpuFeatures : public AllStatic { ...@@ -98,10 +93,9 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask; (cross_compile_ & mask) == mask;
} }
private: static bool SupportsCrankshaft() { return CpuFeatures::IsSupported(VFP3); }
static void Probe(bool serializer_enabled);
static bool hint_creating_snapshot_;
private:
static bool Check(CpuFeature f, unsigned set) { static bool Check(CpuFeature f, unsigned set) {
return (set & flag2set(f)) != 0; return (set & flag2set(f)) != 0;
} }
......
...@@ -46,16 +46,6 @@ ...@@ -46,16 +46,6 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return CpuFeatures::IsSupported(VFP3);
}
void CPU::FlushICache(void* start, size_t size) { void CPU::FlushICache(void* start, size_t size) {
// Nothing to do flushing no instructions. // Nothing to do flushing no instructions.
if (size == 0) { if (size == 0) {
......
...@@ -49,16 +49,6 @@ unsigned CpuFeatures::dcache_line_size_ = 1; ...@@ -49,16 +49,6 @@ unsigned CpuFeatures::dcache_line_size_ = 1;
unsigned CpuFeatures::icache_line_size_ = 1; unsigned CpuFeatures::icache_line_size_ = 1;
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return true;
}
void CPU::FlushICache(void* address, size_t length) { void CPU::FlushICache(void* address, size_t length) {
if (length == 0) { if (length == 0) {
return; return;
...@@ -139,7 +129,7 @@ void CPU::FlushICache(void* address, size_t length) { ...@@ -139,7 +129,7 @@ void CPU::FlushICache(void* address, size_t length) {
} }
void CpuFeatures::Probe() { void CpuFeatures::Probe(bool serializer_enabled) {
// Compute I and D cache line size. The cache type register holds // Compute I and D cache line size. The cache type register holds
// information about the caches. // information about the caches.
uint32_t cache_type_register = GetCacheType(); uint32_t cache_type_register = GetCacheType();
......
...@@ -42,7 +42,7 @@ class CpuFeatures : public AllStatic { ...@@ -42,7 +42,7 @@ class CpuFeatures : public AllStatic {
public: public:
// Detect features of the target CPU. Set safe defaults if the serializer // Detect features of the target CPU. Set safe defaults if the serializer
// is enabled (snapshots must be portable). // is enabled (snapshots must be portable).
static void Probe(); static void Probe(bool serializer_enabled);
// Check whether a feature is supported by the target CPU. // Check whether a feature is supported by the target CPU.
static bool IsSupported(CpuFeature f) { static bool IsSupported(CpuFeature f) {
...@@ -81,6 +81,8 @@ class CpuFeatures : public AllStatic { ...@@ -81,6 +81,8 @@ class CpuFeatures : public AllStatic {
return true; return true;
} }
static bool SupportsCrankshaft() { return true; }
private: private:
// Return the content of the cache type register. // Return the content of the cache type register.
static uint32_t GetCacheType(); static uint32_t GetCacheType();
......
...@@ -102,11 +102,6 @@ class CPU V8_FINAL BASE_EMBEDDED { ...@@ -102,11 +102,6 @@ class CPU V8_FINAL BASE_EMBEDDED {
// Returns the number of processors online. // Returns the number of processors online.
static int NumberOfProcessorsOnline(); static int NumberOfProcessorsOnline();
// Initializes the cpu architecture support. Called once at VM startup.
static void SetUp();
static bool SupportsCrankshaft();
// Flush instruction cache. // Flush instruction cache.
static void FlushICache(void* start, size_t size); static void FlushICache(void* start, size_t size);
......
...@@ -360,10 +360,15 @@ static Flag* FindFlag(const char* name) { ...@@ -360,10 +360,15 @@ static Flag* FindFlag(const char* name) {
} }
bool FlagList::serializer_enabled_ = false;
// static // static
int FlagList::SetFlagsFromCommandLine(int* argc, int FlagList::SetFlagsFromCommandLine(int* argc,
char** argv, char** argv,
bool remove_flags) { bool remove_flags,
bool serializer_enabled) {
serializer_enabled_ = serializer_enabled;
int return_code = 0; int return_code = 0;
// parse arguments // parse arguments
for (int i = 1; i < *argc;) { for (int i = 1; i < *argc;) {
...@@ -545,7 +550,7 @@ void FlagList::ResetAllFlags() { ...@@ -545,7 +550,7 @@ void FlagList::ResetAllFlags() {
void FlagList::PrintHelp() { void FlagList::PrintHelp() {
#if V8_TARGET_ARCH_ARM #if V8_TARGET_ARCH_ARM
CpuFeatures::PrintTarget(); CpuFeatures::PrintTarget();
CpuFeatures::ProbeWithoutIsolate(); CpuFeatures::Probe(serializer_enabled_);
CpuFeatures::PrintFeatures(); CpuFeatures::PrintFeatures();
#endif // V8_TARGET_ARCH_ARM #endif // V8_TARGET_ARCH_ARM
......
...@@ -63,7 +63,10 @@ class FlagList { ...@@ -63,7 +63,10 @@ class FlagList {
// --flag=value (non-bool flags only, no spaces around '=') // --flag=value (non-bool flags only, no spaces around '=')
// --flag value (non-bool flags only) // --flag value (non-bool flags only)
// -- (equivalent to --js_arguments, captures all remaining args) // -- (equivalent to --js_arguments, captures all remaining args)
static int SetFlagsFromCommandLine(int* argc, char** argv, bool remove_flags); static int SetFlagsFromCommandLine(int* argc,
char** argv,
bool remove_flags,
bool serializer_enabled = false);
// Set the flag values by parsing the string str. Splits string into argc // Set the flag values by parsing the string str. Splits string into argc
// substrings argv[], each of which consisting of non-white-space chars, // substrings argv[], each of which consisting of non-white-space chars,
...@@ -78,6 +81,10 @@ class FlagList { ...@@ -78,6 +81,10 @@ class FlagList {
// Set flags as consequence of being implied by another flag. // Set flags as consequence of being implied by another flag.
static void EnforceFlagImplications(); static void EnforceFlagImplications();
private:
// TODO(svenpanne) Remove this when Serializer/startup has been refactored.
static bool serializer_enabled_;
}; };
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -89,13 +89,13 @@ const char* IntelDoubleRegister::AllocationIndexToString(int index) { ...@@ -89,13 +89,13 @@ const char* IntelDoubleRegister::AllocationIndexToString(int index) {
} }
void CpuFeatures::Probe() { void CpuFeatures::Probe(bool serializer_enabled) {
ASSERT(!initialized_); ASSERT(!initialized_);
ASSERT(supported_ == 0); ASSERT(supported_ == 0);
#ifdef DEBUG #ifdef DEBUG
initialized_ = true; initialized_ = true;
#endif #endif
if (Serializer::enabled()) { if (serializer_enabled) {
supported_ |= OS::CpuFeaturesImpliedByPlatform(); supported_ |= OS::CpuFeaturesImpliedByPlatform();
return; // No features if we might serialize. return; // No features if we might serialize.
} }
......
...@@ -530,7 +530,7 @@ class CpuFeatures : public AllStatic { ...@@ -530,7 +530,7 @@ class CpuFeatures : public AllStatic {
public: public:
// Detect features of the target CPU. Set safe defaults if the serializer // Detect features of the target CPU. Set safe defaults if the serializer
// is enabled (snapshots must be portable). // is enabled (snapshots must be portable).
static void Probe(); static void Probe(bool serializer_enabled);
// Check whether a feature is supported by the target CPU. // Check whether a feature is supported by the target CPU.
static bool IsSupported(CpuFeature f) { static bool IsSupported(CpuFeature f) {
...@@ -564,6 +564,8 @@ class CpuFeatures : public AllStatic { ...@@ -564,6 +564,8 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask; (cross_compile_ & mask) == mask;
} }
static bool SupportsCrankshaft() { return IsSupported(SSE2); }
private: private:
static bool Check(CpuFeature f, uint64_t set) { static bool Check(CpuFeature f, uint64_t set) {
return (set & flag2set(f)) != 0; return (set & flag2set(f)) != 0;
......
...@@ -41,16 +41,6 @@ ...@@ -41,16 +41,6 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return CpuFeatures::IsSupported(SSE2);
}
void CPU::FlushICache(void* start, size_t size) { void CPU::FlushICache(void* start, size_t size) {
// No need to flush the instruction cache on Intel. On Intel instruction // No need to flush the instruction cache on Intel. On Intel instruction
// cache flushing is only necessary when multiple cores running the same // cache flushing is only necessary when multiple cores running the same
......
...@@ -1808,7 +1808,7 @@ bool Isolate::Init(Deserializer* des) { ...@@ -1808,7 +1808,7 @@ bool Isolate::Init(Deserializer* des) {
use_crankshaft_ = FLAG_crankshaft use_crankshaft_ = FLAG_crankshaft
&& !Serializer::enabled() && !Serializer::enabled()
&& CPU::SupportsCrankshaft(); && CpuFeatures::SupportsCrankshaft();
if (function_entry_hook() != NULL) { if (function_entry_hook() != NULL) {
// When function entry hooking is in effect, we have to create the code // When function entry hooking is in effect, we have to create the code
......
...@@ -46,7 +46,6 @@ namespace internal { ...@@ -46,7 +46,6 @@ namespace internal {
#ifdef DEBUG #ifdef DEBUG
bool CpuFeatures::initialized_ = false; bool CpuFeatures::initialized_ = false;
#endif #endif
bool CpuFeatures::hint_creating_snapshot_ = false;
unsigned CpuFeatures::supported_ = 0; unsigned CpuFeatures::supported_ = 0;
unsigned CpuFeatures::found_by_runtime_probing_only_ = 0; unsigned CpuFeatures::found_by_runtime_probing_only_ = 0;
unsigned CpuFeatures::cross_compile_ = 0; unsigned CpuFeatures::cross_compile_ = 0;
...@@ -103,22 +102,6 @@ const char* DoubleRegister::AllocationIndexToString(int index) { ...@@ -103,22 +102,6 @@ const char* DoubleRegister::AllocationIndexToString(int index) {
} }
void CpuFeatures::SetHintCreatingSnapshot() {
hint_creating_snapshot_ = true;
}
void CpuFeatures::ProbeWithoutIsolate() {
Probe(hint_creating_snapshot_);
}
void CpuFeatures::Probe() {
// The Serializer can only be queried after isolate initialization.
Probe(Serializer::enabled());
}
void CpuFeatures::Probe(bool serializer_enabled) { void CpuFeatures::Probe(bool serializer_enabled) {
unsigned standard_features = (OS::CpuFeaturesImpliedByPlatform() | unsigned standard_features = (OS::CpuFeaturesImpliedByPlatform() |
CpuFeaturesImpliedByCompiler()); CpuFeaturesImpliedByCompiler());
......
...@@ -425,12 +425,10 @@ class CpuFeatures : public AllStatic { ...@@ -425,12 +425,10 @@ class CpuFeatures : public AllStatic {
public: public:
// Detect features of the target CPU. Set safe defaults if the serializer // Detect features of the target CPU. Set safe defaults if the serializer
// is enabled (snapshots must be portable). // is enabled (snapshots must be portable).
static void Probe(); static void Probe(bool serializer_enabled);
// A special case for printing target and features, which we want to do // A special case for printing target and features, which we want to do
// before initializing the isolate // before initializing the isolate
static void SetHintCreatingSnapshot();
static void ProbeWithoutIsolate();
// Check whether a feature is supported by the target CPU. // Check whether a feature is supported by the target CPU.
static bool IsSupported(CpuFeature f) { static bool IsSupported(CpuFeature f) {
...@@ -459,10 +457,9 @@ class CpuFeatures : public AllStatic { ...@@ -459,10 +457,9 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask; (cross_compile_ & mask) == mask;
} }
private: static bool SupportsCrankshaft() { return CpuFeatures::IsSupported(FPU); }
static void Probe(bool serializer_enabled);
static bool hint_creating_snapshot_;
private:
static bool Check(CpuFeature f, unsigned set) { static bool Check(CpuFeature f, unsigned set) {
return (set & flag2set(f)) != 0; return (set & flag2set(f)) != 0;
} }
......
...@@ -47,16 +47,6 @@ namespace v8 { ...@@ -47,16 +47,6 @@ namespace v8 {
namespace internal { namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return CpuFeatures::IsSupported(FPU);
}
void CPU::FlushICache(void* start, size_t size) { void CPU::FlushICache(void* start, size_t size) {
// Nothing to do, flushing no instructions. // Nothing to do, flushing no instructions.
if (size == 0) { if (size == 0) {
......
...@@ -301,15 +301,9 @@ int main(int argc, char** argv) { ...@@ -301,15 +301,9 @@ int main(int argc, char** argv) {
// By default, log code create information in the snapshot. // By default, log code create information in the snapshot.
i::FLAG_log_code = true; i::FLAG_log_code = true;
#if V8_TARGET_ARCH_ARM
// Printing flags on ARM requires knowing if we intend to enable
// the serializer or not.
v8::internal::CpuFeatures::SetHintCreatingSnapshot();
#endif
// Print the usage if an error occurs when parsing the command line // Print the usage if an error occurs when parsing the command line
// flags or if the help flag is set. // flags or if the help flag is set.
int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true, true);
if (result > 0 || argc != 2 || i::FLAG_help) { if (result > 0 || argc != 2 || i::FLAG_help) {
::printf("Usage: %s [flag] ... outfile\n", argv[0]); ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
i::FlagList::PrintHelp(); i::FlagList::PrintHelp();
......
...@@ -144,7 +144,7 @@ void V8::InitializeOncePerProcessImpl() { ...@@ -144,7 +144,7 @@ void V8::InitializeOncePerProcessImpl() {
platform_ = new DefaultPlatform; platform_ = new DefaultPlatform;
#endif #endif
Sampler::SetUp(); Sampler::SetUp();
CPU::SetUp(); CpuFeatures::Probe(Serializer::enabled());
OS::PostSetUp(); OS::PostSetUp();
ElementsAccessor::InitializeOncePerProcess(); ElementsAccessor::InitializeOncePerProcess();
LOperand::SetUpCaches(); LOperand::SetUpCaches();
......
...@@ -52,13 +52,13 @@ ExternalReference ExternalReference::cpu_features() { ...@@ -52,13 +52,13 @@ ExternalReference ExternalReference::cpu_features() {
} }
void CpuFeatures::Probe() { void CpuFeatures::Probe(bool serializer_enabled) {
ASSERT(supported_ == CpuFeatures::kDefaultCpuFeatures); ASSERT(supported_ == CpuFeatures::kDefaultCpuFeatures);
#ifdef DEBUG #ifdef DEBUG
initialized_ = true; initialized_ = true;
#endif #endif
supported_ = kDefaultCpuFeatures; supported_ = kDefaultCpuFeatures;
if (Serializer::enabled()) { if (serializer_enabled) {
supported_ |= OS::CpuFeaturesImpliedByPlatform(); supported_ |= OS::CpuFeaturesImpliedByPlatform();
return; // No features if we might serialize. return; // No features if we might serialize.
} }
......
...@@ -450,7 +450,7 @@ class CpuFeatures : public AllStatic { ...@@ -450,7 +450,7 @@ class CpuFeatures : public AllStatic {
public: public:
// Detect features of the target CPU. Set safe defaults if the serializer // Detect features of the target CPU. Set safe defaults if the serializer
// is enabled (snapshots must be portable). // is enabled (snapshots must be portable).
static void Probe(); static void Probe(bool serializer_enabled);
// Check whether a feature is supported by the target CPU. // Check whether a feature is supported by the target CPU.
static bool IsSupported(CpuFeature f) { static bool IsSupported(CpuFeature f) {
...@@ -484,6 +484,8 @@ class CpuFeatures : public AllStatic { ...@@ -484,6 +484,8 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask; (cross_compile_ & mask) == mask;
} }
static bool SupportsCrankshaft() { return true; }
private: private:
static bool Check(CpuFeature f, uint64_t set) { static bool Check(CpuFeature f, uint64_t set) {
return (set & flag2set(f)) != 0; return (set & flag2set(f)) != 0;
......
...@@ -41,16 +41,6 @@ ...@@ -41,16 +41,6 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return true; // Yay!
}
void CPU::FlushICache(void* start, size_t size) { void CPU::FlushICache(void* start, size_t size) {
// No need to flush the instruction cache on Intel. On Intel instruction // No need to flush the instruction cache on Intel. On Intel instruction
// cache flushing is only necessary when multiple cores running the same // cache flushing is only necessary when multiple cores running the same
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment