[ Service ] Add 'is_system_isolate' option to Dart_IsolateFlags

Provides a general way to designate an isolate as a 'system isolate'
(formerly known as 'VM internal isolates').

Initial fix for https://github.com/dart-lang/sdk/issues/42875

Change-Id: I8798a3a1c51df1db8008d602f6303df13c958cba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158063
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ben Konyi
2020-08-21 21:44:50 +00:00
committed by commit-bot@chromium.org
parent 6fb1e57f3a
commit e44c0b2264
34 changed files with 472 additions and 237 deletions
+5
View File
@@ -1,5 +1,10 @@
# Changelog
## Unreleased
- Added `isSystemIsolate` property to `IsolateRef` and `Isolate`.
- Added `isSystemIsolateGroup` property to `IsolateGroupRef` and `IsolateGroup`.
- Added `serviceIsolates` and `serviceIsolateGroups` properties to `VM`.
## 4.2.0
- Update to version `3.37.0` of the spec.
- Added `getProcessMemoryUsage` RPC and `ProcessMemoryUsage` and `ProcessMemoryItem` objects.
@@ -656,6 +656,7 @@ vms.IsolateRef assertIsolateRef(vms.IsolateRef obj) {
assertString(obj.id);
assertString(obj.number);
assertString(obj.name);
assertBool(obj.isSystemIsolate);
return obj;
}
@@ -672,6 +673,7 @@ vms.Isolate assertIsolate(vms.Isolate obj) {
assertString(obj.id);
assertString(obj.number);
assertString(obj.name);
assertBool(obj.isSystemIsolate);
assertInt(obj.startTime);
assertBool(obj.runnable);
assertInt(obj.livePorts);
@@ -689,6 +691,7 @@ vms.IsolateGroupRef assertIsolateGroupRef(vms.IsolateGroupRef obj) {
assertString(obj.id);
assertString(obj.number);
assertString(obj.name);
assertBool(obj.isSystemIsolateGroup);
return obj;
}
@@ -706,6 +709,7 @@ vms.IsolateGroup assertIsolateGroup(vms.IsolateGroup obj) {
assertString(obj.id);
assertString(obj.number);
assertString(obj.name);
assertBool(obj.isSystemIsolateGroup);
assertListOfIsolateRef(obj.isolates);
return obj;
}
@@ -1193,6 +1197,8 @@ vms.VM assertVM(vms.VM obj) {
assertInt(obj.startTime);
assertListOfIsolateRef(obj.isolates);
assertListOfIsolateGroupRef(obj.isolateGroups);
assertListOfIsolateRef(obj.systemIsolates);
assertListOfIsolateGroupRef(obj.systemIsolateGroups);
return obj;
}
+1 -1
View File
@@ -1 +1 @@
version=3.37
version=3.38
+53 -6
View File
@@ -28,7 +28,7 @@ export 'snapshot_graph.dart'
HeapSnapshotObjectNoData,
HeapSnapshotObjectNullData;
const String vmServiceVersion = '3.37.0';
const String vmServiceVersion = '3.38.0';
/// @optional
const String optional = 'optional';
@@ -4804,16 +4804,22 @@ class IsolateRef extends Response {
/// A name identifying this isolate. Not guaranteed to be unique.
String name;
/// Specifies whether the isolate was spawned by the VM or embedder for
/// internal use. If `false`, this isolate is likely running user code.
bool isSystemIsolate;
IsolateRef({
@required this.id,
@required this.number,
@required this.name,
@required this.isSystemIsolate,
});
IsolateRef._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
id = json['id'];
number = json['number'];
name = json['name'];
isSystemIsolate = json['isSystemIsolate'];
}
@override
@@ -4824,6 +4830,7 @@ class IsolateRef extends Response {
'id': id,
'number': number,
'name': name,
'isSystemIsolate': isSystemIsolate,
});
return json;
}
@@ -4832,8 +4839,9 @@ class IsolateRef extends Response {
operator ==(other) => other is IsolateRef && id == other.id;
String toString() =>
'[IsolateRef type: ${type}, id: ${id}, number: ${number}, name: ${name}]';
String toString() => '[IsolateRef ' //
'type: ${type}, id: ${id}, number: ${number}, name: ${name}, ' //
'isSystemIsolate: ${isSystemIsolate}]';
}
/// An `Isolate` object provides information about one isolate in the VM.
@@ -4850,6 +4858,10 @@ class Isolate extends Response implements IsolateRef {
/// A name identifying this isolate. Not guaranteed to be unique.
String name;
/// Specifies whether the isolate was spawned by the VM or embedder for
/// internal use. If `false`, this isolate is likely running user code.
bool isSystemIsolate;
/// The time that the VM started in milliseconds since the epoch.
///
/// Suitable to pass to DateTime.fromMillisecondsSinceEpoch.
@@ -4898,6 +4910,7 @@ class Isolate extends Response implements IsolateRef {
@required this.id,
@required this.number,
@required this.name,
@required this.isSystemIsolate,
@required this.startTime,
@required this.runnable,
@required this.livePorts,
@@ -4915,6 +4928,7 @@ class Isolate extends Response implements IsolateRef {
id = json['id'];
number = json['number'];
name = json['name'];
isSystemIsolate = json['isSystemIsolate'];
startTime = json['startTime'];
runnable = json['runnable'];
livePorts = json['livePorts'];
@@ -4940,6 +4954,7 @@ class Isolate extends Response implements IsolateRef {
'id': id,
'number': number,
'name': name,
'isSystemIsolate': isSystemIsolate,
'startTime': startTime,
'runnable': runnable,
'livePorts': livePorts,
@@ -4978,16 +4993,22 @@ class IsolateGroupRef extends Response {
/// A name identifying this isolate group. Not guaranteed to be unique.
String name;
/// Specifies whether the isolate group was spawned by the VM or embedder for
/// internal use. If `false`, this isolate group is likely running user code.
bool isSystemIsolateGroup;
IsolateGroupRef({
@required this.id,
@required this.number,
@required this.name,
@required this.isSystemIsolateGroup,
});
IsolateGroupRef._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
id = json['id'];
number = json['number'];
name = json['name'];
isSystemIsolateGroup = json['isSystemIsolateGroup'];
}
@override
@@ -4998,6 +5019,7 @@ class IsolateGroupRef extends Response {
'id': id,
'number': number,
'name': name,
'isSystemIsolateGroup': isSystemIsolateGroup,
});
return json;
}
@@ -5006,8 +5028,9 @@ class IsolateGroupRef extends Response {
operator ==(other) => other is IsolateGroupRef && id == other.id;
String toString() =>
'[IsolateGroupRef type: ${type}, id: ${id}, number: ${number}, name: ${name}]';
String toString() => '[IsolateGroupRef ' //
'type: ${type}, id: ${id}, number: ${number}, name: ${name}, ' //
'isSystemIsolateGroup: ${isSystemIsolateGroup}]';
}
/// An `Isolate` object provides information about one isolate in the VM.
@@ -5024,6 +5047,10 @@ class IsolateGroup extends Response implements IsolateGroupRef {
/// A name identifying this isolate. Not guaranteed to be unique.
String name;
/// Specifies whether the isolate group was spawned by the VM or embedder for
/// internal use. If `false`, this isolate group is likely running user code.
bool isSystemIsolateGroup;
/// A list of all isolates in this isolate group.
List<IsolateRef> isolates;
@@ -5031,6 +5058,7 @@ class IsolateGroup extends Response implements IsolateGroupRef {
@required this.id,
@required this.number,
@required this.name,
@required this.isSystemIsolateGroup,
@required this.isolates,
});
@@ -5038,6 +5066,7 @@ class IsolateGroup extends Response implements IsolateGroupRef {
id = json['id'];
number = json['number'];
name = json['name'];
isSystemIsolateGroup = json['isSystemIsolateGroup'];
isolates = List<IsolateRef>.from(
createServiceObject(json['isolates'], const ['IsolateRef']) ?? []);
}
@@ -5050,6 +5079,7 @@ class IsolateGroup extends Response implements IsolateGroupRef {
'id': id,
'number': number,
'name': name,
'isSystemIsolateGroup': isSystemIsolateGroup,
'isolates': isolates.map((f) => f.toJson()).toList(),
});
return json;
@@ -5061,7 +5091,7 @@ class IsolateGroup extends Response implements IsolateGroupRef {
String toString() => '[IsolateGroup ' //
'type: ${type}, id: ${id}, number: ${number}, name: ${name}, ' //
'isolates: ${isolates}]';
'isSystemIsolateGroup: ${isSystemIsolateGroup}, isolates: ${isolates}]';
}
/// See [getInboundReferences].
@@ -7063,6 +7093,12 @@ class VM extends Response implements VMRef {
/// A list of isolate groups running in the VM.
List<IsolateGroupRef> isolateGroups;
/// A list of system isolates running in the VM.
List<IsolateRef> systemIsolates;
/// A list of isolate groups which contain system isolates running in the VM.
List<IsolateGroupRef> systemIsolateGroups;
VM({
@required this.name,
@required this.architectureBits,
@@ -7074,6 +7110,8 @@ class VM extends Response implements VMRef {
@required this.startTime,
@required this.isolates,
@required this.isolateGroups,
@required this.systemIsolates,
@required this.systemIsolateGroups,
});
VM._fromJson(Map<String, dynamic> json) : super._fromJson(json) {
@@ -7090,6 +7128,12 @@ class VM extends Response implements VMRef {
isolateGroups = List<IsolateGroupRef>.from(
createServiceObject(json['isolateGroups'], const ['IsolateGroupRef']) ??
[]);
systemIsolates = List<IsolateRef>.from(
createServiceObject(json['systemIsolates'], const ['IsolateRef']) ??
[]);
systemIsolateGroups = List<IsolateGroupRef>.from(createServiceObject(
json['systemIsolateGroups'], const ['IsolateGroupRef']) ??
[]);
}
@override
@@ -7107,6 +7151,9 @@ class VM extends Response implements VMRef {
'startTime': startTime,
'isolates': isolates.map((f) => f.toJson()).toList(),
'isolateGroups': isolateGroups.map((f) => f.toJson()).toList(),
'systemIsolates': systemIsolates.map((f) => f.toJson()).toList(),
'systemIsolateGroups':
systemIsolateGroups.map((f) => f.toJson()).toList(),
});
return json;
}
+1
View File
@@ -176,6 +176,7 @@ void DartDevIsolate::DartDevRunner::RunCallback(uword args) {
flags.null_safety = false;
flags.use_field_guards = true;
flags.use_osr = true;
flags.is_system_isolate = true;
char* error;
Dart_Isolate dartdev_isolate = runner->create_isolate_(
+1
View File
@@ -621,6 +621,7 @@ typedef struct {
bool load_vmservice_library;
bool copy_parent_code;
bool null_safety;
bool is_system_isolate;
} Dart_IsolateFlags;
/**
+1 -38
View File
@@ -29,47 +29,10 @@ class RegisterRunningIsolatesVisitor : public IsolateVisitor {
: IsolateVisitor(),
register_function_(Function::Handle(thread->zone())),
service_isolate_(thread->isolate()) {
ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current()));
// Get library.
const String& library_url = Symbols::DartVMService();
ASSERT(!library_url.IsNull());
const Library& library =
Library::Handle(Library::LookupLibrary(thread, library_url));
ASSERT(!library.IsNull());
// Get function.
const String& function_name =
String::Handle(String::New("_registerIsolate"));
ASSERT(!function_name.IsNull());
register_function_ = library.LookupFunctionAllowPrivate(function_name);
ASSERT(!register_function_.IsNull());
}
virtual void VisitIsolate(Isolate* isolate) {
ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current()));
if (!FLAG_show_invisible_isolates && IsVMInternalIsolate(isolate)) {
// We do not register the service (and descendants), the vm-isolate, or
// the kernel isolate.
return;
}
// Setup arguments for call.
Dart_Port port_id = isolate->main_port();
const Integer& port_int = Integer::Handle(Integer::New(port_id));
ASSERT(!port_int.IsNull());
const SendPort& send_port = SendPort::Handle(SendPort::New(port_id));
const String& name = String::Handle(String::New(isolate->name()));
ASSERT(!name.IsNull());
const Array& args = Array::Handle(Array::New(3));
ASSERT(!args.IsNull());
args.SetAt(0, port_int);
args.SetAt(1, send_port);
args.SetAt(2, name);
const Object& r =
Object::Handle(DartEntry::InvokeFunction(register_function_, args));
if (FLAG_trace_service) {
OS::PrintErr("vm-service: Isolate %s %" Pd64 " registered.\n",
name.ToCString(), port_id);
}
ASSERT(!r.IsError());
ServiceIsolate::RegisterRunningIsolate(isolate);
}
private:
@@ -56,9 +56,10 @@ class IsolateRefElement extends CustomElement implements Renderable {
}
void render() {
final isolateType = isolate.isSystemIsolate ? 'System Isolate' : 'Isolate';
children = <Element>[
new AnchorElement(href: Uris.inspect(isolate))
..text = 'Isolate ${isolate.number} (${isolate.name})'
..text = '$isolateType ${isolate.number} (${isolate.name})'
..classes = ['isolate-ref']
];
}
@@ -94,6 +94,9 @@ class VMViewElement extends CustomElement implements Renderable {
for (var group in _vm.isolateGroups) {
await _isolateGroups.get(group);
}
for (var group in _vm.systemIsolateGroups) {
await _isolateGroups.get(group);
}
_r.dirty();
}
@@ -115,6 +118,7 @@ class VMViewElement extends CustomElement implements Renderable {
describeProcess(),
describeVM(),
describeIsolateGroups(),
describeSystemIsolateGroups(),
new ViewFooterElement(queue: _r.queue).element
];
}
@@ -325,14 +329,22 @@ class VMViewElement extends CustomElement implements Renderable {
..children = isolateGroups.map(describeIsolateGroup).toList();
}
Element describeSystemIsolateGroups() {
final isolateGroups = _vm.systemIsolateGroups.toList();
return new DivElement()
..children = isolateGroups.map(describeIsolateGroup).toList();
}
Element describeIsolateGroup(M.IsolateGroupRef group) {
final isolateType =
group.isSystemIsolateGroup ? 'System Isolate' : 'Isolate';
final isolates = (group as M.IsolateGroup).isolates;
return new DivElement()
..classes = ['content-centered-big']
..children = <Element>[
new HRElement(),
new HeadingElement.h1()
..text = "Isolate Group ${group.number} (${group.name})",
..text = "$isolateType Group ${group.number} (${group.name})",
new LIElement()
..classes = ['list-group-item']
..children = <Element>[
@@ -15,6 +15,9 @@ abstract class IsolateRef {
/// A name identifying this isolate. Not guaranteed to be unique.
String get name;
/// True if the isolate is a system isolate which is not running user code.
bool get isSystemIsolate;
/// Trigger a full GC, collecting all unreachable or weakly reachable objects.
Future collectAllGarbage();
}
@@ -14,6 +14,8 @@ abstract class IsolateGroupRef {
/// A name identifying this isolate group. Not guaranteed to be unique.
String get name;
bool get isSystemIsolateGroup;
}
abstract class IsolateGroup extends IsolateGroupRef {
@@ -51,7 +51,9 @@ abstract class VM implements VMRef {
// A list of isolates running in the VM.
Iterable<IsolateRef> get isolates;
Iterable<IsolateRef> get systemIsolates;
Iterable<IsolateGroupRef> get isolateGroups;
Iterable<IsolateGroupRef> get systemIsolateGroups;
/// Enable the sampling profiler.
Future enableProfiler();
@@ -668,8 +668,10 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
// The list of live isolates, ordered by isolate start time.
final List<Isolate> isolates = <Isolate>[];
final List<Isolate> systemIsolates = <Isolate>[];
final List<IsolateGroup> isolateGroups = <IsolateGroup>[];
final List<IsolateGroup> systemIsolateGroups = <IsolateGroup>[];
final List<Service> services = <Service>[];
@@ -755,10 +757,17 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
}
void _buildIsolateList() {
var isolateList = _isolateCache.values.toList();
var isolateList =
_isolateCache.values.where((i) => !i.isSystemIsolate).toList();
isolateList.sort(_compareIsolates);
isolates.clear();
isolates.addAll(isolateList);
var systemIsolateList =
_isolateCache.values.where((i) => i.isSystemIsolate).toList();
systemIsolateList.sort(_compareIsolates);
systemIsolates.clear();
systemIsolates.addAll(systemIsolateList);
}
void _removeDeadIsolates(List newIsolates) {
@@ -851,10 +860,18 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
}
void _buildIsolateGroupList() {
final isolateGroupList = _isolateGroupCache.values.toList();
final isolateGroupList = _isolateGroupCache.values
.where((g) => !g.isSystemIsolateGroup)
.toList();
isolateGroupList.sort(_compareIsolateGroups);
isolateGroups.clear();
isolateGroups.addAll(isolateGroupList);
final systemIsolateGroupList =
_isolateGroupCache.values.where((g) => g.isSystemIsolateGroup).toList();
systemIsolateGroupList.sort(_compareIsolateGroups);
systemIsolateGroups.clear();
systemIsolateGroups.addAll(systemIsolateGroupList);
}
void _removeDeadIsolateGroups(List newIsolateGroups) {
@@ -1039,8 +1056,14 @@ abstract class VM extends ServiceObjectOwner implements M.VM {
profileVM = map['_profilerMode'] == 'VM';
assertsEnabled = map['_assertsEnabled'];
typeChecksEnabled = map['_typeChecksEnabled'];
_removeDeadIsolates(map['isolates']);
_removeDeadIsolateGroups(map['isolateGroups']);
_removeDeadIsolates([
...map['isolates'],
...map['systemIsolates'],
]);
_removeDeadIsolateGroups([
...map['isolateGroups'],
...map['systemIsolateGroups'],
]);
}
// Reload all isolates.
@@ -1297,6 +1320,7 @@ class IsolateGroup extends ServiceObjectOwner implements M.IsolateGroup {
name = map['name'];
vmName = map.containsKey('_vmName') ? map['_vmName'] : name;
number = int.tryParse(map['number']);
isSystemIsolateGroup = map['isSystemIsolateGroup'];
if (mapIsRef) {
return;
}
@@ -1357,6 +1381,8 @@ class IsolateGroup extends ServiceObjectOwner implements M.IsolateGroup {
@override
int number;
bool isSystemIsolateGroup;
final Map<String, ServiceObject> _cache = Map<String, ServiceObject>();
}
@@ -1614,6 +1640,8 @@ class Isolate extends ServiceObjectOwner implements M.Isolate {
int get numScopedHandles => _numScopedHandles;
int _numScopedHandles;
bool isSystemIsolate;
void _loadHeapSnapshot(ServiceEvent event) {
if (_snapshotFetch == null) {
// No outstanding snapshot request. Presumably another client asked for a
@@ -1648,6 +1676,7 @@ class Isolate extends ServiceObjectOwner implements M.Isolate {
name = map['name'];
vmName = map.containsKey('_vmName') ? map['_vmName'] : name;
number = int.tryParse(map['number']);
isSystemIsolate = map['isSystemIsolate'];
if (mapIsRef) {
return;
}
+9 -1
View File
@@ -1,3 +1,11 @@
name: observatory
environment:
sdk: '>=2.2.2 <3.0.0'
sdk: '>=2.2.2 <3.0.0'
dependencies:
usage: 'any'
dev_dependencies:
build_runner: '>=1.6.2 <2.0.0'
build_web_compilers: '>=2.6.1 <3.0.0'
@@ -16,6 +16,7 @@ var tests = <VMTest>[
expect(result['type'], equals('Isolate'));
expect(result['id'], startsWith('isolates/'));
expect(result['number'], isA<String>());
expect(result['isSystemIsolate'], isFalse);
expect(result['_originNumber'], equals(result['number']));
expect(result['startTime'], isPositive);
expect(result['livePorts'], isPositive);
@@ -12,7 +12,7 @@ var tests = <VMTest>[
var result = await vm.invokeRpcNoUpgrade('getVersion', {});
expect(result['type'], equals('Version'));
expect(result['major'], equals(3));
expect(result['minor'], equals(37));
expect(result['minor'], equals(38));
expect(result['_privateMajor'], equals(0));
expect(result['_privateMinor'], equals(0));
},
@@ -66,6 +66,7 @@ Future<Null> testeeBefore() async {
Expect.equals(result['type'], 'IsolateGroup');
Expect.isTrue(result['id'].startsWith('isolateGroups/'));
Expect.type<String>(result['number']);
Expect.isFalse(result['isSystemIsolateGroup']);
Expect.isTrue(result['isolates'].length > 0);
Expect.equals(result['isolates'][0]['type'], '@Isolate');
} catch (e) {
@@ -262,7 +262,7 @@ bool FlowGraphCompiler::ForceSlowPathForStackOverflow() const {
if ((FLAG_stacktrace_every > 0) || (FLAG_deoptimize_every > 0) ||
(FLAG_gc_every > 0) ||
(isolate()->reload_every_n_stack_overflow_checks() > 0)) {
if (!Isolate::IsVMInternalIsolate(isolate())) {
if (!Isolate::IsSystemIsolate(isolate())) {
return true;
}
}
+5 -4
View File
@@ -259,13 +259,14 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
// Setup default flags for the VM isolate.
Dart_IsolateFlags api_flags;
Isolate::FlagsInitialize(&api_flags);
api_flags.is_system_isolate = true;
// We make a fake [IsolateGroupSource] here, since the "vm-isolate" is not
// really an isolate itself - it acts more as a container for VM-global
// objects.
std::unique_ptr<IsolateGroupSource> source(
new IsolateGroupSource(nullptr, kVmIsolateName, vm_isolate_snapshot,
instructions_snapshot, nullptr, -1, api_flags));
std::unique_ptr<IsolateGroupSource> source(new IsolateGroupSource(
kVmIsolateName, kVmIsolateName, vm_isolate_snapshot,
instructions_snapshot, nullptr, -1, api_flags));
// ObjectStore should be created later, after null objects are initialized.
auto group = new IsolateGroup(std::move(source), /*embedder_data=*/nullptr,
/*object_store=*/nullptr);
@@ -432,7 +433,7 @@ static void DumpAliveIsolates(intptr_t num_attempts,
bool only_aplication_isolates) {
IsolateGroup::ForEach([&](IsolateGroup* group) {
group->ForEachIsolate([&](Isolate* isolate) {
if (!only_aplication_isolates || !Isolate::IsVMInternalIsolate(isolate)) {
if (!only_aplication_isolates || !Isolate::IsSystemIsolate(isolate)) {
OS::PrintErr("Attempt:%" Pd " waiting for isolate %s to check in\n",
num_attempts, isolate->name());
}
+3 -3
View File
@@ -317,12 +317,12 @@ ActivationFrame::ActivationFrame(const Closure& async_activation)
}
bool Debugger::NeedsIsolateEvents() {
return !Isolate::IsVMInternalIsolate(isolate_) &&
return !Isolate::IsSystemIsolate(isolate_) &&
Service::isolate_stream.enabled();
}
bool Debugger::NeedsDebugEvents() {
ASSERT(!Isolate::IsVMInternalIsolate(isolate_));
ASSERT(!Isolate::IsSystemIsolate(isolate_));
return FLAG_warn_on_pause_with_no_debugger || Service::debug_stream.enabled();
}
@@ -1856,7 +1856,7 @@ Debugger::~Debugger() {
void Debugger::Shutdown() {
// TODO(johnmccutchan): Do not create a debugger for isolates that don't need
// them. Then, assert here that isolate_ is not one of those isolates.
if (Isolate::IsVMInternalIsolate(isolate_)) {
if (Isolate::IsSystemIsolate(isolate_)) {
return;
}
while (breakpoint_locations_ != NULL) {
-2
View File
@@ -197,8 +197,6 @@ constexpr bool kDartUseBackgroundCompilation = true;
P(enable_isolate_groups, bool, false, "Enable isolate group support.") \
P(show_invisible_frames, bool, false, \
"Show invisible frames in stack traces.") \
R(show_invisible_isolates, false, bool, false, \
"Show invisible isolates in the vm-service.") \
R(support_il_printer, false, bool, true, "Support the IL printer.") \
D(trace_cha, bool, false, "Trace CHA operations") \
R(trace_field_guards, false, bool, false, "Trace changes in field's cids.") \
+1 -1
View File
@@ -1009,7 +1009,7 @@ void Heap::RecordAfterGC(GCType type) {
// For now we'll emit the same GC events on all isolates.
if (Service::gc_stream.enabled()) {
isolate_group_->ForEachIsolate([&](Isolate* isolate) {
if (!Isolate::IsVMInternalIsolate(isolate)) {
if (!Isolate::IsSystemIsolate(isolate)) {
ServiceEvent event(isolate, ServiceEvent::kGC);
event.set_gc_stats(&stats_);
Service::HandleEvent(&event);
+20 -24
View File
@@ -345,6 +345,7 @@ IsolateGroup::IsolateGroup(std::shared_ptr<IsolateGroupSource> source,
isolates_lock_(new SafepointRwLock()),
isolates_(),
start_time_micros_(OS::GetCurrentMonotonicMicros()),
is_system_isolate_group_(source->flags.is_system_isolate),
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
last_reload_timestamp_(OS::GetCurrentTimeMillis()),
#endif
@@ -730,6 +731,7 @@ void IsolateGroup::PrintToJSONObject(JSONObject* jsobj, bool ref) {
jsobj->AddProperty("name", source()->script_uri);
jsobj->AddPropertyF("number", "%" Pu64 "", id());
jsobj->AddProperty("isSystemIsolateGroup", is_system_isolate_group());
if (ref) {
return;
}
@@ -801,7 +803,7 @@ void IsolateGroup::UnregisterIsolateGroup(IsolateGroup* isolate_group) {
bool IsolateGroup::HasApplicationIsolateGroups() {
ReadRwLocker wl(ThreadState::Current(), isolate_groups_rwlock_);
for (auto group : *isolate_groups_) {
if (!IsolateGroup::IsVMInternalIsolateGroup(group)) {
if (!IsolateGroup::IsSystemIsolateGroup(group)) {
return true;
}
}
@@ -836,8 +838,8 @@ void IsolateGroup::Cleanup() {
isolate_groups_ = nullptr;
}
bool IsolateVisitor::IsVMInternalIsolate(Isolate* isolate) const {
return Isolate::IsVMInternalIsolate(isolate);
bool IsolateVisitor::IsSystemIsolate(Isolate* isolate) const {
return Isolate::IsSystemIsolate(isolate);
}
NoOOBMessageScope::NoOOBMessageScope(Thread* thread)
@@ -1356,7 +1358,7 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage(
}
} else {
#ifndef PRODUCT
if (!Isolate::IsVMInternalIsolate(I)) {
if (!Isolate::IsSystemIsolate(I)) {
// Mark all the user isolates as using a simplified timeline page of
// Observatory. The internal isolates will be filtered out from
// the Timeline due to absence of this argument. We still send them in
@@ -1379,7 +1381,7 @@ MessageHandler::MessageStatus IsolateMessageHandler::HandleMessage(
#ifndef PRODUCT
void IsolateMessageHandler::NotifyPauseOnStart() {
if (Isolate::IsVMInternalIsolate(I)) {
if (Isolate::IsSystemIsolate(I)) {
return;
}
if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) {
@@ -1395,7 +1397,7 @@ void IsolateMessageHandler::NotifyPauseOnStart() {
}
void IsolateMessageHandler::NotifyPauseOnExit() {
if (Isolate::IsVMInternalIsolate(I)) {
if (Isolate::IsSystemIsolate(I)) {
return;
}
if (Service::debug_stream.enabled() || FLAG_warn_on_pause_with_no_debugger) {
@@ -1514,6 +1516,7 @@ void Isolate::FlagsInitialize(Dart_IsolateFlags* api_flags) {
api_flags->load_vmservice_library = false;
api_flags->copy_parent_code = false;
api_flags->null_safety = false;
api_flags->is_system_isolate = false;
}
void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
@@ -1526,6 +1529,7 @@ void Isolate::FlagsCopyTo(Dart_IsolateFlags* api_flags) const {
api_flags->load_vmservice_library = should_load_vmservice();
api_flags->copy_parent_code = false;
api_flags->null_safety = null_safety();
api_flags->is_system_isolate = is_system_isolate();
}
void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
@@ -1556,7 +1560,7 @@ void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
set_should_load_vmservice(api_flags.load_vmservice_library);
set_null_safety(api_flags.null_safety);
set_is_system_isolate(api_flags.is_system_isolate);
// Copy entry points list.
ASSERT(embedder_entry_points_ == NULL);
if (api_flags.entry_points != NULL) {
@@ -1960,7 +1964,7 @@ void Isolate::BuildName(const char* name_prefix) {
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
bool Isolate::CanReload() const {
return !Isolate::IsVMInternalIsolate(this) && is_runnable() &&
return !Isolate::IsSystemIsolate(this) && is_runnable() &&
!group()->IsReloading() && (no_reload_scope_depth_ == 0) &&
IsolateCreationEnabled() &&
OSThread::Current()->HasStackHeadroom(64 * KB);
@@ -2059,7 +2063,7 @@ const char* Isolate::MakeRunnable() {
ASSERT(object_store()->root_library() != Library::null());
set_is_runnable(true);
#ifndef PRODUCT
if (!Isolate::IsVMInternalIsolate(this)) {
if (!Isolate::IsSystemIsolate(this)) {
debugger()->OnIsolateRunnable();
if (FLAG_pause_isolates_on_unhandled_exceptions) {
debugger()->SetExceptionPauseInfo(kPauseOnUnhandledExceptions);
@@ -2081,8 +2085,7 @@ const char* Isolate::MakeRunnable() {
}
#endif
#ifndef PRODUCT
if (!Isolate::IsVMInternalIsolate(this) &&
Service::isolate_stream.enabled()) {
if (!Isolate::IsSystemIsolate(this) && Service::isolate_stream.enabled()) {
ServiceEvent runnableEvent(this, ServiceEvent::kIsolateRunnable);
Service::HandleEvent(&runnableEvent);
}
@@ -2604,8 +2607,7 @@ void Isolate::Shutdown() {
}
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
if (FLAG_check_reloaded && is_runnable() &&
!Isolate::IsVMInternalIsolate(this)) {
if (FLAG_check_reloaded && is_runnable() && !Isolate::IsSystemIsolate(this)) {
if (!HasAttemptedReload()) {
FATAL(
"Isolate did not reload before exiting and "
@@ -3068,6 +3070,7 @@ void Isolate::PrintJSON(JSONStream* stream, bool ref) {
jsobj.AddProperty("name", name());
jsobj.AddPropertyF("number", "%" Pd64 "", static_cast<int64_t>(main_port()));
jsobj.AddProperty("isSystemIsolate", is_system_isolate());
if (ref) {
return;
}
@@ -3435,7 +3438,7 @@ void Isolate::AppendServiceExtensionCall(const Instance& closure,
// done atomically.
void Isolate::RegisterServiceExtensionHandler(const String& name,
const Instance& closure) {
if (Isolate::IsVMInternalIsolate(this)) {
if (Isolate::IsSystemIsolate(this)) {
return;
}
GrowableObjectArray& handlers =
@@ -3631,15 +3634,8 @@ bool Isolate::IsolateCreationEnabled() {
return creation_enabled_;
}
bool IsolateGroup::IsVMInternalIsolateGroup(const IsolateGroup* group) {
// We use a name comparison here because this method can be called during
// shutdown, where the actual isolate pointers might've already been cleared.
const char* name = group->source()->name;
return Dart::VmIsolateNameEquals(name) ||
#if !defined(DART_PRECOMPILED_RUNTIME)
KernelIsolate::NameEquals(name) ||
#endif
ServiceIsolate::NameEquals(name);
bool IsolateGroup::IsSystemIsolateGroup(const IsolateGroup* group) {
return group->source()->flags.is_system_isolate;
}
void Isolate::KillLocked(LibMsgId msg_id) {
@@ -3708,7 +3704,7 @@ class IsolateKillerVisitor : public IsolateVisitor {
// If a target_ is specified, then only kill the target_.
// Otherwise, don't kill the service isolate or vm isolate.
return (((target_ != nullptr) && (isolate == target_)) ||
((target_ == nullptr) && !IsVMInternalIsolate(isolate)));
((target_ == nullptr) && !IsSystemIsolate(isolate)));
}
Isolate* target_;
+16 -8
View File
@@ -121,7 +121,7 @@ class IsolateVisitor {
protected:
// Returns true if |isolate| is the VM or service isolate.
bool IsVMInternalIsolate(Isolate* isolate) const;
bool IsSystemIsolate(Isolate* isolate) const;
private:
DISALLOW_COPY_AND_ASSIGN(IsolateVisitor);
@@ -396,6 +396,9 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
SharedClassTable* shared_class_table() const {
return shared_class_table_.get();
}
bool is_system_isolate_group() const { return is_system_isolate_group_; }
StoreBuffer* store_buffer() const { return store_buffer_.get(); }
ClassTable* class_table() const { return class_table_.get(); }
ObjectStore* object_store() const { return object_store_.get(); }
@@ -562,7 +565,7 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
static bool HasApplicationIsolateGroups();
static bool HasOnlyVMIsolateGroup();
static bool IsVMInternalIsolateGroup(const IsolateGroup* group);
static bool IsSystemIsolateGroup(const IsolateGroup* group);
int64_t UptimeMicros() const;
@@ -647,6 +650,7 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
Dart_LibraryTagHandler library_tag_handler_ = nullptr;
Dart_DeferredLoadHandler deferred_load_handler_ = nullptr;
int64_t start_time_micros_;
bool is_system_isolate_group_;
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
int64_t last_reload_timestamp_;
@@ -934,9 +938,7 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
Mutex* kernel_constants_mutex() { return &kernel_constants_mutex_; }
#if !defined(PRODUCT)
Debugger* debugger() const {
return debugger_;
}
Debugger* debugger() const { return debugger_; }
void set_single_step(bool value) { single_step_ = value; }
bool single_step() const { return single_step_; }
@@ -1321,8 +1323,8 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
static void DisableIsolateCreation();
static void EnableIsolateCreation();
static bool IsolateCreationEnabled();
static bool IsVMInternalIsolate(const Isolate* isolate) {
return IsolateGroup::IsVMInternalIsolateGroup(isolate->group());
static bool IsSystemIsolate(const Isolate* isolate) {
return IsolateGroup::IsSystemIsolateGroup(isolate->group());
}
#if !defined(PRODUCT)
@@ -1399,6 +1401,11 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
void set_user_tag(uword tag) { user_tag_ = tag; }
void set_is_system_isolate(bool is_system_isolate) {
is_system_isolate_ = is_system_isolate;
}
bool is_system_isolate() const { return is_system_isolate_; }
#if !defined(PRODUCT)
GrowableObjectArrayPtr GetAndClearPendingServiceExtensionCalls();
GrowableObjectArrayPtr pending_service_extension_calls() const {
@@ -1441,6 +1448,7 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
ClassPtr* cached_class_table_table_ = nullptr;
FieldTable* field_table_ = nullptr;
bool single_step_ = false;
bool is_system_isolate_ = false;
// End accessed from generated code.
IsolateGroup* isolate_group_;
@@ -1544,7 +1552,7 @@ class Isolate : public BaseIsolate, public IntrusiveDListEntry<Isolate> {
Dart_EnvironmentCallback environment_callback_ = nullptr;
Random random_;
Simulator* simulator_ = nullptr;
Mutex mutex_; // Protects compiler stats.
Mutex mutex_; // Protects compiler stats.
Mutex constant_canonicalization_mutex_; // Protects const canonicalization.
Mutex megamorphic_mutex_; // Protects the table of megamorphic caches and
// their entries.
+2 -2
View File
@@ -484,7 +484,7 @@ void IsolateGroupReloadContext::ReportError(const Error& error) {
// TODO(dartbug.com/36097): We need to change the "reloadSources" service-api
// call to accept an isolate group instead of an isolate.
Isolate* isolate = Isolate::Current();
if (Isolate::IsVMInternalIsolate(isolate)) {
if (Isolate::IsSystemIsolate(isolate)) {
return;
}
TIR_Print("ISO-RELOAD: Error: %s\n", error.ToErrorCString());
@@ -497,7 +497,7 @@ void IsolateGroupReloadContext::ReportSuccess() {
// TODO(dartbug.com/36097): We need to change the "reloadSources" service-api
// call to accept an isolate group instead of an isolate.
Isolate* isolate = Isolate::Current();
if (Isolate::IsVMInternalIsolate(isolate)) {
if (Isolate::IsSystemIsolate(isolate)) {
return;
}
ServiceEvent service_event(isolate, ServiceEvent::kIsolateReload);
+1
View File
@@ -92,6 +92,7 @@ class RunKernelTask : public ThreadPool::Task {
Dart_IsolateFlags api_flags;
Isolate::FlagsInitialize(&api_flags);
api_flags.enable_asserts = false;
api_flags.is_system_isolate = true;
#if !defined(DART_PRECOMPILER)
api_flags.use_field_guards = true;
#endif
+1 -1
View File
@@ -125,7 +125,7 @@ intptr_t Log::cursor() const {
bool Log::ShouldLogForIsolateGroup(const IsolateGroup* isolate_group) {
if (FLAG_isolate_log_filter == nullptr) {
if (IsolateGroup::IsVMInternalIsolateGroup(isolate_group)) {
if (IsolateGroup::IsSystemIsolateGroup(isolate_group)) {
// By default, do not log for the service or kernel isolates.
return false;
}
+1 -1
View File
@@ -2461,7 +2461,7 @@ static void HandleStackOverflowTestCases(Thread* thread) {
isolate->reload_every_n_stack_overflow_checks();
if ((FLAG_deoptimize_every > 0) || (FLAG_stacktrace_every > 0) ||
(FLAG_gc_every > 0) || (isolate_reload_every > 0)) {
if (!Isolate::IsVMInternalIsolate(isolate)) {
if (!Isolate::IsSystemIsolate(isolate)) {
// TODO(turnidge): To make --deoptimize_every and
// --stacktrace-every faster we could move this increment/test to
// the generated code.
+212 -129
View File
@@ -986,8 +986,7 @@ void Service::SendEvent(const char* stream_id,
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
ASSERT(isolate != NULL);
ASSERT(FLAG_show_invisible_isolates ||
!Isolate::IsVMInternalIsolate(isolate));
ASSERT(!Isolate::IsSystemIsolate(isolate));
if (FLAG_trace_service) {
OS::PrintErr(
@@ -1341,10 +1340,10 @@ int64_t Service::CurrentRSS() {
return -1;
}
Dart_EmbedderInformation info = {
0, // version
NULL, // name
0, // max_rss
0 // current_rss
0, // version
NULL, // name
0, // max_rss
0 // current_rss
};
embedder_information_callback_(&info);
ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION);
@@ -1356,10 +1355,10 @@ int64_t Service::MaxRSS() {
return -1;
}
Dart_EmbedderInformation info = {
0, // version
NULL, // name
0, // max_rss
0 // current_rss
0, // version
NULL, // name
0, // max_rss
0 // current_rss
};
embedder_information_callback_(&info);
ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION);
@@ -1401,7 +1400,8 @@ void Service::ScheduleExtensionHandler(const Instance& handler,
}
static const MethodParameter* get_isolate_params[] = {
ISOLATE_PARAMETER, NULL,
ISOLATE_PARAMETER,
NULL,
};
static bool GetIsolate(Thread* thread, JSONStream* js) {
@@ -2158,7 +2158,8 @@ static bool PrintInboundReferences(Thread* thread,
}
static const MethodParameter* get_inbound_references_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetInboundReferences(Thread* thread, JSONStream* js) {
@@ -2275,7 +2276,8 @@ static bool PrintRetainingPath(Thread* thread,
}
static const MethodParameter* get_retaining_path_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetRetainingPath(Thread* thread, JSONStream* js) {
@@ -2315,7 +2317,9 @@ static bool GetRetainingPath(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_retained_size_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new IdParameter("targetId", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new IdParameter("targetId", true),
NULL,
};
static bool GetRetainedSize(Thread* thread, JSONStream* js) {
@@ -2353,7 +2357,9 @@ static bool GetRetainedSize(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_reachable_size_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new IdParameter("targetId", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new IdParameter("targetId", true),
NULL,
};
static bool GetReachableSize(Thread* thread, JSONStream* js) {
@@ -2525,7 +2531,8 @@ static bool Invoke(Thread* thread, JSONStream* js) {
}
static const MethodParameter* evaluate_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool IsAlpha(char c) {
@@ -3034,8 +3041,10 @@ static bool EvaluateCompiledExpression(Thread* thread, JSONStream* js) {
}
static const MethodParameter* evaluate_in_frame_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new UIntParameter("frameIndex", true),
new MethodParameter("expression", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new UIntParameter("frameIndex", true),
new MethodParameter("expression", true),
NULL,
};
static bool EvaluateInFrame(Thread* thread, JSONStream* js) {
@@ -3083,7 +3092,8 @@ class GetInstancesVisitor : public ObjectGraph::Visitor {
};
static const MethodParameter* get_instances_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetInstances(Thread* thread, JSONStream* js) {
@@ -3379,7 +3389,9 @@ static bool AddBreakpointWithScriptUri(Thread* thread, JSONStream* js) {
}
static const MethodParameter* add_breakpoint_at_entry_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new IdParameter("functionId", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new IdParameter("functionId", true),
NULL,
};
static bool AddBreakpointAtEntry(Thread* thread, JSONStream* js) {
@@ -3407,7 +3419,9 @@ static bool AddBreakpointAtEntry(Thread* thread, JSONStream* js) {
}
static const MethodParameter* add_breakpoint_at_activation_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new IdParameter("objectId", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new IdParameter("objectId", true),
NULL,
};
static bool AddBreakpointAtActivation(Thread* thread, JSONStream* js) {
@@ -3434,7 +3448,8 @@ static bool AddBreakpointAtActivation(Thread* thread, JSONStream* js) {
}
static const MethodParameter* remove_breakpoint_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool RemoveBreakpoint(Thread* thread, JSONStream* js) {
@@ -3562,7 +3577,8 @@ static bool HandleDartMetric(Thread* thread, JSONStream* js, const char* id) {
}
static const MethodParameter* get_isolate_metric_list_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetIsolateMetricList(Thread* thread, JSONStream* js) {
@@ -3587,7 +3603,8 @@ static bool GetIsolateMetricList(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_isolate_metric_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetIsolateMetric(Thread* thread, JSONStream* js) {
@@ -3617,7 +3634,8 @@ static bool GetIsolateMetric(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_vm_metric_list_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetVMMetricList(Thread* thread, JSONStream* js) {
@@ -3625,7 +3643,8 @@ static bool GetVMMetricList(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_vm_metric_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetVMMetric(Thread* thread, JSONStream* js) {
@@ -3698,7 +3717,8 @@ static bool SetVMTimelineFlags(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_vm_timeline_flags_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetVMTimelineFlags(Thread* thread, JSONStream* js) {
@@ -3716,7 +3736,8 @@ static bool GetVMTimelineFlags(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_vm_timeline_micros_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetVMTimelineMicros(Thread* thread, JSONStream* js) {
@@ -3727,7 +3748,8 @@ static bool GetVMTimelineMicros(Thread* thread, JSONStream* js) {
}
static const MethodParameter* clear_vm_timeline_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool ClearVMTimeline(Thread* thread, JSONStream* js) {
@@ -3743,8 +3765,10 @@ static bool ClearVMTimeline(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_vm_timeline_params[] = {
NO_ISOLATE_PARAMETER, new Int64Parameter("timeOriginMicros", false),
new Int64Parameter("timeExtentMicros", false), NULL,
NO_ISOLATE_PARAMETER,
new Int64Parameter("timeOriginMicros", false),
new Int64Parameter("timeExtentMicros", false),
NULL,
};
static bool GetVMTimeline(Thread* thread, JSONStream* js) {
@@ -3790,7 +3814,8 @@ static const Debugger::ResumeAction step_enum_values[] = {
static const MethodParameter* resume_params[] = {
RUNNABLE_ISOLATE_PARAMETER,
new EnumParameter("step", false, step_enum_names),
new UIntParameter("frameIndex", false), NULL,
new UIntParameter("frameIndex", false),
NULL,
};
static bool Resume(Thread* thread, JSONStream* js) {
@@ -3876,7 +3901,8 @@ static bool Kill(Thread* thread, JSONStream* js) {
}
static const MethodParameter* pause_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool Pause(Thread* thread, JSONStream* js) {
@@ -3905,7 +3931,8 @@ static bool EnableProfiler(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_tag_profile_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetTagProfile(Thread* thread, JSONStream* js) {
@@ -4063,7 +4090,8 @@ static bool CollectAllGarbage(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_heap_map_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetHeapMap(Thread* thread, JSONStream* js) {
@@ -4125,71 +4153,73 @@ static intptr_t GetProcessMemoryUsageHelper(JSONStream* js) {
JSONArray(&profiler, "children");
}
{
JSONObject timeline(&vm_children);
timeline.AddProperty("name", "Timeline");
timeline.AddProperty(
"description",
"Timeline events from dart:developer and Dart_TimelineEvent");
intptr_t size = Timeline::recorder()->Size();
vm_size += size;
timeline.AddProperty64("size", size);
JSONArray(&timeline, "children");
}
{
JSONObject zone(&vm_children);
zone.AddProperty("name", "Zone");
zone.AddProperty("description", "Arena allocation in the Dart VM");
intptr_t size = Zone::Size();
vm_size += size;
zone.AddProperty64("size", size);
JSONArray(&zone, "children");
}
{
JSONObject semi(&vm_children);
semi.AddProperty("name", "SemiSpace Cache");
semi.AddProperty("description", "Cached heap regions");
intptr_t size = SemiSpace::CachedSize();
vm_size += size;
semi.AddProperty64("size", size);
JSONArray(&semi, "children");
}
IsolateGroup::ForEach([&vm_children, &vm_size](IsolateGroup* isolate_group) {
// Note: new_space()->CapacityInWords() includes memory that hasn't been
// allocated from the OS yet.
int64_t capacity = (isolate_group->heap()->new_space()->UsedInWords() +
isolate_group->heap()->old_space()->CapacityInWords()) *
kWordSize;
int64_t used = isolate_group->heap()->TotalUsedInWords() * kWordSize;
int64_t free = capacity - used;
JSONObject group(&vm_children);
group.AddPropertyF("name", "IsolateGroup %s",
isolate_group->source()->name);
group.AddProperty("description", "Dart heap capacity");
vm_size += capacity;
group.AddProperty64("size", capacity);
JSONArray group_children(&group, "children");
{
JSONObject jsused(&group_children);
jsused.AddProperty("name", "Used");
jsused.AddProperty("description", "");
jsused.AddProperty64("size", used);
JSONArray(&jsused, "children");
JSONObject timeline(&vm_children);
timeline.AddProperty("name", "Timeline");
timeline.AddProperty(
"description",
"Timeline events from dart:developer and Dart_TimelineEvent");
intptr_t size = Timeline::recorder()->Size();
vm_size += size;
timeline.AddProperty64("size", size);
JSONArray(&timeline, "children");
}
{
JSONObject jsfree(&group_children);
jsfree.AddProperty("name", "Free");
jsfree.AddProperty("description", "");
jsfree.AddProperty64("size", free);
JSONArray(&jsfree, "children");
JSONObject zone(&vm_children);
zone.AddProperty("name", "Zone");
zone.AddProperty("description", "Arena allocation in the Dart VM");
intptr_t size = Zone::Size();
vm_size += size;
zone.AddProperty64("size", size);
JSONArray(&zone, "children");
}
});
{
JSONObject semi(&vm_children);
semi.AddProperty("name", "SemiSpace Cache");
semi.AddProperty("description", "Cached heap regions");
intptr_t size = SemiSpace::CachedSize();
vm_size += size;
semi.AddProperty64("size", size);
JSONArray(&semi, "children");
}
IsolateGroup::ForEach(
[&vm_children, &vm_size](IsolateGroup* isolate_group) {
// Note: new_space()->CapacityInWords() includes memory that hasn't
// been allocated from the OS yet.
int64_t capacity =
(isolate_group->heap()->new_space()->UsedInWords() +
isolate_group->heap()->old_space()->CapacityInWords()) *
kWordSize;
int64_t used = isolate_group->heap()->TotalUsedInWords() * kWordSize;
int64_t free = capacity - used;
JSONObject group(&vm_children);
group.AddPropertyF("name", "IsolateGroup %s",
isolate_group->source()->name);
group.AddProperty("description", "Dart heap capacity");
vm_size += capacity;
group.AddProperty64("size", capacity);
JSONArray group_children(&group, "children");
{
JSONObject jsused(&group_children);
jsused.AddProperty("name", "Used");
jsused.AddProperty("description", "");
jsused.AddProperty64("size", used);
JSONArray(&jsused, "children");
}
{
JSONObject jsfree(&group_children);
jsfree.AddProperty("name", "Free");
jsfree.AddProperty("description", "");
jsfree.AddProperty64("size", free);
JSONArray(&jsfree, "children");
}
});
} // vm_children
vm.AddProperty("name", "Dart VM");
@@ -4273,7 +4303,8 @@ void Service::SendExtensionEvent(Isolate* isolate,
}
static const MethodParameter* get_persistent_handles_params[] = {
ISOLATE_PARAMETER, NULL,
ISOLATE_PARAMETER,
NULL,
};
template <typename T>
@@ -4361,7 +4392,8 @@ static bool GetPersistentHandles(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_ports_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetPorts(Thread* thread, JSONStream* js) {
@@ -4389,8 +4421,10 @@ static bool RespondWithMalformedObject(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_object_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new UIntParameter("offset", false),
new UIntParameter("count", false), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new UIntParameter("offset", false),
new UIntParameter("count", false),
NULL,
};
static bool GetObject(Thread* thread, JSONStream* js) {
@@ -4461,7 +4495,8 @@ static bool GetObject(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_object_store_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetObjectStore(Thread* thread, JSONStream* js) {
@@ -4482,7 +4517,8 @@ static bool GetIsolateObjectStore(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_class_list_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetClassList(Thread* thread, JSONStream* js) {
@@ -4493,7 +4529,8 @@ static bool GetClassList(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_type_arguments_list_params[] = {
RUNNABLE_ISOLATE_PARAMETER, NULL,
RUNNABLE_ISOLATE_PARAMETER,
NULL,
};
static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) {
@@ -4529,7 +4566,8 @@ static bool GetTypeArgumentsList(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_version_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetVersion(Thread* thread, JSONStream* js) {
@@ -4550,7 +4588,23 @@ class ServiceIsolateVisitor : public IsolateVisitor {
virtual ~ServiceIsolateVisitor() {}
void VisitIsolate(Isolate* isolate) {
if (FLAG_show_invisible_isolates || !IsVMInternalIsolate(isolate)) {
if (!IsSystemIsolate(isolate)) {
jsarr_->AddValue(isolate);
}
}
private:
JSONArray* jsarr_;
};
class SystemServiceIsolateVisitor : public IsolateVisitor {
public:
explicit SystemServiceIsolateVisitor(JSONArray* jsarr) : jsarr_(jsarr) {}
virtual ~SystemServiceIsolateVisitor() {}
void VisitIsolate(Isolate* isolate) {
if (IsSystemIsolate(isolate) &&
!Dart::VmIsolateNameEquals(isolate->name())) {
jsarr_->AddValue(isolate);
}
}
@@ -4560,16 +4614,17 @@ class ServiceIsolateVisitor : public IsolateVisitor {
};
static const MethodParameter* get_vm_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
void Service::PrintJSONForEmbedderInformation(JSONObject *jsobj) {
void Service::PrintJSONForEmbedderInformation(JSONObject* jsobj) {
if (embedder_information_callback_ != NULL) {
Dart_EmbedderInformation info = {
0, // version
NULL, // name
-1, // max_rss
-1 // current_rss
0, // version
NULL, // name
-1, // max_rss
-1 // current_rss
};
embedder_information_callback_(&info);
ASSERT(info.version == DART_EMBEDDER_INFORMATION_CURRENT_VERSION);
@@ -4611,16 +4666,27 @@ void Service::PrintJSONForVM(JSONStream* js, bool ref) {
ServiceIsolateVisitor visitor(&jsarr);
Isolate::VisitIsolates(&visitor);
}
{
JSONArray jsarr(&jsobj, "systemIsolates");
SystemServiceIsolateVisitor visitor(&jsarr);
Isolate::VisitIsolates(&visitor);
}
{
JSONArray jsarr_isolate_groups(&jsobj, "isolateGroups");
IsolateGroup::ForEach([&jsarr_isolate_groups](IsolateGroup* isolate_group) {
bool has_internal = false;
isolate_group->ForEachIsolate([&has_internal](Isolate* isolate) {
if (Isolate::IsVMInternalIsolate(isolate)) {
has_internal = true;
}
});
if (FLAG_show_invisible_isolates || !has_internal) {
if (!isolate_group->is_system_isolate_group()) {
jsarr_isolate_groups.AddValue(isolate_group);
}
});
}
{
JSONArray jsarr_isolate_groups(&jsobj, "systemIsolateGroups");
IsolateGroup::ForEach([&jsarr_isolate_groups](IsolateGroup* isolate_group) {
// Don't surface the vm-isolate since it's not a "real" isolate.
if (Dart::VmIsolateNameEquals(isolate_group->source()->name)) {
return;
}
if (isolate_group->is_system_isolate_group()) {
jsarr_isolate_groups.AddValue(isolate_group);
}
});
@@ -4638,17 +4704,23 @@ static bool GetVM(Thread* thread, JSONStream* js) {
}
static const char* exception_pause_mode_names[] = {
"All", "None", "Unhandled", NULL,
"All",
"None",
"Unhandled",
NULL,
};
static Dart_ExceptionPauseInfo exception_pause_mode_values[] = {
kPauseOnAllExceptions, kNoPauseOnExceptions, kPauseOnUnhandledExceptions,
kPauseOnAllExceptions,
kNoPauseOnExceptions,
kPauseOnUnhandledExceptions,
kInvalidExceptionPauseInfo,
};
static const MethodParameter* set_exception_pause_mode_params[] = {
ISOLATE_PARAMETER,
new EnumParameter("mode", true, exception_pause_mode_names), NULL,
new EnumParameter("mode", true, exception_pause_mode_names),
NULL,
};
static bool SetExceptionPauseMode(Thread* thread, JSONStream* js) {
@@ -4674,7 +4746,8 @@ static bool SetExceptionPauseMode(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_flag_list_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetFlagList(Thread* thread, JSONStream* js) {
@@ -4683,7 +4756,8 @@ static bool GetFlagList(Thread* thread, JSONStream* js) {
}
static const MethodParameter* set_flags_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool SetFlag(Thread* thread, JSONStream* js) {
@@ -4763,8 +4837,10 @@ static bool SetFlag(Thread* thread, JSONStream* js) {
}
static const MethodParameter* set_library_debuggable_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new IdParameter("libraryId", true),
new BoolParameter("isDebuggable", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new IdParameter("libraryId", true),
new BoolParameter("isDebuggable", true),
NULL,
};
static bool SetLibraryDebuggable(Thread* thread, JSONStream* js) {
@@ -4785,7 +4861,9 @@ static bool SetLibraryDebuggable(Thread* thread, JSONStream* js) {
}
static const MethodParameter* set_name_params[] = {
ISOLATE_PARAMETER, new MethodParameter("name", true), NULL,
ISOLATE_PARAMETER,
new MethodParameter("name", true),
NULL,
};
static bool SetName(Thread* thread, JSONStream* js) {
@@ -4800,7 +4878,9 @@ static bool SetName(Thread* thread, JSONStream* js) {
}
static const MethodParameter* set_vm_name_params[] = {
NO_ISOLATE_PARAMETER, new MethodParameter("name", true), NULL,
NO_ISOLATE_PARAMETER,
new MethodParameter("name", true),
NULL,
};
static bool SetVMName(Thread* thread, JSONStream* js) {
@@ -4816,8 +4896,10 @@ static bool SetVMName(Thread* thread, JSONStream* js) {
}
static const MethodParameter* set_trace_class_allocation_params[] = {
RUNNABLE_ISOLATE_PARAMETER, new IdParameter("classId", true),
new BoolParameter("enable", true), NULL,
RUNNABLE_ISOLATE_PARAMETER,
new IdParameter("classId", true),
new BoolParameter("enable", true),
NULL,
};
static bool SetTraceClassAllocation(Thread* thread, JSONStream* js) {
@@ -4842,7 +4924,8 @@ static bool SetTraceClassAllocation(Thread* thread, JSONStream* js) {
}
static const MethodParameter* get_default_classes_aliases_params[] = {
NO_ISOLATE_PARAMETER, NULL,
NO_ISOLATE_PARAMETER,
NULL,
};
static bool GetDefaultClassesAliases(Thread* thread, JSONStream* js) {
+1 -1
View File
@@ -15,7 +15,7 @@
namespace dart {
#define SERVICE_PROTOCOL_MAJOR_VERSION 3
#define SERVICE_PROTOCOL_MINOR_VERSION 37
#define SERVICE_PROTOCOL_MINOR_VERSION 38
class Array;
class EmbedderServiceHandler;
+26 -2
View File
@@ -1,8 +1,8 @@
# Dart VM Service Protocol 3.37
# Dart VM Service Protocol 3.38
> Please post feedback to the [observatory-discuss group][discuss-list]
This document describes of _version 3.37_ of the Dart VM Service Protocol. This
This document describes of _version 3.38_ of the Dart VM Service Protocol. This
protocol is used to communicate with a running Dart Virtual Machine.
To use the Service Protocol, start the VM with the *--observe* flag.
@@ -2858,6 +2858,10 @@ class @Isolate extends Response {
// A name identifying this isolate. Not guaranteed to be unique.
string name;
// Specifies whether the isolate was spawned by the VM or embedder for
// internal use. If `false`, this isolate is likely running user code.
bool isSystemIsolate;
}
```
@@ -2875,6 +2879,10 @@ class Isolate extends Response {
// A name identifying this isolate. Not guaranteed to be unique.
string name;
// Specifies whether the isolate was spawned by the VM or embedder for
// internal use. If `false`, this isolate is likely running user code.
bool isSystemIsolate;
// The time that the VM started in milliseconds since the epoch.
//
// Suitable to pass to DateTime.fromMillisecondsSinceEpoch.
@@ -2932,6 +2940,10 @@ class @IsolateGroup extends Response {
// A name identifying this isolate group. Not guaranteed to be unique.
string name;
// Specifies whether the isolate group was spawned by the VM or embedder for
// internal use. If `false`, this isolate group is likely running user code.
bool isSystemIsolateGroup;
}
```
@@ -2949,6 +2961,10 @@ class IsolateGroup extends Response {
// A name identifying this isolate. Not guaranteed to be unique.
string name;
// Specifies whether the isolate group was spawned by the VM or embedder for
// internal use. If `false`, this isolate group is likely running user code.
bool isSystemIsolateGroup;
// A list of all isolates in this isolate group.
@Isolate[] isolates;
}
@@ -3862,6 +3878,12 @@ class VM extends Response {
// A list of isolate groups running in the VM.
@IsolateGroup[] isolateGroups;
// A list of system isolates running in the VM.
@Isolate[] systemIsolates;
// A list of isolate groups which contain system isolates running in the VM.
@IsolateGroup[] systemIsolateGroups;
}
```
@@ -3921,5 +3943,7 @@ the VM service.
3.35 | Added `getSupportedProtocols` RPC and `ProtocolList`, `Protocol` objects.
3.36 | Added `getProcessMemoryUsage` RPC and `ProcessMemoryUsage` and `ProcessMemoryItem` objects.
3.37 | Added `getWebSocketTarget` RPC and `WebSocketTarget` object.
3.38 | Added `isSystemIsolate` property to `@Isolate` and `Isolate`, `isSystemIsolateGroup` property to `@IsolateGroup` and `IsolateGroup`,
and properties `systemIsolates` and `systemIsolateGroups` to `VM`.
[discuss-list]: https://groups.google.com/a/dartlang.org/forum/#!forum/observatory-discuss
+3 -2
View File
@@ -36,8 +36,9 @@ ServiceEvent::ServiceEvent(Isolate* isolate, EventKind event_kind)
timestamp_(OS::GetCurrentTimeMillis()) {
// We should never generate events for the vm or service isolates.
ASSERT(isolate_ != Dart::vm_isolate());
ASSERT(isolate == NULL || FLAG_show_invisible_isolates ||
!Isolate::IsVMInternalIsolate(isolate));
ASSERT(isolate == NULL || !Isolate::IsSystemIsolate(isolate) ||
(Isolate::IsSystemIsolate(isolate) &&
event_kind == ServiceEvent::kResume));
if ((event_kind == ServiceEvent::kPauseStart) ||
(event_kind == ServiceEvent::kPauseExit)) {
+41 -3
View File
@@ -213,7 +213,7 @@ bool ServiceIsolate::SendIsolateStartupMessage() {
}
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
if (!FLAG_show_invisible_isolates && Isolate::IsVMInternalIsolate(isolate)) {
if (Dart::VmIsolateNameEquals(isolate->name())) {
return false;
}
ASSERT(isolate != NULL);
@@ -239,7 +239,7 @@ bool ServiceIsolate::SendIsolateShutdownMessage() {
}
Thread* thread = Thread::Current();
Isolate* isolate = thread->isolate();
if (!FLAG_show_invisible_isolates && Isolate::IsVMInternalIsolate(isolate)) {
if (Dart::VmIsolateNameEquals(isolate->name())) {
return false;
}
ASSERT(isolate != NULL);
@@ -351,7 +351,7 @@ class RunServiceTask : public ThreadPool::Task {
Dart_IsolateFlags api_flags;
Isolate::FlagsInitialize(&api_flags);
api_flags.is_system_isolate = true;
isolate = reinterpret_cast<Isolate*>(
create_group_callback(ServiceIsolate::kName, ServiceIsolate::kName,
NULL, NULL, &api_flags, NULL, &error));
@@ -586,6 +586,44 @@ void ServiceIsolate::BootVmServiceLibrary() {
ServiceIsolate::SetServicePort(port);
}
void ServiceIsolate::RegisterRunningIsolate(Isolate* isolate) {
ASSERT(ServiceIsolate::IsServiceIsolate(Isolate::Current()));
// Get library.
const String& library_url = Symbols::DartVMService();
ASSERT(!library_url.IsNull());
// TODO(bkonyi): hoist Thread::Current()
const Library& library =
Library::Handle(Library::LookupLibrary(Thread::Current(), library_url));
ASSERT(!library.IsNull());
// Get function.
const String& function_name = String::Handle(String::New("_registerIsolate"));
ASSERT(!function_name.IsNull());
const Function& register_function_ =
Function::Handle(library.LookupFunctionAllowPrivate(function_name));
ASSERT(!register_function_.IsNull());
// Setup arguments for call.
Dart_Port port_id = isolate->main_port();
const Integer& port_int = Integer::Handle(Integer::New(port_id));
ASSERT(!port_int.IsNull());
const SendPort& send_port = SendPort::Handle(SendPort::New(port_id));
const String& name = String::Handle(String::New(isolate->name()));
ASSERT(!name.IsNull());
const Array& args = Array::Handle(Array::New(3));
ASSERT(!args.IsNull());
args.SetAt(0, port_int);
args.SetAt(1, send_port);
args.SetAt(2, name);
const Object& r =
Object::Handle(DartEntry::InvokeFunction(register_function_, args));
if (FLAG_trace_service) {
OS::PrintErr("vm-service: Isolate %s %" Pd64 " registered.\n",
name.ToCString(), port_id);
}
ASSERT(!r.IsError());
}
void ServiceIsolate::VisitObjectPointers(ObjectPointerVisitor* visitor) {}
} // namespace dart
+3
View File
@@ -50,6 +50,8 @@ class ServiceIsolate : public AllStatic {
static void BootVmServiceLibrary();
static void RegisterRunningIsolate(Isolate* isolate);
static void RequestServerInfo(const SendPort& sp);
static void ControlWebServer(const SendPort& sp,
bool enable,
@@ -106,6 +108,7 @@ class ServiceIsolate : public AllStatic {
static bool SendIsolateShutdownMessage() { return false; }
static void SendServiceExitMessage() {}
static void Shutdown() {}
static void RegisterRunningIsolate(Isolate* isolate) {}
static void VisitObjectPointers(ObjectPointerVisitor* visitor) {}
protected: