OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 | 5 |
6 #include "bin/loader.h" | 6 #include "bin/loader.h" |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/dartutils.h" | 9 #include "bin/dartutils.h" |
| 10 #include "bin/dfe.h" |
10 #include "bin/extensions.h" | 11 #include "bin/extensions.h" |
11 #include "bin/file.h" | 12 #include "bin/file.h" |
12 #include "bin/lockers.h" | 13 #include "bin/lockers.h" |
13 #include "bin/utils.h" | 14 #include "bin/utils.h" |
14 #include "include/dart_tools_api.h" | 15 #include "include/dart_tools_api.h" |
15 #include "platform/growable_array.h" | 16 #include "platform/growable_array.h" |
16 | 17 |
17 namespace dart { | 18 namespace dart { |
18 namespace bin { | 19 namespace bin { |
19 | 20 |
20 // Development flag. | 21 // Development flag. |
21 static bool trace_loader = false; | 22 static bool trace_loader = false; |
| 23 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 24 extern DFE dfe; |
| 25 #endif |
| 26 |
22 // Keep in sync with loader.dart. | 27 // Keep in sync with loader.dart. |
23 static const intptr_t _Dart_kImportExtension = 9; | 28 static const intptr_t _Dart_kImportExtension = 9; |
24 static const intptr_t _Dart_kResolveAsFilePath = 10; | 29 static const intptr_t _Dart_kResolveAsFilePath = 10; |
25 | 30 |
26 Loader::Loader(IsolateData* isolate_data) | 31 Loader::Loader(IsolateData* isolate_data) |
27 : port_(ILLEGAL_PORT), | 32 : port_(ILLEGAL_PORT), |
28 isolate_data_(isolate_data), | 33 isolate_data_(isolate_data), |
29 error_(Dart_Null()), | 34 error_(Dart_Null()), |
30 monitor_(NULL), | 35 monitor_(NULL), |
31 pending_operations_(0), | 36 pending_operations_(0), |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 Dart_Handle library, | 636 Dart_Handle library, |
632 Dart_Handle url, | 637 Dart_Handle url, |
633 const char* library_url_string, | 638 const char* library_url_string, |
634 const char* url_string) { | 639 const char* url_string) { |
635 return Dart_Null(); | 640 return Dart_Null(); |
636 } | 641 } |
637 #else | 642 #else |
638 Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, | 643 Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag, |
639 Dart_Handle library, | 644 Dart_Handle library, |
640 Dart_Handle url) { | 645 Dart_Handle url) { |
| 646 if (dfe.UseDartFrontend()) { |
| 647 Dart_Isolate current = Dart_CurrentIsolate(); |
| 648 if (!Dart_IsServiceIsolate(current) && !Dart_IsKernelIsolate(current)) { |
| 649 // When using DFE the library tag handler should be called only when we |
| 650 // are reloading scripts. |
| 651 // TODO(asiva) We need to ensure that the kernel and service isolates |
| 652 // and the spawnURI paths are always loaded from a kernel IR and do |
| 653 // not use this path. |
| 654 if (tag == Dart_kScriptTag) { |
| 655 return dfe.ReloadScript(current, url); |
| 656 } |
| 657 } |
| 658 } |
641 if (tag == Dart_kCanonicalizeUrl) { | 659 if (tag == Dart_kCanonicalizeUrl) { |
642 Dart_Handle library_url = Dart_LibraryUrl(library); | 660 Dart_Handle library_url = Dart_LibraryUrl(library); |
643 if (Dart_IsError(library_url)) { | 661 if (Dart_IsError(library_url)) { |
644 return library_url; | 662 return library_url; |
645 } | 663 } |
646 return Dart_DefaultCanonicalizeUrl(library_url, url); | 664 return Dart_DefaultCanonicalizeUrl(library_url, url); |
647 } | 665 } |
648 const char* url_string = NULL; | 666 const char* url_string = NULL; |
649 Dart_Handle result = Dart_StringToCString(url, &url_string); | 667 Dart_Handle result = Dart_StringToCString(url, &url_string); |
650 if (Dart_IsError(result)) { | 668 if (Dart_IsError(result)) { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
908 MutexLocker ml(loader_infos_lock_); | 926 MutexLocker ml(loader_infos_lock_); |
909 Loader* loader = LoaderForLocked(dest_port_id); | 927 Loader* loader = LoaderForLocked(dest_port_id); |
910 if (loader == NULL) { | 928 if (loader == NULL) { |
911 return; | 929 return; |
912 } | 930 } |
913 loader->QueueMessage(message); | 931 loader->QueueMessage(message); |
914 } | 932 } |
915 | 933 |
916 } // namespace bin | 934 } // namespace bin |
917 } // namespace dart | 935 } // namespace dart |
OLD | NEW |