Commit b4a9e93f authored by Andreas Haas's avatar Andreas Haas Committed by V8 LUCI CQ

Revert "[d8] quit() should not dispose the isolate"

This reverts commit 9981f2e5.

Reason for revert: This CL landed by accident, we decided back then to land a different CL.

Original change's description:
> [d8] quit() should not dispose the isolate
>
> R=​cbruni@chromium.org
>
> Bug: chromium:1338150
> Change-Id: I5e5f8ede942dd37112766812a3c84a356f0b6ca9
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3714355
> Reviewed-by: Camillo Bruni <cbruni@chromium.org>
> Commit-Queue: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#81827}

Bug: chromium:1338150
Change-Id: Ib058d90a0c09e7cc65bdecee20580dd9e1f184d9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3773776
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Auto-Submit: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81838}
parent d4a8b80b
......@@ -2769,7 +2769,18 @@ void Shell::QuitOnce(v8::FunctionCallbackInfo<v8::Value>* args) {
int exit_code = (*args)[0]
->Int32Value(args->GetIsolate()->GetCurrentContext())
.FromMaybe(0);
PrintCounters();
Isolate* isolate = args->GetIsolate();
isolate->Exit();
// As we exit the process anyway, we do not dispose the platform and other
// global data and manually unlock to quell DCHECKs. Other isolates might
// still be running, so disposing here can cause them to crash.
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
if (i_isolate->thread_manager()->IsLockedByCurrentThread()) {
i_isolate->thread_manager()->Unlock();
}
OnExit(isolate, false);
base::OS::ExitProcess(exit_code);
}
......@@ -3659,7 +3670,25 @@ void Shell::WriteLcovData(v8::Isolate* isolate, const char* file) {
}
}
void Shell::PrintCounters() {
void Shell::OnExit(v8::Isolate* isolate, bool dispose) {
isolate->Dispose();
if (shared_isolate) {
i::Isolate::Delete(reinterpret_cast<i::Isolate*>(shared_isolate));
}
// Simulate errors before disposing V8, as that resets flags (via
// FlagList::ResetAllFlags()), but error simulation reads the random seed.
if (options.simulate_errors && is_valid_fuzz_script()) {
// Simulate several errors detectable by fuzzers behind a flag if the
// minimum file size for fuzzing was executed.
FuzzerMonitor::SimulateErrors();
}
if (dispose) {
V8::Dispose();
V8::DisposePlatform();
}
if (options.dump_counters || options.dump_counters_nvp) {
base::SharedMutexGuard<base::kShared> mutex_guard(&counter_mutex_);
std::vector<std::pair<std::string, Counter*>> counters(
......@@ -3709,27 +3738,6 @@ void Shell::PrintCounters() {
<< std::string(kValueBoxSize, '-') << "+\n";
}
}
}
void Shell::OnExit(v8::Isolate* isolate, bool dispose) {
isolate->Dispose();
if (shared_isolate) {
i::Isolate::Delete(reinterpret_cast<i::Isolate*>(shared_isolate));
}
// Simulate errors before disposing V8, as that resets flags (via
// FlagList::ResetAllFlags()), but error simulation reads the random seed.
if (options.simulate_errors && is_valid_fuzz_script()) {
// Simulate several errors detectable by fuzzers behind a flag if the
// minimum file size for fuzzing was executed.
FuzzerMonitor::SimulateErrors();
}
if (dispose) {
V8::Dispose();
V8::DisposePlatform();
}
PrintCounters();
// Only delete the counters if we are done executing; after calling `quit`,
// other isolates might still be running and accessing that memory. This is a
......
......@@ -520,7 +520,6 @@ class Shell : public i::AllStatic {
static int RunMain(Isolate* isolate, bool last_run);
static int Main(int argc, char* argv[]);
static void Exit(int exit_code);
static void PrintCounters();
static void OnExit(Isolate* isolate, bool dispose);
static void CollectGarbage(Isolate* isolate);
static bool EmptyMessageQueues(Isolate* isolate);
......
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