| 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 "include/dart_native_api.h" | 8 #include "include/dart_native_api.h" | 
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" | 
| 10 #include "platform/json.h" | 10 #include "platform/json.h" | 
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 210 const char* IsolateMessageHandler::name() const { | 210 const char* IsolateMessageHandler::name() const { | 
| 211   return isolate_->name(); | 211   return isolate_->name(); | 
| 212 } | 212 } | 
| 213 | 213 | 
| 214 | 214 | 
| 215 // Isolate library OOB messages are fixed sized arrays which have the | 215 // Isolate library OOB messages are fixed sized arrays which have the | 
| 216 // following format: | 216 // following format: | 
| 217 // [ OOB dispatch, Isolate library dispatch, <message specific data> ] | 217 // [ OOB dispatch, Isolate library dispatch, <message specific data> ] | 
| 218 RawError* IsolateMessageHandler::HandleLibMessage(const Array& message) { | 218 RawError* IsolateMessageHandler::HandleLibMessage(const Array& message) { | 
| 219   if (message.Length() < 2) return Error::null(); | 219   if (message.Length() < 2) return Error::null(); | 
| 220   Zone* zone = I->current_zone(); | 220   Zone* zone = T->zone(); | 
| 221   const Object& type = Object::Handle(zone, message.At(1)); | 221   const Object& type = Object::Handle(zone, message.At(1)); | 
| 222   if (!type.IsSmi()) return Error::null(); | 222   if (!type.IsSmi()) return Error::null(); | 
| 223   const intptr_t msg_type = Smi::Cast(type).Value(); | 223   const intptr_t msg_type = Smi::Cast(type).Value(); | 
| 224   switch (msg_type) { | 224   switch (msg_type) { | 
| 225     case Isolate::kPauseMsg: { | 225     case Isolate::kPauseMsg: { | 
| 226       // [ OOB, kPauseMsg, pause capability, resume capability ] | 226       // [ OOB, kPauseMsg, pause capability, resume capability ] | 
| 227       if (message.Length() != 4) return Error::null(); | 227       if (message.Length() != 4) return Error::null(); | 
| 228       Object& obj = Object::Handle(zone, message.At(2)); | 228       Object& obj = Object::Handle(zone, message.At(2)); | 
| 229       if (!I->VerifyPauseCapability(obj)) return Error::null(); | 229       if (!I->VerifyPauseCapability(obj)) return Error::null(); | 
| 230       obj = message.At(3); | 230       obj = message.At(3); | 
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 633 | 633 | 
| 634   // Invoke the isolate's unhandled exception callback if there is one. | 634   // Invoke the isolate's unhandled exception callback if there is one. | 
| 635   if (Isolate::UnhandledExceptionCallback() != NULL) { | 635   if (Isolate::UnhandledExceptionCallback() != NULL) { | 
| 636     Dart_EnterScope(); | 636     Dart_EnterScope(); | 
| 637     Dart_Handle error = Api::NewHandle(I, result.raw()); | 637     Dart_Handle error = Api::NewHandle(I, result.raw()); | 
| 638     (Isolate::UnhandledExceptionCallback())(error); | 638     (Isolate::UnhandledExceptionCallback())(error); | 
| 639     Dart_ExitScope(); | 639     Dart_ExitScope(); | 
| 640   } | 640   } | 
| 641 | 641 | 
| 642   // Generate the error and stacktrace strings for the error message. | 642   // Generate the error and stacktrace strings for the error message. | 
| 643   String& exc_str = String::Handle(I->current_zone()); | 643   String& exc_str = String::Handle(T->zone()); | 
| 644   String& stacktrace_str = String::Handle(I->current_zone()); | 644   String& stacktrace_str = String::Handle(T->zone()); | 
| 645   if (result.IsUnhandledException()) { | 645   if (result.IsUnhandledException()) { | 
| 646     Zone* zone = I->current_zone(); | 646     Zone* zone = T->zone(); | 
| 647     const UnhandledException& uhe = UnhandledException::Cast(result); | 647     const UnhandledException& uhe = UnhandledException::Cast(result); | 
| 648     const Instance& exception = Instance::Handle(zone, uhe.exception()); | 648     const Instance& exception = Instance::Handle(zone, uhe.exception()); | 
| 649     Object& tmp = Object::Handle(zone); | 649     Object& tmp = Object::Handle(zone); | 
| 650     tmp = DartLibraryCalls::ToString(exception); | 650     tmp = DartLibraryCalls::ToString(exception); | 
| 651     if (!tmp.IsString()) { | 651     if (!tmp.IsString()) { | 
| 652       tmp = String::New(exception.ToCString()); | 652       tmp = String::New(exception.ToCString()); | 
| 653     } | 653     } | 
| 654     exc_str ^= tmp.raw(); | 654     exc_str ^= tmp.raw(); | 
| 655 | 655 | 
| 656     const Instance& stacktrace = Instance::Handle(zone, uhe.stacktrace()); | 656     const Instance& stacktrace = Instance::Handle(zone, uhe.stacktrace()); | 
| (...skipping 1233 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1890       Library::Handle(object_store()->root_library()); | 1890       Library::Handle(object_store()->root_library()); | 
| 1891   if (!lib.IsNull()) { | 1891   if (!lib.IsNull()) { | 
| 1892     jsobj.AddProperty("rootLib", lib); | 1892     jsobj.AddProperty("rootLib", lib); | 
| 1893   } | 1893   } | 
| 1894 | 1894 | 
| 1895   { | 1895   { | 
| 1896     JSONObject tagCounters(&jsobj, "_tagCounters"); | 1896     JSONObject tagCounters(&jsobj, "_tagCounters"); | 
| 1897     vm_tag_counters()->PrintToJSONObject(&tagCounters); | 1897     vm_tag_counters()->PrintToJSONObject(&tagCounters); | 
| 1898   } | 1898   } | 
| 1899   if (object_store()->sticky_error() != Object::null()) { | 1899   if (object_store()->sticky_error() != Object::null()) { | 
| 1900     Error& error = Error::Handle(current_zone(), | 1900     Error& error = Error::Handle(object_store()->sticky_error()); | 
| 1901         object_store()->sticky_error()); |  | 
| 1902     ASSERT(!error.IsNull()); | 1901     ASSERT(!error.IsNull()); | 
| 1903     jsobj.AddProperty("error", error, false); | 1902     jsobj.AddProperty("error", error, false); | 
| 1904   } | 1903   } | 
| 1905 | 1904 | 
| 1906   { | 1905   { | 
| 1907     const GrowableObjectArray& libs = | 1906     const GrowableObjectArray& libs = | 
| 1908         GrowableObjectArray::Handle(object_store()->libraries()); | 1907         GrowableObjectArray::Handle(object_store()->libraries()); | 
| 1909     intptr_t num_libs = libs.Length(); | 1908     intptr_t num_libs = libs.Length(); | 
| 1910     Library& lib = Library::Handle(); | 1909     Library& lib = Library::Handle(); | 
| 1911 | 1910 | 
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2612                            serialized_message_, serialized_message_len_); | 2611                            serialized_message_, serialized_message_len_); | 
| 2613 } | 2612 } | 
| 2614 | 2613 | 
| 2615 | 2614 | 
| 2616 void IsolateSpawnState::Cleanup() { | 2615 void IsolateSpawnState::Cleanup() { | 
| 2617   SwitchIsolateScope switch_scope(I); | 2616   SwitchIsolateScope switch_scope(I); | 
| 2618   Dart::ShutdownIsolate(); | 2617   Dart::ShutdownIsolate(); | 
| 2619 } | 2618 } | 
| 2620 | 2619 | 
| 2621 }  // namespace dart | 2620 }  // namespace dart | 
| OLD | NEW | 
|---|