diff options
Diffstat (limited to 'deps/v8/src/log.cc')
-rw-r--r-- | deps/v8/src/log.cc | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/deps/v8/src/log.cc b/deps/v8/src/log.cc index f19897b27b1..a3f484fd595 100644 --- a/deps/v8/src/log.cc +++ b/deps/v8/src/log.cc @@ -8,7 +8,7 @@ #include <memory> #include <sstream> -#include "src/api.h" +#include "src/api-inl.h" #include "src/bailout-reason.h" #include "src/base/platform/platform.h" #include "src/bootstrapper.h" @@ -127,21 +127,10 @@ class CodeEventLogger::NameBuffer { void AppendString(String* str) { if (str == nullptr) return; - int uc16_length = Min(str->length(), kUtf16BufferSize); - String::WriteToFlat(str, utf16_buffer, 0, uc16_length); - int previous = unibrow::Utf16::kNoPreviousCharacter; - for (int i = 0; i < uc16_length && utf8_pos_ < kUtf8BufferSize; ++i) { - uc16 c = utf16_buffer[i]; - if (c <= unibrow::Utf8::kMaxOneByteChar) { - utf8_buffer_[utf8_pos_++] = static_cast<char>(c); - } else { - int char_length = unibrow::Utf8::Length(c, previous); - if (utf8_pos_ + char_length > kUtf8BufferSize) break; - unibrow::Utf8::Encode(utf8_buffer_ + utf8_pos_, c, previous); - utf8_pos_ += char_length; - } - previous = c; - } + int length = 0; + std::unique_ptr<char[]> c_str = + str->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL, &length); + AppendBytes(c_str.get(), length); } void AppendBytes(const char* bytes, int size) { @@ -188,7 +177,6 @@ class CodeEventLogger::NameBuffer { int utf8_pos_; char utf8_buffer_[kUtf8BufferSize]; - uc16 utf16_buffer[kUtf16BufferSize]; }; CodeEventLogger::CodeEventLogger(Isolate* isolate) @@ -1023,7 +1011,7 @@ void Logger::UncheckedIntPtrTEvent(const char* name, intptr_t value) { if (!log_->IsEnabled()) return; Log::MessageBuilder msg(log_); msg << name << kNext; - msg.Append("%" V8PRIdPTR, value); + msg.AppendFormatString("%" V8PRIdPTR, value); msg.WriteToLogFile(); } @@ -1283,7 +1271,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag, if (name.is_empty()) { msg << "<unknown wasm>"; } else { - msg.AppendStringPart(name.start(), name.length()); + msg.AppendString(name); } // We have to add two extra fields that allow the tick processor to group // events for the same wasm function, even if it gets compiled again. For @@ -1499,7 +1487,8 @@ void Logger::ResourceEvent(const char* name, const char* tag) { if (base::OS::GetUserTime(&sec, &usec) != -1) { msg << sec << kNext << usec << kNext; } - msg.Append("%.0f", V8::GetCurrentPlatform()->CurrentClockTimeMillis()); + msg.AppendFormatString("%.0f", + V8::GetCurrentPlatform()->CurrentClockTimeMillis()); msg.WriteToLogFile(); } @@ -1545,7 +1534,7 @@ void Logger::FunctionEvent(const char* reason, int script_id, double time_delta, AppendFunctionMessage(msg, reason, script_id, time_delta, start_position, end_position, &timer_); if (function_name_length > 0) { - msg.AppendStringPart(function_name, function_name_length); + msg.AppendString(function_name, function_name_length); } msg.WriteToLogFile(); } @@ -2027,17 +2016,20 @@ sampler::Sampler* Logger::sampler() { return ticker_; } - -FILE* Logger::TearDown() { - if (!is_initialized_) return nullptr; - is_initialized_ = false; - - // Stop the profiler before closing the file. +void Logger::StopProfilerThread() { if (profiler_ != nullptr) { profiler_->Disengage(); delete profiler_; profiler_ = nullptr; } +} + +FILE* Logger::TearDown() { + if (!is_initialized_) return nullptr; + is_initialized_ = false; + + // Stop the profiler thread before closing the file. + StopProfilerThread(); delete ticker_; ticker_ = nullptr; @@ -2239,9 +2231,6 @@ void ExistingCodeLogger::LogExistingFunction( #endif CALL_CODE_EVENT_HANDLER(CallbackEvent(shared->DebugName(), entry_point)) } - } else { - CALL_CODE_EVENT_HANDLER(CodeCreateEvent( - tag, *code, *shared, ReadOnlyRoots(isolate_).empty_string())) } } |