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

Side by Side Diff: runtime/bin/vmservice/loader.dart

Issue 2810223003: Attempt 2 -- Fix updating packages map on reload and add a regression test (Closed)
Patch Set: Created 3 years, 8 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/observatory/lib/src/service/object.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 part of vmservice_io; 5 part of vmservice_io;
6 6
7 _sanitizeWindowsPath(path) { 7 _sanitizeWindowsPath(path) {
8 // For Windows we need to massage the paths a bit according to 8 // For Windows we need to massage the paths a bit according to
9 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx 9 // http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
10 // 10 //
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 _rootScript = Uri.parse(rootScript); 83 _rootScript = Uri.parse(rootScript);
84 } 84 }
85 // If the --package-root flag was passed. 85 // If the --package-root flag was passed.
86 if (packageRootFlag != null) { 86 if (packageRootFlag != null) {
87 _setPackageRoot(packageRootFlag); 87 _setPackageRoot(packageRootFlag);
88 } 88 }
89 // If the --packages flag was passed. 89 // If the --packages flag was passed.
90 if (packagesConfigFlag != null) { 90 if (packagesConfigFlag != null) {
91 _setPackagesConfig(packagesConfigFlag); 91 _setPackagesConfig(packagesConfigFlag);
92 } 92 }
93 if (_fileRequestQueue == null) { 93 }
94 _fileRequestQueue = new List<FileRequest>(); 94
95 } 95 void updatePackageMap(String packagesConfigFlag) {
96 _packageMap = null;
97 _setPackagesConfig(packagesConfigFlag);
96 } 98 }
97 99
98 void cleanup() { 100 void cleanup() {
99 _dead = true; 101 _dead = true;
100 if (_packagesPort != null) { 102 if (_packagesPort != null) {
101 _packagesPort.close(); 103 _packagesPort.close();
102 _packagesPort = null; 104 _packagesPort = null;
103 } 105 }
104 } 106 }
105 107
(...skipping 21 matching lines...) Expand all
127 129
128 // The map describing how certain package names are mapped to Uris. 130 // The map describing how certain package names are mapped to Uris.
129 Uri _packageConfig = null; 131 Uri _packageConfig = null;
130 Map<String, Uri> _packageMap = null; 132 Map<String, Uri> _packageMap = null;
131 133
132 // We issue only 16 concurrent calls to File.readAsBytes() to stay within 134 // We issue only 16 concurrent calls to File.readAsBytes() to stay within
133 // platform-specific resource limits (e.g. max open files). The rest go on 135 // platform-specific resource limits (e.g. max open files). The rest go on
134 // _fileRequestQueue and are processed when we can safely issue them. 136 // _fileRequestQueue and are processed when we can safely issue them.
135 static const int _maxFileRequests = 16; 137 static const int _maxFileRequests = 16;
136 int currentFileRequests = 0; 138 int currentFileRequests = 0;
137 List<FileRequest> _fileRequestQueue; 139 final List<FileRequest> _fileRequestQueue = new List<FileRequest>();
138 140
139 bool get shouldIssueFileRequest => currentFileRequests < _maxFileRequests; 141 bool get shouldIssueFileRequest => currentFileRequests < _maxFileRequests;
140 void enqueueFileRequest(FileRequest fr) { 142 void enqueueFileRequest(FileRequest fr) {
141 _fileRequestQueue.add(fr); 143 _fileRequestQueue.add(fr);
142 } 144 }
143 145
144 FileRequest dequeueFileRequest() { 146 FileRequest dequeueFileRequest() {
145 if (_fileRequestQueue.length == 0) { 147 if (_fileRequestQueue.length == 0) {
146 return null; 148 return null;
147 } 149 }
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 case _Dart_kInitLoader: 1029 case _Dart_kInitLoader:
1028 { 1030 {
1029 String packageRoot = request[4]; 1031 String packageRoot = request[4];
1030 String packagesFile = request[5]; 1032 String packagesFile = request[5];
1031 String workingDirectory = request[6]; 1033 String workingDirectory = request[6];
1032 String rootScript = request[7]; 1034 String rootScript = request[7];
1033 if (loaderState == null) { 1035 if (loaderState == null) {
1034 loaderState = new IsolateLoaderState(isolateId); 1036 loaderState = new IsolateLoaderState(isolateId);
1035 isolateEmbedderData[isolateId] = loaderState; 1037 isolateEmbedderData[isolateId] = loaderState;
1036 loaderState.init( 1038 loaderState.init(
1037 packageRoot, packagesFile, workingDirectory, rootScript); 1039 packageRoot, packagesFile, workingDirectory, rootScript);
1040 } else {
1041 loaderState.updatePackageMap(packagesFile);
1038 } 1042 }
1039 loaderState.sp = sp; 1043 loaderState.sp = sp;
1040 assert(isolateEmbedderData[isolateId] == loaderState); 1044 assert(isolateEmbedderData[isolateId] == loaderState);
1041 } 1045 }
1042 break; 1046 break;
1043 case _Dart_kResourceLoad: 1047 case _Dart_kResourceLoad:
1044 { 1048 {
1045 Uri uri = Uri.parse(request[4]); 1049 Uri uri = Uri.parse(request[4]);
1046 _handleResourceRequest( 1050 _handleResourceRequest(
1047 loaderState, sp, traceLoading, tag, uri, uri, null); 1051 loaderState, sp, traceLoading, tag, uri, uri, null);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 msg[2] = resolvedUri.toString(); 1154 msg[2] = resolvedUri.toString();
1151 msg[3] = null; 1155 msg[3] = null;
1152 msg[4] = e.toString(); 1156 msg[4] = e.toString();
1153 sp.send(msg); 1157 sp.send(msg);
1154 } 1158 }
1155 break; 1159 break;
1156 default: 1160 default:
1157 _log('Unknown loader request tag=$tag from $isolateId'); 1161 _log('Unknown loader request tag=$tag from $isolateId');
1158 } 1162 }
1159 } 1163 }
OLDNEW
« no previous file with comments | « runtime/bin/loader.cc ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698