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

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 11440035: Optimize the message queue for many active ports with few messages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge with caching changes. Created 8 years 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 | « no previous file | runtime/vm/dart_entry.h » ('j') | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 patch class ReceivePort { 5 patch class ReceivePort {
6 /* patch */ factory ReceivePort() { 6 /* patch */ factory ReceivePort() {
7 return new _ReceivePortImpl(); 7 return new _ReceivePortImpl();
8 } 8 }
9 } 9 }
10 10
(...skipping 17 matching lines...) Expand all
28 // Called from the VM to create a new ReceivePort instance. 28 // Called from the VM to create a new ReceivePort instance.
29 static _ReceivePortImpl _get_or_create(int id) { 29 static _ReceivePortImpl _get_or_create(int id) {
30 if (_portMap != null) { 30 if (_portMap != null) {
31 _ReceivePortImpl port = _portMap[id]; 31 _ReceivePortImpl port = _portMap[id];
32 if (port != null) { 32 if (port != null) {
33 return port; 33 return port;
34 } 34 }
35 } 35 }
36 return new _ReceivePortImpl._internal(id); 36 return new _ReceivePortImpl._internal(id);
37 } 37 }
38
38 _ReceivePortImpl._internal(int id) : _id = id { 39 _ReceivePortImpl._internal(int id) : _id = id {
39 if (_portMap == null) { 40 if (_portMap == null) {
40 _portMap = new Map(); 41 _portMap = new Map();
41 } 42 }
42 _portMap[id] = this; 43 _portMap[id] = this;
43 } 44 }
44 45
46 // Called from the VM to retrieve the ReceivePort for a message.
47 static _ReceivePortImpl _lookupReceivePort(int id) {
48 assert(_portMap != null);
49 return _portMap[id];
50 }
51
45 // Called from the VM to dispatch to the handler. 52 // Called from the VM to dispatch to the handler.
46 static void _handleMessage(int id, int replyId, var message) { 53 static void _handleMessage(_ReceivePortImpl port, int replyId, var message) {
47 assert(_portMap != null); 54 assert(port != null);
48 ReceivePort port = _portMap[id];
49 SendPort replyTo = (replyId == 0) ? null : new _SendPortImpl(replyId); 55 SendPort replyTo = (replyId == 0) ? null : new _SendPortImpl(replyId);
50 (port._onMessage)(message, replyTo); 56 (port._onMessage)(message, replyTo);
51 } 57 }
52 58
53 // Call into the VM to close the VM maintained mappings. 59 // Call into the VM to close the VM maintained mappings.
54 static _closeInternal(int id) native "ReceivePortImpl_closeInternal"; 60 static _closeInternal(int id) native "ReceivePortImpl_closeInternal";
55 61
56 final int _id; 62 final int _id;
57 var _onMessage; 63 var _onMessage;
58 64
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 162
157 class _TimerFactory { 163 class _TimerFactory {
158 static _TimerFactoryClosure _factory; 164 static _TimerFactoryClosure _factory;
159 } 165 }
160 166
161 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets 167 // TODO(ahe): Warning: this is NOT called by Dartium. Instead, it sets
162 // [_TimerFactory._factory] directly. 168 // [_TimerFactory._factory] directly.
163 void _setTimerFactoryClosure(_TimerFactoryClosure closure) { 169 void _setTimerFactoryClosure(_TimerFactoryClosure closure) {
164 _TimerFactory._factory = closure; 170 _TimerFactory._factory = closure;
165 } 171 }
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698