Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: runtime/observatory/lib/src/service/object.dart

Issue 2194383002: Converted Observatory code-ref function-ref element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixed CSS problem Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of service; 5 part of service;
6 6
7 // Some value smaller than the object ring, so requesting a large array 7 // Some value smaller than the object ring, so requesting a large array
8 // doesn't result in an expired ref because the elements lapped it in the 8 // doesn't result in an expired ref because the elements lapped it in the
9 // object ring. 9 // object ring.
10 const int kDefaultFieldLimit = 100; 10 const int kDefaultFieldLimit = 100;
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 2597
2598 variables = map['variables']; 2598 variables = map['variables'];
2599 2599
2600 // We are fully loaded. 2600 // We are fully loaded.
2601 _loaded = true; 2601 _loaded = true;
2602 } 2602 }
2603 2603
2604 String toString() => 'Context($length)'; 2604 String toString() => 'Context($length)';
2605 } 2605 }
2606 2606
2607 2607 M.FunctionKind stringToFunctionKind(String value) {
2608 // TODO(koda): Sync this with VM. 2608 switch(value) {
2609 class FunctionKind { 2609 case 'RegularFunction': return M.FunctionKind.regular;
2610 final String _strValue; 2610 case 'ClosureFunction': return M.FunctionKind.closure;
2611 FunctionKind._internal(this._strValue); 2611 case 'GetterFunction': return M.FunctionKind.getter;
2612 toString() => _strValue; 2612 case 'SetterFunction': return M.FunctionKind.setter;
2613 bool isSynthetic() => [kCollected, kNative, kStub, kTag].contains(this); 2613 case 'Constructor': return M.FunctionKind.constructor;
2614 bool isDart() => !isSynthetic(); 2614 case 'ImplicitGetter': return M.FunctionKind.implicitGetter;
2615 bool isStub() => (this == kStub); 2615 case 'ImplicitSetter': return M.FunctionKind.implicitSetter;
2616 bool hasDartCode() => isDart() || isStub(); 2616 case 'ImplicitStaticFinalGetter':
2617 static FunctionKind fromJSON(String value) { 2617 return M.FunctionKind.implicitStaticFinalGetter;
2618 switch(value) { 2618 case 'IrregexpFunction': return M.FunctionKind.irregexpFunction;
2619 case 'RegularFunction': return kRegularFunction; 2619 case 'StaticInitializer': return M.FunctionKind.staticInitializer;
2620 case 'ClosureFunction': return kClosureFunction; 2620 case 'MethodExtractor': return M.FunctionKind.methodExtractor;
2621 case 'GetterFunction': return kGetterFunction; 2621 case 'NoSuchMethodDispatcher': return M.FunctionKind.noSuchMethodDispatcher;
2622 case 'SetterFunction': return kSetterFunction; 2622 case 'InvokeFieldDispatcher': return M.FunctionKind.invokeFieldDispatcher;
2623 case 'Constructor': return kConstructor; 2623 case 'Collected': return M.FunctionKind.collected;
2624 case 'ImplicitGetter': return kImplicitGetterFunction; 2624 case 'Native': return M.FunctionKind.native;
2625 case 'ImplicitSetter': return kImplicitSetterFunction; 2625 case 'Stub': return M.FunctionKind.stub;
2626 case 'ImplicitStaticFinalGetter': return kImplicitStaticFinalGetter; 2626 case 'Tag': return M.FunctionKind.tag;
2627 case 'IrregexpFunction': return kIrregexpFunction; 2627 case 'SignatureFunction': return M.FunctionKind.signatureFunction;
2628 case 'StaticInitializer': return kStaticInitializer;
2629 case 'MethodExtractor': return kMethodExtractor;
2630 case 'NoSuchMethodDispatcher': return kNoSuchMethodDispatcher;
2631 case 'InvokeFieldDispatcher': return kInvokeFieldDispatcher;
2632 case 'Collected': return kCollected;
2633 case 'Native': return kNative;
2634 case 'Stub': return kStub;
2635 case 'Tag': return kTag;
2636 case 'SignatureFunction': return kSignatureFunction;
2637 }
2638 Logger.root.severe('Unrecognized function kind: $value');
2639 throw new FallThroughError();
2640 } 2628 }
2641 2629 Logger.root.severe('Unrecognized function kind: $value');
2642 static FunctionKind kRegularFunction = new FunctionKind._internal('function'); 2630 throw new FallThroughError();
2643 static FunctionKind kClosureFunction = new FunctionKind._internal('closure fun ction');
2644 static FunctionKind kGetterFunction = new FunctionKind._internal('getter funct ion');
2645 static FunctionKind kSetterFunction = new FunctionKind._internal('setter funct ion');
2646 static FunctionKind kConstructor = new FunctionKind._internal('constructor');
2647 static FunctionKind kImplicitGetterFunction = new FunctionKind._internal('impl icit getter function');
2648 static FunctionKind kImplicitSetterFunction = new FunctionKind._internal('impl icit setter function');
2649 static FunctionKind kImplicitStaticFinalGetter = new FunctionKind._internal('i mplicit static final getter');
2650 static FunctionKind kIrregexpFunction = new FunctionKind._internal('ir regexp function');
2651 static FunctionKind kStaticInitializer = new FunctionKind._internal('static in itializer');
2652 static FunctionKind kMethodExtractor = new FunctionKind._internal('method extr actor');
2653 static FunctionKind kNoSuchMethodDispatcher = new FunctionKind._internal('noSu chMethod dispatcher');
2654 static FunctionKind kInvokeFieldDispatcher = new FunctionKind._internal('invok e field dispatcher');
2655 static FunctionKind kCollected = new FunctionKind._internal('Collected');
2656 static FunctionKind kNative = new FunctionKind._internal('Native');
2657 static FunctionKind kTag = new FunctionKind._internal('Tag');
2658 static FunctionKind kStub = new FunctionKind._internal('Stub');
2659 static FunctionKind kSignatureFunction = new FunctionKind._internal('Signature Function');
2660 static FunctionKind kUNKNOWN = new FunctionKind._internal('UNKNOWN');
2661 } 2631 }
2662 2632
2663 class ServiceFunction extends HeapObject { 2633 class ServiceFunction extends HeapObject implements M.Function {
2664 // owner is a Library, Class, or ServiceFunction. 2634 // owner is a Library, Class, or ServiceFunction.
2665 @observable ServiceObject dartOwner; 2635 @observable M.ObjectRef dartOwner;
2666 @observable Library library; 2636 @observable Library library;
2667 @observable bool isStatic; 2637 @observable bool isStatic;
2668 @observable bool isConst; 2638 @observable bool isConst;
2669 @observable SourceLocation location; 2639 @observable SourceLocation location;
2670 @observable Code code; 2640 @observable Code code;
2671 @observable Code unoptimizedCode; 2641 @observable Code unoptimizedCode;
2672 @observable bool isOptimizable; 2642 @observable bool isOptimizable;
2673 @observable bool isInlinable; 2643 @observable bool isInlinable;
2674 @observable bool hasIntrinsic; 2644 @observable bool hasIntrinsic;
2675 @observable bool isRecognized; 2645 @observable bool isRecognized;
2676 @observable bool isNative; 2646 @observable bool isNative;
2677 @observable FunctionKind kind; 2647 @observable M.FunctionKind kind;
2678 @observable int deoptimizations; 2648 @observable int deoptimizations;
2679 @observable String qualifiedName; 2649 @observable String qualifiedName;
2680 @observable int usageCounter; 2650 @observable int usageCounter;
2681 @observable bool isDart; 2651 @observable bool isDart;
2682 @observable ProfileFunction profile; 2652 @observable ProfileFunction profile;
2683 @observable Instance icDataArray; 2653 @observable Instance icDataArray;
2684 @observable Field field; 2654 @observable Field field;
2685 2655
2686 bool get canCache => true; 2656 bool get canCache => true;
2687 bool get immutable => false; 2657 bool get immutable => false;
2688 2658
2689 ServiceFunction._empty(ServiceObject owner) : super._empty(owner); 2659 ServiceFunction._empty(ServiceObject owner) : super._empty(owner);
2690 2660
2691 void _update(ObservableMap map, bool mapIsRef) { 2661 void _update(ObservableMap map, bool mapIsRef) {
2692 _upgradeCollection(map, isolate); 2662 _upgradeCollection(map, isolate);
2693 super._update(map, mapIsRef); 2663 super._update(map, mapIsRef);
2694 2664
2695 name = map['name']; 2665 name = map['name'];
2696 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name); 2666 vmName = (map.containsKey('_vmName') ? map['_vmName'] : name);
2697 2667
2698 dartOwner = map['owner']; 2668 dartOwner = map['owner'];
2699 kind = FunctionKind.fromJSON(map['_kind']); 2669 kind = stringToFunctionKind(map['_kind']);
2700 isDart = kind.isDart(); 2670 isDart = M.isDartFunction(kind);
2701 2671
2702 if (dartOwner is ServiceFunction) { 2672 if (dartOwner is ServiceFunction) {
2703 ServiceFunction ownerFunction = dartOwner; 2673 ServiceFunction ownerFunction = dartOwner;
2704 library = ownerFunction.library; 2674 library = ownerFunction.library;
2705 qualifiedName = "${ownerFunction.qualifiedName}.${name}"; 2675 qualifiedName = "${ownerFunction.qualifiedName}.${name}";
2706 2676
2707 } else if (dartOwner is Class) { 2677 } else if (dartOwner is Class) {
2708 Class ownerClass = dartOwner; 2678 Class ownerClass = dartOwner;
2709 library = ownerClass.library; 2679 library = ownerClass.library;
2710 qualifiedName = "${ownerClass.name}.${name}"; 2680 qualifiedName = "${ownerClass.name}.${name}";
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
3543 return; 3513 return;
3544 } 3514 }
3545 if (relativeAddress >= instructionsByAddressOffset.length) { 3515 if (relativeAddress >= instructionsByAddressOffset.length) {
3546 Logger.root.warning('Bad address resolving jump target $relativeAddress'); 3516 Logger.root.warning('Bad address resolving jump target $relativeAddress');
3547 return; 3517 return;
3548 } 3518 }
3549 jumpTarget = instructionsByAddressOffset[relativeAddress]; 3519 jumpTarget = instructionsByAddressOffset[relativeAddress];
3550 } 3520 }
3551 } 3521 }
3552 3522
3553 class CodeKind { 3523 M.CodeKind stringToCodeKind(String s) {
3554 final _value; 3524 if (s == 'Native') {
3555 const CodeKind._internal(this._value); 3525 return M.CodeKind.native;
3556 String toString() => '$_value'; 3526 } else if (s == 'Dart') {
3557 bool isSynthetic() => [Collected, Native, Tag].contains(this); 3527 return M.CodeKind.dart;
3558 bool isDart() => !isSynthetic(); 3528 } else if (s == 'Collected') {
3559 static CodeKind fromString(String s) { 3529 return M.CodeKind.collected;
3560 if (s == 'Native') { 3530 } else if (s == 'Tag') {
3561 return Native; 3531 return M.CodeKind.tag;
3562 } else if (s == 'Dart') { 3532 } else if (s == 'Stub') {
3563 return Dart; 3533 return M.CodeKind.stub;
3564 } else if (s == 'Collected') {
3565 return Collected;
3566 } else if (s == 'Tag') {
3567 return Tag;
3568 } else if (s == 'Stub') {
3569 return Stub;
3570 }
3571 Logger.root.severe("Unrecognized code kind: '$s'");
3572 throw new FallThroughError();
3573 } 3534 }
3574 static const Collected = const CodeKind._internal('Collected'); 3535 Logger.root.severe("Unrecognized code kind: '$s'");
3575 static const Dart = const CodeKind._internal('Dart'); 3536 throw new FallThroughError();
3576 static const Native = const CodeKind._internal('Native');
3577 static const Stub = const CodeKind._internal('Stub');
3578 static const Tag = const CodeKind._internal('Tag');
3579 } 3537 }
3580 3538
3581 class CodeInlineInterval { 3539 class CodeInlineInterval {
3582 final int start; 3540 final int start;
3583 final int end; 3541 final int end;
3584 final List<ServiceFunction> functions = new List<ServiceFunction>(); 3542 final List<ServiceFunction> functions = new List<ServiceFunction>();
3585 bool contains(int pc) => (pc >= start) && (pc < end); 3543 bool contains(int pc) => (pc >= start) && (pc < end);
3586 CodeInlineInterval(this.start, this.end); 3544 CodeInlineInterval(this.start, this.end);
3587 } 3545 }
3588 3546
3589 class Code extends HeapObject { 3547 class Code extends HeapObject implements M.Code {
3590 @observable CodeKind kind; 3548 @observable M.CodeKind kind;
3591 @observable ServiceObject objectPool; 3549 @observable ServiceObject objectPool;
3592 @observable ServiceFunction function; 3550 @observable ServiceFunction function;
3593 @observable Script script; 3551 @observable Script script;
3594 @observable bool isOptimized; 3552 @observable bool isOptimized;
3595 @observable bool hasIntrinsic; 3553 @observable bool hasIntrinsic;
3596 @observable bool isNative; 3554 @observable bool isNative;
3597 3555
3598 @reflectable int startAddress = 0; 3556 @reflectable int startAddress = 0;
3599 @reflectable int endAddress = 0; 3557 @reflectable int endAddress = 0;
3600 @reflectable final instructions = new ObservableList<CodeInstruction>(); 3558 @reflectable final instructions = new ObservableList<CodeInstruction>();
(...skipping 16 matching lines...) Expand all
3617 descriptor.processScript(script); 3575 descriptor.processScript(script);
3618 } 3576 }
3619 } 3577 }
3620 } 3578 }
3621 3579
3622 void loadScript() { 3580 void loadScript() {
3623 if (script != null) { 3581 if (script != null) {
3624 // Already done. 3582 // Already done.
3625 return; 3583 return;
3626 } 3584 }
3627 if (kind != CodeKind.Dart){ 3585 if (kind != M.CodeKind.dart){
3628 return; 3586 return;
3629 } 3587 }
3630 if (function == null) { 3588 if (function == null) {
3631 return; 3589 return;
3632 } 3590 }
3633 if ((function.location == null) || 3591 if ((function.location == null) ||
3634 (function.location.script == null)) { 3592 (function.location.script == null)) {
3635 // Attempt to load the function. 3593 // Attempt to load the function.
3636 function.load().then((func) { 3594 function.load().then((func) {
3637 var script = function.location.script; 3595 var script = function.location.script;
(...skipping 18 matching lines...) Expand all
3656 // We only reload Dart code. 3614 // We only reload Dart code.
3657 return super.reload(count: count); 3615 return super.reload(count: count);
3658 } 3616 }
3659 return new Future.value(this); 3617 return new Future.value(this);
3660 } 3618 }
3661 3619
3662 void _update(ObservableMap m, bool mapIsRef) { 3620 void _update(ObservableMap m, bool mapIsRef) {
3663 name = m['name']; 3621 name = m['name'];
3664 vmName = (m.containsKey('_vmName') ? m['_vmName'] : name); 3622 vmName = (m.containsKey('_vmName') ? m['_vmName'] : name);
3665 isOptimized = m['_optimized']; 3623 isOptimized = m['_optimized'];
3666 kind = CodeKind.fromString(m['kind']); 3624 kind = stringToCodeKind(m['kind']);
3667 hasIntrinsic = m['_intrinsic']; 3625 hasIntrinsic = m['_intrinsic'];
3668 isNative = m['_native']; 3626 isNative = m['_native'];
3669 if (mapIsRef) { 3627 if (mapIsRef) {
3670 return; 3628 return;
3671 } 3629 }
3672 _loaded = true; 3630 _loaded = true;
3673 startAddress = int.parse(m['_startAddress'], radix:16); 3631 startAddress = int.parse(m['_startAddress'], radix:16);
3674 endAddress = int.parse(m['_endAddress'], radix:16); 3632 endAddress = int.parse(m['_endAddress'], radix:16);
3675 function = isolate.getFromMap(m['function']); 3633 function = isolate.getFromMap(m['function']);
3676 objectPool = isolate.getFromMap(m['_objectPool']); 3634 objectPool = isolate.getFromMap(m['_objectPool']);
3677 var disassembly = m['_disassembly']; 3635 var disassembly = m['_disassembly'];
3678 if (disassembly != null) { 3636 if (disassembly != null) {
3679 _processDisassembly(disassembly); 3637 _processDisassembly(disassembly);
3680 } 3638 }
3681 var descriptors = m['_descriptors']; 3639 var descriptors = m['_descriptors'];
3682 if (descriptors != null) { 3640 if (descriptors != null) {
3683 descriptors = descriptors['members']; 3641 descriptors = descriptors['members'];
3684 _processDescriptors(descriptors); 3642 _processDescriptors(descriptors);
3685 } 3643 }
3686 hasDisassembly = (instructions.length != 0) && (kind == CodeKind.Dart); 3644 hasDisassembly = (instructions.length != 0) && (kind == M.CodeKind.dart);
3687 inlinedFunctions.clear(); 3645 inlinedFunctions.clear();
3688 var inlinedFunctionsTable = m['_inlinedFunctions']; 3646 var inlinedFunctionsTable = m['_inlinedFunctions'];
3689 var inlinedIntervals = m['_inlinedIntervals']; 3647 var inlinedIntervals = m['_inlinedIntervals'];
3690 if (inlinedFunctionsTable != null) { 3648 if (inlinedFunctionsTable != null) {
3691 // Iterate and upgrade each ServiceFunction. 3649 // Iterate and upgrade each ServiceFunction.
3692 for (var i = 0; i < inlinedFunctionsTable.length; i++) { 3650 for (var i = 0; i < inlinedFunctionsTable.length; i++) {
3693 // Upgrade each function and set it back in the list. 3651 // Upgrade each function and set it back in the list.
3694 var func = isolate.getFromMap(inlinedFunctionsTable[i]); 3652 var func = isolate.getFromMap(inlinedFunctionsTable[i]);
3695 inlinedFunctionsTable[i] = func; 3653 inlinedFunctionsTable[i] = func;
3696 if (!inlinedFunctions.contains(func)) { 3654 if (!inlinedFunctions.contains(func)) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
3794 'Could not find instruction with pc descriptor address: $address'); 3752 'Could not find instruction with pc descriptor address: $address');
3795 } 3753 }
3796 } 3754 }
3797 } 3755 }
3798 3756
3799 /// Returns true if [address] is contained inside [this]. 3757 /// Returns true if [address] is contained inside [this].
3800 bool contains(int address) { 3758 bool contains(int address) {
3801 return (address >= startAddress) && (address < endAddress); 3759 return (address >= startAddress) && (address < endAddress);
3802 } 3760 }
3803 3761
3804 @reflectable bool get isDartCode => (kind == CodeKind.Dart) || 3762 @reflectable bool get isDartCode => (kind == M.CodeKind.dart) ||
3805 (kind == CodeKind.Stub); 3763 (kind == M.CodeKind.stub);
3806 3764
3807 String toString() => 'Code($kind, $name)'; 3765 String toString() => 'Code($kind, $name)';
3808 } 3766 }
3809 3767
3810 3768
3811 class SocketKind { 3769 class SocketKind {
3812 final _value; 3770 final _value;
3813 const SocketKind._internal(this._value); 3771 const SocketKind._internal(this._value);
3814 String toString() => '$_value'; 3772 String toString() => '$_value';
3815 3773
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 var v = list[i]; 4093 var v = list[i];
4136 if ((v is ObservableMap) && _isServiceMap(v)) { 4094 if ((v is ObservableMap) && _isServiceMap(v)) {
4137 list[i] = owner.getFromMap(v); 4095 list[i] = owner.getFromMap(v);
4138 } else if (v is ObservableList) { 4096 } else if (v is ObservableList) {
4139 _upgradeObservableList(v, owner); 4097 _upgradeObservableList(v, owner);
4140 } else if (v is ObservableMap) { 4098 } else if (v is ObservableMap) {
4141 _upgradeObservableMap(v, owner); 4099 _upgradeObservableMap(v, owner);
4142 } 4100 }
4143 } 4101 }
4144 } 4102 }
OLDNEW
« no previous file with comments | « runtime/observatory/lib/src/models/objects/function.dart ('k') | runtime/observatory/observatory_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698