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

Side by Side Diff: runtime/bin/dartutils.cc

Issue 1403693002: - Implement package map parameter when spawning isolate. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments. Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "include/dart_tools_api.h" 8 #include "include/dart_tools_api.h"
9 #include "include/dart_native_api.h" 9 #include "include/dart_native_api.h"
10 10
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 Dart_PropagateError(err); 630 Dart_PropagateError(err);
631 } 631 }
632 } 632 }
633 633
634 634
635 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib, 635 Dart_Handle DartUtils::PrepareBuiltinLibrary(Dart_Handle builtin_lib,
636 Dart_Handle internal_lib, 636 Dart_Handle internal_lib,
637 bool is_service_isolate, 637 bool is_service_isolate,
638 bool trace_loading, 638 bool trace_loading,
639 const char* package_root, 639 const char* package_root,
640 const char** package_map,
640 const char* packages_file) { 641 const char* packages_file) {
641 // Setup the internal library's 'internalPrint' function. 642 // Setup the internal library's 'internalPrint' function.
642 Dart_Handle print = Dart_Invoke( 643 Dart_Handle print = Dart_Invoke(
643 builtin_lib, NewString("_getPrintClosure"), 0, NULL); 644 builtin_lib, NewString("_getPrintClosure"), 0, NULL);
644 RETURN_IF_ERROR(print); 645 RETURN_IF_ERROR(print);
645 Dart_Handle result = 646 Dart_Handle result =
646 Dart_SetField(internal_lib, NewString("_printClosure"), print); 647 Dart_SetField(internal_lib, NewString("_printClosure"), print);
647 RETURN_IF_ERROR(result); 648 RETURN_IF_ERROR(result);
648 649
649 if (!is_service_isolate) { 650 if (!is_service_isolate) {
(...skipping 13 matching lines...) Expand all
663 Dart_Port load_port = Dart_ServiceWaitForLoadPort(); 664 Dart_Port load_port = Dart_ServiceWaitForLoadPort();
664 if (load_port == ILLEGAL_PORT) { 665 if (load_port == ILLEGAL_PORT) {
665 return NewDartUnsupportedError("Service did not return load port."); 666 return NewDartUnsupportedError("Service did not return load port.");
666 } 667 }
667 result = Builtin::SetLoadPort(load_port); 668 result = Builtin::SetLoadPort(load_port);
668 RETURN_IF_ERROR(result); 669 RETURN_IF_ERROR(result);
669 } 670 }
670 671
671 // Set up package root if specified. 672 // Set up package root if specified.
672 if (package_root != NULL) { 673 if (package_root != NULL) {
674 ASSERT(package_map == NULL);
673 ASSERT(packages_file == NULL); 675 ASSERT(packages_file == NULL);
674 result = NewString(package_root); 676 result = NewString(package_root);
675 RETURN_IF_ERROR(result); 677 RETURN_IF_ERROR(result);
676 const int kNumArgs = 1; 678 const int kNumArgs = 1;
677 Dart_Handle dart_args[kNumArgs]; 679 Dart_Handle dart_args[kNumArgs];
678 dart_args[0] = result; 680 dart_args[0] = result;
679 result = Dart_Invoke(builtin_lib, 681 result = Dart_Invoke(builtin_lib,
680 NewString("_setPackageRoot"), 682 NewString("_setPackageRoot"),
681 kNumArgs, 683 kNumArgs,
682 dart_args); 684 dart_args);
683 RETURN_IF_ERROR(result); 685 RETURN_IF_ERROR(result);
686 } else if (package_map != NULL) {
687 ASSERT(packages_file == NULL);
688 Dart_Handle func_name = NewString("_addPackageMapEntry");
689 RETURN_IF_ERROR(func_name);
690
691 for (int i = 0; package_map[i] != NULL; i +=2) {
692 const int kNumArgs = 2;
693 Dart_Handle dart_args[kNumArgs];
694 // Get the key.
695 result = NewString(package_map[i]);
696 RETURN_IF_ERROR(result);
697 dart_args[0] = result;
698 if (package_map[i + 1] == NULL) {
699 return Dart_NewUnhandledExceptionError(
700 NewDartArgumentError("Adding package map entry without value."));
701 }
702 // Get the value.
703 result = NewString(package_map[i + 1]);
704 RETURN_IF_ERROR(result);
705 dart_args[1] = result;
706 // Setup the next package map entry.
707 result = Dart_Invoke(builtin_lib,
708 func_name,
709 kNumArgs,
710 dart_args);
711 RETURN_IF_ERROR(result);
712 }
684 } else if (packages_file != NULL) { 713 } else if (packages_file != NULL) {
685 result = NewString(packages_file); 714 result = NewString(packages_file);
686 RETURN_IF_ERROR(result); 715 RETURN_IF_ERROR(result);
687 const int kNumArgs = 1; 716 const int kNumArgs = 1;
688 Dart_Handle dart_args[kNumArgs]; 717 Dart_Handle dart_args[kNumArgs];
689 dart_args[0] = result; 718 dart_args[0] = result;
690 result = Dart_Invoke(builtin_lib, 719 result = Dart_Invoke(builtin_lib,
691 NewString("_loadPackagesMap"), 720 NewString("_loadPackagesMap"),
692 kNumArgs, 721 kNumArgs,
693 dart_args); 722 dart_args);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 return Dart_Invoke(io_lib, NewString("_setupHooks"), 0, NULL); 760 return Dart_Invoke(io_lib, NewString("_setupHooks"), 0, NULL);
732 } 761 }
733 762
734 763
735 Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) { 764 Dart_Handle DartUtils::PrepareIsolateLibrary(Dart_Handle isolate_lib) {
736 return Dart_Invoke(isolate_lib, NewString("_setupHooks"), 0, NULL); 765 return Dart_Invoke(isolate_lib, NewString("_setupHooks"), 0, NULL);
737 } 766 }
738 767
739 768
740 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root, 769 Dart_Handle DartUtils::PrepareForScriptLoading(const char* package_root,
770 const char** package_map,
741 const char* packages_file, 771 const char* packages_file,
742 bool is_service_isolate, 772 bool is_service_isolate,
743 bool trace_loading, 773 bool trace_loading,
744 Dart_Handle builtin_lib) { 774 Dart_Handle builtin_lib) {
745 // First ensure all required libraries are available. 775 // First ensure all required libraries are available.
746 Dart_Handle url = NewString(kCoreLibURL); 776 Dart_Handle url = NewString(kCoreLibURL);
747 RETURN_IF_ERROR(url); 777 RETURN_IF_ERROR(url);
748 Dart_Handle core_lib = Dart_LookupLibrary(url); 778 Dart_Handle core_lib = Dart_LookupLibrary(url);
749 RETURN_IF_ERROR(core_lib); 779 RETURN_IF_ERROR(core_lib);
750 url = NewString(kAsyncLibURL); 780 url = NewString(kAsyncLibURL);
(...skipping 14 matching lines...) Expand all
765 // We need to ensure that all the scripts loaded so far are finalized 795 // We need to ensure that all the scripts loaded so far are finalized
766 // as we are about to invoke some Dart code below to setup closures. 796 // as we are about to invoke some Dart code below to setup closures.
767 Dart_Handle result = Dart_FinalizeLoading(false); 797 Dart_Handle result = Dart_FinalizeLoading(false);
768 RETURN_IF_ERROR(result); 798 RETURN_IF_ERROR(result);
769 799
770 result = PrepareBuiltinLibrary(builtin_lib, 800 result = PrepareBuiltinLibrary(builtin_lib,
771 internal_lib, 801 internal_lib,
772 is_service_isolate, 802 is_service_isolate,
773 trace_loading, 803 trace_loading,
774 package_root, 804 package_root,
805 package_map,
775 packages_file); 806 packages_file);
776 RETURN_IF_ERROR(result); 807 RETURN_IF_ERROR(result);
777 808
778 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib)); 809 RETURN_IF_ERROR(PrepareAsyncLibrary(async_lib, isolate_lib));
779 RETURN_IF_ERROR(PrepareCoreLibrary( 810 RETURN_IF_ERROR(PrepareCoreLibrary(
780 core_lib, builtin_lib, is_service_isolate)); 811 core_lib, builtin_lib, is_service_isolate));
781 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib)); 812 RETURN_IF_ERROR(PrepareIsolateLibrary(isolate_lib));
782 RETURN_IF_ERROR(PrepareIOLibrary(io_lib)); 813 RETURN_IF_ERROR(PrepareIOLibrary(io_lib));
783 return result; 814 return result;
784 } 815 }
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 new CObjectString(CObject::NewString(os_error->message())); 1271 new CObjectString(CObject::NewString(os_error->message()));
1241 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1272 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1242 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1273 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1243 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1274 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1244 result->SetAt(2, error_message); 1275 result->SetAt(2, error_message);
1245 return result; 1276 return result;
1246 } 1277 }
1247 1278
1248 } // namespace bin 1279 } // namespace bin
1249 } // namespace dart 1280 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/gen_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698