diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc index 2bd62ad390..953952a91d 100644 --- a/src/cpu-profiler.cc +++ b/src/cpu-profiler.cc @@ -39,13 +39,14 @@ namespace v8 { namespace internal { -static const int kEventsBufferSize = 256*KB; -static const int kTickSamplesBufferChunkSize = 64*KB; +static const int kEventsBufferSize = 256 * KB; +static const int kTickSamplesBufferChunkSize = 64 * KB; static const int kTickSamplesBufferChunksCount = 16; +static const int kProfilerStackSize = 32 * KB; ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator) - : Thread("v8:ProfEvntProc"), + : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), generator_(generator), running_(true), ticks_buffer_(sizeof(TickSampleEventRecord), diff --git a/src/d8.cc b/src/d8.cc index 35d1a5914c..e555c15484 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -120,6 +120,9 @@ ShellOptions Shell::options; const char* Shell::kPrompt = "d8> "; +const int MB = 1024 * 1024; + + #ifndef V8_SHARED bool CounterMap::Match(void* key1, void* key2) { const char* name1 = reinterpret_cast(key1); @@ -1210,14 +1213,11 @@ Handle SourceGroup::ReadFile(const char* name) { #ifndef V8_SHARED i::Thread::Options SourceGroup::GetThreadOptions() { - i::Thread::Options options; - options.name = "IsolateThread"; // On some systems (OSX 10.6) the stack size default is 0.5Mb or less // which is not enough to parse the big literal expressions used in tests. // The stack size should be at least StackGuard::kLimitSize + some - // OS-specific padding for thread startup code. - options.stack_size = 2 << 20; // 2 Mb seems to be enough - return options; + // OS-specific padding for thread startup code. 2Mbytes seems to be enough. + return i::Thread::Options("IsolateThread", 2 * MB); } diff --git a/src/heap-inl.h b/src/heap-inl.h index 4d98fbad10..23fe3060a6 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -505,7 +505,6 @@ Isolate* Heap::isolate() { #define GC_GREEDY_CHECK() { } #endif - // Calls the FUNCTION_CALL function and retries it up to three times // to guarantee that any allocations performed during the call will // succeed if there's enough memory. diff --git a/src/platform-freebsd.cc b/src/platform-freebsd.cc index 6d04fb1aaa..c6dedd4ad2 100644 --- a/src/platform-freebsd.cc +++ b/src/platform-freebsd.cc @@ -464,15 +464,8 @@ class Thread::PlatformData : public Malloced { Thread::Thread(const Options& options) : data_(new PlatformData), - stack_size_(options.stack_size) { - set_name(options.name); -} - - -Thread::Thread(const char* name) - : data_(new PlatformData), - stack_size_(0) { - set_name(name); + stack_size_(options.stack_size()) { + set_name(options.name()); } @@ -717,8 +710,10 @@ class SignalSender : public Thread { FULL_INTERVAL }; + static const int kSignalSenderStackSize = 32 * KB; + explicit SignalSender(int interval) - : Thread("SignalSender"), + : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), interval_(interval) {} static void AddActiveSampler(Sampler* sampler) { diff --git a/src/platform-linux.cc b/src/platform-linux.cc index 30b6086616..6f64f2d31c 100644 --- a/src/platform-linux.cc +++ b/src/platform-linux.cc @@ -720,15 +720,8 @@ class Thread::PlatformData : public Malloced { Thread::Thread(const Options& options) : data_(new PlatformData()), - stack_size_(options.stack_size) { - set_name(options.name); -} - - -Thread::Thread(const char* name) - : data_(new PlatformData()), - stack_size_(0) { - set_name(name); + stack_size_(options.stack_size()) { + set_name(options.name()); } @@ -1035,8 +1028,10 @@ class SignalSender : public Thread { FULL_INTERVAL }; + static const int kSignalSenderStackSize = 32 * KB; + explicit SignalSender(int interval) - : Thread("SignalSender"), + : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), vm_tgid_(getpid()), interval_(interval) {} diff --git a/src/platform-macos.cc b/src/platform-macos.cc index 9f8fe1209f..f061f67a40 100644 --- a/src/platform-macos.cc +++ b/src/platform-macos.cc @@ -473,17 +473,11 @@ class Thread::PlatformData : public Malloced { pthread_t thread_; // Thread handle for pthread. }; + Thread::Thread(const Options& options) : data_(new PlatformData), - stack_size_(options.stack_size) { - set_name(options.name); -} - - -Thread::Thread(const char* name) - : data_(new PlatformData), - stack_size_(0) { - set_name(name); + stack_size_(options.stack_size()) { + set_name(options.name()); } @@ -736,10 +730,13 @@ class Sampler::PlatformData : public Malloced { thread_act_t profiled_thread_; }; + class SamplerThread : public Thread { public: + static const int kSamplerThreadStackSize = 32 * KB; + explicit SamplerThread(int interval) - : Thread("SamplerThread"), + : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), interval_(interval) {} static void AddActiveSampler(Sampler* sampler) { diff --git a/src/platform-openbsd.cc b/src/platform-openbsd.cc index fda5fb4589..96dece0146 100644 --- a/src/platform-openbsd.cc +++ b/src/platform-openbsd.cc @@ -512,15 +512,8 @@ class Thread::PlatformData : public Malloced { Thread::Thread(const Options& options) : data_(new PlatformData()), - stack_size_(options.stack_size) { - set_name(options.name); -} - - -Thread::Thread(const char* name) - : data_(new PlatformData()), - stack_size_(0) { - set_name(name); + stack_size_(options.stack_size()) { + set_name(options.name()); } @@ -789,8 +782,10 @@ class SignalSender : public Thread { FULL_INTERVAL }; + static const int kSignalSenderStackSize = 32 * KB; + explicit SignalSender(int interval) - : Thread("SignalSender"), + : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), vm_tgid_(getpid()), interval_(interval) {} diff --git a/src/platform-solaris.cc b/src/platform-solaris.cc index 9b3713f65a..85a420350b 100644 --- a/src/platform-solaris.cc +++ b/src/platform-solaris.cc @@ -453,17 +453,11 @@ class Thread::PlatformData : public Malloced { pthread_t thread_; // Thread handle for pthread. }; + Thread::Thread(const Options& options) : data_(new PlatformData()), - stack_size_(options.stack_size) { - set_name(options.name); -} - - -Thread::Thread(const char* name) - : data_(new PlatformData()), - stack_size_(0) { - set_name(name); + stack_size_(options.stack_size()) { + set_name(options.name()); } @@ -710,8 +704,10 @@ class SignalSender : public Thread { FULL_INTERVAL }; + static const int kSignalSenderStackSize = 32 * KB; + explicit SignalSender(int interval) - : Thread("SignalSender"), + : Thread(Thread::Options("SignalSender", kSignalSenderStackSize)), interval_(interval) {} static void InstallSignalHandler() { diff --git a/src/platform-win32.cc b/src/platform-win32.cc index ffda6606a8..52bc3f569c 100644 --- a/src/platform-win32.cc +++ b/src/platform-win32.cc @@ -1526,16 +1526,9 @@ class Thread::PlatformData : public Malloced { // handle until it is started. Thread::Thread(const Options& options) - : stack_size_(options.stack_size) { + : stack_size_(options.stack_size()) { data_ = new PlatformData(kNoThread); - set_name(options.name); -} - - -Thread::Thread(const char* name) - : stack_size_(0) { - data_ = new PlatformData(kNoThread); - set_name(name); + set_name(options.name()); } @@ -1901,8 +1894,10 @@ class Sampler::PlatformData : public Malloced { class SamplerThread : public Thread { public: + static const int kSamplerThreadStackSize = 32 * KB; + explicit SamplerThread(int interval) - : Thread("SamplerThread"), + : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), interval_(interval) {} static void AddActiveSampler(Sampler* sampler) { diff --git a/src/platform.h b/src/platform.h index fc12df2d7c..a0186d580f 100644 --- a/src/platform.h +++ b/src/platform.h @@ -412,16 +412,22 @@ class Thread { LOCAL_STORAGE_KEY_MAX_VALUE = kMaxInt }; - struct Options { - Options() : name("v8:"), stack_size(0) {} + class Options { + public: + Options() : name_("v8:"), stack_size_(0) {} + Options(const char* name, int stack_size = 0) + : name_(name), stack_size_(stack_size) {} - const char* name; - int stack_size; + const char* name() const { return name_; } + int stack_size() const { return stack_size_; } + + private: + const char* name_; + int stack_size_; }; // Create new thread. explicit Thread(const Options& options); - explicit Thread(const char* name); virtual ~Thread(); // Start new thread by calling the Run() method in the new thread. diff --git a/test/cctest/test-mark-compact.cc b/test/cctest/test-mark-compact.cc index 3c66c4c80b..0929cd4479 100644 --- a/test/cctest/test-mark-compact.cc +++ b/test/cctest/test-mark-compact.cc @@ -526,12 +526,25 @@ static intptr_t MemoryInUse() { TEST(BootUpMemoryUse) { intptr_t initial_memory = MemoryInUse(); + FLAG_crankshaft = false; // Avoid flakiness. // Only Linux has the proc filesystem and only if it is mapped. If it's not // there we just skip the test. if (initial_memory >= 0) { InitializeVM(); intptr_t booted_memory = MemoryInUse(); - CHECK_LE(booted_memory - initial_memory, 16 * 1024 * 1024); + if (sizeof(initial_memory) == 8) { + if (v8::internal::Snapshot::IsEnabled()) { + CHECK_LE(booted_memory - initial_memory, 7654 * 1024); // 7468. + } else { + CHECK_LE(booted_memory - initial_memory, 7777 * 1024); // 7620. + } + } else { + if (v8::internal::Snapshot::IsEnabled()) { + CHECK_LE(booted_memory - initial_memory, 7500 * 1024); // 7380. + } else { + CHECK_LE(booted_memory - initial_memory, 7654 * 1024); // 7448 + } + } } }