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

Side by Side Diff: runtime/bin/builtin.dart

Issue 1916793003: - Allow for loading dart:html and friends into the standalone (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Rebase. Created 4 years, 7 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/builtin.cc ('k') | runtime/bin/builtin_natives.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 library builtin; 5 library builtin;
6 // NOTE: Do not import 'dart:io' in builtin. 6 // NOTE: Do not import 'dart:io' in builtin.
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:_internal'; 9 import 'dart:_internal';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const _Dart_kScriptTag = null; 60 const _Dart_kScriptTag = null;
61 const _Dart_kImportTag = 0; 61 const _Dart_kImportTag = 0;
62 const _Dart_kSourceTag = 1; 62 const _Dart_kSourceTag = 1;
63 const _Dart_kCanonicalizeUrl = 2; 63 const _Dart_kCanonicalizeUrl = 2;
64 const _Dart_kResourceLoad = 3; 64 const _Dart_kResourceLoad = 3;
65 65
66 // Embedder sets this to true if the --trace-loading flag was passed on the 66 // Embedder sets this to true if the --trace-loading flag was passed on the
67 // command line. 67 // command line.
68 bool _traceLoading = false; 68 bool _traceLoading = false;
69 69
70 // This is currently a build time flag only. We measure the time from the first
71 // load request (opening the receive port) to completing the last load
72 // request (closing the receive port). Future, deferred load operations will
73 // add to this time.
74 bool _timeLoading = false;
75 Stopwatch _stopwatch;
76
70 // A port for communicating with the service isolate for I/O. 77 // A port for communicating with the service isolate for I/O.
71 SendPort _loadPort; 78 SendPort _loadPort;
72 // The receive port for a load request. Multiple sources can be fetched in 79 // The receive port for a load request. Multiple sources can be fetched in
73 // a single load request. 80 // a single load request.
74 RawReceivePort _dataPort; 81 RawReceivePort _dataPort;
75 // A request id valid only for the current load cycle (while the number of 82 // A request id valid only for the current load cycle (while the number of
76 // outstanding load requests is greater than 0). Can be reset when loading is 83 // outstanding load requests is greater than 0). Can be reset when loading is
77 // completed. 84 // completed.
78 int _reqId = 0; 85 int _reqId = 0;
79 // An unordered hash map mapping from request id to a particular load request. 86 // An unordered hash map mapping from request id to a particular load request.
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 var tmp = _reqMap.remove(req._id); 358 var tmp = _reqMap.remove(req._id);
352 assert(tmp == req); 359 assert(tmp == req);
353 if (_traceLoading) { 360 if (_traceLoading) {
354 _log("Loading of ${req._uri} finished: " 361 _log("Loading of ${req._uri} finished: "
355 "${_reqMap.length} requests remaining, " 362 "${_reqMap.length} requests remaining, "
356 "${_pendingPackageLoads.length} packages pending."); 363 "${_pendingPackageLoads.length} packages pending.");
357 } 364 }
358 } 365 }
359 366
360 if (!_pendingLoads() && (_dataPort != null)) { 367 if (!_pendingLoads() && (_dataPort != null)) {
368 _stopwatch.stop();
361 // Close the _dataPort now that there are no more requests outstanding. 369 // Close the _dataPort now that there are no more requests outstanding.
362 if (_traceLoading) { 370 if (_traceLoading || _timeLoading) {
363 _log("Closing loading port."); 371 _log("Closing loading port: ${_stopwatch.elapsedMilliseconds} ms");
364 } 372 }
365 _dataPort.close(); 373 _dataPort.close();
366 _dataPort = null; 374 _dataPort = null;
367 _reqId = 0; 375 _reqId = 0;
368 _signalDoneLoading(); 376 _signalDoneLoading();
369 } 377 }
370 } 378 }
371 379
372 380
373 void _handleLoaderReply(msg) { 381 void _handleLoaderReply(msg) {
(...skipping 27 matching lines...) Expand all
401 _asyncLoadError(req, error, s); 409 _asyncLoadError(req, error, s);
402 } 410 }
403 } 411 }
404 412
405 413
406 void _startLoadRequest(int tag, String uri, Uri resourceUri, context) { 414 void _startLoadRequest(int tag, String uri, Uri resourceUri, context) {
407 if (_dataPort == null) { 415 if (_dataPort == null) {
408 if (_traceLoading) { 416 if (_traceLoading) {
409 _log("Initializing load port."); 417 _log("Initializing load port.");
410 } 418 }
419 // Allocate the Stopwatch if necessary.
420 if (_stopwatch == null) {
421 _stopwatch = new Stopwatch();
422 }
411 assert(_dataPort == null); 423 assert(_dataPort == null);
412 _dataPort = new RawReceivePort(_handleLoaderReply); 424 _dataPort = new RawReceivePort(_handleLoaderReply);
425 _stopwatch.start();
413 } 426 }
414 // Register the load request and send it to the VM service isolate. 427 // Register the load request and send it to the VM service isolate.
415 var req = new _LoadRequest(tag, uri, resourceUri, context); 428 var req = new _LoadRequest(tag, uri, resourceUri, context);
416 429
417 assert(_dataPort != null); 430 assert(_dataPort != null);
418 var msg = new List(4); 431 var msg = new List(4);
419 msg[0] = _dataPort.sendPort; 432 msg[0] = _dataPort.sendPort;
420 msg[1] = _traceLoading; 433 msg[1] = _traceLoading;
421 msg[2] = req._id; 434 msg[2] = req._id;
422 msg[3] = resourceUri.toString(); 435 msg[3] = resourceUri.toString();
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 905
893 // Register callbacks and hooks with the rest of the core libraries. 906 // Register callbacks and hooks with the rest of the core libraries.
894 _setupHooks() { 907 _setupHooks() {
895 _setupCompleted = true; 908 _setupCompleted = true;
896 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes; 909 VMLibraryHooks.resourceReadAsBytes = _resourceReadAsBytes;
897 910
898 VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture; 911 VMLibraryHooks.packageRootUriFuture = _getPackageRootFuture;
899 VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture; 912 VMLibraryHooks.packageConfigUriFuture = _getPackageConfigFuture;
900 VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture; 913 VMLibraryHooks.resolvePackageUriFuture = _resolvePackageUriFuture;
901 } 914 }
OLDNEW
« no previous file with comments | « runtime/bin/builtin.cc ('k') | runtime/bin/builtin_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698