| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 7a70dce commit a5c0bc4
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,7 +29,7 @@ | |||
| 29 | 29 | ||
| 30 | 30 | # Reset this number to 0 on major V8 upgrades. | |
| 31 | 31 | # Increment by one for each non-official patch applied to deps/v8. | |
| 32 | - 'v8_embedder_string': '-node.22', | ||
| 32 | + 'v8_embedder_string': '-node.23', | ||
| 33 | 33 | ||
| 34 | 34 | # Enable disassembler for `--print-code` v8 options | |
| 35 | 35 | 'v8_enable_disassembler': 1, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -273,6 +273,16 @@ class V8_EXPORT CpuProfile { | |||
| 273 | 273 | void Delete(); | |
| 274 | 274 | }; | |
| 275 | 275 | ||
| 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 | + | ||
| 276 | 286 | /** | |
| 277 | 287 | * Interface for controlling CPU profiling. Instance of the | |
| 278 | 288 | * profiler can be created using v8::CpuProfiler::New method. | |
@@ -316,6 +326,13 @@ class V8_EXPORT CpuProfiler { | |||
| 316 | 326 | * |record_samples| parameter controls whether individual samples should | |
| 317 | 327 | * be recorded in addition to the aggregated tree. | |
| 318 | 328 | */ | |
| 329 | + void StartProfiling(Local<String> title, CpuProfilingMode mode, | ||
| 330 | + bool record_samples = false); | ||
| 331 | + /** | ||
| 332 | + * The same as StartProfiling above, but the CpuProfilingMode defaults to | ||
| 333 | + * kLeafNodeLineNumbers mode, which was the previous default behavior of the | ||
| 334 | + * profiler. | ||
| 335 | + */ | ||
| 319 | 336 | void StartProfiling(Local<String> title, bool record_samples = false); | |
| 320 | 337 | ||
| 321 | 338 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10005,7 +10005,7 @@ const char* CpuProfileNode::GetScriptResourceNameStr() const { | |||
| 10005 | 10005 | } | |
| 10006 | 10006 | ||
| 10007 | 10007 | int CpuProfileNode::GetLineNumber() const { | |
| 10008 | - return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number(); | ||
| 10008 | + return reinterpret_cast<const i::ProfileNode*>(this)->line_number(); | ||
| 10009 | 10009 | } | |
| 10010 | 10010 | ||
| 10011 | 10011 | ||
@@ -10143,9 +10143,14 @@ void CpuProfiler::CollectSample() { | |||
| 10143 | 10143 | ||
| 10144 | 10144 | void CpuProfiler::StartProfiling(Local<String> title, bool record_samples) { | |
| 10145 | 10145 | reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( | |
| 10146 | - *Utils::OpenHandle(*title), record_samples); | ||
| 10146 | + *Utils::OpenHandle(*title), record_samples, kLeafNodeLineNumbers); | ||
| 10147 | 10147 | } | |
| 10148 | 10148 | ||
| 10149 | + void CpuProfiler::StartProfiling(Local<String> title, CpuProfilingMode mode, | ||
| 10150 | + bool record_samples) { | ||
| 10151 | + reinterpret_cast<i::CpuProfiler*>(this)->StartProfiling( | ||
| 10152 | + *Utils::OpenHandle(*title), record_samples, mode); | ||
| 10153 | + } | ||
| 10149 | 10154 | ||
| 10150 | 10155 | CpuProfile* CpuProfiler::StopProfiling(Local<String> title) { | |
| 10151 | 10156 | return reinterpret_cast<CpuProfile*>( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -83,7 +83,7 @@ class CodeEventListener { | |||
| 83 | 83 | virtual void GetterCallbackEvent(Name* name, Address entry_point) = 0; | |
| 84 | 84 | virtual void SetterCallbackEvent(Name* name, Address entry_point) = 0; | |
| 85 | 85 | virtual void RegExpCodeCreateEvent(AbstractCode* code, String* source) = 0; | |
| 86 | - virtual void CodeMoveEvent(AbstractCode* from, Address to) = 0; | ||
| 86 | + virtual void CodeMoveEvent(AbstractCode* from, AbstractCode* to) = 0; | ||
| 87 | 87 | virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0; | |
| 88 | 88 | virtual void CodeMovingGCEvent() = 0; | |
| 89 | 89 | virtual void CodeDisableOptEvent(AbstractCode* code, | |
@@ -155,7 +155,7 @@ class CodeEventDispatcher { | |||
| 155 | 155 | void RegExpCodeCreateEvent(AbstractCode* code, String* source) { | |
| 156 | 156 | CODE_EVENT_DISPATCH(RegExpCodeCreateEvent(code, source)); | |
| 157 | 157 | } | |
| 158 | - void CodeMoveEvent(AbstractCode* from, Address to) { | ||
| 158 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) { | ||
| 159 | 159 | CODE_EVENT_DISPATCH(CodeMoveEvent(from, to)); | |
| 160 | 160 | } | |
| 161 | 161 | void SharedFunctionInfoMoveEvent(Address from, Address to) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1136,7 +1136,7 @@ class ProfilingMigrationObserver final : public MigrationObserver { | |||
| 1136 | 1136 | int size) final { | |
| 1137 | 1137 | if (dest == CODE_SPACE || (dest == OLD_SPACE && dst->IsBytecodeArray())) { | |
| 1138 | 1138 | PROFILE(heap_->isolate(), | |
| 1139 | - CodeMoveEvent(AbstractCode::cast(src), dst->address())); | ||
| 1139 | + CodeMoveEvent(AbstractCode::cast(src), AbstractCode::cast(dst))); | ||
| 1140 | 1140 | } | |
| 1141 | 1141 | heap_->OnMoveEvent(dst, src, size); | |
| 1142 | 1142 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -270,7 +270,7 @@ class PerfBasicLogger : public CodeEventLogger { | |||
| 270 | 270 | PerfBasicLogger(); | |
| 271 | 271 | ~PerfBasicLogger() override; | |
| 272 | 272 | ||
| 273 | - void CodeMoveEvent(AbstractCode* from, Address to) override {} | ||
| 273 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override {} | ||
| 274 | 274 | void CodeDisableOptEvent(AbstractCode* code, | |
| 275 | 275 | SharedFunctionInfo* shared) override {} | |
| 276 | 276 | ||
@@ -492,7 +492,7 @@ class LowLevelLogger : public CodeEventLogger { | |||
| 492 | 492 | explicit LowLevelLogger(const char* file_name); | |
| 493 | 493 | ~LowLevelLogger() override; | |
| 494 | 494 | ||
| 495 | - void CodeMoveEvent(AbstractCode* from, Address to) override; | ||
| 495 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override; | ||
| 496 | 496 | void CodeDisableOptEvent(AbstractCode* code, | |
| 497 | 497 | SharedFunctionInfo* shared) override {} | |
| 498 | 498 | void SnapshotPositionEvent(HeapObject* obj, int pos); | |
@@ -610,11 +610,10 @@ void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code, | |||
| 610 | 610 | code->instructions().length()); | |
| 611 | 611 | } | |
| 612 | 612 | ||
| 613 | - void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) { | ||
| 613 | + void LowLevelLogger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) { | ||
| 614 | 614 | CodeMoveStruct event; | |
| 615 | 615 | event.from_address = from->InstructionStart(); | |
| 616 | - size_t header_size = from->InstructionStart() - from->address(); | ||
| 617 | - event.to_address = to + header_size; | ||
| 616 | + event.to_address = to->InstructionStart(); | ||
| 618 | 617 | LogWriteStruct(event); | |
| 619 | 618 | } | |
| 620 | 619 | ||
@@ -636,7 +635,7 @@ class JitLogger : public CodeEventLogger { | |||
| 636 | 635 | public: | |
| 637 | 636 | explicit JitLogger(JitCodeEventHandler code_event_handler); | |
| 638 | 637 | ||
| 639 | - void CodeMoveEvent(AbstractCode* from, Address to) override; | ||
| 638 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override; | ||
| 640 | 639 | void CodeDisableOptEvent(AbstractCode* code, | |
| 641 | 640 | SharedFunctionInfo* shared) override {} | |
| 642 | 641 | void AddCodeLinePosInfoEvent(void* jit_handler_data, int pc_offset, | |
@@ -694,7 +693,7 @@ void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name, | |||
| 694 | 693 | code_event_handler_(&event); | |
| 695 | 694 | } | |
| 696 | 695 | ||
| 697 | - void JitLogger::CodeMoveEvent(AbstractCode* from, Address to) { | ||
| 696 | + void JitLogger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) { | ||
| 698 | 697 | base::LockGuard<base::Mutex> guard(&logger_mutex_); | |
| 699 | 698 | ||
| 700 | 699 | JitCodeEvent event; | |
@@ -703,12 +702,7 @@ void JitLogger::CodeMoveEvent(AbstractCode* from, Address to) { | |||
| 703 | 702 | from->IsCode() ? JitCodeEvent::JIT_CODE : JitCodeEvent::BYTE_CODE; | |
| 704 | 703 | event.code_start = reinterpret_cast<void*>(from->InstructionStart()); | |
| 705 | 704 | event.code_len = from->InstructionSize(); | |
| 706 | - | ||
| 707 | - // Calculate the header size. | ||
| 708 | - const size_t header_size = from->InstructionStart() - from->address(); | ||
| 709 | - | ||
| 710 | - // Calculate the new start address of the instructions. | ||
| 711 | - event.new_code_start = reinterpret_cast<void*>(to + header_size); | ||
| 705 | + event.new_code_start = reinterpret_cast<void*>(to->InstructionStart()); | ||
| 712 | 706 | ||
| 713 | 707 | code_event_handler_(&event); | |
| 714 | 708 | } | |
@@ -1450,9 +1444,10 @@ void Logger::RegExpCodeCreateEvent(AbstractCode* code, String* source) { | |||
| 1450 | 1444 | msg.WriteToLogFile(); | |
| 1451 | 1445 | } | |
| 1452 | 1446 | ||
| 1453 | - void Logger::CodeMoveEvent(AbstractCode* from, Address to) { | ||
| 1447 | + void Logger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) { | ||
| 1454 | 1448 | if (!is_listening_to_code_events()) return; | |
| 1455 | - MoveEventInternal(CodeEventListener::CODE_MOVE_EVENT, from->address(), to); | ||
| 1449 | + MoveEventInternal(CodeEventListener::CODE_MOVE_EVENT, from->address(), | ||
| 1450 | + to->address()); | ||
| 1456 | 1451 | } | |
| 1457 | 1452 | ||
| 1458 | 1453 | namespace { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -209,7 +209,7 @@ class Logger : public CodeEventListener { | |||
| 209 | 209 | // Emits a code create event for a RegExp. | |
| 210 | 210 | void RegExpCodeCreateEvent(AbstractCode* code, String* source); | |
| 211 | 211 | // Emits a code move event. | |
| 212 | - void CodeMoveEvent(AbstractCode* from, Address to); | ||
| 212 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to); | ||
| 213 | 213 | // Emits a code line info record event. | |
| 214 | 214 | void CodeLinePosInfoRecordEvent(Address code_start, | |
| 215 | 215 | ByteArray* source_position_table); | |
@@ -466,7 +466,7 @@ class ExternalCodeEventListener : public CodeEventListener { | |||
| 466 | 466 | void GetterCallbackEvent(Name* name, Address entry_point) override {} | |
| 467 | 467 | void SetterCallbackEvent(Name* name, Address entry_point) override {} | |
| 468 | 468 | void SharedFunctionInfoMoveEvent(Address from, Address to) override {} | |
| 469 | - void CodeMoveEvent(AbstractCode* from, Address to) override {} | ||
| 469 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override {} | ||
| 470 | 470 | void CodeDisableOptEvent(AbstractCode* code, | |
| 471 | 471 | SharedFunctionInfo* shared) override {} | |
| 472 | 472 | void CodeMovingGCEvent() override {} | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -419,7 +419,7 @@ void PerfJitLogger::LogWriteUnwindingInfo(Code* code) { | |||
| 419 | 419 | LogWriteBytes(padding_bytes, static_cast<int>(padding_size)); | |
| 420 | 420 | } | |
| 421 | 421 | ||
| 422 | - void PerfJitLogger::CodeMoveEvent(AbstractCode* from, Address to) { | ||
| 422 | + void PerfJitLogger::CodeMoveEvent(AbstractCode* from, AbstractCode* to) { | ||
| 423 | 423 | // We may receive a CodeMove event if a BytecodeArray object moves. Otherwise | |
| 424 | 424 | // code relocation is not supported. | |
| 425 | 425 | CHECK(from->IsBytecodeArray()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,7 +41,7 @@ class PerfJitLogger : public CodeEventLogger { | |||
| 41 | 41 | PerfJitLogger(); | |
| 42 | 42 | virtual ~PerfJitLogger(); | |
| 43 | 43 | ||
| 44 | - void CodeMoveEvent(AbstractCode* from, Address to) override; | ||
| 44 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override; | ||
| 45 | 45 | void CodeDisableOptEvent(AbstractCode* code, | |
| 46 | 46 | SharedFunctionInfo* shared) override {} | |
| 47 | 47 | ||
@@ -118,7 +118,7 @@ class PerfJitLogger : public CodeEventLogger { | |||
| 118 | 118 | // PerfJitLogger is only implemented on Linux | |
| 119 | 119 | class PerfJitLogger : public CodeEventLogger { | |
| 120 | 120 | public: | |
| 121 | - void CodeMoveEvent(AbstractCode* from, Address to) override { | ||
| 121 | + void CodeMoveEvent(AbstractCode* from, AbstractCode* to) override { | ||
| 122 | 122 | UNIMPLEMENTED(); | |
| 123 | 123 | } | |
| 124 | 124 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,31 +16,35 @@ namespace v8 { | |||
| 16 | 16 | namespace internal { | |
| 17 | 17 | ||
| 18 | 18 | void CodeCreateEventRecord::UpdateCodeMap(CodeMap* code_map) { | |
| 19 | - code_map->AddCode(start, entry, size); | ||
| 19 | + code_map->AddCode(instruction_start, entry, instruction_size); | ||
| 20 | 20 | } | |
| 21 | 21 | ||
| 22 | 22 | ||
| 23 | 23 | void CodeMoveEventRecord::UpdateCodeMap(CodeMap* code_map) { | |
| 24 | - code_map->MoveCode(from, to); | ||
| 24 | + code_map->MoveCode(from_instruction_start, to_instruction_start); | ||
| 25 | 25 | } | |
| 26 | 26 | ||
| 27 | 27 | ||
| 28 | 28 | void CodeDisableOptEventRecord::UpdateCodeMap(CodeMap* code_map) { | |
| 29 | - CodeEntry* entry = code_map->FindEntry(start); | ||
| 29 | + CodeEntry* entry = code_map->FindEntry(instruction_start); | ||
| 30 | 30 | if (entry != nullptr) { | |
| 31 | 31 | entry->set_bailout_reason(bailout_reason); | |
| 32 | 32 | } | |
| 33 | 33 | } | |
| 34 | 34 | ||
| 35 | 35 | ||
| 36 | 36 | void CodeDeoptEventRecord::UpdateCodeMap(CodeMap* code_map) { | |
| 37 | - CodeEntry* entry = code_map->FindEntry(start); | ||
| 38 | - if (entry != nullptr) entry->set_deopt_info(deopt_reason, deopt_id); | ||
| 37 | + CodeEntry* entry = code_map->FindEntry(instruction_start); | ||
| 38 | + if (entry == nullptr) return; | ||
| 39 | + std::vector<CpuProfileDeoptFrame> frames_vector( | ||
| 40 | + deopt_frames, deopt_frames + deopt_frame_count); | ||
| 41 | + entry->set_deopt_info(deopt_reason, deopt_id, std::move(frames_vector)); | ||
| 42 | + delete[] deopt_frames; | ||
| 39 | 43 | } | |
| 40 | 44 | ||
| 41 | 45 | ||
| 42 | 46 | void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) { | |
| 43 | - CodeEntry* entry = code_map->FindEntry(start); | ||
| 47 | + CodeEntry* entry = code_map->FindEntry(instruction_start); | ||
| 44 | 48 | if (!entry) { | |
| 45 | 49 | // Code objects for builtins should already have been added to the map but | |
| 46 | 50 | // some of them have been filtered out by CpuProfiler. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments