[offthread] Enable off-thread logging

Enable logging script events and code position events during a
background compile. This isn't technically thread-safe, but neither
are the existing logger accesses in the parser, so something has to
be done here in general.

Bug: chromium:1011762
Change-Id: I3b610c3bb146880ef826928b6f341f402ca6247e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2162853
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69426}
This commit is contained in:
Leszek Swirski 2020-08-14 17:42:09 +02:00 committed by Commit Bot
parent 4c153339e5
commit f5051f02d7
4 changed files with 46 additions and 9 deletions

View File

@ -2710,6 +2710,7 @@ v8_source_set("v8_base_without_compiler") {
"src/logging/counters-inl.h",
"src/logging/counters.cc",
"src/logging/counters.h",
"src/logging/local-logger.cc",
"src/logging/local-logger.h",
"src/logging/log-inl.h",
"src/logging/log-utils.cc",

View File

@ -16,7 +16,7 @@ LocalIsolate::LocalIsolate(Isolate* isolate)
: HiddenLocalFactory(isolate),
heap_(isolate->heap()),
isolate_(isolate),
logger_(new LocalLogger()),
logger_(new LocalLogger(isolate)),
thread_id_(ThreadId::Current()) {}
LocalIsolate::~LocalIsolate() = default;

View File

@ -0,0 +1,31 @@
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/logging/local-logger.h"
#include "src/execution/isolate.h"
namespace v8 {
namespace internal {
// TODO(leszeks): Add support for logging from off-thread.
LocalLogger::LocalLogger(Isolate* isolate)
: logger_(isolate->logger()),
is_logging_(isolate->logger()->is_logging()),
is_listening_to_code_events_(
isolate->logger()->is_listening_to_code_events()) {}
void LocalLogger::ScriptDetails(Script script) {
logger_->ScriptDetails(script);
}
void LocalLogger::ScriptEvent(Logger::ScriptEventType type, int script_id) {
logger_->ScriptEvent(type, script_id);
}
void LocalLogger::CodeLinePosInfoRecordEvent(Address code_start,
ByteArray source_position_table) {
logger_->CodeLinePosInfoRecordEvent(code_start, source_position_table);
}
} // namespace internal
} // namespace v8

View File

@ -14,16 +14,21 @@ namespace internal {
// TODO(leszeks): Add support for logging from off-thread.
class LocalLogger {
public:
bool is_logging() const { return false; }
bool is_listening_to_code_events() const { return false; }
void ScriptEvent(Logger::ScriptEventType type, int script_id) {
UNREACHABLE();
explicit LocalLogger(Isolate* isolate);
bool is_logging() const { return is_logging_; }
bool is_listening_to_code_events() const {
return is_listening_to_code_events_;
}
void ScriptDetails(Script script) { UNREACHABLE(); }
void ScriptDetails(Script script);
void ScriptEvent(Logger::ScriptEventType type, int script_id);
void CodeLinePosInfoRecordEvent(Address code_start,
ByteArray source_position_table) {
UNREACHABLE();
}
ByteArray source_position_table);
private:
Logger* logger_;
bool is_logging_;
bool is_listening_to_code_events_;
};
} // namespace internal