OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "include/dart_mirrors_api.h" | 6 #include "include/dart_mirrors_api.h" |
7 #include "include/dart_native_api.h" | 7 #include "include/dart_native_api.h" |
8 | 8 |
9 #include "lib/stacktrace.h" | 9 #include "lib/stacktrace.h" |
10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "vm/uri.h" | 53 #include "vm/uri.h" |
54 #include "vm/verifier.h" | 54 #include "vm/verifier.h" |
55 #include "vm/version.h" | 55 #include "vm/version.h" |
56 | 56 |
57 namespace dart { | 57 namespace dart { |
58 | 58 |
59 // Facilitate quick access to the current zone once we have the current thread. | 59 // Facilitate quick access to the current zone once we have the current thread. |
60 #define Z (T->zone()) | 60 #define Z (T->zone()) |
61 | 61 |
62 | 62 |
| 63 DECLARE_FLAG(bool, use_dart_frontend); |
63 DECLARE_FLAG(bool, print_class_table); | 64 DECLARE_FLAG(bool, print_class_table); |
64 DECLARE_FLAG(bool, verify_handles); | 65 DECLARE_FLAG(bool, verify_handles); |
65 #if defined(DART_NO_SNAPSHOT) | 66 #if defined(DART_NO_SNAPSHOT) |
66 DEFINE_FLAG(bool, | 67 DEFINE_FLAG(bool, |
67 check_function_fingerprints, | 68 check_function_fingerprints, |
68 true, | 69 true, |
69 "Check function fingerprints"); | 70 "Check function fingerprints"); |
70 #endif // defined(DART_NO_SNAPSHOT). | 71 #endif // defined(DART_NO_SNAPSHOT). |
71 DEFINE_FLAG(bool, | 72 DEFINE_FLAG(bool, |
72 verify_acquired_data, | 73 verify_acquired_data, |
(...skipping 5562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5635 for (intptr_t i = 0; i < pending_deferred_loads.Length(); i++) { | 5636 for (intptr_t i = 0; i < pending_deferred_loads.Length(); i++) { |
5636 if (pending_deferred_loads.At(i) == lib.raw()) { | 5637 if (pending_deferred_loads.At(i) == lib.raw()) { |
5637 lib.SetLoadError(err); | 5638 lib.SetLoadError(err); |
5638 return Api::Null(); | 5639 return Api::Null(); |
5639 } | 5640 } |
5640 } | 5641 } |
5641 return error_in; | 5642 return error_in; |
5642 } | 5643 } |
5643 | 5644 |
5644 | 5645 |
| 5646 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 5647 static Dart_Handle LoadKernelProgram(Dart_Handle url, Thread* T, void* kernel) { |
| 5648 kernel::KernelReader reader(reinterpret_cast<kernel::Program*>(kernel)); |
| 5649 const Object& tmp = reader.ReadProgram(); |
| 5650 if (tmp.IsError()) { |
| 5651 return Api::NewHandle(T, tmp.raw()); |
| 5652 } |
| 5653 |
| 5654 const String& url_str = Api::UnwrapStringHandle(Z, url); |
| 5655 Library& library = |
| 5656 Library::Handle(T->zone(), Library::LookupLibrary(T, url_str)); |
| 5657 return Api::NewHandle(T, library.raw()); |
| 5658 } |
| 5659 #endif |
| 5660 |
| 5661 |
5645 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, | 5662 DART_EXPORT Dart_Handle Dart_LoadLibrary(Dart_Handle url, |
5646 Dart_Handle resolved_url, | 5663 Dart_Handle resolved_url, |
5647 Dart_Handle source, | 5664 Dart_Handle source, |
5648 intptr_t line_offset, | 5665 intptr_t line_offset, |
5649 intptr_t column_offset) { | 5666 intptr_t column_offset) { |
5650 API_TIMELINE_DURATION; | 5667 API_TIMELINE_DURATION; |
5651 DARTSCOPE(Thread::Current()); | 5668 DARTSCOPE(Thread::Current()); |
5652 Isolate* I = T->isolate(); | 5669 Isolate* I = T->isolate(); |
| 5670 |
| 5671 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 5672 // Kernel isolate is loaded from script in case of dart_bootstrap |
| 5673 // even when FLAG_use_dart_frontend is true. Hence, do not interpret |
| 5674 // |source| as a kernel if the current isolate is the kernel isolate. |
| 5675 if (FLAG_use_dart_frontend && !KernelIsolate::IsKernelIsolate(I)) { |
| 5676 return LoadKernelProgram(url, T, reinterpret_cast<void*>(source)); |
| 5677 } |
| 5678 #endif |
| 5679 |
5653 const String& url_str = Api::UnwrapStringHandle(Z, url); | 5680 const String& url_str = Api::UnwrapStringHandle(Z, url); |
5654 if (url_str.IsNull()) { | 5681 if (url_str.IsNull()) { |
5655 RETURN_TYPE_ERROR(Z, url, String); | 5682 RETURN_TYPE_ERROR(Z, url, String); |
5656 } | 5683 } |
5657 if (::Dart_IsNull(resolved_url)) { | 5684 if (::Dart_IsNull(resolved_url)) { |
5658 resolved_url = url; | 5685 resolved_url = url; |
5659 } | 5686 } |
5660 const String& resolved_url_str = Api::UnwrapStringHandle(Z, resolved_url); | 5687 const String& resolved_url_str = Api::UnwrapStringHandle(Z, resolved_url); |
5661 if (resolved_url_str.IsNull()) { | 5688 if (resolved_url_str.IsNull()) { |
5662 RETURN_TYPE_ERROR(Z, resolved_url, String); | 5689 RETURN_TYPE_ERROR(Z, resolved_url, String); |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6964 } | 6991 } |
6965 | 6992 |
6966 | 6993 |
6967 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { | 6994 DART_EXPORT void Dart_DumpNativeStackTrace(void* context) { |
6968 #ifndef PRODUCT | 6995 #ifndef PRODUCT |
6969 Profiler::DumpStackTrace(context); | 6996 Profiler::DumpStackTrace(context); |
6970 #endif | 6997 #endif |
6971 } | 6998 } |
6972 | 6999 |
6973 } // namespace dart | 7000 } // namespace dart |
OLD | NEW |