Revert "[ Observatory ] Add basic records support to Observatory"

This reverts commit fca7813650.

Reason for revert: Broke analyzer tryjob

Original change's description:
> [ Observatory ] Add basic records support to Observatory
>
> Fixes https://github.com/dart-lang/sdk/issues/50405
>
> TEST=Manual testing
>
> Change-Id: If14f434792c89e3509895fcdd17561df810798e3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268581
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Derek Xu <derekx@google.com>

TBR=bkonyi@google.com,rmacnak@google.com,derekx@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: I30c4404adb9ac8f1851a89a0c846cb70461e410c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269220
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
Auto-Submit: Derek Xu <derekx@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
This commit is contained in:
Derek Xu 2022-11-10 23:42:08 +00:00 committed by Commit Queue
parent 5adeb03c2f
commit 3ab116198c
13 changed files with 42 additions and 142 deletions

View file

@ -93,8 +93,6 @@ Element anyRef(M.IsolateRef isolate, ref, M.ObjectRepository objects,
}
} else if (ref is M.Sentinel) {
return new SentinelValueElement(ref, queue: queue).element;
} else if (ref is num || ref is String) {
return new SpanElement()..text = ref.toString();
}
throw new Exception('Unknown ref type (${ref.runtimeType})');
}

View file

@ -128,7 +128,6 @@ class InstanceRefElement extends CustomElement implements Renderable {
case M.InstanceKind.functionType:
case M.InstanceKind.typeRef:
case M.InstanceKind.typeParameter:
case M.InstanceKind.recordType:
return [
new AnchorElement(href: Uris.inspect(_isolate, object: _instance))
..text = _instance.name
@ -195,10 +194,12 @@ class InstanceRefElement extends CustomElement implements Renderable {
]
];
case M.InstanceKind.mirrorReference:
return [
new AnchorElement(href: Uris.inspect(_isolate, object: _instance))
..classes = ['emphasize']
..text = _instance.clazz!.name
];
case M.InstanceKind.weakProperty:
case M.InstanceKind.finalizer:
case M.InstanceKind.weakReference:
case M.InstanceKind.record:
return [
new AnchorElement(href: Uris.inspect(_isolate, object: _instance))
..classes = ['emphasize']
@ -215,7 +216,6 @@ class InstanceRefElement extends CustomElement implements Renderable {
case M.InstanceKind.mirrorReference:
case M.InstanceKind.stackTrace:
case M.InstanceKind.weakProperty:
case M.InstanceKind.recordType:
return true;
case M.InstanceKind.list:
case M.InstanceKind.map:
@ -339,18 +339,6 @@ class InstanceRefElement extends CustomElement implements Renderable {
queue: _r.queue)
.element,
];
case M.InstanceKind.recordType:
final fields = _loadedInstance!.fields!.toList();
return [
for (int i = 0; i < fields.length; ++i) ...[
new SpanElement()..text = '${fields[i].name} = ',
new InstanceRefElement(
_isolate, fields[i].value!.asValue!, _objects,
queue: _r.queue)
.element,
if (i + 1 != fields.length) new BRElement(),
]
];
default:
return [];
}

View file

@ -335,12 +335,9 @@ class InstanceViewElement extends CustomElement implements Renderable {
..content = <Element>[
new DivElement()
..classes = ['memberList']
..children = fields.map<Element>((f) {
final name = _instance.kind == M.InstanceKind.record
? f.name
: f.decl;
return member(name, f.value);
}).toList()
..children = fields
.map<Element>((f) => member(f.decl, f.value))
.toList()
])
.element
]

View file

@ -126,18 +126,6 @@ enum InstanceKind {
/// An instance of the Dart class RawReceivePort
receivePort,
/// An instance of Record.
record,
/// An instance of RecordType
recordType,
/// An instance of Finalizer
finalizer,
/// An instance of WeakReference
weakReference,
}
bool isTypedData(InstanceKind? kind) {
@ -475,8 +463,7 @@ abstract class Instance extends Object implements InstanceRef {
abstract class BoundField {
FieldRef? get decl;
Guarded<dynamic>? get value;
dynamic get name;
Guarded<InstanceRef>? get value;
}
abstract class NativeField {

View file

@ -2108,7 +2108,7 @@ class ServiceMap extends ServiceObject
_map.clear();
map.forEach((k, v) => _map[k] = v);
name = _map['name']?.toString();
name = _map['name'];
vmName = (_map.containsKey('_vmName') ? _map['_vmName'] : name);
}
@ -2791,33 +2791,25 @@ M.InstanceKind stringToInstanceKind(String s) {
return M.InstanceKind.typeRef;
case 'ReceivePort':
return M.InstanceKind.receivePort;
case '_RecordType':
return M.InstanceKind.recordType;
case '_Record':
return M.InstanceKind.record;
case 'Finalizer':
return M.InstanceKind.finalizer;
case 'WeakReference':
return M.InstanceKind.weakReference;
}
var message = 'Unrecognized instance kind: $s';
Logger.root.severe(message);
throw new ArgumentError(message);
}
class Guarded<T> implements M.Guarded<T> {
class Guarded<T extends ServiceObject> implements M.Guarded<T> {
bool get isValue => asValue != null;
bool get isSentinel => asSentinel != null;
final Sentinel? asSentinel;
final T? asValue;
factory Guarded(dynamic obj) {
factory Guarded(ServiceObject obj) {
if (obj is Sentinel) {
return new Guarded.fromSentinel(obj);
} else if (obj is T) {
return new Guarded.fromValue(obj);
}
throw new Exception('${obj.runtimeType} is neither Sentinel or $T');
throw new Exception('${obj.type} is neither Sentinel or $T');
}
Guarded.fromSentinel(this.asSentinel) : asValue = null;
@ -2825,11 +2817,9 @@ class Guarded<T> implements M.Guarded<T> {
}
class BoundField implements M.BoundField {
final Field? decl;
// String|int
final dynamic name;
final Guarded<dynamic> value;
BoundField(this.decl, this.name, value) : value = new Guarded(value);
final Field decl;
final Guarded<Instance> value;
BoundField(this.decl, value) : value = new Guarded(value);
}
class NativeField implements M.NativeField {
@ -2926,7 +2916,7 @@ class Instance extends HeapObject implements M.Instance {
Instance._empty(ServiceObjectOwner? owner) : super._empty(owner);
void _update(Map map, bool mapIsRef) {
// Extract full properties.
// Extract full properties.1
_upgradeCollection(map, isolate);
super._update(map, mapIsRef);
@ -2935,7 +2925,7 @@ class Instance extends HeapObject implements M.Instance {
// Coerce absence to false.
valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true;
closureFunction = map['closureFunction'];
name = map['name']?.toString();
name = map['name'];
length = map['length'];
pattern = map['pattern'];
typeClass = map['typeClass'];
@ -2968,7 +2958,7 @@ class Instance extends HeapObject implements M.Instance {
if (map['fields'] != null) {
var fields = <BoundField>[];
for (var f in map['fields']) {
fields.add(new BoundField(f['decl'], f['name'], f['value']));
fields.add(new BoundField(f['decl'], f['value']));
}
this.fields = fields;
} else {

View file

@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.19
// See inspector.txt for expected behavior.
library manual_inspector_test;
@ -45,13 +43,10 @@ class Node {
var blockCopying;
var blockFull;
var blockFullWithChain;
var blockType;
var boundedType;
var capability;
var counter;
var expando;
var finalizer;
var finalizerEntry;
var float32x4;
var float64;
var float64x2;
@ -67,10 +62,7 @@ class Node {
var mirrorReference;
var portReceive;
var portSend;
var record;
var recordType;
var regex;
late var sentinel; // Not initialized
var smi;
var stacktrace;
var string;
@ -84,12 +76,9 @@ class Node {
var theTrue;
var type;
var typeParameter;
var typedDataArray;
var typedDataView;
var typedDataUnmodifiableView;
var typedData;
var userTag;
var weakProperty;
var weakReference;
genStackTrace() {
try {
@ -152,19 +141,16 @@ class Node {
array[0] = 1;
array[1] = 2;
array[2] = 3;
bigint = BigInt.one << 65;
bigint = 1 << 65;
blockClean = genCleanBlock();
blockCopying = genCopyingBlock();
blockFull = genFullBlock();
blockFullWithChain = genFullBlockWithChain();
blockType = blockClean.runtimeType;
boundedType = extractPrivateField(
reflect(new B<int>()).type.typeVariables.single, '_reflectee');
counter = new Counter("CounterName", "Counter description");
expando = new Expando("expando-name");
expando[array] = 'The weakly associated value';
finalizer = Finalizer<dynamic>((_){});
finalizer.attach(this, this);
float32x4 = new Float32x4(0.0, -1.0, 3.14, 2e28);
float64 = 3.14;
float64x2 = new Float64x2(0.0, 3.14);
@ -184,8 +170,6 @@ class Node {
mirrorReference = extractPrivateField(mirrorClass, '_reflectee');
portReceive = new RawReceivePort();
portSend = portReceive.sendPort;
record = (1, 2, three: 3, four: 4);
recordType = record.runtimeType;
regex = new RegExp("a*b+c");
smi = 7;
stacktrace = genStackTrace();
@ -201,13 +185,10 @@ class Node {
type = String;
typeParameter =
extractPrivateField(reflectClass(A).typeVariables.single, '_reflectee');
typedDataArray = Uint8List(32);
typedDataView = Uint8List.view(typedDataArray.buffer, 16);
typedDataUnmodifiableView = UnmodifiableUint8ListView(typedDataArray);
typedData = extractPrivateField(new ByteData(64), '_typedData');
userTag = new UserTag("Example tag name");
weakProperty =
extractPrivateField(expando, '_data').firstWhere((e) => e != null);
weakReference = WeakReference(this);
Isolate.spawn(secondMain, "Hello2").then((otherIsolate) {
isolate = otherIsolate;

View file

@ -2,8 +2,6 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// @dart = 2.19
part of manual_inspector_test;
functionInPart() {}

View file

@ -93,8 +93,6 @@ Element anyRef(M.IsolateRef isolate, ref, M.ObjectRepository objects,
}
} else if (ref is M.Sentinel) {
return new SentinelValueElement(ref, queue: queue).element;
} else if (ref is num || ref is String) {
return new SpanElement()..text = ref.toString();
}
throw new Exception('Unknown ref type (${ref.runtimeType})');
}

View file

@ -127,7 +127,6 @@ class InstanceRefElement extends CustomElement implements Renderable {
case M.InstanceKind.functionType:
case M.InstanceKind.typeRef:
case M.InstanceKind.typeParameter:
case M.InstanceKind.recordType:
return [
new AnchorElement(href: Uris.inspect(_isolate, object: _instance))
..text = _instance.name
@ -193,10 +192,12 @@ class InstanceRefElement extends CustomElement implements Renderable {
]
];
case M.InstanceKind.mirrorReference:
return [
new AnchorElement(href: Uris.inspect(_isolate, object: _instance))
..classes = ['emphasize']
..text = _instance.clazz.name
];
case M.InstanceKind.weakProperty:
case M.InstanceKind.finalizer:
case M.InstanceKind.weakReference:
case M.InstanceKind.record:
return [
new AnchorElement(href: Uris.inspect(_isolate, object: _instance))
..classes = ['emphasize']
@ -213,7 +214,6 @@ class InstanceRefElement extends CustomElement implements Renderable {
case M.InstanceKind.mirrorReference:
case M.InstanceKind.stackTrace:
case M.InstanceKind.weakProperty:
case M.InstanceKind.recordType:
return true;
case M.InstanceKind.list:
case M.InstanceKind.map:
@ -337,17 +337,6 @@ class InstanceRefElement extends CustomElement implements Renderable {
queue: _r.queue)
.element,
];
case M.InstanceKind.recordType:
final fields = _loadedInstance.fields.toList();
return [
for (int i = 0; i < fields.length; ++i) ...[
new SpanElement()..text = '${fields[i].name} = ',
new InstanceRefElement(_isolate, fields[i].value.asValue, _objects,
queue: _r.queue)
.element,
if (i + 1 != fields.length) new BRElement(),
]
];
default:
return [];
}

View file

@ -334,12 +334,9 @@ class InstanceViewElement extends CustomElement implements Renderable {
..content = <Element>[
new DivElement()
..classes = ['memberList']
..children = fields.map<Element>((f) {
final name = _instance.kind == M.InstanceKind.record
? f.name
: f.decl;
return member(name, f.value);
}).toList()
..children = fields
.map<Element>((f) => member(f.decl, f.value))
.toList()
])
.element
]

View file

@ -126,18 +126,6 @@ enum InstanceKind {
/// An instance of the Dart class RawReceivePort
receivePort,
/// An instance of Record.
record,
/// An instance of RecordType
recordType,
/// An instance of Finalizer
finalizer,
/// An instance of WeakReference
weakReference,
}
bool isTypedData(InstanceKind kind) {
@ -466,8 +454,7 @@ abstract class Instance extends Object implements InstanceRef {
abstract class BoundField {
FieldRef get decl;
dynamic get name;
Guarded<dynamic> get value;
Guarded<InstanceRef> get value;
}
abstract class NativeField {

View file

@ -2118,7 +2118,7 @@ class ServiceMap extends ServiceObject
_map.clear();
_map.addAll(map);
name = _map['name']?.toString();
name = _map['name'];
vmName = (_map.containsKey('_vmName') ? _map['_vmName'] : name);
}
@ -2800,33 +2800,25 @@ M.InstanceKind stringToInstanceKind(String s) {
return M.InstanceKind.typeRef;
case 'ReceivePort':
return M.InstanceKind.receivePort;
case '_Record':
return M.InstanceKind.record;
case '_RecordType':
return M.InstanceKind.recordType;
case 'Finalizer':
return M.InstanceKind.finalizer;
case 'WeakReference':
return M.InstanceKind.weakReference;
}
var message = 'Unrecognized instance kind: $s';
Logger.root.severe(message);
throw new ArgumentError(message);
}
class Guarded<T> implements M.Guarded<T> {
class Guarded<T extends ServiceObject> implements M.Guarded<T> {
bool get isValue => asValue != null;
bool get isSentinel => asSentinel != null;
final Sentinel asSentinel;
final T asValue;
factory Guarded(dynamic obj) {
factory Guarded(ServiceObject obj) {
if (obj is Sentinel) {
return new Guarded.fromSentinel(obj);
} else if (obj is T) {
return new Guarded.fromValue(obj);
}
throw new Exception('${obj.runtimeType} is neither Sentinel or $T');
throw new Exception('${obj.type} is neither Sentinel or $T');
}
Guarded.fromSentinel(this.asSentinel) : asValue = null;
@ -2835,10 +2827,8 @@ class Guarded<T> implements M.Guarded<T> {
class BoundField implements M.BoundField {
final Field decl;
// String|int
final dynamic name;
final Guarded<dynamic> value;
BoundField(this.decl, this.name, value) : value = new Guarded(value);
final Guarded<Instance> value;
BoundField(this.decl, value) : value = new Guarded(value);
}
class NativeField implements M.NativeField {
@ -2939,7 +2929,7 @@ class Instance extends HeapObject implements M.Instance {
Instance._empty(ServiceObjectOwner owner) : super._empty(owner);
void _update(Map map, bool mapIsRef) {
// Extract full properties.
// Extract full properties.1
_upgradeCollection(map, isolate);
super._update(map, mapIsRef);
@ -2948,7 +2938,7 @@ class Instance extends HeapObject implements M.Instance {
// Coerce absence to false.
valueAsStringIsTruncated = map['valueAsStringIsTruncated'] == true;
closureFunction = map['closureFunction'];
name = map['name']?.toString();
name = map['name'];
length = map['length'];
pattern = map['pattern'];
typeClass = map['typeClass'];
@ -2981,7 +2971,7 @@ class Instance extends HeapObject implements M.Instance {
if (map['fields'] != null) {
var fields = <BoundField>[];
for (var f in map['fields']) {
fields.add(new BoundField(f['decl'], f['name'], f['value']));
fields.add(new BoundField(f['decl'], f['value']));
}
this.fields = fields;
} else {

View file

@ -1128,7 +1128,7 @@ void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
Array& field_array = Array::Handle();
Field& field = Field::Handle();
Object& field_value = Object::Handle();
Instance& field_value = Instance::Handle();
{
JSONArray jsarr(jsobj, "fields");
for (intptr_t i = classes.length() - 1; i >= 0; i--) {
@ -1137,7 +1137,7 @@ void Instance::PrintSharedInstanceJSON(JSONObject* jsobj,
for (intptr_t j = 0; j < field_array.Length(); j++) {
field ^= field_array.At(j);
if (!field.is_static()) {
field_value = GetField(field);
field_value ^= GetField(field);
JSONObject jsfield(&jsarr);
jsfield.AddProperty("type", "BoundField");
jsfield.AddProperty("decl", field);