Commit 2dbdfcdd authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[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/+/2739978Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73338}
parent d18b37ce
...@@ -46,7 +46,10 @@ ...@@ -46,7 +46,10 @@
#include "src/objects/shared-function-info.h" #include "src/objects/shared-function-info.h"
#include "src/snapshot/embedded/embedded-data.h" #include "src/snapshot/embedded/embedded-data.h"
#include "src/utils/ostreams.h" #include "src/utils/ostreams.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-code-manager.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -247,6 +250,7 @@ void PerfJitLogger::LogRecordedBuffer( ...@@ -247,6 +250,7 @@ void PerfJitLogger::LogRecordedBuffer(
length); length);
} }
#if V8_ENABLE_WEBASSEMBLY
void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code, void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code,
const char* name, int length) { const char* name, int length) {
base::LockGuard<base::RecursiveMutex> guard_file(file_mutex_.Pointer()); base::LockGuard<base::RecursiveMutex> guard_file(file_mutex_.Pointer());
...@@ -260,6 +264,7 @@ void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code, ...@@ -260,6 +264,7 @@ void PerfJitLogger::LogRecordedBuffer(const wasm::WasmCode* code,
WriteJitCodeLoadEntry(code->instructions().begin(), WriteJitCodeLoadEntry(code->instructions().begin(),
code->instructions().length(), name, length); code->instructions().length(), name, length);
} }
#endif // V8_ENABLE_WEBASSEMBLY
void PerfJitLogger::WriteJitCodeLoadEntry(const uint8_t* code_pointer, void PerfJitLogger::WriteJitCodeLoadEntry(const uint8_t* code_pointer,
uint32_t code_size, const char* name, uint32_t code_size, const char* name,
...@@ -401,6 +406,7 @@ void PerfJitLogger::LogWriteDebugInfo(Handle<Code> code, ...@@ -401,6 +406,7 @@ void PerfJitLogger::LogWriteDebugInfo(Handle<Code> code,
LogWriteBytes(padding_bytes, padding); LogWriteBytes(padding_bytes, padding);
} }
#if V8_ENABLE_WEBASSEMBLY
void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) { void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) {
wasm::WasmModuleSourceMap* source_map = wasm::WasmModuleSourceMap* source_map =
code->native_module()->GetWasmSourceMap(); code->native_module()->GetWasmSourceMap();
...@@ -467,6 +473,7 @@ void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) { ...@@ -467,6 +473,7 @@ void PerfJitLogger::LogWriteDebugInfo(const wasm::WasmCode* code) {
char padding_bytes[8] = {0}; char padding_bytes[8] = {0};
LogWriteBytes(padding_bytes, padding); LogWriteBytes(padding_bytes, padding);
} }
#endif // V8_ENABLE_WEBASSEMBLY
void PerfJitLogger::LogWriteUnwindingInfo(Code code) { void PerfJitLogger::LogWriteUnwindingInfo(Code code) {
PerfJitCodeUnwindingInfo unwinding_info_header; PerfJitCodeUnwindingInfo unwinding_info_header;
......
...@@ -58,8 +58,10 @@ class PerfJitLogger : public CodeEventLogger { ...@@ -58,8 +58,10 @@ class PerfJitLogger : public CodeEventLogger {
void LogRecordedBuffer(Handle<AbstractCode> code, void LogRecordedBuffer(Handle<AbstractCode> code,
MaybeHandle<SharedFunctionInfo> maybe_shared, MaybeHandle<SharedFunctionInfo> maybe_shared,
const char* name, int length) override; const char* name, int length) override;
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override; int length) override;
#endif // V8_ENABLE_WEBASSEMBLY
// Extension added to V8 log file name to get the low-level log name. // Extension added to V8 log file name to get the low-level log name.
static const char kFilenameFormatString[]; static const char kFilenameFormatString[];
...@@ -75,7 +77,9 @@ class PerfJitLogger : public CodeEventLogger { ...@@ -75,7 +77,9 @@ class PerfJitLogger : public CodeEventLogger {
void LogWriteBytes(const char* bytes, int size); void LogWriteBytes(const char* bytes, int size);
void LogWriteHeader(); void LogWriteHeader();
void LogWriteDebugInfo(Handle<Code> code, Handle<SharedFunctionInfo> shared); void LogWriteDebugInfo(Handle<Code> code, Handle<SharedFunctionInfo> shared);
#if V8_ENABLE_WEBASSEMBLY
void LogWriteDebugInfo(const wasm::WasmCode* code); void LogWriteDebugInfo(const wasm::WasmCode* code);
#endif // V8_ENABLE_WEBASSEMBLY
void LogWriteUnwindingInfo(Code code); void LogWriteUnwindingInfo(Code code);
static const uint32_t kElfMachIA32 = 3; static const uint32_t kElfMachIA32 = 3;
......
...@@ -85,9 +85,11 @@ class CodeEventListener { ...@@ -85,9 +85,11 @@ class CodeEventListener {
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, Handle<Name> script_name, int line,
int column) = 0; int column) = 0;
#if V8_ENABLE_WEBASSEMBLY
virtual void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, virtual void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) = 0; int code_offset, int script_id) = 0;
#endif // V8_ENABLE_WEBASSEMBLY
virtual void CallbackEvent(Handle<Name> name, Address entry_point) = 0; virtual void CallbackEvent(Handle<Name> name, Address entry_point) = 0;
virtual void GetterCallbackEvent(Handle<Name> name, Address entry_point) = 0; virtual void GetterCallbackEvent(Handle<Name> name, Address entry_point) = 0;
...@@ -174,6 +176,7 @@ class CodeEventDispatcher : public CodeEventListener { ...@@ -174,6 +176,7 @@ class CodeEventDispatcher : public CodeEventListener {
listener->CodeCreateEvent(tag, code, shared, source, line, column); listener->CodeCreateEvent(tag, code, shared, source, line, column);
}); });
} }
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override { int code_offset, int script_id) override {
...@@ -182,6 +185,7 @@ class CodeEventDispatcher : public CodeEventListener { ...@@ -182,6 +185,7 @@ class CodeEventDispatcher : public CodeEventListener {
script_id); script_id);
}); });
} }
#endif // V8_ENABLE_WEBASSEMBLY
void CallbackEvent(Handle<Name> name, Address entry_point) override { void CallbackEvent(Handle<Name> name, Address entry_point) override {
DispatchEventToListeners([=](CodeEventListener* listener) { DispatchEventToListeners([=](CodeEventListener* listener) {
listener->CallbackEvent(name, entry_point); listener->CallbackEvent(name, entry_point);
......
...@@ -43,9 +43,12 @@ ...@@ -43,9 +43,12 @@
#include "src/tracing/tracing-category-observer.h" #include "src/tracing/tracing-category-observer.h"
#include "src/utils/memcopy.h" #include "src/utils/memcopy.h"
#include "src/utils/version.h" #include "src/utils/version.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-objects-inl.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -98,6 +101,7 @@ static const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) { ...@@ -98,6 +101,7 @@ static const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) {
return CodeKindToMarker(kind); return CodeKindToMarker(kind);
} }
#if V8_ENABLE_WEBASSEMBLY
static const char* ComputeMarker(const wasm::WasmCode* code) { static const char* ComputeMarker(const wasm::WasmCode* code) {
switch (code->kind()) { switch (code->kind()) {
case wasm::WasmCode::kFunction: case wasm::WasmCode::kFunction:
...@@ -106,6 +110,7 @@ static const char* ComputeMarker(const wasm::WasmCode* code) { ...@@ -106,6 +110,7 @@ static const char* ComputeMarker(const wasm::WasmCode* code) {
return ""; return "";
} }
} }
#endif // V8_ENABLE_WEBASSEMBLY
class CodeEventLogger::NameBuffer { class CodeEventLogger::NameBuffer {
public: public:
...@@ -247,6 +252,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -247,6 +252,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size()); LogRecordedBuffer(code, shared, name_buffer_->get(), name_buffer_->size());
} }
#if V8_ENABLE_WEBASSEMBLY
void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag, void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code, const wasm::WasmCode* code,
wasm::WasmName name, wasm::WasmName name,
...@@ -265,6 +271,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag, ...@@ -265,6 +271,7 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
name_buffer_->AppendBytes(ExecutionTierToString(code->tier())); name_buffer_->AppendBytes(ExecutionTierToString(code->tier()));
LogRecordedBuffer(code, name_buffer_->get(), name_buffer_->size()); LogRecordedBuffer(code, name_buffer_->get(), name_buffer_->size());
} }
#endif // V8_ENABLE_WEBASSEMBLY
void CodeEventLogger::RegExpCodeCreateEvent(Handle<AbstractCode> code, void CodeEventLogger::RegExpCodeCreateEvent(Handle<AbstractCode> code,
Handle<String> source) { Handle<String> source) {
...@@ -289,8 +296,10 @@ class PerfBasicLogger : public CodeEventLogger { ...@@ -289,8 +296,10 @@ class PerfBasicLogger : public CodeEventLogger {
void LogRecordedBuffer(Handle<AbstractCode> code, void LogRecordedBuffer(Handle<AbstractCode> code,
MaybeHandle<SharedFunctionInfo> maybe_shared, MaybeHandle<SharedFunctionInfo> maybe_shared,
const char* name, int length) override; const char* name, int length) override;
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override; int length) override;
#endif // V8_ENABLE_WEBASSEMBLY
void WriteLogRecordedBuffer(uintptr_t address, int size, const char* name, void WriteLogRecordedBuffer(uintptr_t address, int size, const char* name,
int name_length); int name_length);
...@@ -349,11 +358,13 @@ void PerfBasicLogger::LogRecordedBuffer(Handle<AbstractCode> code, ...@@ -349,11 +358,13 @@ void PerfBasicLogger::LogRecordedBuffer(Handle<AbstractCode> code,
code->InstructionSize(), name, length); code->InstructionSize(), name, length);
} }
#if V8_ENABLE_WEBASSEMBLY
void PerfBasicLogger::LogRecordedBuffer(const wasm::WasmCode* code, void PerfBasicLogger::LogRecordedBuffer(const wasm::WasmCode* code,
const char* name, int length) { const char* name, int length) {
WriteLogRecordedBuffer(static_cast<uintptr_t>(code->instruction_start()), WriteLogRecordedBuffer(static_cast<uintptr_t>(code->instruction_start()),
code->instructions().length(), name, length); code->instructions().length(), name, length);
} }
#endif // V8_ENABLE_WEBASSEMBLY
#endif // V8_OS_LINUX #endif // V8_OS_LINUX
// External CodeEventListener // External CodeEventListener
...@@ -475,11 +486,13 @@ void ExternalCodeEventListener::CodeCreateEvent( ...@@ -475,11 +486,13 @@ void ExternalCodeEventListener::CodeCreateEvent(
code_event_handler_->Handle(reinterpret_cast<v8::CodeEvent*>(&code_event)); code_event_handler_->Handle(reinterpret_cast<v8::CodeEvent*>(&code_event));
} }
#if V8_ENABLE_WEBASSEMBLY
void ExternalCodeEventListener::CodeCreateEvent( void ExternalCodeEventListener::CodeCreateEvent(
LogEventsAndTags tag, const wasm::WasmCode* code, wasm::WasmName name, LogEventsAndTags tag, const wasm::WasmCode* code, wasm::WasmName name,
const char* source_url, int code_offset, int script_id) { const char* source_url, int code_offset, int script_id) {
// TODO(mmarchini): handle later // TODO(mmarchini): handle later
} }
#endif // V8_ENABLE_WEBASSEMBLY
void ExternalCodeEventListener::RegExpCodeCreateEvent(Handle<AbstractCode> code, void ExternalCodeEventListener::RegExpCodeCreateEvent(Handle<AbstractCode> code,
Handle<String> source) { Handle<String> source) {
...@@ -530,8 +543,10 @@ class LowLevelLogger : public CodeEventLogger { ...@@ -530,8 +543,10 @@ class LowLevelLogger : public CodeEventLogger {
void LogRecordedBuffer(Handle<AbstractCode> code, void LogRecordedBuffer(Handle<AbstractCode> code,
MaybeHandle<SharedFunctionInfo> maybe_shared, MaybeHandle<SharedFunctionInfo> maybe_shared,
const char* name, int length) override; const char* name, int length) override;
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override; int length) override;
#endif // V8_ENABLE_WEBASSEMBLY
// Low-level profiling event structures. // Low-level profiling event structures.
struct CodeCreateStruct { struct CodeCreateStruct {
...@@ -626,6 +641,7 @@ void LowLevelLogger::LogRecordedBuffer(Handle<AbstractCode> code, ...@@ -626,6 +641,7 @@ void LowLevelLogger::LogRecordedBuffer(Handle<AbstractCode> code,
code->InstructionSize()); code->InstructionSize());
} }
#if V8_ENABLE_WEBASSEMBLY
void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code, void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code,
const char* name, int length) { const char* name, int length) {
CodeCreateStruct event; CodeCreateStruct event;
...@@ -637,6 +653,7 @@ void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code, ...@@ -637,6 +653,7 @@ void LowLevelLogger::LogRecordedBuffer(const wasm::WasmCode* code,
LogWriteBytes(reinterpret_cast<const char*>(code->instruction_start()), LogWriteBytes(reinterpret_cast<const char*>(code->instruction_start()),
code->instructions().length()); code->instructions().length());
} }
#endif // V8_ENABLE_WEBASSEMBLY
void LowLevelLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) { void LowLevelLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) {
CodeMoveStruct event; CodeMoveStruct event;
...@@ -675,8 +692,10 @@ class JitLogger : public CodeEventLogger { ...@@ -675,8 +692,10 @@ class JitLogger : public CodeEventLogger {
void LogRecordedBuffer(Handle<AbstractCode> code, void LogRecordedBuffer(Handle<AbstractCode> code,
MaybeHandle<SharedFunctionInfo> maybe_shared, MaybeHandle<SharedFunctionInfo> maybe_shared,
const char* name, int length) override; const char* name, int length) override;
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override; int length) override;
#endif // V8_ENABLE_WEBASSEMBLY
JitCodeEventHandler code_event_handler_; JitCodeEventHandler code_event_handler_;
base::Mutex logger_mutex_; base::Mutex logger_mutex_;
...@@ -707,6 +726,7 @@ void JitLogger::LogRecordedBuffer(Handle<AbstractCode> code, ...@@ -707,6 +726,7 @@ void JitLogger::LogRecordedBuffer(Handle<AbstractCode> code,
code_event_handler_(&event); code_event_handler_(&event);
} }
#if V8_ENABLE_WEBASSEMBLY
void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name, void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) { int length) {
JitCodeEvent event; JitCodeEvent event;
...@@ -756,6 +776,7 @@ void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name, ...@@ -756,6 +776,7 @@ void JitLogger::LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
} }
code_event_handler_(&event); code_event_handler_(&event);
} }
#endif // V8_ENABLE_WEBASSEMBLY
void JitLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) { void JitLogger::CodeMoveEvent(AbstractCode from, AbstractCode to) {
base::MutexGuard guard(&logger_mutex_); base::MutexGuard guard(&logger_mutex_);
...@@ -1374,6 +1395,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code, ...@@ -1374,6 +1395,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
LogCodeDisassemble(code); LogCodeDisassemble(code);
} }
#if V8_ENABLE_WEBASSEMBLY
void Logger::CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void Logger::CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* /*source_url*/, wasm::WasmName name, const char* /*source_url*/,
int /*code_offset*/, int /*script_id*/) { int /*code_offset*/, int /*script_id*/) {
...@@ -1396,6 +1418,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, ...@@ -1396,6 +1418,7 @@ void Logger::CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
msg << kNext << tag_ptr << kNext << ComputeMarker(code); msg << kNext << tag_ptr << kNext << ComputeMarker(code);
msg.WriteToLogFile(); msg.WriteToLogFile();
} }
#endif // V8_ENABLE_WEBASSEMBLY
void Logger::CallbackEventInternal(const char* prefix, Handle<Name> name, void Logger::CallbackEventInternal(const char* prefix, Handle<Name> name,
Address entry_point) { Address entry_point) {
...@@ -1870,22 +1893,6 @@ EnumerateCompiledFunctions(Heap* heap) { ...@@ -1870,22 +1893,6 @@ EnumerateCompiledFunctions(Heap* heap) {
return compiled_funcs; return compiled_funcs;
} }
static std::vector<Handle<WasmModuleObject>> EnumerateWasmModuleObjects(
Heap* heap) {
HeapObjectIterator iterator(heap);
DisallowGarbageCollection no_gc;
std::vector<Handle<WasmModuleObject>> module_objects;
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
if (obj.IsWasmModuleObject()) {
WasmModuleObject module = WasmModuleObject::cast(obj);
module_objects.emplace_back(module, Isolate::FromHeap(heap));
}
}
return module_objects;
}
void Logger::LogCodeObjects() { existing_code_logger_.LogCodeObjects(); } void Logger::LogCodeObjects() { existing_code_logger_.LogCodeObjects(); }
void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared, void Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
...@@ -2041,9 +2048,11 @@ void Logger::SetCodeEventHandler(uint32_t options, ...@@ -2041,9 +2048,11 @@ void Logger::SetCodeEventHandler(uint32_t options,
} }
if (event_handler) { if (event_handler) {
#if V8_ENABLE_WEBASSEMBLY
if (isolate_->wasm_engine() != nullptr) { if (isolate_->wasm_engine() != nullptr) {
isolate_->wasm_engine()->EnableCodeLogging(isolate_); isolate_->wasm_engine()->EnableCodeLogging(isolate_);
} }
#endif // V8_ENABLE_WEBASSEMBLY
jit_logger_ = std::make_unique<JitLogger>(isolate_, event_handler); jit_logger_ = std::make_unique<JitLogger>(isolate_, event_handler);
AddCodeEventListener(jit_logger_.get()); AddCodeEventListener(jit_logger_.get());
if (options & kJitCodeEventEnumExisting) { if (options & kJitCodeEventEnumExisting) {
...@@ -2207,12 +2216,18 @@ void ExistingCodeLogger::LogCompiledFunctions() { ...@@ -2207,12 +2216,18 @@ void ExistingCodeLogger::LogCompiledFunctions() {
LogExistingFunction(pair.first, pair.second); LogExistingFunction(pair.first, pair.second);
} }
const std::vector<Handle<WasmModuleObject>> wasm_module_objects = #if V8_ENABLE_WEBASSEMBLY
EnumerateWasmModuleObjects(heap); HeapObjectIterator iterator(heap);
for (auto& module_object : wasm_module_objects) { DisallowGarbageCollection no_gc;
module_object->native_module()->LogWasmCodes(isolate_,
module_object->script()); for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
if (!obj.IsWasmModuleObject()) continue;
auto module_object = WasmModuleObject::cast(obj);
module_object.native_module()->LogWasmCodes(isolate_,
module_object.script());
} }
#endif // V8_ENABLE_WEBASSEMBLY
} }
void ExistingCodeLogger::LogExistingFunction( void ExistingCodeLogger::LogExistingFunction(
......
...@@ -195,9 +195,11 @@ class Logger : public CodeEventListener { ...@@ -195,9 +195,11 @@ class Logger : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code, void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) override; Handle<Name> script_name, int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override; int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
void CallbackEvent(Handle<Name> name, Address entry_point) override; void CallbackEvent(Handle<Name> name, Address entry_point) override;
void GetterCallbackEvent(Handle<Name> name, Address entry_point) override; void GetterCallbackEvent(Handle<Name> name, Address entry_point) override;
...@@ -396,9 +398,11 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener { ...@@ -396,9 +398,11 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code, void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) override; Handle<Name> script_name, int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override; int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
void RegExpCodeCreateEvent(Handle<AbstractCode> code, void RegExpCodeCreateEvent(Handle<AbstractCode> code,
Handle<String> source) override; Handle<String> source) override;
...@@ -423,8 +427,10 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener { ...@@ -423,8 +427,10 @@ class V8_EXPORT_PRIVATE CodeEventLogger : public CodeEventListener {
virtual void LogRecordedBuffer(Handle<AbstractCode> code, virtual void LogRecordedBuffer(Handle<AbstractCode> code,
MaybeHandle<SharedFunctionInfo> maybe_shared, MaybeHandle<SharedFunctionInfo> maybe_shared,
const char* name, int length) = 0; const char* name, int length) = 0;
#if V8_ENABLE_WEBASSEMBLY
virtual void LogRecordedBuffer(const wasm::WasmCode* code, const char* name, virtual void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) = 0; int length) = 0;
#endif // V8_ENABLE_WEBASSEMBLY
std::unique_ptr<NameBuffer> name_buffer_; std::unique_ptr<NameBuffer> name_buffer_;
}; };
...@@ -457,9 +463,11 @@ class ExternalCodeEventListener : public CodeEventListener { ...@@ -457,9 +463,11 @@ class ExternalCodeEventListener : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code, void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<Name> source, Handle<SharedFunctionInfo> shared, Handle<Name> source,
int line, int column) override; int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override; int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
void RegExpCodeCreateEvent(Handle<AbstractCode> code, void RegExpCodeCreateEvent(Handle<AbstractCode> code,
Handle<String> source) override; Handle<String> source) override;
......
...@@ -47,13 +47,17 @@ void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) { ...@@ -47,13 +47,17 @@ void ReportBuiltinEventRecord::UpdateCodeMap(CodeMap* code_map) {
CodeEntry* entry = code_map->FindEntry(instruction_start); CodeEntry* entry = code_map->FindEntry(instruction_start);
if (entry) { if (entry) {
entry->SetBuiltinId(builtin_id); entry->SetBuiltinId(builtin_id);
} else if (builtin_id == Builtins::kGenericJSToWasmWrapper) { return;
}
#if V8_ENABLE_WEBASSEMBLY
if (builtin_id == Builtins::kGenericJSToWasmWrapper) {
// Make sure to add the generic js-to-wasm wrapper builtin, because that // Make sure to add the generic js-to-wasm wrapper builtin, because that
// one is supposed to show up in profiles. // one is supposed to show up in profiles.
entry = new CodeEntry(CodeEventListener::BUILTIN_TAG, entry = new CodeEntry(CodeEventListener::BUILTIN_TAG,
Builtins::name(builtin_id)); Builtins::name(builtin_id));
code_map->AddCode(instruction_start, entry, instruction_size); code_map->AddCode(instruction_start, entry, instruction_size);
} }
#endif // V8_ENABLE_WEBASSEMBLY
} }
TickSample* SamplingEventsProcessor::StartTickSample() { TickSample* SamplingEventsProcessor::StartTickSample() {
......
...@@ -19,7 +19,10 @@ ...@@ -19,7 +19,10 @@
#include "src/profiler/cpu-profiler.h" #include "src/profiler/cpu-profiler.h"
#include "src/profiler/profile-generator-inl.h" #include "src/profiler/profile-generator-inl.h"
#include "src/utils/vector.h" #include "src/utils/vector.h"
#if V8_ENABLE_WEBASSEMBLY
#include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-code-manager.h"
#endif // V8_ENABLE_WEBASSEMBLY
namespace v8 { namespace v8 {
namespace internal { namespace internal {
...@@ -220,6 +223,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag, ...@@ -220,6 +223,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
DispatchCodeEvent(evt_rec); DispatchCodeEvent(evt_rec);
} }
#if V8_ENABLE_WEBASSEMBLY
void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag, void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
const wasm::WasmCode* code, const wasm::WasmCode* code,
wasm::WasmName name, wasm::WasmName name,
...@@ -240,6 +244,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag, ...@@ -240,6 +244,7 @@ void ProfilerListener::CodeCreateEvent(LogEventsAndTags tag,
rec->instruction_size = code->instructions().length(); rec->instruction_size = code->instructions().length();
DispatchCodeEvent(evt_rec); DispatchCodeEvent(evt_rec);
} }
#endif // V8_ENABLE_WEBASSEMBLY
void ProfilerListener::CallbackEvent(Handle<Name> name, Address entry_point) { void ProfilerListener::CallbackEvent(Handle<Name> name, Address entry_point) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION); CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
......
...@@ -43,9 +43,11 @@ class V8_EXPORT_PRIVATE ProfilerListener : public CodeEventListener { ...@@ -43,9 +43,11 @@ class V8_EXPORT_PRIVATE ProfilerListener : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code, void CodeCreateEvent(LogEventsAndTags tag, Handle<AbstractCode> code,
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) override; Handle<Name> script_name, int line, int column) override;
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) override; int code_offset, int script_id) override;
#endif // V8_ENABLE_WEBASSEMBLY
void CallbackEvent(Handle<Name> name, Address entry_point) override; void CallbackEvent(Handle<Name> name, Address entry_point) override;
void GetterCallbackEvent(Handle<Name> name, Address entry_point) override; void GetterCallbackEvent(Handle<Name> name, Address entry_point) override;
......
...@@ -1240,9 +1240,11 @@ RUNTIME_FUNCTION(Runtime_EnableCodeLoggingForTesting) { ...@@ -1240,9 +1240,11 @@ RUNTIME_FUNCTION(Runtime_EnableCodeLoggingForTesting) {
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared,
Handle<Name> script_name, int line, int column) final { Handle<Name> script_name, int line, int column) final {
} }
#if V8_ENABLE_WEBASSEMBLY
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code, void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name, const char* source_url, wasm::WasmName name, const char* source_url,
int code_offset, int script_id) final {} int code_offset, int script_id) final {}
#endif // V8_ENABLE_WEBASSEMBLY
void CallbackEvent(Handle<Name> name, Address entry_point) final {} void CallbackEvent(Handle<Name> name, Address entry_point) final {}
void GetterCallbackEvent(Handle<Name> name, Address entry_point) final {} void GetterCallbackEvent(Handle<Name> name, Address entry_point) final {}
......
...@@ -124,10 +124,12 @@ class CodeAddressMap : public CodeEventLogger { ...@@ -124,10 +124,12 @@ class CodeAddressMap : public CodeEventLogger {
address_to_name_map_.Insert(code->address(), name, length); address_to_name_map_.Insert(code->address(), name, length);
} }
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override { int length) override {
UNREACHABLE(); UNREACHABLE();
} }
#endif // V8_ENABLE_WEBASSEMBLY
NameMap address_to_name_map_; NameMap address_to_name_map_;
}; };
......
...@@ -268,9 +268,13 @@ void WasmCode::LogCode(Isolate* isolate, const char* source_url, ...@@ -268,9 +268,13 @@ void WasmCode::LogCode(Isolate* isolate, const char* source_url,
"wasm-function[%d]", index())); "wasm-function[%d]", index()));
name = VectorOf(name_buffer); name = VectorOf(name_buffer);
} }
// TODO(clemensb): Remove this #if once this compilation unit is excluded in
// no-wasm builds.
#if V8_ENABLE_WEBASSEMBLY
int code_offset = module->functions[index_].code.offset(); int code_offset = module->functions[index_].code.offset();
PROFILE(isolate, CodeCreateEvent(CodeEventListener::FUNCTION_TAG, this, name, PROFILE(isolate, CodeCreateEvent(CodeEventListener::FUNCTION_TAG, this, name,
source_url, code_offset, script_id)); source_url, code_offset, script_id));
#endif // V8_ENABLE_WEBASSEMBLY
if (!source_positions().empty()) { if (!source_positions().empty()) {
LOG_CODE_EVENT(isolate, CodeLinePosInfoRecordEvent(instruction_start(), LOG_CODE_EVENT(isolate, CodeLinePosInfoRecordEvent(instruction_start(),
......
...@@ -457,8 +457,10 @@ UNINITIALIZED_TEST(Issue539892) { ...@@ -457,8 +457,10 @@ UNINITIALIZED_TEST(Issue539892) {
void LogRecordedBuffer(i::Handle<i::AbstractCode> code, void LogRecordedBuffer(i::Handle<i::AbstractCode> code,
i::MaybeHandle<i::SharedFunctionInfo> maybe_shared, i::MaybeHandle<i::SharedFunctionInfo> maybe_shared,
const char* name, int length) override {} const char* name, int length) override {}
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const i::wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const i::wasm::WasmCode* code, const char* name,
int length) override {} int length) override {}
#endif // V8_ENABLE_WEBASSEMBLY
}; };
SETUP_FLAGS(); SETUP_FLAGS();
...@@ -1236,8 +1238,10 @@ TEST(BytecodeFlushEvents) { ...@@ -1236,8 +1238,10 @@ TEST(BytecodeFlushEvents) {
void LogRecordedBuffer(i::Handle<i::AbstractCode> code, void LogRecordedBuffer(i::Handle<i::AbstractCode> code,
i::MaybeHandle<i::SharedFunctionInfo> maybe_shared, i::MaybeHandle<i::SharedFunctionInfo> maybe_shared,
const char* name, int length) override {} const char* name, int length) override {}
#if V8_ENABLE_WEBASSEMBLY
void LogRecordedBuffer(const i::wasm::WasmCode* code, const char* name, void LogRecordedBuffer(const i::wasm::WasmCode* code, const char* name,
int length) override {} int length) override {}
#endif // V8_ENABLE_WEBASSEMBLY
i::Address flushed_compiled_data_start = i::kNullAddress; i::Address flushed_compiled_data_start = i::kNullAddress;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment