| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2b5d63d commit c2111dd
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,7 +38,7 @@ | |||
| 38 | 38 | ||
| 39 | 39 | # Reset this number to 0 on major V8 upgrades. | |
| 40 | 40 | # Increment by one for each non-official patch applied to deps/v8. | |
| 41 | - 'v8_embedder_string': '-node.24', | ||
| 41 | + 'v8_embedder_string': '-node.25', | ||
| 42 | 42 | ||
| 43 | 43 | ##### V8 defaults for Node.js ##### | |
| 44 | 44 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -408,7 +408,7 @@ void CodeGenerator::AssembleCode() { | |||
| 408 | 408 | } | |
| 409 | 409 | } | |
| 410 | 410 | ||
| 411 | - // The LinuxPerfJitLogger logs code up until here, excluding the safepoint | ||
| 411 | + // The PerfJitLogger logs code up until here, excluding the safepoint | ||
| 412 | 412 | // table. Resolve the unwinding info now so it is aware of the same code | |
| 413 | 413 | // size as reported by perf. | |
| 414 | 414 | unwinding_info_writer_.Finish(masm()->pc_offset()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,8 +30,8 @@ | |||
| 30 | 30 | #include "src/common/assert-scope.h" | |
| 31 | 31 | #include "src/flags/flags.h" | |
| 32 | 32 | ||
| 33 | - // Only compile the {LinuxPerfJitLogger} on Linux. | ||
| 34 | - #if V8_OS_LINUX | ||
| 33 | + // Only compile the {PerfJitLogger} on Linux & Darwin. | ||
| 34 | + #if V8_OS_LINUX || V8_OS_DARWIN | ||
| 35 | 35 | ||
| 36 | 36 | #include <fcntl.h> | |
| 37 | 37 | #include <sys/mman.h> | |
@@ -118,22 +118,22 @@ struct PerfJitCodeUnwindingInfo : PerfJitBase { | |||
| 118 | 118 | // Followed by size_ - sizeof(PerfJitCodeUnwindingInfo) bytes of data. | |
| 119 | 119 | }; | |
| 120 | 120 | ||
| 121 | - const char LinuxPerfJitLogger::kFilenameFormatString[] = "%s/jit-%d.dump"; | ||
| 121 | + const char PerfJitLogger::kFilenameFormatString[] = "%s/jit-%d.dump"; | ||
| 122 | 122 | ||
| 123 | 123 | // Extra padding for the PID in the filename | |
| 124 | - const int LinuxPerfJitLogger::kFilenameBufferPadding = 16; | ||
| 124 | + const int PerfJitLogger::kFilenameBufferPadding = 16; | ||
| 125 | 125 | ||
| 126 | 126 | static const char kStringTerminator[] = {'\0'}; | |
| 127 | 127 | ||
| 128 | 128 | // The following static variables are protected by | |
| 129 | 129 | // GetFileMutex(). | |
| 130 | - int LinuxPerfJitLogger::process_id_ = 0; | ||
| 131 | - uint64_t LinuxPerfJitLogger::reference_count_ = 0; | ||
| 132 | - void* LinuxPerfJitLogger::marker_address_ = nullptr; | ||
| 133 | - uint64_t LinuxPerfJitLogger::code_index_ = 0; | ||
| 134 | - FILE* LinuxPerfJitLogger::perf_output_handle_ = nullptr; | ||
| 130 | + int PerfJitLogger::process_id_ = 0; | ||
| 131 | + uint64_t PerfJitLogger::reference_count_ = 0; | ||
| 132 | + void* PerfJitLogger::marker_address_ = nullptr; | ||
| 133 | + uint64_t PerfJitLogger::code_index_ = 0; | ||
| 134 | + FILE* PerfJitLogger::perf_output_handle_ = nullptr; | ||
| 135 | 135 | ||
| 136 | - void LinuxPerfJitLogger::OpenJitDumpFile() { | ||
| 136 | + void PerfJitLogger::OpenJitDumpFile() { | ||
| 137 | 137 | // Open the perf JIT dump file. | |
| 138 | 138 | perf_output_handle_ = nullptr; | |
| 139 | 139 | ||
@@ -153,22 +153,31 @@ void LinuxPerfJitLogger::OpenJitDumpFile() { | |||
| 153 | 153 | if (v8_flags.perf_prof_delete_file) | |
| 154 | 154 | CHECK_EQ(0, unlink(perf_dump_name.begin())); | |
| 155 | 155 | ||
| 156 | + // On Linux, call OpenMarkerFile so that perf knows about the file path via | ||
| 157 | + // an MMAP record. | ||
| 158 | + // On macOS, don't call OpenMarkerFile because samply has already detected | ||
| 159 | + // the file path during the call to `open` above (it interposes `open` with | ||
| 160 | + // a preloaded library), and because the mmap call can be slow. | ||
| 161 | + #if V8_OS_DARWIN | ||
| 162 | + marker_address_ = nullptr; | ||
| 163 | + #else | ||
| 156 | 164 | marker_address_ = OpenMarkerFile(fd); | |
| 157 | 165 | if (marker_address_ == nullptr) return; | |
| 166 | + #endif | ||
| 158 | 167 | ||
| 159 | 168 | perf_output_handle_ = fdopen(fd, "w+"); | |
| 160 | 169 | if (perf_output_handle_ == nullptr) return; | |
| 161 | 170 | ||
| 162 | 171 | setvbuf(perf_output_handle_, nullptr, _IOFBF, kLogBufferSize); | |
| 163 | 172 | } | |
| 164 | 173 | ||
| 165 | - void LinuxPerfJitLogger::CloseJitDumpFile() { | ||
| 174 | + void PerfJitLogger::CloseJitDumpFile() { | ||
| 166 | 175 | if (perf_output_handle_ == nullptr) return; | |
| 167 | 176 | base::Fclose(perf_output_handle_); | |
| 168 | 177 | perf_output_handle_ = nullptr; | |
| 169 | 178 | } | |
| 170 | 179 | ||
| 171 | - void* LinuxPerfJitLogger::OpenMarkerFile(int fd) { | ||
| 180 | + void* PerfJitLogger::OpenMarkerFile(int fd) { | ||
| 172 | 181 | long page_size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int) | |
| 173 | 182 | if (page_size == -1) return nullptr; | |
| 174 | 183 | ||
@@ -180,15 +189,14 @@ void* LinuxPerfJitLogger::OpenMarkerFile(int fd) { | |||
| 180 | 189 | return (marker_address == MAP_FAILED) ? nullptr : marker_address; | |
| 181 | 190 | } | |
| 182 | 191 | ||
| 183 | - void LinuxPerfJitLogger::CloseMarkerFile(void* marker_address) { | ||
| 192 | + void PerfJitLogger::CloseMarkerFile(void* marker_address) { | ||
| 184 | 193 | if (marker_address == nullptr) return; | |
| 185 | 194 | long page_size = sysconf(_SC_PAGESIZE); // NOLINT(runtime/int) | |
| 186 | 195 | if (page_size == -1) return; | |
| 187 | 196 | munmap(marker_address, page_size); | |
| 188 | 197 | } | |
| 189 | 198 | ||
| 190 | - LinuxPerfJitLogger::LinuxPerfJitLogger(Isolate* isolate) | ||
| 191 | - : CodeEventLogger(isolate) { | ||
| 199 | + PerfJitLogger::PerfJitLogger(Isolate* isolate) : CodeEventLogger(isolate) { | ||
| 192 | 200 | base::LockGuard<base::RecursiveMutex> guard_file(GetFileMutex().Pointer()); | |
| 193 | 201 | process_id_ = base::OS::GetCurrentProcessId(); | |
| 194 | 202 | ||
@@ -201,7 +209,7 @@ LinuxPerfJitLogger::LinuxPerfJitLogger(Isolate* isolate) | |||
| 201 | 209 | } | |
| 202 | 210 | } | |
| 203 | 211 | ||
| 204 | - LinuxPerfJitLogger::~LinuxPerfJitLogger() { | ||
| 212 | + PerfJitLogger::~PerfJitLogger() { | ||
| 205 | 213 | base::LockGuard<base::RecursiveMutex> guard_file(GetFileMutex().Pointer()); | |
| 206 | 214 | ||
| 207 | 215 | reference_count_--; | |
@@ -211,16 +219,11 @@ LinuxPerfJitLogger::~LinuxPerfJitLogger() { | |||
| 211 | 219 | } | |
| 212 | 220 | } | |
| 213 | 221 | ||
| 214 | - uint64_t LinuxPerfJitLogger::GetTimestamp() { | ||
| 215 | - struct timespec ts; | ||
| 216 | - int result = clock_gettime(CLOCK_MONOTONIC, &ts); | ||
| 217 | - DCHECK_EQ(0, result); | ||
| 218 | - USE(result); | ||
| 219 | - static const uint64_t kNsecPerSec = 1000000000; | ||
| 220 | - return (ts.tv_sec * kNsecPerSec) + ts.tv_nsec; | ||
| 222 | + uint64_t PerfJitLogger::GetTimestamp() { | ||
| 223 | + return base::TimeTicks::Now().since_origin().InNanoseconds(); | ||
| 221 | 224 | } | |
| 222 | 225 | ||
| 223 | - void LinuxPerfJitLogger::LogRecordedBuffer( | ||
| 226 | + void PerfJitLogger::LogRecordedBuffer( | ||
| 224 | 227 | Tagged<AbstractCode> abstract_code, | |
| 225 | 228 | MaybeHandle<SharedFunctionInfo> maybe_sfi, const char* name, int length) { | |
| 226 | 229 | DisallowGarbageCollection no_gc; | |
@@ -263,8 +266,8 @@ void LinuxPerfJitLogger::LogRecordedBuffer( | |||
| 263 | 266 | } | |
| 264 | 267 | ||
| 265 | 268 | #if V8_ENABLE_WEBASSEMBLY | |
| 266 | - void LinuxPerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code, | ||
| 267 | - const char* name, int length) { | ||
| 269 | + void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code, | ||
| 270 | + const char* name, int length) { | ||
| 268 | 271 | base::LockGuard<base::RecursiveMutex> guard_file(GetFileMutex().Pointer()); | |
| 269 | 272 | ||
| 270 | 273 | if (perf_output_handle_ == nullptr) return; | |
@@ -276,10 +279,9 @@ void LinuxPerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code, | |||
| 276 | 279 | } | |
| 277 | 280 | #endif // V8_ENABLE_WEBASSEMBLY | |
| 278 | 281 | ||
| 279 | - void LinuxPerfJitLogger::WriteJitCodeLoadEntry(const uint8_t* code_pointer, | ||
| 280 | - uint32_t code_size, | ||
| 281 | - const char* name, | ||
| 282 | - int name_length) { | ||
| 282 | + void PerfJitLogger::WriteJitCodeLoadEntry(const uint8_t* code_pointer, | ||
| 283 | + uint32_t code_size, const char* name, | ||
| 284 | + int name_length) { | ||
| 283 | 285 | PerfJitCodeLoad code_load; | |
| 284 | 286 | code_load.event_ = PerfJitCodeLoad::kLoad; | |
| 285 | 287 | code_load.size_ = sizeof(code_load) + name_length + 1 + code_size; | |
@@ -342,8 +344,8 @@ SourcePositionInfo GetSourcePositionInfo(Isolate* isolate, Tagged<Code> code, | |||
| 342 | 344 | ||
| 343 | 345 | } // namespace | |
| 344 | 346 | ||
| 345 | - void LinuxPerfJitLogger::LogWriteDebugInfo(Tagged<Code> code, | ||
| 346 | - Handle<SharedFunctionInfo> shared) { | ||
| 347 | + void PerfJitLogger::LogWriteDebugInfo(Tagged<Code> code, | ||
| 348 | + Handle<SharedFunctionInfo> shared) { | ||
| 347 | 349 | // Line ends of all scripts have been initialized prior to this. | |
| 348 | 350 | DisallowGarbageCollection no_gc; | |
| 349 | 351 | // The WasmToJS wrapper stubs have source position entries. | |
@@ -426,7 +428,7 @@ void LinuxPerfJitLogger::LogWriteDebugInfo(Tagged<Code> code, | |||
| 426 | 428 | } | |
| 427 | 429 | ||
| 428 | 430 | #if V8_ENABLE_WEBASSEMBLY | |
| 429 | - void LinuxPerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) { | ||
| 431 | + void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) { | ||
| 430 | 432 | wasm::WasmModuleSourceMap* source_map = | |
| 431 | 433 | code->native_module()->GetWasmSourceMap(); | |
| 432 | 434 | wasm::WireBytesRef code_ref = | |
@@ -494,7 +496,7 @@ void LinuxPerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) { | |||
| 494 | 496 | } | |
| 495 | 497 | #endif // V8_ENABLE_WEBASSEMBLY | |
| 496 | 498 | ||
| 497 | - void LinuxPerfJitLogger::LogWriteUnwindingInfo(Tagged<Code> code) { | ||
| 499 | + void PerfJitLogger::LogWriteUnwindingInfo(Tagged<Code> code) { | ||
| 498 | 500 | PerfJitCodeUnwindingInfo unwinding_info_header; | |
| 499 | 501 | unwinding_info_header.event_ = PerfJitCodeLoad::kUnwindingInfo; | |
| 500 | 502 | unwinding_info_header.time_stamp_ = GetTimestamp(); | |
@@ -529,13 +531,13 @@ void LinuxPerfJitLogger::LogWriteUnwindingInfo(Tagged<Code> code) { | |||
| 529 | 531 | LogWriteBytes(padding_bytes, static_cast<int>(padding_size)); | |
| 530 | 532 | } | |
| 531 | 533 | ||
| 532 | - void LinuxPerfJitLogger::LogWriteBytes(const char* bytes, int size) { | ||
| 534 | + void PerfJitLogger::LogWriteBytes(const char* bytes, int size) { | ||
| 533 | 535 | size_t rv = fwrite(bytes, 1, size, perf_output_handle_); | |
| 534 | 536 | DCHECK(static_cast<size_t>(size) == rv); | |
| 535 | 537 | USE(rv); | |
| 536 | 538 | } | |
| 537 | 539 | ||
| 538 | - void LinuxPerfJitLogger::LogWriteHeader() { | ||
| 540 | + void PerfJitLogger::LogWriteHeader() { | ||
| 539 | 541 | DCHECK_NOT_NULL(perf_output_handle_); | |
| 540 | 542 | PerfJitHeader header; | |
| 541 | 543 | ||
@@ -556,4 +558,4 @@ void LinuxPerfJitLogger::LogWriteHeader() { | |||
| 556 | 558 | } // namespace internal | |
| 557 | 559 | } // namespace v8 | |
| 558 | 560 | ||
| 559 | - #endif // V8_OS_LINUX | ||
| 561 | + #endif // V8_OS_LINUX || V8_OS_DARWIN | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,19 +30,19 @@ | |||
| 30 | 30 | ||
| 31 | 31 | #include "include/v8config.h" | |
| 32 | 32 | ||
| 33 | - // {LinuxPerfJitLogger} is only implemented on Linux. | ||
| 34 | - #if V8_OS_LINUX | ||
| 33 | + // {PerfJitLogger} is only implemented on Linux & Darwin. | ||
| 34 | + #if V8_OS_LINUX || V8_OS_DARWIN | ||
| 35 | 35 | ||
| 36 | 36 | #include "src/logging/log.h" | |
| 37 | 37 | ||
| 38 | 38 | namespace v8 { | |
| 39 | 39 | namespace internal { | |
| 40 | 40 | ||
| 41 | 41 | // Linux perf tool logging support. | |
| 42 | - class LinuxPerfJitLogger : public CodeEventLogger { | ||
| 42 | + class PerfJitLogger : public CodeEventLogger { | ||
| 43 | 43 | public: | |
| 44 | - explicit LinuxPerfJitLogger(Isolate* isolate); | ||
| 45 | - ~LinuxPerfJitLogger() override; | ||
| 44 | + explicit PerfJitLogger(Isolate* isolate); | ||
| 45 | + ~PerfJitLogger() override; | ||
| 46 | 46 | ||
| 47 | 47 | void CodeMoveEvent(Tagged<InstructionStream> from, | |
| 48 | 48 | Tagged<InstructionStream> to) override { | |
@@ -142,6 +142,6 @@ class LinuxPerfJitLogger : public CodeEventLogger { | |||
| 142 | 142 | } // namespace internal | |
| 143 | 143 | } // namespace v8 | |
| 144 | 144 | ||
| 145 | - #endif // V8_OS_LINUX | ||
| 145 | + #endif // V8_OS_LINUX || V8_OS_DARWIN | ||
| 146 | 146 | ||
| 147 | 147 | #endif // V8_DIAGNOSTICS_PERF_JIT_H_ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2782,7 +2782,7 @@ DEFINE_IMPLICATION(prof, log_code) | |||
| 2782 | 2782 | ||
| 2783 | 2783 | DEFINE_BOOL(ll_prof, false, "Enable low-level linux profiler.") | |
| 2784 | 2784 | ||
| 2785 | - #if V8_OS_LINUX | ||
| 2785 | + #if V8_OS_LINUX || V8_OS_DARWIN | ||
| 2786 | 2786 | #define DEFINE_PERF_PROF_BOOL(nam, cmt) DEFINE_BOOL(nam, false, cmt) | |
| 2787 | 2787 | #define DEFINE_PERF_PROF_IMPLICATION DEFINE_IMPLICATION | |
| 2788 | 2788 | #else | |
@@ -2799,7 +2799,7 @@ DEFINE_BOOL(ll_prof, false, "Enable low-level linux profiler.") | |||
| 2799 | 2799 | #endif | |
| 2800 | 2800 | ||
| 2801 | 2801 | DEFINE_PERF_PROF_BOOL(perf_basic_prof, | |
| 2802 | - "Enable perf linux profiler (basic support).") | ||
| 2802 | + "Enable basic support for perf profiler.") | ||
| 2803 | 2803 | DEFINE_NEG_IMPLICATION(perf_basic_prof, compact_code_space) | |
| 2804 | 2804 | DEFINE_STRING(perf_basic_prof_path, DEFAULT_PERF_BASIC_PROF_PATH, | |
| 2805 | 2805 | "directory to write perf-<pid>.map symbol file to") | |
@@ -2808,8 +2808,8 @@ DEFINE_PERF_PROF_BOOL( | |||
| 2808 | 2808 | "Only report function code ranges to perf (i.e. no stubs).") | |
| 2809 | 2809 | DEFINE_PERF_PROF_IMPLICATION(perf_basic_prof_only_functions, perf_basic_prof) | |
| 2810 | 2810 | ||
| 2811 | - DEFINE_PERF_PROF_BOOL( | ||
| 2812 | - perf_prof, "Enable perf linux profiler (experimental annotate support).") | ||
| 2811 | + DEFINE_PERF_PROF_BOOL(perf_prof, | ||
| 2812 | + "Enable experimental annotate support for perf profiler.") | ||
| 2813 | 2813 | DEFINE_STRING(perf_prof_path, DEFAULT_PERF_PROF_PATH, | |
| 2814 | 2814 | "directory to write jit-<pid>.dump symbol file to") | |
| 2815 | 2815 | DEFINE_PERF_PROF_BOOL( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments