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

Unified Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 247863005: Revert "Insert checks before deferred calls and accesses." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index 9147ae536e3aae27091536c0a31b24355b6255a4..73dd57ed8909f88a176d4dd459d3fffdae30a1af 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -2726,13 +2726,6 @@ checkMalformedType(value, message) {
throw new TypeErrorImplementation.fromMessage(message);
}
-@NoInline()
-void checkDeferredIsLoaded(String loadId, String uri) {
- if (!_loadedLibraries.contains(loadId)) {
- throw new DeferredNotLoadedError(uri);
- }
-}
-
/**
* Special interface recognized by the compiler and implemented by DOM
* objects that support integer indexing. This interface is not
@@ -2825,16 +2818,6 @@ class RuntimeError extends Error {
String toString() => "RuntimeError: $message";
}
-class DeferredNotLoadedError extends Error {
- String libraryName;
-
- DeferredNotLoadedError(this.libraryName);
-
- String toString() {
- return "Deferred library $libraryName was not loaded.";
- }
-}
-
abstract class RuntimeType {
const RuntimeType();
@@ -3248,10 +3231,10 @@ LoadLibraryFunctionType _loadLibraryWrapper(String loadId) {
return () => loadDeferredLibrary(loadId);
}
-final Map<String, Future<Null>> _loadingLibraries = <String, Future<Null>>{};
-final Set<String> _loadedLibraries = new Set<String>();
+final Map<String, Future<Null>> _loadedLibraries = <String, Future<Null>>{};
+
+Future<bool> loadDeferredLibrary(String loadId, [String uri]) {
-Future<Null> loadDeferredLibrary(String loadId, [String uri]) {
List<List<String>> hunkLists = JS('JSExtendableArray|Null',
'\$.libraries_to_load[#]', loadId);
if (hunkLists == null) return new Future.value(null);
@@ -3260,14 +3243,14 @@ Future<Null> loadDeferredLibrary(String loadId, [String uri]) {
Iterable<Future<Null>> allLoads =
hunkNames.map((hunkName) => _loadHunk(hunkName, uri));
return Future.wait(allLoads).then((_) => null);
- }).then((_) => _loadedLibraries.add(loadId));
+ });
}
Future<Null> _loadHunk(String hunkName, String uri) {
// TODO(ahe): Validate libraryName. Kasper points out that you want
// to be able to experiment with the effect of toggling @DeferLoad,
// so perhaps we should silently ignore "bad" library names.
- Future<Null> future = _loadingLibraries[hunkName];
+ Future<Null> future = _loadedLibraries[hunkName];
if (future != null) {
return future.then((_) => null);
}
@@ -3281,7 +3264,7 @@ Future<Null> _loadHunk(String hunkName, String uri) {
if (Primitives.isJsshell || Primitives.isD8) {
// TODO(ahe): Move this code to a JavaScript command helper script that is
// not included in generated output.
- return _loadingLibraries[hunkName] = new Future<Null>(() {
+ return _loadedLibraries[hunkName] = new Future<Null>(() {
try {
// Create a new function to avoid getting access to current function
// context.
@@ -3293,7 +3276,7 @@ Future<Null> _loadHunk(String hunkName, String uri) {
});
} else if (isWorker()) {
// We are in a web worker. Load the code with an XMLHttpRequest.
- return _loadingLibraries[hunkName] = new Future<Null>(() {
+ return _loadedLibraries[hunkName] = new Future<Null>(() {
Completer completer = new Completer<Null>();
enterJsAsync();
Future<Null> leavingFuture = completer.future.whenComplete(() {
@@ -3335,7 +3318,7 @@ Future<Null> _loadHunk(String hunkName, String uri) {
});
}
// We are in a dom-context.
- return _loadingLibraries[hunkName] = new Future<Null>(() {
+ return _loadedLibraries[hunkName] = new Future<Null>(() {
Completer completer = new Completer<Null>();
// Inject a script tag.
var script = JS('', 'document.createElement("script")');
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/ssa.dart ('k') | tests/compiler/dart2js_extra/deferred/deferred_class_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698