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
5053namespace v8 {
5154namespace internal {
@@ -98,6 +101,7 @@ static const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) {
98101 return CodeKindToMarker (kind);
99102}
100103
104+ #if V8_ENABLE_WEBASSEMBLY
101105static 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
110115class 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
250256void 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
269276void 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
352362void 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
478490void 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
484497void 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
629645void 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
641658void 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
710730void 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
760781void 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
13771399void 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
14001423void 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-
18891896void Logger::LogCodeObjects () { existing_code_logger_.LogCodeObjects (); }
18901897
18911898void 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
22182233void ExistingCodeLogger::LogExistingFunction (
0 commit comments