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

Unified Diff: runtime/vm/dart_api_impl.cc

Issue 2949323002: Load vmservice from a .dill file when generating AOT snapshots. (Closed)
Patch Set: Address comments Created 3 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/tests/vm/vm.status ('k') | no next file » | 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 fa48aeee52b36bf6c82b24b8434e6451cbb43796..39423ac5808537f3a0567e54063139a0b24ce6c7 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -60,6 +60,7 @@ namespace dart {
#define Z (T->zone())
+DECLARE_FLAG(bool, use_dart_frontend);
DECLARE_FLAG(bool, print_class_table);
DECLARE_FLAG(bool, verify_handles);
#if defined(DART_NO_SNAPSHOT)
@@ -5642,6 +5643,22 @@ DART_EXPORT Dart_Handle Dart_LibraryHandleError(Dart_Handle library_in,
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
+static Dart_Handle LoadKernelProgram(Dart_Handle url, Thread* T, void* kernel) {
+ kernel::KernelReader reader(reinterpret_cast<kernel::Program*>(kernel));
+ const Object& tmp = reader.ReadProgram();
+ if (tmp.IsError()) {
+ return Api::NewHandle(T, tmp.raw());
+ }
+
+ const String& url_str = Api::UnwrapStringHandle(Z, url);
+ Library& library =
+ Library::Handle(T->zone(), Library::LookupLibrary(T, url_str));
+ return Api::NewHandle(T, library.raw());
+}
+#endif
+
+
DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
Dart_Handle resolved_url,
Dart_Handle source,
@@ -5650,6 +5667,16 @@ DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url,
API_TIMELINE_DURATION;
DARTSCOPE(Thread::Current());
Isolate* I = T->isolate();
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ // Kernel isolate is loaded from script in case of dart_bootstrap
+ // even when FLAG_use_dart_frontend is true. Hence, do not interpret
+ // |source| as a kernel if the current isolate is the kernel isolate.
+ if (FLAG_use_dart_frontend && !KernelIsolate::IsKernelIsolate(I)) {
+ return LoadKernelProgram(url, T, reinterpret_cast<void*>(source));
+ }
+#endif
+
const String& url_str = Api::UnwrapStringHandle(Z, url);
if (url_str.IsNull()) {
RETURN_TYPE_ERROR(Z, url, String);
« no previous file with comments | « runtime/tests/vm/vm.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698