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

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: 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..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) {
« 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