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