⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.cc.svn-base

📁 Google浏览器V8内核代码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
  fprintf(logfile_, "\n");#endif}void Logger::RegExpExecEvent(Handle<JSRegExp> regexp,                             int start_index,                             Handle<String> input_string) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_regexp) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "regexp-run,");  LogRegExpSource(regexp);  fprintf(logfile_, ",0x%08x,%d..%d\n",      input_string->Hash(), start_index, input_string->length());#endif}void Logger::ApiIndexedSecurityCheck(uint32_t index) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_api) return;  ApiEvent("api,check-security,%u\n", index);#endif}void Logger::ApiNamedPropertyAccess(const char* tag,                                    JSObject* holder,                                    Object* name) {#ifdef ENABLE_LOGGING_AND_PROFILING  ASSERT(name->IsString());  if (logfile_ == NULL || !FLAG_log_api) return;  String* class_name_obj = holder->class_name();  SmartPointer<char> class_name =      class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);  SmartPointer<char> property_name =      String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);  Logger::ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name);#endif}void Logger::ApiIndexedPropertyAccess(const char* tag,                                      JSObject* holder,                                      uint32_t index) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_api) return;  String* class_name_obj = holder->class_name();  SmartPointer<char> class_name =      class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);  Logger::ApiEvent("api,%s,\"%s\",%u\n", tag, *class_name, index);#endif}void Logger::ApiObjectAccess(const char* tag, JSObject* object) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_api) return;  String* class_name_obj = object->class_name();  SmartPointer<char> class_name =      class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);  Logger::ApiEvent("api,%s,\"%s\"\n", tag, *class_name);#endif}void Logger::ApiEntryCall(const char* name) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_api) return;  Logger::ApiEvent("api,%s\n", name);#endif}void Logger::NewEvent(const char* name, void* object, size_t size) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "new,%s,0x%x,%u\n", name,          reinterpret_cast<unsigned int>(object),          static_cast<unsigned int>(size));#endif}void Logger::DeleteEvent(const char* name, void* object) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "delete,%s,0x%x\n", name,          reinterpret_cast<unsigned int>(object));#endif}void Logger::CodeCreateEvent(const char* tag, Code* code, const char* comment) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_code) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "code-creation,%s,0x%x,%d,\"", tag,          reinterpret_cast<unsigned int>(code->address()),          code->instruction_size());  for (const char* p = comment; *p != '\0'; p++) {    if (*p == '\"') fprintf(logfile_, "\\");    fprintf(logfile_, "%c", *p);  }  fprintf(logfile_, "\"\n");#endif}void Logger::CodeCreateEvent(const char* tag, Code* code, String* name) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_code) return;  ScopedLock sl(mutex_);  SmartPointer<char> str =      name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);  fprintf(logfile_, "code-creation,%s,0x%x,%d,\"%s\"\n", tag,          reinterpret_cast<unsigned int>(code->address()),          code->instruction_size(), *str);#endif}void Logger::CodeCreateEvent(const char* tag, Code* code, int args_count) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_code) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "code-creation,%s,0x%x,%d,\"args_count: %d\"\n", tag,          reinterpret_cast<unsigned int>(code->address()),          code->instruction_size(),          args_count);#endif}void Logger::CodeMoveEvent(Address from, Address to) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_code) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "code-move,0x%x,0x%x\n",          reinterpret_cast<unsigned int>(from),          reinterpret_cast<unsigned int>(to));#endif}void Logger::CodeDeleteEvent(Address from) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_code) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "code-delete,0x%x\n", reinterpret_cast<unsigned int>(from));#endif}void Logger::ResourceEvent(const char* name, const char* tag) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "%s,%s,", name, tag);  uint32_t sec, usec;  if (OS::GetUserTime(&sec, &usec) != -1) {    fprintf(logfile_, "%d,%d,", sec, usec);  }  fprintf(logfile_, "%.0f", OS::TimeCurrentMillis());  fprintf(logfile_, "\n");#endif}void Logger::SuspectReadEvent(String* name, String* obj) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_suspect) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "suspect-read,");  obj->PrintOn(logfile_);  fprintf(logfile_, ",\"");  name->PrintOn(logfile_);  fprintf(logfile_, "\"\n");#endif}void Logger::HeapSampleBeginEvent(const char* space, const char* kind) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_gc) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "heap-sample-begin,\"%s\",\"%s\"\n", space, kind);#endif}void Logger::HeapSampleEndEvent(const char* space, const char* kind) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_gc) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "heap-sample-end,\"%s\",\"%s\"\n", space, kind);#endif}void Logger::HeapSampleItemEvent(const char* type, int number, int bytes) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL || !FLAG_log_gc) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "heap-sample-item,%s,%d,%d\n", type, number, bytes);#endif}void Logger::DebugTag(const char* call_site_tag) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "debug-tag,%s\n", call_site_tag);#endif}void Logger::DebugEvent(const char* event_type, Vector<uint16_t> parameter) {#ifdef ENABLE_LOGGING_AND_PROFILING  if (logfile_ == NULL) return;  StringBuilder s(parameter.length() + 1);  for (int i = 0; i < parameter.length(); ++i) {    s.AddCharacter(static_cast<char>(parameter[i]));  }  char* parameter_string = s.Finalize();  ScopedLock sl(mutex_);  fprintf(logfile_,          "debug-queue-event,%s,%15.3f,%s\n",          event_type,          OS::TimeCurrentMillis(),          parameter_string);  DeleteArray(parameter_string);#endif}#ifdef ENABLE_LOGGING_AND_PROFILINGvoid Logger::TickEvent(TickSample* sample, bool overflow) {  if (logfile_ == NULL) return;  ScopedLock sl(mutex_);  fprintf(logfile_, "tick,0x%x,0x%x,%d", sample->pc, sample->sp,          static_cast<int>(sample->state));  if (overflow) fprintf(logfile_, ",overflow");  fprintf(logfile_, "\n");}#endifbool Logger::Setup() {#ifdef ENABLE_LOGGING_AND_PROFILING  // --log-all enables all the log flags.  if (FLAG_log_all) {    FLAG_log_api = true;    FLAG_log_code = true;    FLAG_log_gc = true;    FLAG_log_suspect = true;    FLAG_log_handles = true;    FLAG_log_regexp = true;  }  // --prof implies --log-code.  if (FLAG_prof) FLAG_log_code = true;  // Each of the individual log flags implies --log.  Check after  // checking --log-all and --prof in case they set --log-code.  if (FLAG_log_api || FLAG_log_code || FLAG_log_gc ||      FLAG_log_handles || FLAG_log_suspect || FLAG_log_regexp) {    FLAG_log = true;  }  // If we're logging anything, we need to open the log file.  if (FLAG_log) {    if (strcmp(FLAG_logfile, "-") == 0) {      logfile_ = stdout;    } else {      logfile_ = OS::FOpen(FLAG_logfile, "w");    }    mutex_ = OS::CreateMutex();  }  current_state_ = new VMState(OTHER);  ticker_ = new Ticker(10);  if (FLAG_sliding_state_window && sliding_state_window_ == NULL) {    sliding_state_window_ = new SlidingStateWindow();  }  if (FLAG_prof) {    profiler_ = new Profiler();    profiler_->Engage();  }  return true;#else  return false;#endif}void Logger::TearDown() {#ifdef ENABLE_LOGGING_AND_PROFILING  // Stop the profiler before closing the file.  if (profiler_ != NULL) {    profiler_->Disengage();    delete profiler_;    profiler_ = NULL;  }  // Deleting the current_state_ has the side effect of assigning to it(!).  while (current_state_) delete current_state_;  delete sliding_state_window_;  delete ticker_;  if (logfile_ != NULL) {    fclose(logfile_);    logfile_ = NULL;    delete mutex_;    mutex_ = NULL;  }#endif}void Logger::EnableSlidingStateWindow() {#ifdef ENABLE_LOGGING_AND_PROFILING  // If the ticker is NULL, Logger::Setup has not been called yet.  In  // that case, we set the sliding_state_window flag so that the  // sliding window computation will be started when Logger::Setup is  // called.  if (ticker_ == NULL) {    FLAG_sliding_state_window = true;    return;  }  // Otherwise, if the sliding state window computation has not been  // started we do it now.  if (sliding_state_window_ == NULL) {    sliding_state_window_ = new SlidingStateWindow();  }#endif}//// VMState class implementation.  A simple stack of VM states held by the// logger and partially threaded through the call stack.  States are pushed by// VMState construction and popped by destruction.//#ifdef ENABLE_LOGGING_AND_PROFILINGstatic const char* StateToString(StateTag state) {  switch (state) {    case GC:      return "GC";    case COMPILER:      return "COMPILER";    case OTHER:      return "OTHER";    default:      UNREACHABLE();      return NULL;  }}VMState::VMState(StateTag state) {  state_ = state;  previous_ = Logger::current_state_;  Logger::current_state_ = this;  if (FLAG_log_state_changes) {    LOG(StringEvent("Entering", StateToString(state_)));    if (previous_) {      LOG(StringEvent("From", StateToString(previous_->state_)));    }  }}VMState::~VMState() {  Logger::current_state_ = previous_;  if (FLAG_log_state_changes) {    LOG(StringEvent("Leaving", StateToString(state_)));    if (previous_) {      LOG(StringEvent("To", StateToString(previous_->state_)));    }  }}#endif} }  // namespace v8::internal

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -