Commit 3554c2ad authored by Georg Neis's avatar Georg Neis Committed by V8 LUCI CQ

Move DetachGlobal from Bootstrapper to Isolate

... as it has nothing to do with bootstrapping.

Change-Id: I364469b023b3f0811a674ea39aefd46313dd10fc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3164536Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76877}
parent defedd0c
...@@ -6387,7 +6387,7 @@ void Context::DetachGlobal() { ...@@ -6387,7 +6387,7 @@ void Context::DetachGlobal() {
i::Handle<i::Context> context = Utils::OpenHandle(this); i::Handle<i::Context> context = Utils::OpenHandle(this);
i::Isolate* isolate = context->GetIsolate(); i::Isolate* isolate = context->GetIsolate();
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate);
isolate->bootstrapper()->DetachGlobal(context); isolate->DetachGlobal(context);
} }
Local<v8::Object> Context::GetExtrasBindingObject() { Local<v8::Object> Context::GetExtrasBindingObject() {
......
...@@ -4727,6 +4727,24 @@ void Isolate::CheckDetachedContextsAfterGC() { ...@@ -4727,6 +4727,24 @@ void Isolate::CheckDetachedContextsAfterGC() {
} }
} }
void Isolate::DetachGlobal(Handle<Context> env) {
counters()->errors_thrown_per_context()->AddSample(
env->native_context().GetErrorsThrown());
ReadOnlyRoots roots(this);
Handle<JSGlobalProxy> global_proxy(env->global_proxy(), this);
global_proxy->set_native_context(roots.null_value());
// NOTE: Turbofan's JSNativeContextSpecialization depends on DetachGlobal
// causing a map change.
JSObject::ForceSetPrototype(this, global_proxy, factory()->null_value());
global_proxy->map().set_constructor_or_back_pointer(roots.null_value(),
kRelaxedStore);
if (FLAG_track_detached_contexts) AddDetachedContext(env);
DCHECK(global_proxy->IsDetached());
env->native_context().set_microtask_queue(this, nullptr);
}
double Isolate::LoadStartTimeMs() { double Isolate::LoadStartTimeMs() {
base::MutexGuard guard(&rail_mutex_); base::MutexGuard guard(&rail_mutex_);
return load_start_time_ms_; return load_start_time_ms_;
......
...@@ -1560,6 +1560,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory { ...@@ -1560,6 +1560,9 @@ class V8_EXPORT_PRIVATE Isolate final : private HiddenFactory {
void AddDetachedContext(Handle<Context> context); void AddDetachedContext(Handle<Context> context);
void CheckDetachedContextsAfterGC(); void CheckDetachedContextsAfterGC();
// Detach the environment from its outer global object.
void DetachGlobal(Handle<Context> env);
std::vector<Object>* startup_object_cache() { return &startup_object_cache_; } std::vector<Object>* startup_object_cache() { return &startup_object_cache_; }
bool IsGeneratingEmbeddedBuiltins() const { bool IsGeneratingEmbeddedBuiltins() const {
......
...@@ -357,27 +357,6 @@ void Bootstrapper::LogAllMaps() { ...@@ -357,27 +357,6 @@ void Bootstrapper::LogAllMaps() {
LOG(isolate_, LogAllMaps()); LOG(isolate_, LogAllMaps());
} }
void Bootstrapper::DetachGlobal(Handle<Context> env) {
isolate_->counters()->errors_thrown_per_context()->AddSample(
env->native_context().GetErrorsThrown());
ReadOnlyRoots roots(isolate_);
Handle<JSGlobalProxy> global_proxy(env->global_proxy(), isolate_);
global_proxy->set_native_context(roots.null_value());
// NOTE: Turbofan's JSNativeContextSpecialization depends on DetachGlobal
// causing a map change.
JSObject::ForceSetPrototype(isolate_, global_proxy,
isolate_->factory()->null_value());
global_proxy->map().set_constructor_or_back_pointer(roots.null_value(),
kRelaxedStore);
if (FLAG_track_detached_contexts) {
isolate_->AddDetachedContext(env);
}
DCHECK(global_proxy->IsDetached());
env->native_context().set_microtask_queue(isolate_, nullptr);
}
namespace { namespace {
#ifdef DEBUG #ifdef DEBUG
......
...@@ -80,9 +80,6 @@ class Bootstrapper final { ...@@ -80,9 +80,6 @@ class Bootstrapper final {
MaybeHandle<JSGlobalProxy> maybe_global_proxy, MaybeHandle<JSGlobalProxy> maybe_global_proxy,
v8::Local<v8::ObjectTemplate> global_object_template); v8::Local<v8::ObjectTemplate> global_object_template);
// Detach the environment from its outer global object.
void DetachGlobal(Handle<Context> env);
// Traverses the pointers for memory management. // Traverses the pointers for memory management.
void Iterate(RootVisitor* v); void Iterate(RootVisitor* v);
......
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