| Index: src/log.cc
|
| ===================================================================
|
| --- src/log.cc (revision 8618)
|
| +++ src/log.cc (working copy)
|
| @@ -122,6 +122,7 @@
|
| // Returns the next index in the cyclic buffer.
|
| int Succ(int index) { return (index + 1) % kBufferSize; }
|
|
|
| + Isolate* isolate_;
|
| // Cyclic buffer for communicating profiling samples
|
| // between the signal handler and the worker thread.
|
| static const int kBufferSize = 128;
|
| @@ -148,10 +149,6 @@
|
| void StackTracer::Trace(Isolate* isolate, TickSample* sample) {
|
| ASSERT(isolate->IsInitialized());
|
|
|
| - sample->tos = NULL;
|
| - sample->frames_count = 0;
|
| - sample->has_external_callback = false;
|
| -
|
| // Avoid collecting traces while doing GC.
|
| if (sample->state == GC) return;
|
|
|
| @@ -271,7 +268,8 @@
|
| // Profiler implementation.
|
| //
|
| Profiler::Profiler(Isolate* isolate)
|
| - : Thread(isolate, "v8:Profiler"),
|
| + : Thread("v8:Profiler"),
|
| + isolate_(isolate),
|
| head_(0),
|
| tail_(0),
|
| overflow_(false),
|
| @@ -326,9 +324,8 @@
|
| void Profiler::Run() {
|
| TickSample sample;
|
| bool overflow = Remove(&sample);
|
| - i::Isolate* isolate = ISOLATE;
|
| while (running_) {
|
| - LOG(isolate, TickEvent(&sample, overflow));
|
| + LOG(isolate_, TickEvent(&sample, overflow));
|
| overflow = Remove(&sample);
|
| }
|
| }
|
| @@ -399,8 +396,10 @@
|
|
|
| void Remove(Address code_address) {
|
| HashMap::Entry* entry = FindEntry(code_address);
|
| - if (entry != NULL) DeleteArray(static_cast<const char*>(entry->value));
|
| - RemoveEntry(entry);
|
| + if (entry != NULL) {
|
| + DeleteArray(static_cast<char*>(entry->value));
|
| + RemoveEntry(entry);
|
| + }
|
| }
|
|
|
| void Move(Address from, Address to) {
|
| @@ -522,7 +521,6 @@
|
| log_events_(NULL),
|
| logging_nesting_(0),
|
| cpu_profiler_nesting_(0),
|
| - heap_profiler_nesting_(0),
|
| log_(new Log(this)),
|
| name_buffer_(new NameBuffer),
|
| address_to_name_map_(NULL),
|
| @@ -1287,19 +1285,6 @@
|
| }
|
|
|
|
|
| -void Logger::HeapSampleStats(const char* space, const char* kind,
|
| - intptr_t capacity, intptr_t used) {
|
| -#ifdef ENABLE_LOGGING_AND_PROFILING
|
| - if (!log_->IsEnabled() || !FLAG_log_gc) return;
|
| - LogMessageBuilder msg(this);
|
| - msg.Append("heap-sample-stats,\"%s\",\"%s\","
|
| - "%" V8_PTR_PREFIX "d,%" V8_PTR_PREFIX "d\n",
|
| - space, kind, capacity, used);
|
| - msg.WriteToLogFile();
|
| -#endif
|
| -}
|
| -
|
| -
|
| void Logger::HeapSampleEndEvent(const char* space, const char* kind) {
|
| #ifdef ENABLE_LOGGING_AND_PROFILING
|
| if (!log_->IsEnabled() || !FLAG_log_gc) return;
|
| @@ -1320,72 +1305,6 @@
|
| }
|
|
|
|
|
| -void Logger::HeapSampleJSConstructorEvent(const char* constructor,
|
| - int number, int bytes) {
|
| -#ifdef ENABLE_LOGGING_AND_PROFILING
|
| - if (!log_->IsEnabled() || !FLAG_log_gc) return;
|
| - LogMessageBuilder msg(this);
|
| - msg.Append("heap-js-cons-item,%s,%d,%d\n", constructor, number, bytes);
|
| - msg.WriteToLogFile();
|
| -#endif
|
| -}
|
| -
|
| -// Event starts with comma, so we don't have it in the format string.
|
| -static const char kEventText[] = "heap-js-ret-item,%s";
|
| -// We take placeholder strings into account, but it's OK to be conservative.
|
| -static const int kEventTextLen = sizeof(kEventText)/sizeof(kEventText[0]);
|
| -
|
| -void Logger::HeapSampleJSRetainersEvent(
|
| - const char* constructor, const char* event) {
|
| -#ifdef ENABLE_LOGGING_AND_PROFILING
|
| - if (!log_->IsEnabled() || !FLAG_log_gc) return;
|
| - const int cons_len = StrLength(constructor);
|
| - const int event_len = StrLength(event);
|
| - int pos = 0;
|
| - // Retainer lists can be long. We may need to split them into multiple events.
|
| - do {
|
| - LogMessageBuilder msg(this);
|
| - msg.Append(kEventText, constructor);
|
| - int to_write = event_len - pos;
|
| - if (to_write > Log::kMessageBufferSize - (cons_len + kEventTextLen)) {
|
| - int cut_pos = pos + Log::kMessageBufferSize - (cons_len + kEventTextLen);
|
| - ASSERT(cut_pos < event_len);
|
| - while (cut_pos > pos && event[cut_pos] != ',') --cut_pos;
|
| - if (event[cut_pos] != ',') {
|
| - // Crash in debug mode, skip in release mode.
|
| - ASSERT(false);
|
| - return;
|
| - }
|
| - // Append a piece of event that fits, without trailing comma.
|
| - msg.AppendStringPart(event + pos, cut_pos - pos);
|
| - // Start next piece with comma.
|
| - pos = cut_pos;
|
| - } else {
|
| - msg.Append("%s", event + pos);
|
| - pos += event_len;
|
| - }
|
| - msg.Append('\n');
|
| - msg.WriteToLogFile();
|
| - } while (pos < event_len);
|
| -#endif
|
| -}
|
| -
|
| -
|
| -void Logger::HeapSampleJSProducerEvent(const char* constructor,
|
| - Address* stack) {
|
| -#ifdef ENABLE_LOGGING_AND_PROFILING
|
| - if (!log_->IsEnabled() || !FLAG_log_gc) return;
|
| - LogMessageBuilder msg(this);
|
| - msg.Append("heap-js-prod-item,%s", constructor);
|
| - while (*stack != NULL) {
|
| - msg.Append(",0x%" V8PRIxPTR, *stack++);
|
| - }
|
| - msg.Append("\n");
|
| - msg.WriteToLogFile();
|
| -#endif
|
| -}
|
| -
|
| -
|
| void Logger::DebugTag(const char* call_site_tag) {
|
| #ifdef ENABLE_LOGGING_AND_PROFILING
|
| if (!log_->IsEnabled() || !FLAG_log) return;
|
| @@ -1443,21 +1362,14 @@
|
| }
|
|
|
|
|
| -int Logger::GetActiveProfilerModules() {
|
| - int result = PROFILER_MODULE_NONE;
|
| - if (profiler_ != NULL && !profiler_->paused()) {
|
| - result |= PROFILER_MODULE_CPU;
|
| - }
|
| - if (FLAG_log_gc) {
|
| - result |= PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS;
|
| - }
|
| - return result;
|
| +bool Logger::IsProfilerPaused() {
|
| + return profiler_ == NULL || profiler_->paused();
|
| }
|
|
|
|
|
| -void Logger::PauseProfiler(int flags, int tag) {
|
| +void Logger::PauseProfiler() {
|
| if (!log_->IsEnabled()) return;
|
| - if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) {
|
| + if (profiler_ != NULL) {
|
| // It is OK to have negative nesting.
|
| if (--cpu_profiler_nesting_ == 0) {
|
| profiler_->pause();
|
| @@ -1472,25 +1384,12 @@
|
| --logging_nesting_;
|
| }
|
| }
|
| - if (flags &
|
| - (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
|
| - if (--heap_profiler_nesting_ == 0) {
|
| - FLAG_log_gc = false;
|
| - --logging_nesting_;
|
| - }
|
| - }
|
| - if (tag != 0) {
|
| - UncheckedIntEvent("close-tag", tag);
|
| - }
|
| }
|
|
|
|
|
| -void Logger::ResumeProfiler(int flags, int tag) {
|
| +void Logger::ResumeProfiler() {
|
| if (!log_->IsEnabled()) return;
|
| - if (tag != 0) {
|
| - UncheckedIntEvent("open-tag", tag);
|
| - }
|
| - if (profiler_ != NULL && (flags & PROFILER_MODULE_CPU)) {
|
| + if (profiler_ != NULL) {
|
| if (cpu_profiler_nesting_++ == 0) {
|
| ++logging_nesting_;
|
| if (FLAG_prof_lazy) {
|
| @@ -1506,20 +1405,13 @@
|
| profiler_->resume();
|
| }
|
| }
|
| - if (flags &
|
| - (PROFILER_MODULE_HEAP_STATS | PROFILER_MODULE_JS_CONSTRUCTORS)) {
|
| - if (heap_profiler_nesting_++ == 0) {
|
| - ++logging_nesting_;
|
| - FLAG_log_gc = true;
|
| - }
|
| - }
|
| }
|
|
|
|
|
| // This function can be called when Log's mutex is acquired,
|
| // either from main or Profiler's thread.
|
| void Logger::LogFailure() {
|
| - PauseProfiler(PROFILER_MODULE_CPU, 0);
|
| + PauseProfiler();
|
| }
|
|
|
|
|
| @@ -1544,8 +1436,12 @@
|
| virtual void LeaveContext(Context* context) {}
|
|
|
| virtual void VisitFunction(JSFunction* function) {
|
| + SharedFunctionInfo* sfi = SharedFunctionInfo::cast(function->shared());
|
| + Object* maybe_script = sfi->script();
|
| + if (maybe_script->IsScript()
|
| + && !Script::cast(maybe_script)->HasValidSource()) return;
|
| if (sfis_ != NULL) {
|
| - sfis_[*count_] = Handle<SharedFunctionInfo>(function->shared());
|
| + sfis_[*count_] = Handle<SharedFunctionInfo>(sfi);
|
| }
|
| if (code_objects_ != NULL) {
|
| ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION);
|
| @@ -1841,9 +1737,9 @@
|
|
|
| if (FLAG_ll_prof) LogCodeInfo();
|
|
|
| - ticker_ = new Ticker(Isolate::Current(), kSamplingIntervalMs);
|
| -
|
| Isolate* isolate = Isolate::Current();
|
| + ticker_ = new Ticker(isolate, kSamplingIntervalMs);
|
| +
|
| if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {
|
| sliding_state_window_ = new SlidingStateWindow(isolate);
|
| }
|
| @@ -1877,7 +1773,11 @@
|
|
|
|
|
| Sampler* Logger::sampler() {
|
| +#ifdef ENABLE_LOGGING_AND_PROFILING
|
| return ticker_;
|
| +#else
|
| + return NULL;
|
| +#endif
|
| }
|
|
|
|
|
| @@ -1954,8 +1854,10 @@
|
|
|
|
|
| static void ComputeCpuProfiling(Sampler* sampler, void* flag_ptr) {
|
| +#ifdef ENABLE_LOGGING_AND_PROFILING
|
| bool* flag = reinterpret_cast<bool*>(flag_ptr);
|
| *flag |= sampler->IsProfiling();
|
| +#endif
|
| }
|
|
|
|
|
|
|