| 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 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 | 961 |
| 962 | 962 |
| 963 template<class T> | 963 template<class T> |
| 964 T* Isolate::AllocateReusableHandle() { | 964 T* Isolate::AllocateReusableHandle() { |
| 965 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); | 965 T* handle = reinterpret_cast<T*>(reusable_handles_.AllocateScopedHandle()); |
| 966 T::initializeHandle(handle, T::null()); | 966 T::initializeHandle(handle, T::null()); |
| 967 return handle; | 967 return handle; |
| 968 } | 968 } |
| 969 | 969 |
| 970 | 970 |
| 971 static char* GetRootScriptUri(Isolate* isolate) { | |
| 972 const Library& library = | |
| 973 Library::Handle(isolate->object_store()->root_library()); | |
| 974 ASSERT(!library.IsNull()); | |
| 975 const String& script_name = String::Handle(library.url()); | |
| 976 return isolate->current_zone()->MakeCopyOfString(script_name.ToCString()); | |
| 977 } | |
| 978 | |
| 979 | |
| 980 IsolateSpawnState::IsolateSpawnState(const Function& func, | 971 IsolateSpawnState::IsolateSpawnState(const Function& func, |
| 981 const Function& callback_func) | 972 const Function& callback_func) |
| 982 : isolate_(NULL), | 973 : isolate_(NULL), |
| 983 script_url_(NULL), | 974 script_url_(NULL), |
| 984 library_url_(NULL), | 975 library_url_(NULL), |
| 985 function_name_(NULL), | 976 function_name_(NULL), |
| 986 exception_callback_name_(NULL) { | 977 exception_callback_name_(NULL) { |
| 987 script_url_ = strdup(GetRootScriptUri(Isolate::Current())); | 978 script_url_ = NULL; |
| 988 const Class& cls = Class::Handle(func.Owner()); | 979 const Class& cls = Class::Handle(func.Owner()); |
| 989 ASSERT(cls.IsTopLevel()); | 980 ASSERT(cls.IsTopLevel()); |
| 990 const Library& lib = Library::Handle(cls.library()); | 981 const Library& lib = Library::Handle(cls.library()); |
| 991 const String& lib_url = String::Handle(lib.url()); | 982 const String& lib_url = String::Handle(lib.url()); |
| 992 library_url_ = strdup(lib_url.ToCString()); | 983 library_url_ = strdup(lib_url.ToCString()); |
| 993 | 984 |
| 994 const String& func_name = String::Handle(func.name()); | 985 const String& func_name = String::Handle(func.name()); |
| 995 function_name_ = strdup(func_name.ToCString()); | 986 function_name_ = strdup(func_name.ToCString()); |
| 996 if (!callback_func.IsNull()) { | 987 if (!callback_func.IsNull()) { |
| 997 const String& callback_name = String::Handle(callback_func.name()); | 988 const String& callback_name = String::Handle(callback_func.name()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 return func.raw(); | 1042 return func.raw(); |
| 1052 } | 1043 } |
| 1053 | 1044 |
| 1054 | 1045 |
| 1055 void IsolateSpawnState::Cleanup() { | 1046 void IsolateSpawnState::Cleanup() { |
| 1056 SwitchIsolateScope switch_scope(isolate()); | 1047 SwitchIsolateScope switch_scope(isolate()); |
| 1057 Dart::ShutdownIsolate(); | 1048 Dart::ShutdownIsolate(); |
| 1058 } | 1049 } |
| 1059 | 1050 |
| 1060 } // namespace dart | 1051 } // namespace dart |
| OLD | NEW |