Skip to content

Commit 2dbdfcd

Browse files
backesCommit Bot
authored andcommitted
[no-wasm][logging] Remove wasm support for logging
The definition of {wasm::WasmCode} will not be available in no-wasm builds, hence avoid any accesses to WasmCode for logging. Drive-by: Inline enumeration of wasm modules for logging of existing code, to avoid another #if. R=petermarshall@chromium.org, jgruber@chromium.org Bug: v8:11238 Change-Id: I3b78cf90f9ad155b5bea64e0941531aed2d4291a Cq-Include-Trybots: luci.v8.try:v8_linux64_no_wasm_compile_rel Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2739978 Reviewed-by: Peter Marshall <petermarshall@chromium.org> Reviewed-by: Jakob Gruber <jgruber@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#73338}
1 parent d18b37c commit 2dbdfcd

12 files changed

Lines changed: 83 additions & 22 deletions

File tree

src/diagnostics/perf-jit.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@
4646
#include "src/objects/shared-function-info.h"
4747
#include "src/snapshot/embedded/embedded-data.h"
4848
#include "src/utils/ostreams.h"
49+
50+
#if V8_ENABLE_WEBASSEMBLY
4951
#include "src/wasm/wasm-code-manager.h"
52+
#endif // V8_ENABLE_WEBASSEMBLY
5053

5154
namespace v8 {
5255
namespace internal {
@@ -247,6 +250,7 @@ void PerfJitLogger::LogRecordedBuffer(
247250
length);
248251
}
249252

253+
#if V8_ENABLE_WEBASSEMBLY
250254
void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code,
251255
const char* name, int length) {
252256
base::LockGuard<base::RecursiveMutex> guard_file(file_mutex_.Pointer());
@@ -260,6 +264,7 @@ void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code,
260264
WriteJitCodeLoadEntry(code->instructions().begin(),
261265
code->instructions().length(), name, length);
262266
}
267+
#endif // V8_ENABLE_WEBASSEMBLY
263268

264269
void PerfJitLogger::WriteJitCodeLoadEntry(const uint8_t* code_pointer,
265270
uint32_t code_size, const char* name,
@@ -401,6 +406,7 @@ void PerfJitLogger::LogWriteDebugInfo(Handle<Code> code,
401406
LogWriteBytes(padding_bytes, padding);
402407
}
403408

409+
#if V8_ENABLE_WEBASSEMBLY
404410
void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) {
405411
wasm::WasmModuleSourceMap* source_map =
406412
code->native_module()->GetWasmSourceMap();
@@ -467,6 +473,7 @@ void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) {
467473
char padding_bytes[8] = {0};
468474
LogWriteBytes(padding_bytes, padding);
469475
}
476+
#endif // V8_ENABLE_WEBASSEMBLY
470477

471478
void PerfJitLogger::LogWriteUnwindingInfo(Code code) {
472479
PerfJitCodeUnwindingInfo unwinding_info_header;

src/diagnostics/perf-jit.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ class PerfJitLogger : public CodeEventLogger {
5858
void LogRecordedBuffer(Handle<AbstractCode> code,
5959
MaybeHandle<SharedFunctionInfo> maybe_shared,
6060
const char* name, int length) override;
61+
#if V8_ENABLE_WEBASSEMBLY
6162
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
6263
int length) override;
64+
#endif // V8_ENABLE_WEBASSEMBLY
6365

6466
// Extension added to V8 log file name to get the low-level log name.
6567
static const char kFilenameFormatString[];
@@ -75,7 +77,9 @@ class PerfJitLogger : public CodeEventLogger {
7577
void LogWriteBytes(const char* bytes, int size);
7678
void LogWriteHeader();
7779
void LogWriteDebugInfo(Handle<Code> code, Handle<SharedFunctionInfo> shared);
80+
#if V8_ENABLE_WEBASSEMBLY
7881
void LogWriteDebugInfo(const wasm::WasmCode* code);
82+
#endif // V8_ENABLE_WEBASSEMBLY
7983
void LogWriteUnwindingInfo(Code code);
8084

8185
static const uint32_t kElfMachIA32 = 3;

src/logging/code-events.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ class CodeEventListener {
8585
Handle<SharedFunctionInfo> shared,
8686
Handle<Name> script_name, int line,
8787
int column) = 0;
88+
#if V8_ENABLE_WEBASSEMBLY
8889
virtual void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
8990
wasm::WasmName name, const char* source_url,
9091
int code_offset, int script_id) = 0;
92+
#endif // V8_ENABLE_WEBASSEMBLY
9193

9294
virtual void CallbackEvent(Handle<Name> name, Address entry_point) = 0;
9395
virtual void GetterCallbackEvent(Handle<Name> name, Address entry_point) = 0;
@@ -174,6 +176,7 @@ class CodeEventDispatcher : public CodeEventListener {
174176
listener->CodeCreateEvent(tag, code, shared, source, line, column);
175177
});
176178
}
179+
#if V8_ENABLE_WEBASSEMBLY
177180
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
178181
wasm::WasmName name, const char* source_url,
179182
int code_offset, int script_id) override {
@@ -182,6 +185,7 @@ class CodeEventDispatcher : public CodeEventListener {
182185
script_id);
183186
});
184187
}
188+
#endif // V8_ENABLE_WEBASSEMBLY
185189
void CallbackEvent(Handle<Name> name, Address entry_point) override {
186190
DispatchEventToListeners([=](CodeEventListener* listener) {
187191
listener->CallbackEvent(name, entry_point);

src/logging/log.cc

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,12 @@
4343
#include "src/tracing/tracing-category-observer.h"
4444
#include "src/utils/memcopy.h"
4545
#include "src/utils/version.h"
46+
47+
#if V8_ENABLE_WEBASSEMBLY
4648
#include "src/wasm/wasm-code-manager.h"
4749
#include "src/wasm/wasm-engine.h"
4850
#include "src/wasm/wasm-objects-inl.h"
51+
#endif // V8_ENABLE_WEBASSEMBLY
4952

5053
namespace v8 {
5154
namespace internal {
@@ -98,6 +101,7 @@ static const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) {
98101
return CodeKindToMarker(kind);
99102
}
100103

104+
#if V8_ENABLE_WEBASSEMBLY
101105
static const char* ComputeMarker(const wasm::WasmCode* code) {
102106
switch (code->kind()) {
103107
case wasm::WasmCode::kFunction:
@@ -106,6 +110,7 @@ static const char* ComputeMarker(const wasm::WasmCode* code) {
106110
return "";
107111
}
108112
}
113+
#endif // V8_ENABLE_WEBASSEMBLY
109114

110115
class CodeEventLogger::NameBuffer {
111116
public:
@@ -247,6 +252,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
247252
LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size());
248253
}
249254

255+
#if V8_ENABLE_WEBASSEMBLY
250256
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
251257
const wasm::WasmCode* code,
252258
wasm::WasmName name,
@@ -265,6 +271,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
265271
name_buffer_->AppendBytes(ExecutionTierToString(code->tier()));
266272
LogRecordedBuffer(code, name_buffer_->get(), name_buffer_->size());
267273
}
274+
#endif // V8_ENABLE_WEBASSEMBLY
268275

269276
void CodeEventLogger::RegExpCodeCreateEvent(Handle<AbstractCode> code,
270277
Handle<String> source) {
@@ -289,8 +296,10 @@ class PerfBasicLogger : public CodeEventLogger {
289296
void LogRecordedBuffer(Handle<AbstractCode> code,
290297
MaybeHandle<SharedFunctionInfo> maybe_shared,
291298
const char* name, int length) override;
299+
#if V8_ENABLE_WEBASSEMBLY
292300
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
293301
int length) override;
302+
#endif // V8_ENABLE_WEBASSEMBLY
294303
void WriteLogRecordedBuffer(uintptr_t address, int size, const char* name,
295304
int name_length);
296305

@@ -349,11 +358,13 @@ void PerfBasicLogger::LogRecordedBuffer(Handle<AbstractCode> code,
349358
code->InstructionSize(), name, length);
350359
}
351360

361+
#if V8_ENABLE_WEBASSEMBLY
352362
void PerfBasicLogger::LogRecordedBuffer(const wasm::WasmCode* code,
353363
const char* name, int length) {
354364
WriteLogRecordedBuffer(static_cast<uintptr_t>(code->instruction_start()),
355365
code->instructions().length(), name, length);
356366
}
367+
#endif // V8_ENABLE_WEBASSEMBLY
357368
#endif // V8_OS_LINUX
358369

359370
// External CodeEventListener
@@ -475,11 +486,13 @@ void ExternalCodeEventListener::CodeCreateEvent(
475486
code_event_handler_->Handle(reinterpret_cast<v8::CodeEvent*>(&code_event));
476487
}
477488

489+
#if V8_ENABLE_WEBASSEMBLY
478490
void ExternalCodeEventListener::CodeCreateEvent(
479491
LogEventsAndTags tag, const wasm::WasmCode* code, wasm::WasmName name,
480492
const char* source_url, int code_offset, int script_id) {
481493
// TODO(mmarchini): handle later
482494
}
495+
#endif // V8_ENABLE_WEBASSEMBLY
483496

484497
void ExternalCodeEventListener::RegExpCodeCreateEvent(Handle<AbstractCode> code,
485498
Handle<String> source) {
@@ -530,8 +543,10 @@ class LowLevelLogger : public CodeEventLogger {
530543
void LogRecordedBuffer(Handle<AbstractCode> code,
531544
MaybeHandle<SharedFunctionInfo> maybe_shared,
532545
const char* name, int length) override;
546+
#if V8_ENABLE_WEBASSEMBLY
533547
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
534548
int length) override;
549+
#endif // V8_ENABLE_WEBASSEMBLY
535550

536551
// Low-level profiling event structures.
537552
struct CodeCreateStruct {
@@ -626,6 +641,7 @@ void LowLevelLogger::LogRecordedBuffer(Handle<AbstractCode> code,
626641
code->InstructionSize());
627642
}
628643

644+
#if V8_ENABLE_WEBASSEMBLY
629645
void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code,
630646
const char* name, int length) {
631647
CodeCreateStruct event;
@@ -637,6 +653,7 @@ void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code,
637653
LogWriteBytes(reinterpret_cast<const char*>(code->instruction_start()),
638654
code->instructions().length());
639655
}
656+
#endif // V8_ENABLE_WEBASSEMBLY
640657

641658
void LowLevelLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) {
642659
CodeMoveStruct event;
@@ -675,8 +692,10 @@ class JitLogger : public CodeEventLogger {
675692
void LogRecordedBuffer(Handle<AbstractCode> code,
676693
MaybeHandle<SharedFunctionInfo> maybe_shared,
677694
const char* name, int length) override;
695+
#if V8_ENABLE_WEBASSEMBLY
678696
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
679697
int length) override;
698+
#endif // V8_ENABLE_WEBASSEMBLY
680699

681700
JitCodeEventHandler code_event_handler_;
682701
base::Mutex logger_mutex_;
@@ -707,6 +726,7 @@ void JitLogger::LogRecordedBuffer(Handle<AbstractCode> code,
707726
code_event_handler_(&event);
708727
}
709728

729+
#if V8_ENABLE_WEBASSEMBLY
710730
void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
711731
int length) {
712732
JitCodeEvent event;
@@ -756,6 +776,7 @@ void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
756776
}
757777
code_event_handler_(&event);
758778
}
779+
#endif // V8_ENABLE_WEBASSEMBLY
759780

760781
void JitLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) {
761782
base::MutexGuard guard(&logger_mutex_);
@@ -1374,6 +1395,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
13741395
LogCodeDisassemble(code);
13751396
}
13761397

1398+
#if V8_ENABLE_WEBASSEMBLY
13771399
void Logger::CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
13781400
wasm::WasmName name, const char* /*source_url*/,
13791401
int /*code_offset*/, int /*script_id*/) {
@@ -1396,6 +1418,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
13961418
msg << kNext << tag_ptr << kNext << ComputeMarker(code);
13971419
msg.WriteToLogFile();
13981420
}
1421+
#endif // V8_ENABLE_WEBASSEMBLY
13991422

14001423
void Logger::CallbackEventInternal(const char* prefix, Handle<Name> name,
14011424
Address entry_point) {
@@ -1870,22 +1893,6 @@ EnumerateCompiledFunctions(Heap* heap) {
18701893
return compiled_funcs;
18711894
}
18721895

1873-
static std::vector<Handle<WasmModuleObject>> EnumerateWasmModuleObjects(
1874-
Heap* heap) {
1875-
HeapObjectIterator iterator(heap);
1876-
DisallowGarbageCollection no_gc;
1877-
std::vector<Handle<WasmModuleObject>> module_objects;
1878-
1879-
for (HeapObject obj = iterator.Next(); !obj.is_null();
1880-
obj = iterator.Next()) {
1881-
if (obj.IsWasmModuleObject()) {
1882-
WasmModuleObject module = WasmModuleObject::cast(obj);
1883-
module_objects.emplace_back(module, Isolate::FromHeap(heap));
1884-
}
1885-
}
1886-
return module_objects;
1887-
}
1888-
18891896
void Logger::LogCodeObjects() { existing_code_logger_.LogCodeObjects(); }
18901897

18911898
void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
@@ -2041,9 +2048,11 @@ void Logger::SetCodeEventHandler(uint32_t options,
20412048
}
20422049

20432050
if (event_handler) {
2051+
#if V8_ENABLE_WEBASSEMBLY
20442052
if (isolate_->wasm_engine() != nullptr) {
20452053
isolate_->wasm_engine()->EnableCodeLogging(isolate_);
20462054
}
2055+
#endif // V8_ENABLE_WEBASSEMBLY
20472056
jit_logger_ = std::make_unique<JitLogger>(isolate_, event_handler);
20482057
AddCodeEventListener(jit_logger_.get());
20492058
if (options & kJitCodeEventEnumExisting) {
@@ -2207,12 +2216,18 @@ void ExistingCodeLogger::LogCompiledFunctions() {
22072216
LogExistingFunction(pair.first, pair.second);
22082217
}
22092218

2210-
const std::vector<Handle<WasmModuleObject>> wasm_module_objects =
2211-
EnumerateWasmModuleObjects(heap);
2212-
for (auto& module_object : wasm_module_objects) {
2213-
module_object->native_module()->LogWasmCodes(isolate_,
2214-
module_object->script());
2219+
#if V8_ENABLE_WEBASSEMBLY
2220+
HeapObjectIterator iterator(heap);
2221+
DisallowGarbageCollection no_gc;
2222+
2223+
for (HeapObject obj = iterator.Next(); !obj.is_null();
2224+
obj = iterator.Next()) {
2225+
if (!obj.IsWasmModuleObject()) continue;
2226+
auto module_object = WasmModuleObject::cast(obj);
2227+
module_object.native_module()->LogWasmCodes(isolate_,
2228+
module_object.script());
22152229
}
2230+
#endif // V8_ENABLE_WEBASSEMBLY
22162231
}
22172232

22182233
void ExistingCodeLogger::LogExistingFunction(

src/logging/log.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ class Logger : public CodeEventListener {
195195
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
196196
Handle<SharedFunctionInfo> shared,
197197
Handle<Name> script_name, int line, int column) override;
198+
#if V8_ENABLE_WEBASSEMBLY
198199
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
199200
wasm::WasmName name, const char* source_url,
200201
int code_offset, int script_id) override;
202+
#endif // V8_ENABLE_WEBASSEMBLY
201203

202204
void CallbackEvent(Handle<Name> name, Address entry_point) override;
203205
void GetterCallbackEvent(Handle<Name> name, Address entry_point) override;
@@ -396,9 +398,11 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener {
396398
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
397399
Handle<SharedFunctionInfo> shared,
398400
Handle<Name> script_name, int line, int column) override;
401+
#if V8_ENABLE_WEBASSEMBLY
399402
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
400403
wasm::WasmName name, const char* source_url,
401404
int code_offset, int script_id) override;
405+
#endif // V8_ENABLE_WEBASSEMBLY
402406

403407
void RegExpCodeCreateEvent(Handle<AbstractCode> code,
404408
Handle<String> source) override;
@@ -423,8 +427,10 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener {
423427
virtual void LogRecordedBuffer(Handle<AbstractCode> code,
424428
MaybeHandle<SharedFunctionInfo> maybe_shared,
425429
const char* name, int length) = 0;
430+
#if V8_ENABLE_WEBASSEMBLY
426431
virtual void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
427432
int length) = 0;
433+
#endif // V8_ENABLE_WEBASSEMBLY
428434

429435
std::unique_ptr<NameBuffer> name_buffer_;
430436
};
@@ -457,9 +463,11 @@ class ExternalCodeEventListener : public CodeEventListener {
457463
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
458464
Handle<SharedFunctionInfo> shared, Handle<Name> source,
459465
int line, int column) override;
466+
#if V8_ENABLE_WEBASSEMBLY
460467
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
461468
wasm::WasmName name, const char* source_url,
462469
int code_offset, int script_id) override;
470+
#endif // V8_ENABLE_WEBASSEMBLY
463471

464472
void RegExpCodeCreateEvent(Handle<AbstractCode> code,
465473
Handle<String> source) override;

src/profiler/cpu-profiler-inl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
4747
CodeEntry* entry = code_map->FindEntry(instruction_start);
4848
if (entry) {
4949
entry->SetBuiltinId(builtin_id);
50-
} else if (builtin_id == Builtins::kGenericJSToWasmWrapper) {
50+
return;
51+
}
52+
#if V8_ENABLE_WEBASSEMBLY
53+
if (builtin_id == Builtins::kGenericJSToWasmWrapper) {
5154
// Make sure to add the generic js-to-wasm wrapper builtin, because that
5255
// one is supposed to show up in profiles.
5356
entry = new CodeEntry(CodeEventListener::BUILTIN_TAG,
5457
Builtins::name(builtin_id));
5558
code_map->AddCode(instruction_start, entry, instruction_size);
5659
}
60+
#endif // V8_ENABLE_WEBASSEMBLY
5761
}
5862

5963
TickSample* SamplingEventsProcessor::StartTickSample() {

src/profiler/profiler-listener.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
#include "src/profiler/cpu-profiler.h"
2020
#include "src/profiler/profile-generator-inl.h"
2121
#include "src/utils/vector.h"
22+
23+
#if V8_ENABLE_WEBASSEMBLY
2224
#include "src/wasm/wasm-code-manager.h"
25+
#endif // V8_ENABLE_WEBASSEMBLY
2326

2427
namespace v8 {
2528
namespace internal {
@@ -220,6 +223,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
220223
DispatchCodeEvent(evt_rec);
221224
}
222225

226+
#if V8_ENABLE_WEBASSEMBLY
223227
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
224228
const wasm::WasmCode* code,
225229
wasm::WasmName name,
@@ -240,6 +244,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
240244
rec->instruction_size = code->instructions().length();
241245
DispatchCodeEvent(evt_rec);
242246
}
247+
#endif // V8_ENABLE_WEBASSEMBLY
243248

244249
void ProfilerListener::CallbackEvent(Handle<Name> name, Address entry_point) {
245250
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);

0 commit comments

Comments
 (0)