[wasm][gc] Check that no archived threads exist

Wasm code GC does not support visiting archived threads. Archived
threads are currently not used in combination with Wasm, so just check
for that at the moment and crash reliably and with a useful error
message once we hit that case.

R=mstarzinger@chromium.org

Bug: v8:8217
Change-Id: If6f870a0a445a1b2700e5c20cce392f1fb51ff3a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687672
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62508}
This commit is contained in:
Clemens Hammacher 2019-07-03 12:04:22 +02:00 committed by Commit Bot
parent 1250611b99
commit e937bc5ed6

View File

@ -8,6 +8,7 @@
#include "src/diagnostics/code-tracer.h"
#include "src/diagnostics/compilation-statistics.h"
#include "src/execution/frames.h"
#include "src/execution/v8threads.h"
#include "src/logging/counters.h"
#include "src/objects/heap-number.h"
#include "src/objects/js-promise.h"
@ -88,6 +89,18 @@ class LogCodesTask : public Task {
WasmEngine* const engine_;
};
void CheckNoArchivedThreads(Isolate* isolate) {
class ArchivedThreadsVisitor : public ThreadVisitor {
void VisitThread(Isolate* isolate, ThreadLocalTop* top) override {
// Archived threads are rarely used, and not combined with Wasm at the
// moment. Implement this and test it properly once we have a use case for
// that.
FATAL("archived threads in combination with wasm not supported");
}
} archived_threads_visitor;
isolate->thread_manager()->IterateArchivedThreads(&archived_threads_visitor);
}
class WasmGCForegroundTask : public Task {
public:
explicit WasmGCForegroundTask(Isolate* isolate) : isolate_(isolate) {
@ -114,6 +127,7 @@ class WasmGCForegroundTask : public Task {
DCHECK_NE(StackFrame::WASM_COMPILED, it.frame()->type());
}
#endif
CheckNoArchivedThreads(isolate_);
engine->ReportLiveCodeForGC(isolate_, Vector<WasmCode*>{});
// Cancel to signal to the destructor that this task executed.
Cancel();
@ -778,6 +792,8 @@ void WasmEngine::ReportLiveCodeFromStackForGC(Isolate* isolate) {
live_wasm_code.insert(WasmCompiledFrame::cast(frame)->wasm_code());
}
CheckNoArchivedThreads(isolate);
ReportLiveCodeForGC(isolate,
OwnedVector<WasmCode*>::Of(live_wasm_code).as_vector());
}