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

Side by Side Diff: runtime/vm/message.cc

Issue 1499853004: Adds a special case for sending an int over a port with the native API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include "vm/message.h" 5 #include "vm/message.h"
6 6
7 #include "vm/dart_entry.h" 7 #include "vm/dart_entry.h"
8 #include "vm/json_stream.h" 8 #include "vm/json_stream.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/port.h" 10 #include "vm/port.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 MessageQueue::Iterator it(this); 188 MessageQueue::Iterator it(this);
189 intptr_t depth = 0; 189 intptr_t depth = 0;
190 while (it.HasNext()) { 190 while (it.HasNext()) {
191 Message* current = it.Next(); 191 Message* current = it.Next();
192 JSONObject message(&messages); 192 JSONObject message(&messages);
193 message.AddProperty("type", "Message"); 193 message.AddProperty("type", "Message");
194 message.AddPropertyF("name", "Isolate Message (%" Px ")", current->Id()); 194 message.AddPropertyF("name", "Isolate Message (%" Px ")", current->Id());
195 message.AddPropertyF("messageObjectId", "messages/%" Px "", 195 message.AddPropertyF("messageObjectId", "messages/%" Px "",
196 current->Id()); 196 current->Id());
197 message.AddProperty("size", current->len()); 197 if (current->type() == Message::kDataType) {
198 message.AddProperty("size", current->len());
199 } else {
200 ASSERT(current->type() == Message::kIntegerType);
201 message.AddProperty("integer", current->integer());
202 }
198 message.AddProperty("index", depth++); 203 message.AddProperty("index", depth++);
199 message.AddPropertyF("_destinationPort", "%" Pd64 "", 204 message.AddPropertyF("_destinationPort", "%" Pd64 "",
200 static_cast<int64_t>(current->dest_port())); 205 static_cast<int64_t>(current->dest_port()));
201 message.AddProperty("_priority", 206 message.AddProperty("_priority",
202 Message::PriorityAsString(current->priority())); 207 Message::PriorityAsString(current->priority()));
203 // TODO(johnmccutchan): Move port -> handler map out of Dart and into the 208 // TODO(johnmccutchan): Move port -> handler map out of Dart and into the
204 // VM, that way we can lookup the handler without invoking Dart code. 209 // VM, that way we can lookup the handler without invoking Dart code.
205 msg_handler = DartLibraryCalls::LookupHandler(current->dest_port()); 210 msg_handler = DartLibraryCalls::LookupHandler(current->dest_port());
206 if (msg_handler.IsInstance() && Instance::Cast(msg_handler).IsClosure()) { 211 if (msg_handler.IsInstance() && Instance::Cast(msg_handler).IsClosure()) {
207 // Grab function from closure. 212 // Grab function from closure.
208 msg_handler = Closure::function(Instance::Cast(msg_handler)); 213 msg_handler = Closure::function(Instance::Cast(msg_handler));
209 } 214 }
210 if (msg_handler.IsFunction()) { 215 if (msg_handler.IsFunction()) {
211 const Function& function = Function::Cast(msg_handler); 216 const Function& function = Function::Cast(msg_handler);
212 message.AddProperty("handler", function); 217 message.AddProperty("handler", function);
213 218
214 const Script& script = Script::Handle(function.script()); 219 const Script& script = Script::Handle(function.script());
215 if (!script.IsNull()) { 220 if (!script.IsNull()) {
216 message.AddLocation(script, function.token_pos(), 221 message.AddLocation(script, function.token_pos(),
217 function.end_token_pos()); 222 function.end_token_pos());
218 } 223 }
219 } 224 }
220 } 225 }
221 } 226 }
222 227
223 } // namespace dart 228 } // namespace dart
OLDNEW
« runtime/vm/message.h ('K') | « runtime/vm/message.h ('k') | runtime/vm/message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698