OLD | NEW |
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 Isolate* isolate = Isolate::Current(); | 184 Isolate* isolate = Isolate::Current(); |
185 JSONArray messages(stream); | 185 JSONArray messages(stream); |
186 | 186 |
187 Object& msg_handler = Object::Handle(isolate); | 187 Object& msg_handler = Object::Handle(isolate); |
188 | 188 |
189 MessageQueue::Iterator it(this); | 189 MessageQueue::Iterator it(this); |
190 intptr_t depth = 0; | 190 intptr_t depth = 0; |
191 while (it.HasNext()) { | 191 while (it.HasNext()) { |
192 Message* current = it.Next(); | 192 Message* current = it.Next(); |
193 JSONObject message(&messages); | 193 JSONObject message(&messages); |
194 message.AddProperty("type", "Message"); | |
195 message.AddPropertyF("name", "Isolate Message (%" Px ")", current->Id()); | 194 message.AddPropertyF("name", "Isolate Message (%" Px ")", current->Id()); |
196 message.AddPropertyF("messageObjectId", "messages/%" Px "", | 195 message.AddPropertyF("messageObjectId", "messages/%" Px "", |
197 current->Id()); | 196 current->Id()); |
198 message.AddProperty("size", current->len()); | 197 message.AddProperty("size", current->len()); |
199 message.AddProperty("depth", depth++); | 198 message.AddProperty("index", depth++); |
200 message.AddProperty("_destinationPort", | 199 message.AddProperty("_destinationPort", |
201 static_cast<intptr_t>(current->dest_port())); | 200 static_cast<intptr_t>(current->dest_port())); |
202 message.AddProperty("priority", | 201 message.AddProperty("_priority", |
203 Message::PriorityAsString(current->priority())); | 202 Message::PriorityAsString(current->priority())); |
204 // TODO(johnmccutchan): Move port -> handler map out of Dart and into the | 203 // TODO(johnmccutchan): Move port -> handler map out of Dart and into the |
205 // VM, that way we can lookup the handler without invoking Dart code. | 204 // VM, that way we can lookup the handler without invoking Dart code. |
206 msg_handler = DartLibraryCalls::LookupHandler(current->dest_port()); | 205 msg_handler = DartLibraryCalls::LookupHandler(current->dest_port()); |
207 if (msg_handler.IsInstance() && Instance::Cast(msg_handler).IsClosure()) { | 206 if (msg_handler.IsInstance() && Instance::Cast(msg_handler).IsClosure()) { |
208 // Grab function from closure. | 207 // Grab function from closure. |
209 msg_handler = Closure::function(Instance::Cast(msg_handler)); | 208 msg_handler = Closure::function(Instance::Cast(msg_handler)); |
210 } | 209 } |
211 if (!msg_handler.IsFunction()) { | 210 if (!msg_handler.IsFunction()) { |
212 // No handler function. | 211 // No handler function. |
213 continue; | 212 continue; |
214 } | 213 } |
215 const Function& function = Function::Cast(msg_handler); | 214 const Function& function = Function::Cast(msg_handler); |
216 const Script& script = Script::Handle(function.script()); | 215 const Script& script = Script::Handle(function.script()); |
217 message.AddProperty("handlerFunction", function); | 216 message.AddProperty("handlerFunction", function); |
218 message.AddProperty("handlerScript", script); | 217 message.AddProperty("handlerScript", script); |
219 message.AddProperty("handlerTokenPos", function.token_pos()); | 218 message.AddProperty("handlerTokenPos", function.token_pos()); |
220 } | 219 } |
221 } | 220 } |
222 | 221 |
223 } // namespace dart | 222 } // namespace dart |
OLD | NEW |