OLD | NEW |
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 #include "vm/isolate.h" | 5 #include "vm/isolate.h" |
6 | 6 |
7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/json.h" | 9 #include "platform/json.h" |
10 #include "lib/mirrors.h" | 10 #include "lib/mirrors.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 | 115 |
116 bool IsolateMessageHandler::HandleMessage(Message* message) { | 116 bool IsolateMessageHandler::HandleMessage(Message* message) { |
117 StartIsolateScope start_scope(isolate_); | 117 StartIsolateScope start_scope(isolate_); |
118 StackZone zone(isolate_); | 118 StackZone zone(isolate_); |
119 HandleScope handle_scope(isolate_); | 119 HandleScope handle_scope(isolate_); |
120 // TODO(turnidge): Rework collection total dart execution. This can | 120 // TODO(turnidge): Rework collection total dart execution. This can |
121 // overcount when other things (gc, compilation) are active. | 121 // overcount when other things (gc, compilation) are active. |
122 TIMERSCOPE(isolate_, time_dart_execution); | 122 TIMERSCOPE(isolate_, time_dart_execution); |
123 | 123 |
124 // If the message is in band we lookup the receive port to dispatch to. If | 124 // If the message is in band we lookup the handler to dispatch to. If the |
125 // the receive port is closed, we drop the message without deserializing it. | 125 // receive port was closed, we drop the message without deserializing it. |
126 Object& receive_port = Object::Handle(); | 126 Object& msg_handler = Object::Handle(); |
127 if (!message->IsOOB()) { | 127 if (!message->IsOOB()) { |
128 receive_port = DartLibraryCalls::LookupReceivePort(message->dest_port()); | 128 msg_handler = DartLibraryCalls::LookupHandler(message->dest_port()); |
129 if (receive_port.IsError()) { | 129 if (msg_handler.IsError()) { |
130 return ProcessUnhandledException(Object::null_instance(), | 130 return ProcessUnhandledException(Object::null_instance(), |
131 Error::Cast(receive_port)); | 131 Error::Cast(msg_handler)); |
132 } | 132 } |
133 if (receive_port.IsNull()) { | 133 if (msg_handler.IsNull()) { |
134 delete message; | 134 delete message; |
135 return true; | 135 return true; |
136 } | 136 } |
137 } | 137 } |
138 | 138 |
139 // Parse the message. | 139 // Parse the message. |
140 SnapshotReader reader(message->data(), message->len(), | 140 SnapshotReader reader(message->data(), message->len(), |
141 Snapshot::kMessage, Isolate::Current()); | 141 Snapshot::kMessage, Isolate::Current()); |
142 const Object& msg_obj = Object::Handle(reader.ReadObject()); | 142 const Object& msg_obj = Object::Handle(reader.ReadObject()); |
143 if (msg_obj.IsError()) { | 143 if (msg_obj.IsError()) { |
(...skipping 11 matching lines...) Expand all Loading... |
155 } | 155 } |
156 | 156 |
157 Instance& msg = Instance::Handle(); | 157 Instance& msg = Instance::Handle(); |
158 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null. | 158 msg ^= msg_obj.raw(); // Can't use Instance::Cast because may be null. |
159 | 159 |
160 bool success = true; | 160 bool success = true; |
161 if (message->IsOOB()) { | 161 if (message->IsOOB()) { |
162 Service::HandleIsolateMessage(isolate_, msg); | 162 Service::HandleIsolateMessage(isolate_, msg); |
163 } else { | 163 } else { |
164 const Object& result = Object::Handle( | 164 const Object& result = Object::Handle( |
165 DartLibraryCalls::HandleMessage(receive_port, msg)); | 165 DartLibraryCalls::HandleMessage(msg_handler, msg)); |
166 if (result.IsError()) { | 166 if (result.IsError()) { |
167 success = ProcessUnhandledException(msg, Error::Cast(result)); | 167 success = ProcessUnhandledException(msg, Error::Cast(result)); |
168 } else { | 168 } else { |
169 ASSERT(result.IsNull()); | 169 ASSERT(result.IsNull()); |
170 } | 170 } |
171 } | 171 } |
172 delete message; | 172 delete message; |
173 return success; | 173 return success; |
174 } | 174 } |
175 | 175 |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 return func.raw(); | 1167 return func.raw(); |
1168 } | 1168 } |
1169 | 1169 |
1170 | 1170 |
1171 void IsolateSpawnState::Cleanup() { | 1171 void IsolateSpawnState::Cleanup() { |
1172 SwitchIsolateScope switch_scope(isolate()); | 1172 SwitchIsolateScope switch_scope(isolate()); |
1173 Dart::ShutdownIsolate(); | 1173 Dart::ShutdownIsolate(); |
1174 } | 1174 } |
1175 | 1175 |
1176 } // namespace dart | 1176 } // namespace dart |
OLD | NEW |