Chromium Code Reviews| 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 "vm/code_observers.h" | 10 #include "vm/code_observers.h" |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 | 562 |
| 563 const Instance& stacktrace = Instance::Handle(I, uhe.stacktrace()); | 563 const Instance& stacktrace = Instance::Handle(I, uhe.stacktrace()); |
| 564 tmp = DartLibraryCalls::ToString(stacktrace); | 564 tmp = DartLibraryCalls::ToString(stacktrace); |
| 565 if (!tmp.IsString()) { | 565 if (!tmp.IsString()) { |
| 566 tmp = String::New(stacktrace.ToCString()); | 566 tmp = String::New(stacktrace.ToCString()); |
| 567 } | 567 } |
| 568 stacktrace_str ^= tmp.raw();; | 568 stacktrace_str ^= tmp.raw();; |
| 569 } else { | 569 } else { |
| 570 exc_str = String::New(result.ToErrorCString()); | 570 exc_str = String::New(result.ToErrorCString()); |
| 571 } | 571 } |
| 572 I->NotifyErrorListeners(exc_str, stacktrace_str); | 572 bool has_listener = I->NotifyErrorListeners(exc_str, stacktrace_str); |
| 573 | 573 |
| 574 if (I->ErrorsFatal()) { | 574 if (I->ErrorsFatal()) { |
| 575 I->object_store()->set_sticky_error(result); | 575 if (has_listener) { |
| 576 const String& msg = String::Handle(String::New("isolate terminated")); | |
| 577 const UnwindError& error = UnwindError::Handle(UnwindError::New(msg)); | |
| 578 I->object_store()->set_sticky_error(error); | |
|
Ivan Posva
2015/08/14 05:18:30
If we have notified the listener, then we can just
| |
| 579 } else { | |
| 580 I->object_store()->set_sticky_error(result); | |
| 581 } | |
| 576 return false; | 582 return false; |
| 577 } | 583 } |
| 578 return true; | 584 return true; |
| 579 } | 585 } |
| 580 | 586 |
| 581 | 587 |
| 582 Isolate::Flags::Flags() | 588 Isolate::Flags::Flags() |
| 583 : type_checks_(FLAG_enable_type_checks), | 589 : type_checks_(FLAG_enable_type_checks), |
| 584 asserts_(FLAG_enable_asserts), | 590 asserts_(FLAG_enable_asserts), |
| 585 error_on_bad_type_(FLAG_error_on_bad_type), | 591 error_on_bad_type_(FLAG_error_on_bad_type), |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1196 if (!current.IsNull() && (current.Id() == listener.Id())) { | 1202 if (!current.IsNull() && (current.Id() == listener.Id())) { |
| 1197 // Remove the matching listener from the list. | 1203 // Remove the matching listener from the list. |
| 1198 current = SendPort::null(); | 1204 current = SendPort::null(); |
| 1199 listeners.SetAt(i, current); | 1205 listeners.SetAt(i, current); |
| 1200 return; | 1206 return; |
| 1201 } | 1207 } |
| 1202 } | 1208 } |
| 1203 } | 1209 } |
| 1204 | 1210 |
| 1205 | 1211 |
| 1206 void Isolate::NotifyErrorListeners(const String& msg, | 1212 bool Isolate::NotifyErrorListeners(const String& msg, |
| 1207 const String& stacktrace) { | 1213 const String& stacktrace) { |
| 1208 const GrowableObjectArray& listeners = GrowableObjectArray::Handle( | 1214 const GrowableObjectArray& listeners = GrowableObjectArray::Handle( |
| 1209 this, this->object_store()->error_listeners()); | 1215 this, this->object_store()->error_listeners()); |
| 1210 if (listeners.IsNull()) return; | 1216 if (listeners.IsNull()) return false; |
| 1211 | 1217 |
| 1212 const Array& arr = Array::Handle(this, Array::New(2)); | 1218 const Array& arr = Array::Handle(this, Array::New(2)); |
| 1213 arr.SetAt(0, msg); | 1219 arr.SetAt(0, msg); |
| 1214 arr.SetAt(1, stacktrace); | 1220 arr.SetAt(1, stacktrace); |
| 1215 SendPort& listener = SendPort::Handle(this); | 1221 SendPort& listener = SendPort::Handle(this); |
| 1216 for (intptr_t i = 0; i < listeners.Length(); i++) { | 1222 for (intptr_t i = 0; i < listeners.Length(); i++) { |
| 1217 listener ^= listeners.At(i); | 1223 listener ^= listeners.At(i); |
| 1218 if (!listener.IsNull()) { | 1224 if (!listener.IsNull()) { |
| 1219 Dart_Port port_id = listener.Id(); | 1225 Dart_Port port_id = listener.Id(); |
| 1220 uint8_t* data = NULL; | 1226 uint8_t* data = NULL; |
| 1221 intptr_t len = 0; | 1227 intptr_t len = 0; |
| 1222 SerializeObject(arr, &data, &len, false); | 1228 SerializeObject(arr, &data, &len, false); |
| 1223 Message* msg = new Message(port_id, data, len, Message::kNormalPriority); | 1229 Message* msg = new Message(port_id, data, len, Message::kNormalPriority); |
| 1224 PortMap::PostMessage(msg); | 1230 PortMap::PostMessage(msg); |
| 1225 } | 1231 } |
| 1226 } | 1232 } |
| 1233 return listeners.Length() > 0; | |
| 1227 } | 1234 } |
| 1228 | 1235 |
| 1229 | 1236 |
| 1230 static void StoreError(Isolate* isolate, const Object& obj) { | 1237 static void StoreError(Isolate* isolate, const Object& obj) { |
| 1231 ASSERT(obj.IsError()); | 1238 ASSERT(obj.IsError()); |
| 1232 isolate->object_store()->set_sticky_error(Error::Cast(obj)); | 1239 isolate->object_store()->set_sticky_error(Error::Cast(obj)); |
| 1233 } | 1240 } |
| 1234 | 1241 |
| 1235 | 1242 |
| 1236 static bool RunIsolate(uword parameter) { | 1243 static bool RunIsolate(uword parameter) { |
| (...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2160 serialized_message_, serialized_message_len_); | 2167 serialized_message_, serialized_message_len_); |
| 2161 } | 2168 } |
| 2162 | 2169 |
| 2163 | 2170 |
| 2164 void IsolateSpawnState::Cleanup() { | 2171 void IsolateSpawnState::Cleanup() { |
| 2165 SwitchIsolateScope switch_scope(I); | 2172 SwitchIsolateScope switch_scope(I); |
| 2166 Dart::ShutdownIsolate(); | 2173 Dart::ShutdownIsolate(); |
| 2167 } | 2174 } |
| 2168 | 2175 |
| 2169 } // namespace dart | 2176 } // namespace dart |
| OLD | NEW |