Commit a36c9cb7 authored by Peter Marshall's avatar Peter Marshall Committed by Commit Bot

cleanup: Use unique_ptr in src/logging/ and other cleanups

- Get rid of a bunch of unnecessary friend classes. This required making
  the constructor public
- Remove log_events_ field which is not used
- Use unique_ptr for owned members
- Use make_unique instead of bare constructors
- Use a scoped vector instead of a unique ptr to array for
  the dynamically sized array of WasmModules

Bug: v8:9396
Change-Id: Icdca904e7227d2ce2d75caf092f259d47ff15809
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1803339Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Peter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63776}
parent 91132126
......@@ -75,8 +75,7 @@ FILE* Log::Close() {
}
output_handle_ = nullptr;
DeleteArray(format_buffer_);
format_buffer_ = nullptr;
format_buffer_.reset();
is_stopped_ = false;
return result;
......@@ -84,7 +83,7 @@ FILE* Log::Close() {
Log::MessageBuilder::MessageBuilder(Log* log)
: log_(log), lock_guard_(&log_->mutex_) {
DCHECK_NOT_NULL(log_->format_buffer_);
DCHECK_NOT_NULL(log_->format_buffer_.get());
}
void Log::MessageBuilder::AppendString(String str,
......@@ -185,7 +184,7 @@ void Log::MessageBuilder::AppendSymbolNameDetails(String str,
int Log::MessageBuilder::FormatStringIntoBuffer(const char* format,
va_list args) {
Vector<char> buf(log_->format_buffer_, Log::kMessageBufferSize);
Vector<char> buf(log_->format_buffer_.get(), Log::kMessageBufferSize);
int length = v8::internal::VSNPrintF(buf, format, args);
// |length| is -1 if output was truncated.
if (length == -1) length = Log::kMessageBufferSize;
......
......@@ -125,7 +125,7 @@ class Log {
// Buffer used for formatting log messages. This is a singleton buffer and
// mutex_ should be acquired before using it.
char* format_buffer_;
std::unique_ptr<char[]> format_buffer_;
Logger* logger_;
......
This diff is collapsed.
......@@ -116,6 +116,9 @@ class Logger : public CodeEventListener {
kStreamingCompile
};
explicit Logger(Isolate* isolate);
~Logger();
// The separator is used to write an unescaped "," into the log.
static const LogSeparator kNext;
......@@ -274,9 +277,6 @@ class Logger : public CodeEventListener {
void LogCodeObject(Object code_object);
private:
explicit Logger(Isolate* isolate);
~Logger() override;
// Emits the profiler's first message.
void ProfilerBeginEvent();
......@@ -315,21 +315,11 @@ class Logger : public CodeEventListener {
// of samples.
std::unique_ptr<Profiler> profiler_;
// An array of log events names.
const char* const* log_events_;
// Internal implementation classes with access to
// private members.
friend class EventLog;
friend class Isolate;
friend class TimeLog;
// Internal implementation classes with access to private members.
friend class Profiler;
template <StateTag Tag>
friend class VMState;
friend class LoggerTestHelper;
bool is_logging_;
Log* log_;
std::unique_ptr<Log> log_;
std::unique_ptr<PerfBasicLogger> perf_basic_logger_;
std::unique_ptr<PerfJitLogger> perf_jit_logger_;
std::unique_ptr<LowLevelLogger> ll_logger_;
......@@ -420,7 +410,7 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener {
virtual void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) = 0;
NameBuffer* name_buffer_;
std::unique_ptr<NameBuffer> name_buffer_;
};
struct CodeEvent {
......
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