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

Side by Side Diff: runtime/vm/service/vmservice.dart

Issue 533073005: Reduce service isolate startup time from ~80ms to ~30ms (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library vmservice; 5 library vmservice;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:isolate'; 9 import 'dart:isolate';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
11 11
12 part 'client.dart'; 12 part 'client.dart';
13 part 'constants.dart'; 13 part 'constants.dart';
14 part 'running_isolate.dart'; 14 part 'running_isolate.dart';
15 part 'running_isolates.dart'; 15 part 'running_isolates.dart';
16 part 'message.dart'; 16 part 'message.dart';
17 part 'message_router.dart'; 17 part 'message_router.dart';
18 18
19 final RawReceivePort isolateLifecyclePort = new RawReceivePort();
20 final RawReceivePort scriptLoadPort = new RawReceivePort();
21
19 class VMService extends MessageRouter { 22 class VMService extends MessageRouter {
20 static VMService _instance; 23 static VMService _instance;
21 /// Collection of currently connected clients. 24 /// Collection of currently connected clients.
22 final Set<Client> clients = new Set<Client>(); 25 final Set<Client> clients = new Set<Client>();
23 26
24 // A map encoding which clients are interested in which kinds of events. 27 // A map encoding which clients are interested in which kinds of events.
25 final Map<int, Set<Client>> eventMap = new Map<int, Set<Client>>(); 28 final Map<int, Set<Client>> eventMap = new Map<int, Set<Client>>();
26 29
27 /// Collection of currently running isolates. 30 /// Collection of currently running isolates.
28 RunningIsolates runningIsolates = new RunningIsolates(); 31 RunningIsolates runningIsolates = new RunningIsolates();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 if (message is List && message.length == 4) { 100 if (message is List && message.length == 4) {
98 _controlMessageHandler(message[0], message[1], message[2], message[3]); 101 _controlMessageHandler(message[0], message[1], message[2], message[3]);
99 } else if (message is List && message.length == 2) { 102 } else if (message is List && message.length == 2) {
100 _eventMessageHandler(message[0], message[1]); 103 _eventMessageHandler(message[0], message[1]);
101 } else { 104 } else {
102 Logger.root.severe('Unexpected message: $message'); 105 Logger.root.severe('Unexpected message: $message');
103 } 106 }
104 } 107 }
105 108
106 VMService._internal() 109 VMService._internal()
107 : eventPort = new RawReceivePort() { 110 : eventPort = isolateLifecyclePort {
108 eventPort.handler = messageHandler; 111 eventPort.handler = messageHandler;
109 } 112 }
110 113
111 factory VMService() { 114 factory VMService() {
112 if (VMService._instance == null) { 115 if (VMService._instance == null) {
113 VMService._instance = new VMService._internal(); 116 VMService._instance = new VMService._internal();
117 _onStart();
114 } 118 }
115 return _instance; 119 return _instance;
116 } 120 }
117 121
118 void _clientCollection(Message message) { 122 void _clientCollection(Message message) {
119 var members = []; 123 var members = [];
120 var result = {}; 124 var result = {};
121 clients.forEach((client) { 125 clients.forEach((client) {
122 members.add(client.toJson()); 126 members.add(client.toJson());
123 }); 127 });
(...skipping 11 matching lines...) Expand all
135 return message.response; 139 return message.response;
136 } 140 }
137 if (message.path[0] == 'isolates') { 141 if (message.path[0] == 'isolates') {
138 return runningIsolates.route(message); 142 return runningIsolates.route(message);
139 } 143 }
140 return message.sendToVM(); 144 return message.sendToVM();
141 } 145 }
142 } 146 }
143 147
144 RawReceivePort boot() { 148 RawReceivePort boot() {
145 // Boot the VMService.
146 // Return the port we expect isolate startup and shutdown messages on. 149 // Return the port we expect isolate startup and shutdown messages on.
147 return new VMService().eventPort; 150 return isolateLifecyclePort;
148 } 151 }
149 152
150 void _registerIsolate(int port_id, SendPort sp, String name) { 153 void _registerIsolate(int port_id, SendPort sp, String name) {
151 var service = new VMService(); 154 var service = new VMService();
152 service.runningIsolates.isolateStartup(port_id, sp, name); 155 service.runningIsolates.isolateStartup(port_id, sp, name);
153 } 156 }
154 157
155 void _setEventMask(int mask) 158 void _setEventMask(int mask)
156 native "VMService_SetEventMask"; 159 native "VMService_SetEventMask";
160
161 void _onStart() native "VMService_OnStart";
OLDNEW
« no previous file with comments | « runtime/vm/service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698