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 {
#ifdef DEBUG
bool CpuFeatures::initialized_ = false;
#endif
bool CpuFeatures::hint_creating_snapshot_ = false;
unsigned CpuFeatures::supported_ = 0;
unsigned CpuFeatures::found_by_runtime_probing_only_ = 0;
unsigned CpuFeatures::cross_compile_ = 0;
......@@ -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) {
uint64_t standard_features = static_cast<unsigned>(
OS::CpuFeaturesImpliedByPlatform()) | CpuFeaturesImpliedByCompiler();
......@@ -133,8 +116,6 @@ void CpuFeatures::Probe(bool serializer_enabled) {
if (serializer_enabled) {
// No probing for features if we might serialize (generate snapshot).
printf(" ");
PrintFeatures();
return;
}
......
......@@ -56,12 +56,7 @@ class CpuFeatures : public AllStatic {
public:
// Detect features of the target CPU. Set safe defaults if the serializer
// is enabled (snapshots must be portable).
static void Probe();
// A special case for printing target and features, which we want to do
// before initializing the isolate
static void SetHintCreatingSnapshot();
static void ProbeWithoutIsolate();
static void Probe(bool serializer_enabled);
// Display target use when compiling.
static void PrintTarget();
......@@ -98,10 +93,9 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask;
}
private:
static void Probe(bool serializer_enabled);
static bool hint_creating_snapshot_;
static bool SupportsCrankshaft() { return CpuFeatures::IsSupported(VFP3); }
private:
static bool Check(CpuFeature f, unsigned set) {
return (set & flag2set(f)) != 0;
}
......
......@@ -46,16 +46,6 @@
namespace v8 {
namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return CpuFeatures::IsSupported(VFP3);
}
void CPU::FlushICache(void* start, size_t size) {
// Nothing to do flushing no instructions.
if (size == 0) {
......
......@@ -49,16 +49,6 @@ unsigned CpuFeatures::dcache_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) {
if (length == 0) {
return;
......@@ -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
// information about the caches.
uint32_t cache_type_register = GetCacheType();
......
......@@ -42,7 +42,7 @@ class CpuFeatures : public AllStatic {
public:
// Detect features of the target CPU. Set safe defaults if the serializer
// 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.
static bool IsSupported(CpuFeature f) {
......@@ -81,6 +81,8 @@ class CpuFeatures : public AllStatic {
return true;
}
static bool SupportsCrankshaft() { return true; }
private:
// Return the content of the cache type register.
static uint32_t GetCacheType();
......
......@@ -102,11 +102,6 @@ class CPU V8_FINAL BASE_EMBEDDED {
// Returns the number of processors online.
static int NumberOfProcessorsOnline();
// Initializes the cpu architecture support. Called once at VM startup.
static void SetUp();
static bool SupportsCrankshaft();
// Flush instruction cache.
static void FlushICache(void* start, size_t size);
......
......@@ -360,10 +360,15 @@ static Flag* FindFlag(const char* name) {
}
bool FlagList::serializer_enabled_ = false;
// static
int FlagList::SetFlagsFromCommandLine(int* argc,
char** argv,
bool remove_flags) {
bool remove_flags,
bool serializer_enabled) {
serializer_enabled_ = serializer_enabled;
int return_code = 0;
// parse arguments
for (int i = 1; i < *argc;) {
......@@ -545,7 +550,7 @@ void FlagList::ResetAllFlags() {
void FlagList::PrintHelp() {
#if V8_TARGET_ARCH_ARM
CpuFeatures::PrintTarget();
CpuFeatures::ProbeWithoutIsolate();
CpuFeatures::Probe(serializer_enabled_);
CpuFeatures::PrintFeatures();
#endif // V8_TARGET_ARCH_ARM
......
......@@ -63,7 +63,10 @@ class FlagList {
// --flag=value (non-bool flags only, no spaces around '=')
// --flag value (non-bool flags only)
// -- (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
// substrings argv[], each of which consisting of non-white-space chars,
......@@ -78,6 +81,10 @@ class FlagList {
// Set flags as consequence of being implied by another flag.
static void EnforceFlagImplications();
private:
// TODO(svenpanne) Remove this when Serializer/startup has been refactored.
static bool serializer_enabled_;
};
} } // namespace v8::internal
......
......@@ -89,13 +89,13 @@ const char* IntelDoubleRegister::AllocationIndexToString(int index) {
}
void CpuFeatures::Probe() {
void CpuFeatures::Probe(bool serializer_enabled) {
ASSERT(!initialized_);
ASSERT(supported_ == 0);
#ifdef DEBUG
initialized_ = true;
#endif
if (Serializer::enabled()) {
if (serializer_enabled) {
supported_ |= OS::CpuFeaturesImpliedByPlatform();
return; // No features if we might serialize.
}
......
......@@ -530,7 +530,7 @@ class CpuFeatures : public AllStatic {
public:
// Detect features of the target CPU. Set safe defaults if the serializer
// 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.
static bool IsSupported(CpuFeature f) {
......@@ -564,6 +564,8 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask;
}
static bool SupportsCrankshaft() { return IsSupported(SSE2); }
private:
static bool Check(CpuFeature f, uint64_t set) {
return (set & flag2set(f)) != 0;
......
......@@ -41,16 +41,6 @@
namespace v8 {
namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return CpuFeatures::IsSupported(SSE2);
}
void CPU::FlushICache(void* start, size_t size) {
// No need to flush the instruction cache on Intel. On Intel instruction
// cache flushing is only necessary when multiple cores running the same
......
......@@ -1808,7 +1808,7 @@ bool Isolate::Init(Deserializer* des) {
use_crankshaft_ = FLAG_crankshaft
&& !Serializer::enabled()
&& CPU::SupportsCrankshaft();
&& CpuFeatures::SupportsCrankshaft();
if (function_entry_hook() != NULL) {
// When function entry hooking is in effect, we have to create the code
......
......@@ -46,7 +46,6 @@ namespace internal {
#ifdef DEBUG
bool CpuFeatures::initialized_ = false;
#endif
bool CpuFeatures::hint_creating_snapshot_ = false;
unsigned CpuFeatures::supported_ = 0;
unsigned CpuFeatures::found_by_runtime_probing_only_ = 0;
unsigned CpuFeatures::cross_compile_ = 0;
......@@ -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) {
unsigned standard_features = (OS::CpuFeaturesImpliedByPlatform() |
CpuFeaturesImpliedByCompiler());
......
......@@ -425,12 +425,10 @@ class CpuFeatures : public AllStatic {
public:
// Detect features of the target CPU. Set safe defaults if the serializer
// 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();
// Check whether a feature is supported by the target CPU.
static bool IsSupported(CpuFeature f) {
......@@ -459,10 +457,9 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask;
}
private:
static void Probe(bool serializer_enabled);
static bool hint_creating_snapshot_;
static bool SupportsCrankshaft() { return CpuFeatures::IsSupported(FPU); }
private:
static bool Check(CpuFeature f, unsigned set) {
return (set & flag2set(f)) != 0;
}
......
......@@ -47,16 +47,6 @@ namespace v8 {
namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return CpuFeatures::IsSupported(FPU);
}
void CPU::FlushICache(void* start, size_t size) {
// Nothing to do, flushing no instructions.
if (size == 0) {
......
......@@ -301,15 +301,9 @@ int main(int argc, char** argv) {
// By default, log code create information in the snapshot.
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
// 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) {
::printf("Usage: %s [flag] ... outfile\n", argv[0]);
i::FlagList::PrintHelp();
......
......@@ -144,7 +144,7 @@ void V8::InitializeOncePerProcessImpl() {
platform_ = new DefaultPlatform;
#endif
Sampler::SetUp();
CPU::SetUp();
CpuFeatures::Probe(Serializer::enabled());
OS::PostSetUp();
ElementsAccessor::InitializeOncePerProcess();
LOperand::SetUpCaches();
......
......@@ -52,13 +52,13 @@ ExternalReference ExternalReference::cpu_features() {
}
void CpuFeatures::Probe() {
void CpuFeatures::Probe(bool serializer_enabled) {
ASSERT(supported_ == CpuFeatures::kDefaultCpuFeatures);
#ifdef DEBUG
initialized_ = true;
#endif
supported_ = kDefaultCpuFeatures;
if (Serializer::enabled()) {
if (serializer_enabled) {
supported_ |= OS::CpuFeaturesImpliedByPlatform();
return; // No features if we might serialize.
}
......
......@@ -450,7 +450,7 @@ class CpuFeatures : public AllStatic {
public:
// Detect features of the target CPU. Set safe defaults if the serializer
// 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.
static bool IsSupported(CpuFeature f) {
......@@ -484,6 +484,8 @@ class CpuFeatures : public AllStatic {
(cross_compile_ & mask) == mask;
}
static bool SupportsCrankshaft() { return true; }
private:
static bool Check(CpuFeature f, uint64_t set) {
return (set & flag2set(f)) != 0;
......
......@@ -41,16 +41,6 @@
namespace v8 {
namespace internal {
void CPU::SetUp() {
CpuFeatures::Probe();
}
bool CPU::SupportsCrankshaft() {
return true; // Yay!
}
void CPU::FlushICache(void* start, size_t size) {
// No need to flush the instruction cache on Intel. On Intel instruction
// 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