Commit d7b20edc authored by Emanuel Ziegler's avatar Emanuel Ziegler Committed by Commit Bot

[wasm][ukm] Add tests for Wasm events

Ensure that events are triggered when a module is decoded, compiled,
instantiated and tiered-up.

R=clemensb@chromium.org

Bug: chromium:1092417

Change-Id: I9dc87957fc03023c5ab1c4f49e865957c8324e1a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2351676
Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69508}
parent c6fb303f
......@@ -2475,6 +2475,7 @@ void AsyncStreamingProcessor::OnFinishedChunk() {
void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) {
TRACE_STREAMING("Finish stream...\n");
DCHECK_EQ(NativeModuleCache::PrefixHash(bytes.as_vector()), prefix_hash_);
decoder_.SetModuleWireBytes(bytes.begin(), bytes.end());
ModuleResult result = decoder_.FinishDecoding(false);
if (result.failed()) {
FinishAsyncCompileJobWithError(result.error());
......
......@@ -295,6 +295,8 @@ class ModuleDecoderImpl : public Decoder {
explicit ModuleDecoderImpl(const WasmFeatures& enabled, ModuleOrigin origin)
: Decoder(nullptr, nullptr),
enabled_features_(enabled),
module_start_(nullptr),
module_end_(nullptr),
origin_(FLAG_assume_asmjs_origin ? kAsmJsSloppyOrigin : origin) {}
ModuleDecoderImpl(const WasmFeatures& enabled, const byte* module_start,
......@@ -306,6 +308,13 @@ class ModuleDecoderImpl : public Decoder {
error(start_, "end is less than start");
end_ = start_;
}
SetModuleWireBytes(module_start, module_end);
}
void SetModuleWireBytes(const byte* module_start, const byte* module_end) {
DCHECK_NOT_NULL(module_start);
DCHECK_NOT_NULL(module_end);
DCHECK_GE(module_end, module_start);
module_start_ = module_start;
module_end_ = module_end;
}
......@@ -1214,7 +1223,7 @@ class ModuleDecoderImpl : public Decoder {
if (metrics_) {
metrics_->success = ok() && !intermediate_error_.has_error();
metrics_->module_size_in_bytes = end() - start();
metrics_->module_size_in_bytes = module_end_ - module_start_;
metrics_->function_count = module_->num_declared_functions;
metrics_.reset();
}
......@@ -2219,6 +2228,11 @@ const std::shared_ptr<WasmModule>& ModuleDecoder::shared_module() const {
return impl_->shared_module();
}
void ModuleDecoder::SetModuleWireBytes(const byte* module_start,
const byte* module_end) {
impl_->SetModuleWireBytes(module_start, module_end);
}
void ModuleDecoder::StartDecoding(
Counters* counters, std::shared_ptr<metrics::Recorder> metrics_recorder,
v8::metrics::Recorder::ContextId context_id, AccountingAllocator* allocator,
......
......@@ -199,6 +199,8 @@ class ModuleDecoder {
explicit ModuleDecoder(const WasmFeatures& enabled);
~ModuleDecoder();
void SetModuleWireBytes(const byte* module_start, const byte* module_end);
void StartDecoding(Counters* counters,
std::shared_ptr<metrics::Recorder> metrics_recorder,
v8::metrics::Recorder::ContextId context_id,
......
......@@ -676,7 +676,7 @@ Vector<byte> WasmCodeAllocator::AllocateForCodeInRegion(
}
DCHECK(IsAligned(code_space.begin(), kCodeAlignment));
allocated_code_space_.Merge(code_space);
generated_code_size_.fetch_add(code_space.size(), std::memory_order_relaxed);
generated_code_size_.fetch_add(code_space.size(), std::memory_order_release);
TRACE_HEAP("Code alloc for %p: 0x%" PRIxPTR ",+%zu\n", this,
code_space.begin(), size);
......
......@@ -304,6 +304,7 @@ v8_source_set("cctest_sources") {
"wasm/test-wasm-debug-evaluate.cc",
"wasm/test-wasm-debug-evaluate.h",
"wasm/test-wasm-import-wrapper-cache.cc",
"wasm/test-wasm-metrics.cc",
"wasm/test-wasm-serialization.cc",
"wasm/test-wasm-shared-engine.cc",
"wasm/test-wasm-stack.cc",
......
......@@ -508,6 +508,7 @@
'test-wasm-codegen/*': [SKIP],
'test-wasm-debug-evaluate/*': [SKIP],
'test-wasm-import-wrapper-cache/*': [SKIP],
'test-wasm-metrics/*': [SKIP],
'test-wasm-serialization/*': [SKIP],
'test-wasm-shared-engine/*': [SKIP],
'test-wasm-stack/*': [SKIP],
......
This diff is collapsed.
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