Commit d529da01 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Introduce v8.wasm.detailed trace event category

This CL repurposes the v8.wasm trace event category, and introduces
additionally the v8.wasm.detailed category.

The v8.wasm category is enabled by default and captures core wasm events
like validation, compilation, instantiation, and important operations
like grow-memory and tier-up timings.

The v8.wasm.detailed category is disabled by default. It captures all
events the previous v8.wasm category captured, like compilation of
single functions, time needed for register allocation, ...

This CL splits these categories to allow enabling the v8.wasm category
in telemetry benchmarks to calculate compile time and other metrics
from traces of telemetry runs.

R=ecmziegler@chromium.org

Bug: chromium:1084929
Change-Id: Ida58b8f344b0ccb6ee1210e259c3e0e993eff497
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2210230
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Reviewed-by: 's avatarEmanuel Ziegler <ecmziegler@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68156}
parent b96855f1
...@@ -18,10 +18,10 @@ namespace compiler { ...@@ -18,10 +18,10 @@ namespace compiler {
namespace { namespace {
// We log detailed phase information about the pipeline // We log detailed phase information about the pipeline
// in both the v8.turbofan and the v8.wasm categories. // in both the v8.turbofan and the v8.wasm.detailed categories.
constexpr const char kTraceCategory[] = // -- constexpr const char kTraceCategory[] = // --
TRACE_DISABLED_BY_DEFAULT("v8.turbofan") "," // -- TRACE_DISABLED_BY_DEFAULT("v8.turbofan") "," // --
TRACE_DISABLED_BY_DEFAULT("v8.wasm"); TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed");
} // namespace } // namespace
......
...@@ -6530,8 +6530,8 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic( ...@@ -6530,8 +6530,8 @@ wasm::WasmCompilationResult CompileWasmMathIntrinsic(
const wasm::FunctionSig* sig) { const wasm::FunctionSig* sig) {
DCHECK_EQ(1, sig->return_count()); DCHECK_EQ(1, sig->return_count());
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"CompileWasmMathIntrinsic"); "wasm.CompileWasmMathIntrinsic");
Zone zone(wasm_engine->allocator(), ZONE_NAME); Zone zone(wasm_engine->allocator(), ZONE_NAME);
...@@ -6604,8 +6604,8 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper( ...@@ -6604,8 +6604,8 @@ wasm::WasmCompilationResult CompileWasmImportCallWrapper(
return CompileWasmMathIntrinsic(wasm_engine, kind, sig); return CompileWasmMathIntrinsic(wasm_engine, kind, sig);
} }
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"CompileWasmImportCallWrapper"); "wasm.CompileWasmImportCallWrapper");
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Create the Graph // Create the Graph
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
...@@ -6647,7 +6647,8 @@ wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine* wasm_engine, ...@@ -6647,7 +6647,8 @@ wasm::WasmCode* CompileWasmCapiCallWrapper(wasm::WasmEngine* wasm_engine,
wasm::NativeModule* native_module, wasm::NativeModule* native_module,
const wasm::FunctionSig* sig, const wasm::FunctionSig* sig,
Address address) { Address address) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "CompileWasmCapiFunction"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileWasmCapiFunction");
Zone zone(wasm_engine->allocator(), ZONE_NAME); Zone zone(wasm_engine->allocator(), ZONE_NAME);
...@@ -6858,9 +6859,9 @@ wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation( ...@@ -6858,9 +6859,9 @@ wasm::WasmCompilationResult ExecuteTurbofanWasmCompilation(
wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env, wasm::WasmEngine* wasm_engine, wasm::CompilationEnv* env,
const wasm::FunctionBody& func_body, int func_index, Counters* counters, const wasm::FunctionBody& func_body, int func_index, Counters* counters,
wasm::WasmFeatures* detected) { wasm::WasmFeatures* detected) {
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"ExecuteTurbofanCompilation", "func_index", func_index, "wasm.CompileTopTier", "func_index", func_index, "body_size",
"body_size", func_body.end - func_body.start); func_body.end - func_body.start);
Zone zone(wasm_engine->allocator(), ZONE_NAME); Zone zone(wasm_engine->allocator(), ZONE_NAME);
MachineGraph* mcgraph = new (&zone) MachineGraph( MachineGraph* mcgraph = new (&zone) MachineGraph(
new (&zone) Graph(&zone), new (&zone) CommonOperatorBuilder(&zone), new (&zone) Graph(&zone), new (&zone) CommonOperatorBuilder(&zone),
......
...@@ -272,8 +272,7 @@ Object StackGuard::HandleInterrupts() { ...@@ -272,8 +272,7 @@ Object StackGuard::HandleInterrupts() {
} }
if (TestAndClear(&interrupt_flags, GROW_SHARED_MEMORY)) { if (TestAndClear(&interrupt_flags, GROW_SHARED_MEMORY)) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0("v8.wasm", "V8.WasmGrowSharedMemory");
"V8.WasmGrowSharedMemory");
BackingStore::UpdateSharedWasmMemoryObjects(isolate_); BackingStore::UpdateSharedWasmMemoryObjects(isolate_);
} }
...@@ -297,12 +296,12 @@ Object StackGuard::HandleInterrupts() { ...@@ -297,12 +296,12 @@ Object StackGuard::HandleInterrupts() {
} }
if (TestAndClear(&interrupt_flags, LOG_WASM_CODE)) { if (TestAndClear(&interrupt_flags, LOG_WASM_CODE)) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "LogCode"); TRACE_EVENT0("v8.wasm", "V8.LogCode");
isolate_->wasm_engine()->LogOutstandingCodesForIsolate(isolate_); isolate_->wasm_engine()->LogOutstandingCodesForIsolate(isolate_);
} }
if (TestAndClear(&interrupt_flags, WASM_CODE_GC)) { if (TestAndClear(&interrupt_flags, WASM_CODE_GC)) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "WasmCodeGC"); TRACE_EVENT0("v8.wasm", "V8.WasmCodeGC");
isolate_->wasm_engine()->ReportLiveCodeFromStackForGC(isolate_); isolate_->wasm_engine()->ReportLiveCodeFromStackForGC(isolate_);
} }
......
...@@ -32,6 +32,7 @@ PERFETTO_DEFINE_CATEGORIES( ...@@ -32,6 +32,7 @@ PERFETTO_DEFINE_CATEGORIES(
perfetto::Category("v8.console"), perfetto::Category("v8.console"),
perfetto::Category("v8.execute"), perfetto::Category("v8.execute"),
perfetto::Category("v8.runtime"), perfetto::Category("v8.runtime"),
perfetto::Category("v8.wasm"),
perfetto::Category::Group("devtools.timeline,v8"), perfetto::Category::Group("devtools.timeline,v8"),
perfetto::Category::Group("devtools.timeline," perfetto::Category::Group("devtools.timeline,"
TRACE_DISABLED_BY_DEFAULT("v8.gc")), TRACE_DISABLED_BY_DEFAULT("v8.gc")),
...@@ -46,11 +47,11 @@ PERFETTO_DEFINE_CATEGORIES( ...@@ -46,11 +47,11 @@ PERFETTO_DEFINE_CATEGORIES(
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats")), perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats")),
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling")), perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.runtime_stats_sampling")),
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.turbofan")), perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.turbofan")),
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.wasm")), perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed")),
perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.zone_stats")), perfetto::Category(TRACE_DISABLED_BY_DEFAULT("v8.zone_stats")),
perfetto::Category::Group("v8,devtools.timeline"), perfetto::Category::Group("v8,devtools.timeline"),
perfetto::Category::Group(TRACE_DISABLED_BY_DEFAULT("v8.turbofan") "," perfetto::Category::Group(TRACE_DISABLED_BY_DEFAULT("v8.turbofan") ","
TRACE_DISABLED_BY_DEFAULT("v8.wasm"))); TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed")));
// clang-format on // clang-format on
#endif // defined(V8_USE_PERFETTO) #endif // defined(V8_USE_PERFETTO)
......
...@@ -3710,9 +3710,9 @@ WasmCompilationResult ExecuteLiftoffCompilation( ...@@ -3710,9 +3710,9 @@ WasmCompilationResult ExecuteLiftoffCompilation(
std::unique_ptr<DebugSideTable>* debug_sidetable, std::unique_ptr<DebugSideTable>* debug_sidetable,
Vector<int> extra_source_pos) { Vector<int> extra_source_pos) {
int func_body_size = static_cast<int>(func_body.end - func_body.start); int func_body_size = static_cast<int>(func_body.end - func_body.start);
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"ExecuteLiftoffCompilation", "func_index", func_index, "wasm.CompileBaseline", "func_index", func_index, "body_size",
"body_size", func_body_size); func_body_size);
Zone zone(allocator, "LiftoffCompilationZone"); Zone zone(allocator, "LiftoffCompilationZone");
auto call_descriptor = compiler::GetWasmCallDescriptor(&zone, func_body.sig); auto call_descriptor = compiler::GetWasmCallDescriptor(&zone, func_body.sig);
......
...@@ -278,7 +278,8 @@ JSToWasmWrapperCompilationUnit::JSToWasmWrapperCompilationUnit( ...@@ -278,7 +278,8 @@ JSToWasmWrapperCompilationUnit::JSToWasmWrapperCompilationUnit(
JSToWasmWrapperCompilationUnit::~JSToWasmWrapperCompilationUnit() = default; JSToWasmWrapperCompilationUnit::~JSToWasmWrapperCompilationUnit() = default;
void JSToWasmWrapperCompilationUnit::Execute() { void JSToWasmWrapperCompilationUnit::Execute() {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "CompileJSToWasmWrapper"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.CompileJSToWasmWrapper");
CompilationJob::Status status = job_->ExecuteJob(nullptr); CompilationJob::Status status = job_->ExecuteJob(nullptr);
CHECK_EQ(status, CompilationJob::SUCCEEDED); CHECK_EQ(status, CompilationJob::SUCCEEDED);
} }
......
...@@ -1047,7 +1047,7 @@ bool ExecuteCompilationUnits( ...@@ -1047,7 +1047,7 @@ bool ExecuteCompilationUnits(
const std::shared_ptr<BackgroundCompileToken>& token, Counters* counters, const std::shared_ptr<BackgroundCompileToken>& token, Counters* counters,
int task_id, CompileBaselineOnly baseline_only) { int task_id, CompileBaselineOnly baseline_only) {
TRACE_COMPILE("Compiling (task %d)...\n", task_id); TRACE_COMPILE("Compiling (task %d)...\n", task_id);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "ExecuteCompilationUnits"); TRACE_EVENT0("v8.wasm", "wasm.ExecuteCompilationUnits");
// Execute JS to Wasm wrapper units first, so that they are ready to be // Execute JS to Wasm wrapper units first, so that they are ready to be
// finalized by the main thread when the kFinishedBaselineCompilation event is // finalized by the main thread when the kFinishedBaselineCompilation event is
...@@ -1108,8 +1108,9 @@ bool ExecuteCompilationUnits( ...@@ -1108,8 +1108,9 @@ bool ExecuteCompilationUnits(
auto publish_results = [&results_to_publish]( auto publish_results = [&results_to_publish](
BackgroundCompileScope* compile_scope) { BackgroundCompileScope* compile_scope) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "PublishResults", TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"num_results", results_to_publish.size()); "wasm.PublishCompilationResults", "num_results",
results_to_publish.size());
if (results_to_publish.empty()) return; if (results_to_publish.empty()) return;
std::vector<std::unique_ptr<WasmCode>> unpublished_code = std::vector<std::unique_ptr<WasmCode>> unpublished_code =
compile_scope->native_module()->AddCompiledCode( compile_scope->native_module()->AddCompiledCode(
...@@ -1512,7 +1513,8 @@ AsyncCompileJob::AsyncCompileJob( ...@@ -1512,7 +1513,8 @@ AsyncCompileJob::AsyncCompileJob(
bytes_copy_(std::move(bytes_copy)), bytes_copy_(std::move(bytes_copy)),
wire_bytes_(bytes_copy_.get(), bytes_copy_.get() + length), wire_bytes_(bytes_copy_.get(), bytes_copy_.get() + length),
resolver_(std::move(resolver)) { resolver_(std::move(resolver)) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "new AsyncCompileJob"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.AsyncCompileJob");
CHECK(FLAG_wasm_async_compilation); CHECK(FLAG_wasm_async_compilation);
CHECK(!FLAG_jitless); CHECK(!FLAG_jitless);
v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); v8::Isolate* v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
...@@ -1660,8 +1662,8 @@ void AsyncCompileJob::PrepareRuntimeObjects() { ...@@ -1660,8 +1662,8 @@ void AsyncCompileJob::PrepareRuntimeObjects() {
// This function assumes that it is executed in a HandleScope, and that a // This function assumes that it is executed in a HandleScope, and that a
// context is set on the isolate. // context is set on the isolate.
void AsyncCompileJob::FinishCompile(bool is_after_cache_hit) { void AsyncCompileJob::FinishCompile(bool is_after_cache_hit) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"AsyncCompileJob::FinishCompile"); "wasm.FinishAsyncCompile");
bool is_after_deserialization = !module_object_.is_null(); bool is_after_deserialization = !module_object_.is_null();
auto compilation_state = Impl(native_module_->compilation_state()); auto compilation_state = Impl(native_module_->compilation_state());
if (!is_after_deserialization) { if (!is_after_deserialization) {
...@@ -1693,7 +1695,8 @@ void AsyncCompileJob::FinishCompile(bool is_after_cache_hit) { ...@@ -1693,7 +1695,8 @@ void AsyncCompileJob::FinishCompile(bool is_after_cache_hit) {
script->set_source_mapping_url(*src_map_str.ToHandleChecked()); script->set_source_mapping_url(*src_map_str.ToHandleChecked());
} }
{ {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "Debug::OnAfterCompile"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.Debug.OnAfterCompile");
isolate_->debug()->OnAfterCompile(script); isolate_->debug()->OnAfterCompile(script);
} }
...@@ -1740,8 +1743,8 @@ void AsyncCompileJob::AsyncCompileFailed() { ...@@ -1740,8 +1743,8 @@ void AsyncCompileJob::AsyncCompileFailed() {
} }
void AsyncCompileJob::AsyncCompileSucceeded(Handle<WasmModuleObject> result) { void AsyncCompileJob::AsyncCompileSucceeded(Handle<WasmModuleObject> result) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"CompilationResultResolver::OnCompilationSucceeded"); "wasm.OnCompilationSucceeded");
resolver_->OnCompilationSucceeded(result); resolver_->OnCompilationSucceeded(result);
} }
...@@ -1938,8 +1941,8 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep { ...@@ -1938,8 +1941,8 @@ class AsyncCompileJob::DecodeModule : public AsyncCompileJob::CompileStep {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
// Decode the module bytes. // Decode the module bytes.
TRACE_COMPILE("(1) Decoding module...\n"); TRACE_COMPILE("(1) Decoding module...\n");
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"AsyncCompileJob::DecodeModule"); "wasm.DecodeModule");
auto enabled_features = job->enabled_features_; auto enabled_features = job->enabled_features_;
result = DecodeWasmModule(enabled_features, job->wire_bytes_.start(), result = DecodeWasmModule(enabled_features, job->wire_bytes_.start(),
job->wire_bytes_.end(), false, kWasmOrigin, job->wire_bytes_.end(), false, kWasmOrigin,
...@@ -2446,6 +2449,7 @@ void AsyncStreamingProcessor::OnAbort() { ...@@ -2446,6 +2449,7 @@ void AsyncStreamingProcessor::OnAbort() {
bool AsyncStreamingProcessor::Deserialize(Vector<const uint8_t> module_bytes, bool AsyncStreamingProcessor::Deserialize(Vector<const uint8_t> module_bytes,
Vector<const uint8_t> wire_bytes) { Vector<const uint8_t> wire_bytes) {
TRACE_EVENT0("v8.wasm", "wasm.Deserialize");
// DeserializeNativeModule and FinishCompile assume that they are executed in // DeserializeNativeModule and FinishCompile assume that they are executed in
// a HandleScope, and that a context is set on the isolate. // a HandleScope, and that a context is set on the isolate.
HandleScope scope(job_->isolate_); HandleScope scope(job_->isolate_);
...@@ -2690,8 +2694,9 @@ void CompilationStateImpl::FinalizeJSToWasmWrappers( ...@@ -2690,8 +2694,9 @@ void CompilationStateImpl::FinalizeJSToWasmWrappers(
// TODO(6792): Wrappers below are allocated with {Factory::NewCode}. As an // TODO(6792): Wrappers below are allocated with {Factory::NewCode}. As an
// optimization we keep the code space unlocked to avoid repeated unlocking // optimization we keep the code space unlocked to avoid repeated unlocking
// because many such wrapper are allocated in sequence below. // because many such wrapper are allocated in sequence below.
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "FinalizeJSToWasmWrappers", TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"num_wrappers", js_to_wasm_wrapper_units_.size()); "wasm.FinalizeJSToWasmWrappers", "num_wrappers",
js_to_wasm_wrapper_units_.size());
CodeSpaceMemoryModificationScope modification_scope(isolate->heap()); CodeSpaceMemoryModificationScope modification_scope(isolate->heap());
for (auto& unit : js_to_wasm_wrapper_units_) { for (auto& unit : js_to_wasm_wrapper_units_) {
Handle<Code> code = unit->Finalize(isolate); Handle<Code> code = unit->Finalize(isolate);
...@@ -2709,8 +2714,8 @@ CompilationStateImpl::GetNextCompilationUnit( ...@@ -2709,8 +2714,8 @@ CompilationStateImpl::GetNextCompilationUnit(
} }
void CompilationStateImpl::OnFinishedUnits(Vector<WasmCode*> code_vector) { void CompilationStateImpl::OnFinishedUnits(Vector<WasmCode*> code_vector) {
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "OnFinishedUnits", TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"num_units", code_vector.size()); "wasm.OnFinishedUnits", "num_units", code_vector.size());
base::MutexGuard guard(&callbacks_mutex_); base::MutexGuard guard(&callbacks_mutex_);
...@@ -2833,13 +2838,13 @@ void CompilationStateImpl::TriggerCallbacks( ...@@ -2833,13 +2838,13 @@ void CompilationStateImpl::TriggerCallbacks(
for (auto event : for (auto event :
{std::make_pair(CompilationEvent::kFinishedBaselineCompilation, {std::make_pair(CompilationEvent::kFinishedBaselineCompilation,
"BaselineFinished"), "wasm.BaselineFinished"),
std::make_pair(CompilationEvent::kFinishedTopTierCompilation, std::make_pair(CompilationEvent::kFinishedTopTierCompilation,
"TopTierFinished"), "wasm.TopTierFinished"),
std::make_pair(CompilationEvent::kFinishedRecompilation, std::make_pair(CompilationEvent::kFinishedRecompilation,
"RecompilationFinished")}) { "wasm.RecompilationFinished")}) {
if (!triggered_events.contains(event.first)) continue; if (!triggered_events.contains(event.first)) continue;
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), event.second); TRACE_EVENT0("v8.wasm", event.second);
for (auto& callback : callbacks_) { for (auto& callback : callbacks_) {
callback(event.first); callback(event.first);
} }
......
...@@ -304,7 +304,8 @@ InstanceBuilder::InstanceBuilder(Isolate* isolate, ErrorThrower* thrower, ...@@ -304,7 +304,8 @@ InstanceBuilder::InstanceBuilder(Isolate* isolate, ErrorThrower* thrower,
// Build an instance, in all of its glory. // Build an instance, in all of its glory.
MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "InstanceBuilder::Build"); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"wasm.InstanceBuilder.Build");
// Check that an imports argument was provided, if the module requires it. // Check that an imports argument was provided, if the module requires it.
// No point in continuing otherwise. // No point in continuing otherwise.
if (!module_->import_table.empty() && ffi_.is_null()) { if (!module_->import_table.empty() && ffi_.is_null()) {
...@@ -616,8 +617,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() { ...@@ -616,8 +617,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
} }
bool InstanceBuilder::ExecuteStartFunction() { bool InstanceBuilder::ExecuteStartFunction() {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm.detailed"),
"InstanceBuilder::ExecuteStartFunction"); "wasm.ExecuteStartFunction");
if (start_function_.is_null()) return true; // No start function. if (start_function_.is_null()) return true; // No start function.
HandleScope scope(isolate_); HandleScope scope(isolate_);
......
...@@ -409,6 +409,7 @@ WasmEngine::~WasmEngine() { ...@@ -409,6 +409,7 @@ WasmEngine::~WasmEngine() {
bool WasmEngine::SyncValidate(Isolate* isolate, const WasmFeatures& enabled, bool WasmEngine::SyncValidate(Isolate* isolate, const WasmFeatures& enabled,
const ModuleWireBytes& bytes) { const ModuleWireBytes& bytes) {
TRACE_EVENT0("v8.wasm", "wasm.SyncValidate");
// TODO(titzer): remove dependency on the isolate. // TODO(titzer): remove dependency on the isolate.
if (bytes.start() == nullptr || bytes.length() == 0) return false; if (bytes.start() == nullptr || bytes.length() == 0) return false;
ModuleResult result = ModuleResult result =
...@@ -421,6 +422,7 @@ MaybeHandle<AsmWasmData> WasmEngine::SyncCompileTranslatedAsmJs( ...@@ -421,6 +422,7 @@ MaybeHandle<AsmWasmData> WasmEngine::SyncCompileTranslatedAsmJs(
Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes, Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes,
Vector<const byte> asm_js_offset_table_bytes, Vector<const byte> asm_js_offset_table_bytes,
Handle<HeapNumber> uses_bitset, LanguageMode language_mode) { Handle<HeapNumber> uses_bitset, LanguageMode language_mode) {
TRACE_EVENT0("v8.wasm", "wasm.SyncCompileTranslatedAsmJs");
ModuleOrigin origin = language_mode == LanguageMode::kSloppy ModuleOrigin origin = language_mode == LanguageMode::kSloppy
? kAsmJsSloppyOrigin ? kAsmJsSloppyOrigin
: kAsmJsStrictOrigin; : kAsmJsStrictOrigin;
...@@ -464,6 +466,7 @@ Handle<WasmModuleObject> WasmEngine::FinalizeTranslatedAsmJs( ...@@ -464,6 +466,7 @@ Handle<WasmModuleObject> WasmEngine::FinalizeTranslatedAsmJs(
MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile( MaybeHandle<WasmModuleObject> WasmEngine::SyncCompile(
Isolate* isolate, const WasmFeatures& enabled, ErrorThrower* thrower, Isolate* isolate, const WasmFeatures& enabled, ErrorThrower* thrower,
const ModuleWireBytes& bytes) { const ModuleWireBytes& bytes) {
TRACE_EVENT0("v8.wasm", "wasm.SyncCompile");
ModuleResult result = ModuleResult result =
DecodeWasmModule(enabled, bytes.start(), bytes.end(), false, kWasmOrigin, DecodeWasmModule(enabled, bytes.start(), bytes.end(), false, kWasmOrigin,
isolate->counters(), allocator()); isolate->counters(), allocator());
...@@ -509,6 +512,7 @@ MaybeHandle<WasmInstanceObject> WasmEngine::SyncInstantiate( ...@@ -509,6 +512,7 @@ MaybeHandle<WasmInstanceObject> WasmEngine::SyncInstantiate(
Isolate* isolate, ErrorThrower* thrower, Isolate* isolate, ErrorThrower* thrower,
Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports, Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports,
MaybeHandle<JSArrayBuffer> memory) { MaybeHandle<JSArrayBuffer> memory) {
TRACE_EVENT0("v8.wasm", "wasm.SyncInstantiate");
return InstantiateToInstanceObject(isolate, thrower, module_object, imports, return InstantiateToInstanceObject(isolate, thrower, module_object, imports,
memory); memory);
} }
...@@ -517,6 +521,7 @@ void WasmEngine::AsyncInstantiate( ...@@ -517,6 +521,7 @@ void WasmEngine::AsyncInstantiate(
Isolate* isolate, std::unique_ptr<InstantiationResultResolver> resolver, Isolate* isolate, std::unique_ptr<InstantiationResultResolver> resolver,
Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports) { Handle<WasmModuleObject> module_object, MaybeHandle<JSReceiver> imports) {
ErrorThrower thrower(isolate, "WebAssembly.instantiate()"); ErrorThrower thrower(isolate, "WebAssembly.instantiate()");
TRACE_EVENT0("v8.wasm", "wasm.AsyncInstantiate");
// Instantiate a TryCatch so that caught exceptions won't progagate out. // Instantiate a TryCatch so that caught exceptions won't progagate out.
// They will still be set as pending exceptions on the isolate. // They will still be set as pending exceptions on the isolate.
// TODO(clemensb): Avoid TryCatch, use Execution::TryCall internally to invoke // TODO(clemensb): Avoid TryCatch, use Execution::TryCall internally to invoke
...@@ -552,6 +557,7 @@ void WasmEngine::AsyncCompile( ...@@ -552,6 +557,7 @@ void WasmEngine::AsyncCompile(
std::shared_ptr<CompilationResultResolver> resolver, std::shared_ptr<CompilationResultResolver> resolver,
const ModuleWireBytes& bytes, bool is_shared, const ModuleWireBytes& bytes, bool is_shared,
const char* api_method_name_for_errors) { const char* api_method_name_for_errors) {
TRACE_EVENT0("v8.wasm", "wasm.AsyncCompile");
if (!FLAG_wasm_async_compilation) { if (!FLAG_wasm_async_compilation) {
// Asynchronous compilation disabled; fall back on synchronous compilation. // Asynchronous compilation disabled; fall back on synchronous compilation.
ErrorThrower thrower(isolate, api_method_name_for_errors); ErrorThrower thrower(isolate, api_method_name_for_errors);
...@@ -600,6 +606,7 @@ std::shared_ptr<StreamingDecoder> WasmEngine::StartStreamingCompilation( ...@@ -600,6 +606,7 @@ std::shared_ptr<StreamingDecoder> WasmEngine::StartStreamingCompilation(
Isolate* isolate, const WasmFeatures& enabled, Handle<Context> context, Isolate* isolate, const WasmFeatures& enabled, Handle<Context> context,
const char* api_method_name, const char* api_method_name,
std::shared_ptr<CompilationResultResolver> resolver) { std::shared_ptr<CompilationResultResolver> resolver) {
TRACE_EVENT0("v8.wasm", "wasm.StartStreamingCompilation");
if (FLAG_wasm_async_compilation) { if (FLAG_wasm_async_compilation) {
AsyncCompileJob* job = CreateAsyncCompileJob( AsyncCompileJob* job = CreateAsyncCompileJob(
isolate, enabled, std::unique_ptr<byte[]>(nullptr), 0, context, isolate, enabled, std::unique_ptr<byte[]>(nullptr), 0, context,
...@@ -1170,7 +1177,7 @@ void WasmEngine::SampleTopTierCodeSizeInAllIsolates( ...@@ -1170,7 +1177,7 @@ void WasmEngine::SampleTopTierCodeSizeInAllIsolates(
void WasmEngine::ReportLiveCodeForGC(Isolate* isolate, void WasmEngine::ReportLiveCodeForGC(Isolate* isolate,
Vector<WasmCode*> live_code) { Vector<WasmCode*> live_code) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "ReportLiveCodeForGC"); TRACE_EVENT0("v8.wasm", "wasm.ReportLiveCodeForGC");
TRACE_CODE_GC("Isolate %d reporting %zu live code objects.\n", isolate->id(), TRACE_CODE_GC("Isolate %d reporting %zu live code objects.\n", isolate->id(),
live_code.size()); live_code.size());
base::MutexGuard guard(&mutex_); base::MutexGuard guard(&mutex_);
...@@ -1243,7 +1250,7 @@ void WasmEngine::FreeDeadCode(const DeadCodeMap& dead_code) { ...@@ -1243,7 +1250,7 @@ void WasmEngine::FreeDeadCode(const DeadCodeMap& dead_code) {
} }
void WasmEngine::FreeDeadCodeLocked(const DeadCodeMap& dead_code) { void WasmEngine::FreeDeadCodeLocked(const DeadCodeMap& dead_code) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "FreeDeadCode"); TRACE_EVENT0("v8.wasm", "wasm.FreeDeadCode");
DCHECK(!mutex_.TryLock()); DCHECK(!mutex_.TryLock());
for (auto& dead_code_entry : dead_code) { for (auto& dead_code_entry : dead_code) {
NativeModule* native_module = dead_code_entry.first; NativeModule* native_module = dead_code_entry.first;
......
...@@ -93,37 +93,48 @@ class WasmStreaming::WasmStreamingImpl { ...@@ -93,37 +93,48 @@ class WasmStreaming::WasmStreamingImpl {
}; };
WasmStreaming::WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl) WasmStreaming::WasmStreaming(std::unique_ptr<WasmStreamingImpl> impl)
: impl_(std::move(impl)) {} : impl_(std::move(impl)) {
TRACE_EVENT0("v8.wasm", "wasm.InitializeStreaming");
}
// The destructor is defined here because we have a unique_ptr with forward // The destructor is defined here because we have a unique_ptr with forward
// declaration. // declaration.
WasmStreaming::~WasmStreaming() = default; WasmStreaming::~WasmStreaming() = default;
void WasmStreaming::OnBytesReceived(const uint8_t* bytes, size_t size) { void WasmStreaming::OnBytesReceived(const uint8_t* bytes, size_t size) {
TRACE_EVENT1("v8.wasm", "wasm.OnBytesReceived", "num_bytes", size);
impl_->OnBytesReceived(bytes, size); impl_->OnBytesReceived(bytes, size);
} }
void WasmStreaming::Finish() { impl_->Finish(); } void WasmStreaming::Finish() {
TRACE_EVENT0("v8.wasm", "wasm.FinishStreaming");
impl_->Finish();
}
void WasmStreaming::Abort(MaybeLocal<Value> exception) { void WasmStreaming::Abort(MaybeLocal<Value> exception) {
TRACE_EVENT0("v8.wasm", "wasm.AbortStreaming");
impl_->Abort(exception); impl_->Abort(exception);
} }
bool WasmStreaming::SetCompiledModuleBytes(const uint8_t* bytes, size_t size) { bool WasmStreaming::SetCompiledModuleBytes(const uint8_t* bytes, size_t size) {
TRACE_EVENT0("v8.wasm", "wasm.SetCompiledModuleBytes");
return impl_->SetCompiledModuleBytes(bytes, size); return impl_->SetCompiledModuleBytes(bytes, size);
} }
void WasmStreaming::SetClient(std::shared_ptr<Client> client) { void WasmStreaming::SetClient(std::shared_ptr<Client> client) {
TRACE_EVENT0("v8.wasm", "wasm.WasmStreaming.SetClient");
impl_->SetClient(client); impl_->SetClient(client);
} }
void WasmStreaming::SetUrl(const char* url, size_t length) { void WasmStreaming::SetUrl(const char* url, size_t length) {
TRACE_EVENT0("v8.wasm", "wasm.SetUrl");
impl_->SetUrl(internal::VectorOf(url, length)); impl_->SetUrl(internal::VectorOf(url, length));
} }
// static // static
std::shared_ptr<WasmStreaming> WasmStreaming::Unpack(Isolate* isolate, std::shared_ptr<WasmStreaming> WasmStreaming::Unpack(Isolate* isolate,
Local<Value> value) { Local<Value> value) {
TRACE_EVENT0("v8.wasm", "wasm.WasmStreaming.Unpack");
i::HandleScope scope(reinterpret_cast<i::Isolate*>(isolate)); i::HandleScope scope(reinterpret_cast<i::Isolate*>(isolate));
auto managed = auto managed =
i::Handle<i::Managed<WasmStreaming>>::cast(Utils::OpenHandle(*value)); i::Handle<i::Managed<WasmStreaming>>::cast(Utils::OpenHandle(*value));
......
...@@ -856,7 +856,7 @@ void WasmMemoryObject::update_instances(Isolate* isolate, ...@@ -856,7 +856,7 @@ void WasmMemoryObject::update_instances(Isolate* isolate,
int32_t WasmMemoryObject::Grow(Isolate* isolate, int32_t WasmMemoryObject::Grow(Isolate* isolate,
Handle<WasmMemoryObject> memory_object, Handle<WasmMemoryObject> memory_object,
uint32_t pages) { uint32_t pages) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.wasm"), "GrowMemory"); TRACE_EVENT0("v8.wasm", "wasm.GrowMemory");
Handle<JSArrayBuffer> old_buffer(memory_object->array_buffer(), isolate); Handle<JSArrayBuffer> old_buffer(memory_object->array_buffer(), isolate);
// Any buffer used as an asmjs memory cannot be detached, and // Any buffer used as an asmjs memory cannot be detached, and
// therefore this memory cannot be grown. // therefore this memory cannot be grown.
......
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