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

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

Issue 10693039: Terminate event handler thread on isolate shutdown. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Adding new file to gyp file Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | no next file » | 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 <stdlib.h> 5 #include <stdlib.h>
6 #include <string.h> 6 #include <string.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "include/dart_api.h" 9 #include "include/dart_api.h"
10 #include "include/dart_debugger_api.h" 10 #include "include/dart_debugger_api.h"
11 11
12 #include "bin/builtin.h" 12 #include "bin/builtin.h"
13 #include "bin/dartutils.h" 13 #include "bin/dartutils.h"
14 #include "bin/dbg_connection.h" 14 #include "bin/dbg_connection.h"
15 #include "bin/directory.h" 15 #include "bin/directory.h"
16 #include "bin/eventhandler.h" 16 #include "bin/eventhandler.h"
17 #include "bin/extensions.h" 17 #include "bin/extensions.h"
18 #include "bin/file.h" 18 #include "bin/file.h"
19 #include "bin/isolate_data.h"
19 #include "bin/platform.h" 20 #include "bin/platform.h"
20 #include "bin/process.h" 21 #include "bin/process.h"
21 #include "platform/globals.h" 22 #include "platform/globals.h"
22 23
23 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise 24 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise
24 // it is initialized to NULL. 25 // it is initialized to NULL.
25 extern const uint8_t* snapshot_buffer; 26 extern const uint8_t* snapshot_buffer;
26 27
27 28
28 // Global state that stores the original working directory.. 29 // Global state that stores the original working directory..
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 return true; 606 return true;
606 } 607 }
607 608
608 609
609 static bool CreateIsolateAndSetup(const char* script_uri, 610 static bool CreateIsolateAndSetup(const char* script_uri,
610 const char* main, 611 const char* main,
611 void* data, char** error) { 612 void* data, char** error) {
612 return CreateIsolateAndSetupHelper(script_uri, 613 return CreateIsolateAndSetupHelper(script_uri,
613 main, 614 main,
614 false, // script_uri already canonical. 615 false, // script_uri already canonical.
615 data, 616 new IsolateData(),
616 error); 617 error);
617 } 618 }
618 619
619 620
620 static void PrintUsage() { 621 static void PrintUsage() {
621 fprintf(stderr, 622 fprintf(stderr,
622 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n"); 623 "dart [<vm-flags>] <dart-script-file> [<dart-options>]\n");
623 } 624 }
624 625
625 626
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 va_end(arguments); 686 va_end(arguments);
686 687
687 Dart_ExitScope(); 688 Dart_ExitScope();
688 Dart_ShutdownIsolate(); 689 Dart_ShutdownIsolate();
689 free(const_cast<char*>(original_working_directory)); 690 free(const_cast<char*>(original_working_directory));
690 691
691 return kErrorExitCode; 692 return kErrorExitCode;
692 } 693 }
693 694
694 695
696 static void ShutdownIsolate(void* callback_data) {
697 IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data);
698 EventHandler* handler = isolate_data->event_handler;
699 if (handler != NULL) handler->Shutdown();
700 delete isolate_data;
701 }
702
703
695 int main(int argc, char** argv) { 704 int main(int argc, char** argv) {
696 char* executable_name; 705 char* executable_name;
697 char* script_name; 706 char* script_name;
698 CommandLineOptions vm_options(argc); 707 CommandLineOptions vm_options(argc);
699 CommandLineOptions dart_options(argc); 708 CommandLineOptions dart_options(argc);
700 CommandLineOptions import_map(argc); 709 CommandLineOptions import_map(argc);
701 import_map_options = &import_map; 710 import_map_options = &import_map;
702 bool print_flags_seen = false; 711 bool print_flags_seen = false;
703 712
704 // Perform platform specific initialization. 713 // Perform platform specific initialization.
(...skipping 16 matching lines...) Expand all
721 return 0; 730 return 0;
722 } else { 731 } else {
723 PrintUsage(); 732 PrintUsage();
724 return kErrorExitCode; 733 return kErrorExitCode;
725 } 734 }
726 } 735 }
727 736
728 Dart_SetVMFlags(vm_options.count(), vm_options.arguments()); 737 Dart_SetVMFlags(vm_options.count(), vm_options.arguments());
729 738
730 // Initialize the Dart VM. 739 // Initialize the Dart VM.
731 Dart_Initialize(CreateIsolateAndSetup, NULL, NULL); 740 Dart_Initialize(CreateIsolateAndSetup,
741 NULL,
742 ShutdownIsolate);
732 743
733 original_working_directory = Directory::Current(); 744 original_working_directory = Directory::Current();
734 745
735 // Call CreateIsolateAndSetup which creates an isolate and loads up 746 // Call CreateIsolateAndSetup which creates an isolate and loads up
736 // the specified application script. 747 // the specified application script.
737 char* error = NULL; 748 char* error = NULL;
738 char* isolate_name = BuildIsolateName(script_name, "main"); 749 char* isolate_name = BuildIsolateName(script_name, "main");
739 if (!CreateIsolateAndSetupHelper(script_name, 750 if (!CreateIsolateAndSetupHelper(script_name,
740 "main", 751 "main",
741 true, // Canonicalize the script name. 752 true, // Canonicalize the script name.
742 NULL, 753 new IsolateData(),
743 &error)) { 754 &error)) {
744 fprintf(stderr, "%s\n", error); 755 fprintf(stderr, "%s\n", error);
745 free(const_cast<char*>(original_working_directory)); 756 free(const_cast<char*>(original_working_directory));
746 free(error); 757 free(error);
747 delete [] isolate_name; 758 delete [] isolate_name;
748 return kErrorExitCode; // Indicates we encountered an error. 759 return kErrorExitCode; // Indicates we encountered an error.
749 } 760 }
750 delete [] isolate_name; 761 delete [] isolate_name;
751 762
752 Dart_Isolate isolate = Dart_CurrentIsolate(); 763 Dart_Isolate isolate = Dart_CurrentIsolate();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 DumpPprofSymbolInfo(); 817 DumpPprofSymbolInfo();
807 // Shutdown the isolate. 818 // Shutdown the isolate.
808 Dart_ShutdownIsolate(); 819 Dart_ShutdownIsolate();
809 // Terminate process exit-code handler. 820 // Terminate process exit-code handler.
810 Process::TerminateExitCodeHandler(); 821 Process::TerminateExitCodeHandler();
811 822
812 free(const_cast<char*>(original_working_directory)); 823 free(const_cast<char*>(original_working_directory));
813 824
814 return 0; 825 return 0;
815 } 826 }
OLDNEW
« no previous file with comments | « runtime/bin/isolate_data.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698