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 fa48aeee52b36bf6c82b24b8434e6451cbb43796..c81951415aa690196425584d12f93ca28795d66e 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 LoadLibraryFromKernel(Thread* T, void* kernel_program) { |
|
siva
2017/06/22 23:51:37
Is it LoadLibraryFromKernel or LoadKernelProgram a
sivachandra
2017/06/23 01:14:57
Done.
|
| + kernel::KernelReader reader( |
| + reinterpret_cast<kernel::Program*>(kernel_program)); |
| + const Object& tmp = reader.ReadProgram(); |
| + if (tmp.IsError()) { |
| + return Api::NewHandle(T, tmp.raw()); |
| + } |
| + |
| + Library& library = Library::Handle(T->zone()); |
| + library ^= tmp.raw(); |
| + return Api::NewHandle(T, library.raw()); |
|
siva
2017/06/22 23:51:37
I think currently reader.ReadProgram returns the l
sivachandra
2017/06/23 01:14:57
Done.
|
| +} |
| +#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 LoadLibraryFromKernel(T, reinterpret_cast<void*>(source)); |
| + } |
| +#endif |
| + |
| const String& url_str = Api::UnwrapStringHandle(Z, url); |
| if (url_str.IsNull()) { |
| RETURN_TYPE_ERROR(Z, url, String); |