| Index: vm/dart_api_impl.cc
|
| ===================================================================
|
| --- vm/dart_api_impl.cc (revision 2601)
|
| +++ vm/dart_api_impl.cc (working copy)
|
| @@ -613,6 +613,7 @@
|
| intptr_t* size) {
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| + TIMERSCOPE(time_creating_snapshot);
|
| if (buffer == NULL) {
|
| return Api::Error("%s expects argument 'buffer' to be non-null.",
|
| CURRENT_FUNC);
|
| @@ -635,11 +636,11 @@
|
| }
|
|
|
|
|
| -DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(Dart_Handle library,
|
| - uint8_t** buffer,
|
| +DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer,
|
| intptr_t* size) {
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| + TIMERSCOPE(time_creating_snapshot);
|
| if (buffer == NULL) {
|
| return Api::Error("%s expects argument 'buffer' to be non-null.",
|
| CURRENT_FUNC);
|
| @@ -648,16 +649,17 @@
|
| return Api::Error("%s expects argument 'size' to be non-null.",
|
| CURRENT_FUNC);
|
| }
|
| - const Library& root_lib = Api::UnwrapLibraryHandle(library);
|
| - if (root_lib.IsNull()) {
|
| - RETURN_TYPE_ERROR(library, Library);
|
| - }
|
| const char* msg = CheckIsolateState(isolate);
|
| if (msg != NULL) {
|
| return Api::Error(msg);
|
| }
|
| - ScriptSnapshotWriter writer(root_lib, buffer, ApiAllocator);
|
| - writer.WriteScriptSnapshot();
|
| + Library& library = Library::Handle(isolate->object_store()->root_library());
|
| + if (library.IsNull()) {
|
| + return Api::Error("%s expects the isolate to have a script loaded in it.",
|
| + CURRENT_FUNC);
|
| + }
|
| + ScriptSnapshotWriter writer(buffer, ApiAllocator);
|
| + writer.WriteScriptSnapshot(library);
|
| *size = writer.Size();
|
| return Api::Success();
|
| }
|
| @@ -2287,6 +2289,7 @@
|
| DART_EXPORT Dart_Handle Dart_LoadScriptFromSnapshot(const uint8_t* buffer) {
|
| Isolate* isolate = Isolate::Current();
|
| DARTSCOPE(isolate);
|
| + TIMERSCOPE(time_script_loading);
|
| if (buffer == NULL) {
|
| return Api::Error("%s expects argument 'buffer' to be non-null.",
|
| CURRENT_FUNC);
|
| @@ -2309,6 +2312,7 @@
|
| CURRENT_FUNC);
|
| }
|
| library ^= tmp.raw();
|
| + library.Register();
|
| isolate->object_store()->set_root_library(library);
|
| return Api::NewLocalHandle(library);
|
| }
|
|
|