Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(777)

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 1168223002: Fix for issue 23598, add a Dart_CreateLibrarySnapshot entrypoint to the API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address code review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9562941a55c1c60df280fc5fbc503b0682092fa2 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 == Dart_Null()) {
+ 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(Dart_Null(), buffer, size);
+}
+
+
+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) {
« no previous file with comments | « runtime/include/dart_api.h ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698