57 file_name_(file_name),
58 output_handle_(
LogFile::CreateOutputHandle(file_name)),
59 os_(output_handle_ == nullptr ? stdout : output_handle_),
60 format_buffer_(
NewArray<char>(kMessageBufferSize)) {
84 std::unique_ptr<LogFile::MessageBuilder>
result(
110 : log_(log), lock_guard_(&log_->
mutex_) {}
113 std::optional<int> length_limit) {
118 int length = str->length();
119 if (length_limit) length = std::min(length, *length_limit);
121 uint16_t c = str->Get(
i, access_guard);
123 AppendCharacter(
static_cast<char>(c));
126 AppendRawFormatString(
"\\u%04x", c & 0xFFFF);
132 for (
auto i = str.
begin();
i < str.
end();
i++) AppendCharacter(*
i);
136 if (str ==
nullptr)
return;
137 AppendString(str, strlen(str));
142 if (str ==
nullptr)
return;
146 AppendCharacter(str[
i]);
150 for (
size_t i = 0;
i + 1 <
length;
i += 2) {
151 AppendTwoByteCharacter(str[
i], str[
i + 1]);
156void LogFile::MessageBuilder::AppendFormatString(
const char* format, ...) {
158 va_start(
args, format);
159 const int length = FormatStringIntoBuffer(format,
args);
163 AppendCharacter(log_->format_buffer_[
i]);
172 AppendRawFormatString(
"\\u%02x%02x", c1 & 0xFF, c2 & 0xFF);
176 if (std::isprint(c)) {
179 AppendRawString(
"\\x2C");
180 }
else if (c ==
'\\') {
181 AppendRawString(
"\\\\");
184 AppendRawCharacter(c);
186 }
else if (c ==
'\n') {
188 AppendRawString(
"\\n");
191 AppendRawFormatString(
"\\x%02x", c & 0xFF);
196 DCHECK(!symbol.is_null());
199 if (!IsUndefined(symbol->description())) {
201 AppendSymbolNameDetails(
Cast<String>(symbol->description()),
false);
204 os <<
"hash " << std::hex << symbol->hash() << std::dec <<
")";
208 bool show_impl_info) {
213 int limit = str->length();
214 if (limit > 0x1000) limit = 0x1000;
215 if (show_impl_info) {
216 os << (str->IsOneByteRepresentation() ?
'a' :
'2');
219 os <<
':' << str->length() <<
':';
221 AppendString(str, limit);
224int LogFile::MessageBuilder::FormatStringIntoBuffer(
const char* format,
236void LogFile::MessageBuilder::AppendRawFormatString(
const char* format, ...) {
238 va_start(
args, format);
239 const int length = FormatStringIntoBuffer(format,
args);
243 AppendRawCharacter(log_->format_buffer_[
i]);
257 const char*
string) {
258 this->AppendString(
string);
268 os <<
"0x" << std::hex << reinterpret_cast<intptr_t>(pointer) << std::dec;
273LogFile::MessageBuilder& LogFile::MessageBuilder::operator<<<char>(
char c) {
274 this->AppendCharacter(c);
279LogFile::MessageBuilder& LogFile::MessageBuilder::operator<< <Tagged<String>>(
281 this->AppendString(
string);
286LogFile::MessageBuilder& LogFile::MessageBuilder::operator<< <Tagged<Symbol>>(
288 this->AppendSymbolName(symbol);
293LogFile::MessageBuilder& LogFile::MessageBuilder::operator<< <Tagged<Name>>(
295 if (IsString(name)) {
304LogFile::MessageBuilder& LogFile::MessageBuilder::operator<<<LogSeparator>(
307 this->AppendRawCharacter(
',');
static const char *const LogFileOpenMode
static FILE * OpenTemporaryFile()
static FILE * FOpen(const char *path, const char *mode)
constexpr T * begin() const
constexpr T * end() const
void void AppendRawString(const char *format)
void AppendSymbolName(Tagged< Symbol > symbol)
void AppendSymbolNameDetails(Tagged< String > str, bool show_impl_info)
void void AppendCharacter(char c)
MessageBuilder(LogFile *log)
void AppendString(Tagged< String > str, std::optional< int > length_limit=std::nullopt)
void AppendRawCharacter(const char character)
void AppendTwoByteCharacter(char c1, char c2)
LogFile(V8FileLogger *logger, std::string log_file_name)
static FILE * CreateOutputHandle(std::string file_name)
static V8_EXPORT_PRIVATE bool IsLoggingToTemporaryFile(std::string file_name)
std::unique_ptr< LogFile::MessageBuilder > NewMessageBuilder()
std::unique_ptr< char[]> format_buffer_
std::string file_name() const
static V8_EXPORT_PRIVATE bool IsLoggingToConsole(std::string file_name)
static const char *const kLogToConsole
static const int kMessageBufferSize
static V8_EXPORT_PRIVATE const char *const kLogToTemporaryFile
V8_INLINE constexpr bool is_null() const
V8_EXPORT_PRIVATE bool is_logging()
static const char * GetEmbedder()
static bool IsCandidate()
base::Vector< const DirectHandle< Object > > args
ZoneVector< RpoNumber > & result
int VSNPrintF(Vector< char > str, const char *format, va_list args)
Tagged(T object) -> Tagged< T >
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
V8_EXPORT_PRIVATE FlagValues v8_flags
T * NewArray(size_t size)
template const char * string
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_LE(v1, v2)
#define DCHECK_NOT_NULL(val)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_NE(v1, v2)
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define V8_TARGET_OS_STRING