GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — deps: V8: backport 20 CPU profiler commits from upstream · nodejs/node@48f31bd

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • deps/v8
    • include
      • v8-profiler.h
      • v8-version.h
    • src
      • api.cc
      • code-events.h
      • compilation-info.cc
      • flag-definitions.h
      • heap
        • mark-compact.cc
      • isolate.cc
      • isolate.h
      • log.cc
      • log.h
      • perf-jit.cc
      • perf-jit.h
      • profiler
        • cpu-profiler-inl.h
        • cpu-profiler.cc
        • cpu-profiler.h
        • heap-profiler.cc
        • profile-generator-inl.h
        • profile-generator.cc
        • profile-generator.h
        • profiler-listener.cc
        • profiler-listener.h
        • strings-storage.cc
        • strings-storage.h
      • snapshot
        • serializer.h
    • test/cctest
      • cctest.status
      • test-cpu-profiler.cc
      • test-log.cc
      • test-profile-generator.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎deps/v8/include/v8-profiler.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8-profiler.h
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ class V8_EXPORT CpuProfile {
273273
void Delete();
274274
};
275275

276+
enum CpuProfilingMode {
277+
// In the resulting CpuProfile tree, intermediate nodes in a stack trace
278+
// (from the root to a leaf) will have line numbers that point to the start
279+
// line of the function, rather than the line of the callsite of the child.
280+
kLeafNodeLineNumbers,
281+
// In the resulting CpuProfile tree, nodes are separated based on the line
282+
// number of their callsite in their parent.
283+
kCallerLineNumbers,
284+
};
285+
276286
/**
277287
* Interface for controlling CPU profiling. Instance of the
278288
* profiler can be created using v8::CpuProfiler::New method.
@@ -309,6 +319,13 @@ class V8_EXPORT CpuProfiler {
309319
* |record_samples| parameter controls whether individual samples should
310320
* be recorded in addition to the aggregated tree.
311321
*/
322+
void StartProfiling(Local<String> title, CpuProfilingMode mode,
323+
bool record_samples = false);
324+
/**
325+
* The same as StartProfiling above, but the CpuProfilingMode defaults to
326+
* kLeafNodeLineNumbers mode, which was the previous default behavior of the
327+
* profiler.
328+
*/
312329
void StartProfiling(Local<String> title, bool record_samples = false);
313330

314331
/**
Collapse file

‎deps/v8/include/v8-version.h‎

Copy file name to clipboardExpand all lines: deps/v8/include/v8-version.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 6
1212
#define V8_MINOR_VERSION 2
1313
#define V8_BUILD_NUMBER 414
14-
#define V8_PATCH_LEVEL 67
14+
#define V8_PATCH_LEVEL 68
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)
Collapse file

‎deps/v8/src/api.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/api.cc
+9-12Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8418,7 +8418,7 @@ HeapProfiler* Isolate::GetHeapProfiler() {
84188418

84198419
CpuProfiler* Isolate::GetCpuProfiler() {
84208420
i::CpuProfiler* cpu_profiler =
8421-
reinterpret_cast<i::Isolate*>(this)->cpu_profiler();
8421+
reinterpret_cast<i::Isolate*>(this)->EnsureCpuProfiler();
84228422
return reinterpret_cast<CpuProfiler*>(cpu_profiler);
84238423
}
84248424

@@ -10138,15 +10138,7 @@ Local<String> CpuProfileNode::GetFunctionName() const {
1013810138
const i::CodeEntry* entry = node->entry();
1013910139
i::Handle<i::String> name =
1014010140
isolate->factory()->InternalizeUtf8String(entry->name());
10141-
if (!entry->has_name_prefix()) {
10142-
return ToApiHandle<String>(name);
10143-
} else {
10144-
// We do not expect this to fail. Change this if it does.
10145-
i::Handle<i::String> cons = isolate->factory()->NewConsString(
10146-
isolate->factory()->InternalizeUtf8String(entry->name_prefix()),
10147-
name).ToHandleChecked();
10148-
return ToApiHandle<String>(cons);
10149-
}
10141+
return ToApiHandle<String>(name);
1015010142
}
1015110143

1015210144
int debug::Coverage::BlockData::StartOffset() const { return block_->start; }
@@ -10237,7 +10229,7 @@ const char* CpuProfileNode::GetScriptResourceNameStr() const {
1023710229
}
1023810230

1023910231
int CpuProfileNode::GetLineNumber() const {
10240-
return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
10232+
return reinterpret_cast<const i::ProfileNode*>(this)->line_number();
1024110233
}
1024210234

1024310235

@@ -10370,9 +10362,14 @@ void CpuProfiler::CollectSample() {
1037010362

1037110363
void CpuProfiler::StartProfiling(Local<String> title, bool record_samples) {
1037210364
reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
10373-
*Utils::OpenHandle(*title), record_samples);
10365+
*Utils::OpenHandle(*title), record_samples, kLeafNodeLineNumbers);
1037410366
}
1037510367

10368+
void CpuProfiler::StartProfiling(Local<String> title, CpuProfilingMode mode,
10369+
bool record_samples) {
10370+
reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling(
10371+
*Utils::OpenHandle(*title), record_samples, mode);
10372+
}
1037610373

1037710374
CpuProfile* CpuProfiler::StopProfiling(Local<String> title) {
1037810375
return reinterpret_cast<CpuProfile*>(
Collapse file

‎deps/v8/src/code-events.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/code-events.h
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CodeEventListener {
101101
virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0;
102102
virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0;
103103
virtual void RegExpCodeCreateEvent(AbstractCode* code, String* source) = 0;
104-
virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0;
104+
virtual void CodeMoveEvent(AbstractCode* from, AbstractCode* to) = 0;
105105
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
106106
virtual void CodeMovingGCEvent() = 0;
107107
virtual void CodeDisableOptEvent(AbstractCode* code,
@@ -163,7 +163,7 @@ class CodeEventDispatcher {
163163
void RegExpCodeCreateEvent(AbstractCode* code, String* source) {
164164
CODE_EVENT_DISPATCH(RegExpCodeCreateEvent(code, source));
165165
}
166-
void CodeMoveEvent(AbstractCode* from, Address to) {
166+
void CodeMoveEvent(AbstractCode* from, AbstractCode* to) {
167167
CODE_EVENT_DISPATCH(CodeMoveEvent(from, to));
168168
}
169169
void SharedFunctionInfoMoveEvent(Address from, Address to) {
Collapse file

‎deps/v8/src/compilation-info.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/compilation-info.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate,
5151
// Collect source positions for optimized code when profiling or if debugger
5252
// is active, to be able to get more precise source positions at the price of
5353
// more memory consumption.
54-
if (isolate_->NeedsSourcePositionsForProfiling()) {
54+
if (isolate_->NeedsDetailedOptimizedCodeLineInfo()) {
5555
MarkAsSourcePositionsEnabled();
5656
}
5757
}
Collapse file

‎deps/v8/src/flag-definitions.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/flag-definitions.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ DEFINE_BOOL(log_source_code, false, "Log source code.")
10821082
DEFINE_BOOL(prof, false,
10831083
"Log statistical profiling information (implies --log-code).")
10841084

1085+
DEFINE_BOOL(detailed_line_info, true,
1086+
"Always generate detailed line information for CPU profiling.")
1087+
10851088
#if defined(ANDROID)
10861089
// Phones and tablets have processors that are much slower than desktop
10871090
// and laptop computers for which current heuristics are tuned.
Collapse file

‎deps/v8/src/heap/mark-compact.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/heap/mark-compact.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ class ProfilingMigrationObserver final : public MigrationObserver {
14841484
int size) final {
14851485
if (dest == CODE_SPACE || (dest == OLD_SPACE && dst->IsBytecodeArray())) {
14861486
PROFILE(heap_->isolate(),
1487-
CodeMoveEvent(AbstractCode::cast(src), dst->address()));
1487+
CodeMoveEvent(AbstractCode::cast(src), AbstractCode::cast(dst)));
14881488
}
14891489
heap_->OnMoveEvent(dst, src, size);
14901490
}
Collapse file

‎deps/v8/src/isolate.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/isolate.cc
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2697,7 +2697,6 @@ bool Isolate::Init(StartupDeserializer* des) {
26972697
call_descriptor_data_ =
26982698
new CallInterfaceDescriptorData[CallDescriptors::NUMBER_OF_DESCRIPTORS];
26992699
access_compiler_data_ = new AccessCompilerData();
2700-
cpu_profiler_ = new CpuProfiler(this);
27012700
heap_profiler_ = new HeapProfiler(heap());
27022701
interpreter_ = new interpreter::Interpreter(this);
27032702
compiler_dispatcher_ =
@@ -2970,6 +2969,10 @@ bool Isolate::use_optimizer() {
29702969
!is_precise_count_code_coverage() && !is_block_count_code_coverage();
29712970
}
29722971

2972+
bool Isolate::NeedsDetailedOptimizedCodeLineInfo() const {
2973+
return NeedsSourcePositionsForProfiling() || FLAG_detailed_line_info;
2974+
}
2975+
29732976
bool Isolate::NeedsSourcePositionsForProfiling() const {
29742977
return FLAG_trace_deopt || FLAG_trace_turbo || FLAG_trace_turbo_graph ||
29752978
FLAG_turbo_profiling || FLAG_perf_prof || is_profiling() ||
@@ -3694,6 +3697,13 @@ void Isolate::PrintWithTimestamp(const char* format, ...) {
36943697
va_end(arguments);
36953698
}
36963699

3700+
CpuProfiler* Isolate::EnsureCpuProfiler() {
3701+
if (!cpu_profiler_) {
3702+
cpu_profiler_ = new CpuProfiler(this);
3703+
}
3704+
return cpu_profiler_;
3705+
}
3706+
36973707
bool StackLimitCheck::JsHasOverflowed(uintptr_t gap) const {
36983708
StackGuard* stack_guard = isolate_->stack_guard();
36993709
#ifdef USE_SIMULATOR
Collapse file

‎deps/v8/src/isolate.h‎

Copy file name to clipboardExpand all lines: deps/v8/src/isolate.h
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,8 @@ class Isolate {
10191019

10201020
bool NeedsSourcePositionsForProfiling() const;
10211021

1022+
bool NeedsDetailedOptimizedCodeLineInfo() const;
1023+
10221024
bool is_best_effort_code_coverage() const {
10231025
return code_coverage_mode() == debug::Coverage::kBestEffort;
10241026
}
@@ -1449,7 +1451,7 @@ class Isolate {
14491451

14501452
// TODO(alph): Remove along with the deprecated GetCpuProfiler().
14511453
friend v8::CpuProfiler* v8::Isolate::GetCpuProfiler();
1452-
CpuProfiler* cpu_profiler() const { return cpu_profiler_; }
1454+
CpuProfiler* EnsureCpuProfiler();
14531455

14541456
base::Atomic32 id_;
14551457
EntryStackItem* entry_stack_;
Collapse file

‎deps/v8/src/log.cc‎

Copy file name to clipboardExpand all lines: deps/v8/src/log.cc
+11-37Lines changed: 11 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "src/log-utils.h"
2323
#include "src/macro-assembler.h"
2424
#include "src/perf-jit.h"
25-
#include "src/profiler/profiler-listener.h"
2625
#include "src/profiler/tick-sample.h"
2726
#include "src/runtime-profiler.h"
2827
#include "src/source-position-table.h"
@@ -218,7 +217,7 @@ class PerfBasicLogger : public CodeEventLogger {
218217
PerfBasicLogger();
219218
~PerfBasicLogger() override;
220219

221-
void CodeMoveEvent(AbstractCode* from, Address to) override {}
220+
void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override {}
222221
void CodeDisableOptEvent(AbstractCode* code,
223222
SharedFunctionInfo* shared) override {}
224223

@@ -287,7 +286,7 @@ class LowLevelLogger : public CodeEventLogger {
287286
explicit LowLevelLogger(const char* file_name);
288287
~LowLevelLogger() override;
289288

290-
void CodeMoveEvent(AbstractCode* from, Address to) override;
289+
void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override;
291290
void CodeDisableOptEvent(AbstractCode* code,
292291
SharedFunctionInfo* shared) override {}
293292
void SnapshotPositionEvent(HeapObject* obj, int pos);
@@ -393,11 +392,10 @@ void LowLevelLogger::LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo*,
393392
code->instruction_size());
394393
}
395394

396-
void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) {
395+
void LowLevelLogger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) {
397396
CodeMoveStruct event;
398397
event.from_address = from->instruction_start();
399-
size_t header_size = from->instruction_start() - from->address();
400-
event.to_address = to + header_size;
398+
event.to_address = to->instruction_start();
401399
LogWriteStruct(event);
402400
}
403401

@@ -419,7 +417,7 @@ class JitLogger : public CodeEventLogger {
419417
public:
420418
explicit JitLogger(JitCodeEventHandler code_event_handler);
421419

422-
void CodeMoveEvent(AbstractCode* from, Address to) override;
420+
void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override;
423421
void CodeDisableOptEvent(AbstractCode* code,
424422
SharedFunctionInfo* shared) override {}
425423
void AddCodeLinePosInfoEvent(void* jit_handler_data, int pc_offset,
@@ -460,19 +458,14 @@ void JitLogger::LogRecordedBuffer(AbstractCode* code,
460458
code_event_handler_(&event);
461459
}
462460

463-
void JitLogger::CodeMoveEvent(AbstractCode* from, Address to) {
461+
void JitLogger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) {
464462
base::LockGuard<base::Mutex> guard(&logger_mutex_);
465463

466464
JitCodeEvent event;
467465
event.type = JitCodeEvent::CODE_MOVED;
468-
event.code_start = from->instruction_start();
466+
event.code_start = reinterpret_cast<void*>(from->instruction_start());
469467
event.code_len = from->instruction_size();
470-
471-
// Calculate the header size.
472-
const size_t header_size = from->instruction_start() - from->address();
473-
474-
// Calculate the new start address of the instructions.
475-
event.new_code_start = to + header_size;
468+
event.new_code_start = reinterpret_cast<void*>(to->instruction_start());
476469

477470
code_event_handler_(&event);
478471
}
@@ -739,7 +732,6 @@ Logger::Logger(Isolate* isolate)
739732
perf_jit_logger_(NULL),
740733
ll_logger_(NULL),
741734
jit_logger_(NULL),
742-
listeners_(5),
743735
is_initialized_(false) {}
744736

745737
Logger::~Logger() {
@@ -1297,9 +1289,10 @@ void Logger::RegExpCodeCreateEvent(AbstractCode* code, String* source) {
12971289
msg.WriteToLogFile();
12981290
}
12991291

1300-
void Logger::CodeMoveEvent(AbstractCode* from, Address to) {
1292+
void Logger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) {
13011293
if (!is_logging_code_events()) return;
1302-
MoveEventInternal(CodeEventListener::CODE_MOVE_EVENT, from->address(), to);
1294+
MoveEventInternal(CodeEventListener::CODE_MOVE_EVENT, from->address(),
1295+
to->address());
13031296
}
13041297

13051298
void Logger::CodeLinePosInfoRecordEvent(AbstractCode* code,
@@ -1876,8 +1869,6 @@ bool Logger::SetUp(Isolate* isolate) {
18761869
profiler_->Engage();
18771870
}
18781871

1879-
profiler_listener_.reset();
1880-
18811872
if (is_logging_) {
18821873
addCodeEventListener(this);
18831874
}
@@ -1905,19 +1896,6 @@ void Logger::SetCodeEventHandler(uint32_t options,
19051896
}
19061897
}
19071898

1908-
void Logger::SetUpProfilerListener() {
1909-
if (!is_initialized_) return;
1910-
if (profiler_listener_.get() == nullptr) {
1911-
profiler_listener_.reset(new ProfilerListener(isolate_));
1912-
}
1913-
addCodeEventListener(profiler_listener_.get());
1914-
}
1915-
1916-
void Logger::TearDownProfilerListener() {
1917-
if (profiler_listener_->HasObservers()) return;
1918-
removeCodeEventListener(profiler_listener_.get());
1919-
}
1920-
19211899
sampler::Sampler* Logger::sampler() {
19221900
return ticker_;
19231901
}
@@ -1961,10 +1939,6 @@ FILE* Logger::TearDown() {
19611939
jit_logger_ = NULL;
19621940
}
19631941

1964-
if (profiler_listener_.get() != nullptr) {
1965-
removeCodeEventListener(profiler_listener_.get());
1966-
}
1967-
19681942
return log_->Close();
19691943
}
19701944

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.