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

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

Issue 1023753006: First step towards splitting a full snapshot into a vm isolate snapshot and a (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 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/gen_snapshot.cc ('k') | runtime/bin/run_vm_tests.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 <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"
(...skipping 10 matching lines...) Expand all
21 #include "bin/platform.h" 21 #include "bin/platform.h"
22 #include "bin/process.h" 22 #include "bin/process.h"
23 #include "bin/thread.h" 23 #include "bin/thread.h"
24 #include "bin/vmservice_impl.h" 24 #include "bin/vmservice_impl.h"
25 #include "platform/globals.h" 25 #include "platform/globals.h"
26 #include "platform/hashmap.h" 26 #include "platform/hashmap.h"
27 27
28 namespace dart { 28 namespace dart {
29 namespace bin { 29 namespace bin {
30 30
31 // snapshot_buffer points to a snapshot if we link in a snapshot otherwise 31 // vm_isolate_snapshot_buffer points to a snapshot for the vm isolate if we
32 // it is initialized to NULL. 32 // link in a snapshot otherwise it is initialized to NULL.
33 extern const uint8_t* snapshot_buffer; 33 extern const uint8_t* vm_isolate_snapshot_buffer;
34
35 // isolate_snapshot_buffer points to a snapshot for an isolate if we link in a
36 // snapshot otherwise it is initialized to NULL.
37 extern const uint8_t* isolate_snapshot_buffer;
34 38
35 // Global state that stores a pointer to the application script snapshot. 39 // Global state that stores a pointer to the application script snapshot.
36 static bool generate_script_snapshot = false; 40 static bool generate_script_snapshot = false;
37 static const char* snapshot_filename = NULL; 41 static const char* snapshot_filename = NULL;
38 42
39 43
40 // Global state that indicates whether there is a debug breakpoint. 44 // Global state that indicates whether there is a debug breakpoint.
41 // This pointer points into an argv buffer and does not need to be 45 // This pointer points into an argv buffer and does not need to be
42 // free'd. 46 // free'd.
43 static const char* breakpoint_at = NULL; 47 static const char* breakpoint_at = NULL;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 } 290 }
287 has_print_script = true; 291 has_print_script = true;
288 return true; 292 return true;
289 } 293 }
290 294
291 295
292 static bool ProcessGenScriptSnapshotOption(const char* filename, 296 static bool ProcessGenScriptSnapshotOption(const char* filename,
293 CommandLineOptions* vm_options) { 297 CommandLineOptions* vm_options) {
294 if (filename != NULL && strlen(filename) != 0) { 298 if (filename != NULL && strlen(filename) != 0) {
295 // Ensure that are already running using a full snapshot. 299 // Ensure that are already running using a full snapshot.
296 if (snapshot_buffer == NULL) { 300 if (isolate_snapshot_buffer == NULL) {
297 Log::PrintErr("Script snapshots cannot be generated in this version of" 301 Log::PrintErr("Script snapshots cannot be generated in this version of"
298 " dart\n"); 302 " dart\n");
299 return false; 303 return false;
300 } 304 }
301 snapshot_filename = filename; 305 snapshot_filename = filename;
302 generate_script_snapshot = true; 306 generate_script_snapshot = true;
303 return true; 307 return true;
304 } 308 }
305 return false; 309 return false;
306 } 310 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 const char* main, 581 const char* main,
578 const char* package_root, 582 const char* package_root,
579 char** error, 583 char** error,
580 int* exit_code) { 584 int* exit_code) {
581 ASSERT(script_uri != NULL); 585 ASSERT(script_uri != NULL);
582 IsolateData* isolate_data = new IsolateData(script_uri, package_root); 586 IsolateData* isolate_data = new IsolateData(script_uri, package_root);
583 Dart_Isolate isolate = NULL; 587 Dart_Isolate isolate = NULL;
584 588
585 isolate = Dart_CreateIsolate(script_uri, 589 isolate = Dart_CreateIsolate(script_uri,
586 main, 590 main,
587 snapshot_buffer, 591 isolate_snapshot_buffer,
588 isolate_data, 592 isolate_data,
589 error); 593 error);
590 594
591 if (isolate == NULL) { 595 if (isolate == NULL) {
592 return NULL; 596 return NULL;
593 } 597 }
594 598
595 Dart_EnterScope(); 599 Dart_EnterScope();
596 600
597 if (snapshot_buffer != NULL) { 601 if (isolate_snapshot_buffer != NULL) {
598 // Setup the native resolver as the snapshot does not carry it. 602 // Setup the native resolver as the snapshot does not carry it.
599 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary); 603 Builtin::SetNativeResolver(Builtin::kBuiltinLibrary);
600 Builtin::SetNativeResolver(Builtin::kIOLibrary); 604 Builtin::SetNativeResolver(Builtin::kIOLibrary);
601 } 605 }
602 606
603 // Set up the library tag handler for this isolate. 607 // Set up the library tag handler for this isolate.
604 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler); 608 Dart_Handle result = Dart_SetLibraryTagHandler(DartUtils::LibraryTagHandler);
605 CHECK_RESULT(result); 609 CHECK_RESULT(result);
606 610
607 if (Dart_IsServiceIsolate(isolate)) { 611 if (Dart_IsServiceIsolate(isolate)) {
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 bool print_msg = verbose_debug_seen || (debug_port == 0); 957 bool print_msg = verbose_debug_seen || (debug_port == 0);
954 debug_port = DebuggerConnectionHandler::StartHandler(debug_ip, debug_port); 958 debug_port = DebuggerConnectionHandler::StartHandler(debug_ip, debug_port);
955 if (print_msg) { 959 if (print_msg) {
956 Log::Print("Debugger listening on port %d\n", debug_port); 960 Log::Print("Debugger listening on port %d\n", debug_port);
957 } 961 }
958 } else { 962 } else {
959 DebuggerConnectionHandler::InitForVmService(); 963 DebuggerConnectionHandler::InitForVmService();
960 } 964 }
961 965
962 // Initialize the Dart VM. 966 // Initialize the Dart VM.
963 if (!Dart_Initialize(CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate, 967 if (!Dart_Initialize(NULL,
968 CreateIsolateAndSetup, NULL, NULL, ShutdownIsolate,
964 DartUtils::OpenFile, 969 DartUtils::OpenFile,
965 DartUtils::ReadFile, 970 DartUtils::ReadFile,
966 DartUtils::WriteFile, 971 DartUtils::WriteFile,
967 DartUtils::CloseFile, 972 DartUtils::CloseFile,
968 DartUtils::EntropySource)) { 973 DartUtils::EntropySource)) {
969 fprintf(stderr, "%s", "VM initialization failed\n"); 974 fprintf(stderr, "%s", "VM initialization failed\n");
970 fflush(stderr); 975 fflush(stderr);
971 exit(kErrorExitCode); 976 exit(kErrorExitCode);
972 } 977 }
973 978
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 exit(Process::GlobalExitCode()); 1117 exit(Process::GlobalExitCode());
1113 } 1118 }
1114 1119
1115 } // namespace bin 1120 } // namespace bin
1116 } // namespace dart 1121 } // namespace dart
1117 1122
1118 int main(int argc, char** argv) { 1123 int main(int argc, char** argv) {
1119 dart::bin::main(argc, argv); 1124 dart::bin::main(argc, argv);
1120 UNREACHABLE(); 1125 UNREACHABLE();
1121 } 1126 }
OLDNEW
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/run_vm_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698