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

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

Issue 2186423002: Only reload libraries when they may have been modified. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Code review Created 4 years, 4 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/loader.cc ('k') | runtime/bin/vmservice/loader.dart » ('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_tools_api.h" 10 #include "include/dart_tools_api.h"
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 1036
1037 static void ServiceStreamCancelCallback(const char* stream_id) { 1037 static void ServiceStreamCancelCallback(const char* stream_id) {
1038 if (strcmp(stream_id, kStdoutStreamId) == 0) { 1038 if (strcmp(stream_id, kStdoutStreamId) == 0) {
1039 SetCaptureStdout(false); 1039 SetCaptureStdout(false);
1040 } else if (strcmp(stream_id, kStderrStreamId) == 0) { 1040 } else if (strcmp(stream_id, kStderrStreamId) == 0) {
1041 SetCaptureStderr(false); 1041 SetCaptureStderr(false);
1042 } 1042 }
1043 } 1043 }
1044 1044
1045 1045
1046 static bool FileModifiedCallback(const char* url, int64_t since) {
1047 if (strncmp(url, "file:///", 8) == 0) {
1048 // If it isn't a file on local disk, we don't know if it has been
1049 // modified.
1050 return true;
1051 }
1052 int64_t data[File::kStatSize];
1053 File::Stat(url + 7, data);
1054 if (data[File::kType] == File::kDoesNotExist) {
1055 return true;
1056 }
1057 bool modified = data[File::kModifiedTime] > since;
1058 return modified;
1059 }
1060
1061
1046 static void WriteSnapshotFile(const char* snapshot_directory, 1062 static void WriteSnapshotFile(const char* snapshot_directory,
1047 const char* filename, 1063 const char* filename,
1048 bool write_magic_number, 1064 bool write_magic_number,
1049 const uint8_t* buffer, 1065 const uint8_t* buffer,
1050 const intptr_t size) { 1066 const intptr_t size) {
1051 char* concat = NULL; 1067 char* concat = NULL;
1052 const char* qualified_filename; 1068 const char* qualified_filename;
1053 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) { 1069 if ((snapshot_directory != NULL) && (strlen(snapshot_directory) > 0)) {
1054 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename); 1070 intptr_t len = snprintf(NULL, 0, "%s/%s", snapshot_directory, filename);
1055 concat = new char[len + 1]; 1071 concat = new char[len + 1];
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
1701 fprintf(stderr, "VM initialization failed: %s\n", error); 1717 fprintf(stderr, "VM initialization failed: %s\n", error);
1702 fflush(stderr); 1718 fflush(stderr);
1703 free(error); 1719 free(error);
1704 Platform::Exit(kErrorExitCode); 1720 Platform::Exit(kErrorExitCode);
1705 } 1721 }
1706 1722
1707 Dart_RegisterIsolateServiceRequestCallback( 1723 Dart_RegisterIsolateServiceRequestCallback(
1708 "getIO", &ServiceGetIOHandler, NULL); 1724 "getIO", &ServiceGetIOHandler, NULL);
1709 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback, 1725 Dart_SetServiceStreamCallbacks(&ServiceStreamListenCallback,
1710 &ServiceStreamCancelCallback); 1726 &ServiceStreamCancelCallback);
1727 Dart_SetFileModifiedCallback(&FileModifiedCallback);
1711 1728
1712 // Run the main isolate until we aren't told to restart. 1729 // Run the main isolate until we aren't told to restart.
1713 while (RunMainIsolate(script_name, &dart_options)) { 1730 while (RunMainIsolate(script_name, &dart_options)) {
1714 Log::PrintErr("Restarting VM\n"); 1731 Log::PrintErr("Restarting VM\n");
1715 } 1732 }
1716 1733
1717 // Terminate process exit-code handler. 1734 // Terminate process exit-code handler.
1718 Process::TerminateExitCodeHandler(); 1735 Process::TerminateExitCodeHandler();
1719 1736
1720 error = Dart_Cleanup(); 1737 error = Dart_Cleanup();
(...skipping 24 matching lines...) Expand all
1745 Platform::Exit(Process::GlobalExitCode()); 1762 Platform::Exit(Process::GlobalExitCode());
1746 } 1763 }
1747 1764
1748 } // namespace bin 1765 } // namespace bin
1749 } // namespace dart 1766 } // namespace dart
1750 1767
1751 int main(int argc, char** argv) { 1768 int main(int argc, char** argv) {
1752 dart::bin::main(argc, argv); 1769 dart::bin::main(argc, argv);
1753 UNREACHABLE(); 1770 UNREACHABLE();
1754 } 1771 }
OLDNEW
« no previous file with comments | « runtime/bin/loader.cc ('k') | runtime/bin/vmservice/loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698