[ VM / Service ] Allow for system isolates to register service extensions

System isolates should be able to register service extensions with the
exception of a few special isolates:
  - Kernel isolate
  - Service isolate
  - VM isolate

Required to help resolve b/203694081

TEST=CQ

Change-Id: I1f11acd89132636039a817a5dfddb6189817a7fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222032
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This commit is contained in:
Ben Konyi 2021-12-08 22:09:08 +00:00 committed by Commit Bot
parent 5bff102009
commit bea5dfdb08
3 changed files with 11 additions and 4 deletions

View file

@ -3369,7 +3369,8 @@ void Isolate::AppendServiceExtensionCall(const Instance& closure,
// done atomically.
void Isolate::RegisterServiceExtensionHandler(const String& name,
const Instance& closure) {
if (Isolate::IsSystemIsolate(this)) {
// Don't allow for service extensions to be registered for internal isolates.
if (Isolate::IsVMInternalIsolate(this)) {
return;
}
GrowableObjectArray& handlers =
@ -3573,6 +3574,11 @@ bool IsolateGroup::IsSystemIsolateGroup(const IsolateGroup* group) {
return group->source()->flags.is_system_isolate;
}
bool Isolate::IsVMInternalIsolate(const Isolate* isolate) {
return isolate->is_kernel_isolate() || isolate->is_service_isolate() ||
(Dart::vm_isolate() == isolate);
}
void Isolate::KillLocked(LibMsgId msg_id) {
Dart_CObject kill_msg;
Dart_CObject* list_values[4];

View file

@ -1401,6 +1401,7 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
static bool IsSystemIsolate(const Isolate* isolate) {
return IsolateGroup::IsSystemIsolateGroup(isolate->group());
}
static bool IsVMInternalIsolate(const Isolate* isolate);
HandlerInfoCache* handler_info_cache() { return &handler_info_cache_; }

View file

@ -54,14 +54,14 @@ ServiceEvent::ServiceEvent(IsolateGroup* isolate_group,
// over the service.
ASSERT(isolate_ != Dart::vm_isolate());
// System isolates should never post service events. However, the Isolate
// VM internal isolates should never post service events. However, the Isolate
// service object uses a service event to represent the current running state
// of the isolate, so we need to allow for system isolates to create resume
// and none events for this purpose. The resume event represents a running
// isolate and the none event is returned for an isolate that has not yet
// been marked as runnable (see "pauseEvent" in Isolate::PrintJSON).
ASSERT(isolate == NULL || !Isolate::IsSystemIsolate(isolate) ||
(Isolate::IsSystemIsolate(isolate) &&
ASSERT(isolate == NULL || !Isolate::IsVMInternalIsolate(isolate) ||
(Isolate::IsVMInternalIsolate(isolate) &&
(event_kind == ServiceEvent::kResume ||
event_kind == ServiceEvent::kNone ||
// VM service can print Observatory information to Stdout or Stderr