Chromium Code Reviews| Index: runtime/vm/dart_api_impl.cc |
| diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc |
| index bc36704424b32c1b9ab8117fa09ca7ccdb760420..1d5cd02287d872c836ca663a19198a8eb82f0433 100644 |
| --- a/runtime/vm/dart_api_impl.cc |
| +++ b/runtime/vm/dart_api_impl.cc |
| @@ -1475,8 +1475,9 @@ DART_EXPORT Dart_Handle Dart_CreateSnapshot( |
| } |
| -DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, |
| - intptr_t* size) { |
| +static Dart_Handle createLibrarySnapshot(Dart_Handle library, |
| + uint8_t** buffer, |
| + intptr_t* size) { |
| Isolate* isolate = Isolate::Current(); |
| DARTSCOPE(isolate); |
| TIMERSCOPE(isolate, time_creating_snapshot); |
| @@ -1491,20 +1492,32 @@ DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, |
| if (::Dart_IsError(state)) { |
| return state; |
| } |
| - Library& library = |
| - Library::Handle(isolate, isolate->object_store()->root_library()); |
| - if (library.IsNull()) { |
| - return |
| - Api::NewError("%s expects the isolate to have a script loaded in it.", |
| - CURRENT_FUNC); |
| + Library& lib = Library::Handle(isolate); |
| + if (library == NULL) { |
|
Cutch
2015/06/08 23:00:51
library == Dart_Null() ?
siva
2015/06/09 00:49:21
Done.
|
| + lib ^= isolate->object_store()->root_library(); |
| + } else { |
| + lib ^= Api::UnwrapHandle(library); |
| } |
| ScriptSnapshotWriter writer(buffer, ApiReallocate); |
| - writer.WriteScriptSnapshot(library); |
| + writer.WriteScriptSnapshot(lib); |
| *size = writer.BytesWritten(); |
| return Api::Success(); |
| } |
| +DART_EXPORT Dart_Handle Dart_CreateScriptSnapshot(uint8_t** buffer, |
| + intptr_t* size) { |
| + return createLibrarySnapshot(NULL, buffer, size); |
|
Cutch
2015/06/08 23:00:51
It looks weird to pass NULL here. Shouldn't we pas
siva
2015/06/09 00:49:21
Good point, changed it to Dart_Null()
|
| +} |
| + |
| + |
| +DART_EXPORT Dart_Handle Dart_CreateLibrarySnapshot(Dart_Handle library, |
| + uint8_t** buffer, |
| + intptr_t* size) { |
| + return createLibrarySnapshot(library, buffer, size); |
| +} |
| + |
| + |
| DART_EXPORT void Dart_InterruptIsolate(Dart_Isolate isolate) { |
| TRACE_API_CALL(CURRENT_FUNC); |
| if (isolate == NULL) { |