Revert "[wasm] Do not log code of functions whose module is not fully loaded"

This reverts commit 63e243a0c2.

Reason for revert: Speculative revert for https://ci.chromium.org/p/v8/builders/ci/V8%20Linux64%20TSAN/31811?

Original change's description:
> [wasm] Do not log code of functions whose module is not fully loaded
> 
> Under some circumstances, Wasm is trying to log code for which the
> wire bytes are not fully loaded yet. This can happen during streaming
> compilation when a few functions are already fully compiled but the
> engine is still streaming the remaining functions.
> 
> If the profiler now kicks in, it will attempt to log these freshly
> compiled functions. As these functions will not be executed before
> the module is fully compiled, we can simply defer the logging in this
> case.
> 
> R=​clemensb@chromium.org
> 
> Bug: chromium:1085852
> Change-Id: Idb1061cafcba7a2a654a207402dca520f79a3bbe
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2219938
> Reviewed-by: Clemens Backes <clemensb@chromium.org>
> Commit-Queue: Emanuel Ziegler <ecmziegler@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#68174}

TBR=clemensb@chromium.org,ecmziegler@chromium.org

Change-Id: I444c70e63b876b8473bf9599643bdfe39c8f1eae
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:1085852
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2230531
Reviewed-by: Nico Hartmann <nicohartmann@chromium.org>
Commit-Queue: Nico Hartmann <nicohartmann@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68177}
This commit is contained in:
Nico Hartmann 2020-06-04 13:44:26 +00:00 committed by Commit Bot
parent 4f3d7225b2
commit 1d9c4a1f16
2 changed files with 1 additions and 47 deletions

View File

@ -627,10 +627,7 @@ void BackgroundCompileToken::PublishCode(
NativeModule* native_module, Vector<std::unique_ptr<WasmCode>> code) {
WasmCodeRefScope code_ref_scope;
std::vector<WasmCode*> published_code = native_module->PublishCode(code);
// Defer logging code until wire bytes were fully received.
if (!native_module->wire_bytes().empty()) {
native_module->engine()->LogCode(VectorOf(published_code));
}
native_module->engine()->LogCode(VectorOf(published_code));
Impl(native_module->compilation_state())
->OnFinishedUnits(VectorOf(published_code));
@ -2415,7 +2412,6 @@ void AsyncStreamingProcessor::OnFinishedStream(OwnedVector<uint8_t> bytes) {
} else {
job_->native_module_->SetWireBytes(
{std::move(job_->bytes_copy_), job_->wire_bytes_.length()});
job_->native_module_->LogWasmCodes(job_->isolate_);
}
const bool needs_finish = job_->DecrementAndCheckFinisherCount();
DCHECK_IMPLIES(!has_code_section, needs_finish);

View File

@ -1254,48 +1254,6 @@ STREAM_TEST(TestSetModuleCodeSection) {
CHECK(tester.IsPromiseFulfilled());
}
// Test that profiler does not crash when module is only partly compiled.
STREAM_TEST(TestProfilingMidStreaming) {
StreamTester tester;
v8::Isolate* isolate = CcTest::isolate();
Isolate* i_isolate = CcTest::i_isolate();
Zone* zone = tester.zone();
// Build module with one exported (named) function.
ZoneBuffer buffer(zone);
{
TestSignatures sigs;
WasmModuleBuilder builder(zone);
WasmFunctionBuilder* f = builder.AddFunction(sigs.v_v());
uint8_t code[] = {kExprEnd};
f->EmitCode(code, arraysize(code));
builder.AddExport(VectorOf("foo", 3), f);
builder.WriteTo(&buffer);
}
// Start profiler to force code logging.
v8::CpuProfiler* cpu_profiler = v8::CpuProfiler::New(isolate);
v8::CpuProfilingOptions profile_options;
cpu_profiler->StartProfiling(v8::String::Empty(isolate), profile_options);
// Send incomplete wire bytes and start compilation.
tester.OnBytesReceived(buffer.begin(), buffer.end() - buffer.begin());
tester.RunCompilerTasks();
// Trigger code logging explicitly like the profiler would do.
CHECK(WasmCode::ShouldBeLogged(i_isolate));
i_isolate->wasm_engine()->LogOutstandingCodesForIsolate(i_isolate);
CHECK(tester.IsPromisePending());
// Finalize stream, stop profiler and clean up.
tester.FinishStream();
CHECK(tester.IsPromiseFulfilled());
v8::CpuProfile* profile =
cpu_profiler->StopProfiling(v8::String::Empty(isolate));
profile->Delete();
cpu_profiler->Dispose();
}
#undef STREAM_TEST
} // namespace wasm