| OLD | NEW |
| 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 part of js_backend; | 5 part of js_backend; |
| 6 | 6 |
| 7 const VERBOSE_OPTIMIZER_HINTS = false; | 7 const VERBOSE_OPTIMIZER_HINTS = false; |
| 8 | 8 |
| 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { | 9 class JavaScriptItemCompilationContext extends ItemCompilationContext { |
| 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); | 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 DUMMY_INTERCEPTOR, | 216 DUMMY_INTERCEPTOR, |
| 217 EMPTY_VALUE, | 217 EMPTY_VALUE, |
| 218 TYPEVARIABLE_REFERENCE, | 218 TYPEVARIABLE_REFERENCE, |
| 219 NAME | 219 NAME |
| 220 } | 220 } |
| 221 | 221 |
| 222 class JavaScriptBackend extends Backend { | 222 class JavaScriptBackend extends Backend { |
| 223 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); | 223 static final Uri DART_JS_HELPER = new Uri(scheme: 'dart', path: '_js_helper'); |
| 224 static final Uri DART_INTERCEPTORS = | 224 static final Uri DART_INTERCEPTORS = |
| 225 new Uri(scheme: 'dart', path: '_interceptors'); | 225 new Uri(scheme: 'dart', path: '_interceptors'); |
| 226 static final Uri DART_INTERNAL = | |
| 227 new Uri(scheme: 'dart', path: '_internal'); | |
| 228 static final Uri DART_FOREIGN_HELPER = | 226 static final Uri DART_FOREIGN_HELPER = |
| 229 new Uri(scheme: 'dart', path: '_foreign_helper'); | 227 new Uri(scheme: 'dart', path: '_foreign_helper'); |
| 230 static final Uri DART_JS_MIRRORS = | 228 static final Uri DART_JS_MIRRORS = |
| 231 new Uri(scheme: 'dart', path: '_js_mirrors'); | 229 new Uri(scheme: 'dart', path: '_js_mirrors'); |
| 232 static final Uri DART_JS_NAMES = | 230 static final Uri DART_JS_NAMES = |
| 233 new Uri(scheme: 'dart', path: '_js_names'); | 231 new Uri(scheme: 'dart', path: '_js_names'); |
| 234 static final Uri DART_EMBEDDED_NAMES = | 232 static final Uri DART_EMBEDDED_NAMES = |
| 235 new Uri(scheme: 'dart', path: '_js_embedded_names'); | 233 new Uri(scheme: 'dart', path: '_js_embedded_names'); |
| 236 static final Uri DART_ISOLATE_HELPER = | 234 static final Uri DART_ISOLATE_HELPER = |
| 237 new Uri(scheme: 'dart', path: '_isolate_helper'); | 235 new Uri(scheme: 'dart', path: '_isolate_helper'); |
| 238 static final Uri DART_ASYNC = new Uri(scheme: 'dart', path: 'async'); | |
| 239 static final Uri DART_HTML = new Uri(scheme: 'dart', path: 'html'); | |
| 240 | 236 |
| 241 static const String INVOKE_ON = '_getCachedInvocation'; | 237 static const String INVOKE_ON = '_getCachedInvocation'; |
| 242 static const String START_ROOT_ISOLATE = 'startRootIsolate'; | 238 static const String START_ROOT_ISOLATE = 'startRootIsolate'; |
| 243 | 239 |
| 244 | 240 |
| 245 String get patchVersion => emitter.patchVersion; | 241 String get patchVersion => emitter.patchVersion; |
| 246 | 242 |
| 247 bool get supportsReflection => emitter.emitter.supportsReflection; | 243 bool get supportsReflection => emitter.emitter.supportsReflection; |
| 248 | 244 |
| 249 final Annotations annotations; | 245 final Annotations annotations; |
| (...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 } | 2019 } |
| 2024 return true; | 2020 return true; |
| 2025 } | 2021 } |
| 2026 return false; | 2022 return false; |
| 2027 } | 2023 } |
| 2028 | 2024 |
| 2029 void onLibraryCreated(LibraryElement library) { | 2025 void onLibraryCreated(LibraryElement library) { |
| 2030 Uri uri = library.canonicalUri; | 2026 Uri uri = library.canonicalUri; |
| 2031 if (uri == DART_JS_HELPER) { | 2027 if (uri == DART_JS_HELPER) { |
| 2032 jsHelperLibrary = library; | 2028 jsHelperLibrary = library; |
| 2033 } else if (uri == DART_ASYNC) { | 2029 } else if (uri == Uris.dart_async) { |
| 2034 asyncLibrary = library; | 2030 asyncLibrary = library; |
| 2035 } else if (uri == DART_INTERNAL) { | 2031 } else if (uri == Uris.dart__internal) { |
| 2036 internalLibrary = library; | 2032 internalLibrary = library; |
| 2037 } else if (uri == DART_INTERCEPTORS) { | 2033 } else if (uri == DART_INTERCEPTORS) { |
| 2038 interceptorsLibrary = library; | 2034 interceptorsLibrary = library; |
| 2039 } else if (uri == DART_FOREIGN_HELPER) { | 2035 } else if (uri == DART_FOREIGN_HELPER) { |
| 2040 foreignLibrary = library; | 2036 foreignLibrary = library; |
| 2041 } else if (uri == DART_ISOLATE_HELPER) { | 2037 } else if (uri == DART_ISOLATE_HELPER) { |
| 2042 isolateHelperLibrary = library; | 2038 isolateHelperLibrary = library; |
| 2043 } | 2039 } |
| 2044 } | 2040 } |
| 2045 | 2041 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2128 } else if (uri == DART_JS_MIRRORS) { | 2124 } else if (uri == DART_JS_MIRRORS) { |
| 2129 disableTreeShakingMarker = find(library, 'disableTreeShaking'); | 2125 disableTreeShakingMarker = find(library, 'disableTreeShaking'); |
| 2130 preserveMetadataMarker = find(library, 'preserveMetadata'); | 2126 preserveMetadataMarker = find(library, 'preserveMetadata'); |
| 2131 preserveUrisMarker = find(library, 'preserveUris'); | 2127 preserveUrisMarker = find(library, 'preserveUris'); |
| 2132 preserveLibraryNamesMarker = find(library, 'preserveLibraryNames'); | 2128 preserveLibraryNamesMarker = find(library, 'preserveLibraryNames'); |
| 2133 } else if (uri == DART_JS_NAMES) { | 2129 } else if (uri == DART_JS_NAMES) { |
| 2134 preserveNamesMarker = find(library, 'preserveNames'); | 2130 preserveNamesMarker = find(library, 'preserveNames'); |
| 2135 } else if (uri == DART_EMBEDDED_NAMES) { | 2131 } else if (uri == DART_EMBEDDED_NAMES) { |
| 2136 jsGetNameEnum = find(library, 'JsGetName'); | 2132 jsGetNameEnum = find(library, 'JsGetName'); |
| 2137 jsBuiltinEnum = find(library, 'JsBuiltin'); | 2133 jsBuiltinEnum = find(library, 'JsBuiltin'); |
| 2138 } else if (uri == DART_HTML) { | 2134 } else if (uri == Uris.dart_html) { |
| 2139 htmlLibraryIsLoaded = true; | 2135 htmlLibraryIsLoaded = true; |
| 2140 } | 2136 } |
| 2141 annotations.onLibraryScanned(library); | 2137 annotations.onLibraryScanned(library); |
| 2142 }); | 2138 }); |
| 2143 } | 2139 } |
| 2144 | 2140 |
| 2145 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 2141 Future onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 2146 if (!loadedLibraries.containsLibrary(Compiler.DART_CORE)) { | 2142 if (!loadedLibraries.containsLibrary(Uris.dart_core)) { |
| 2147 return new Future.value(); | 2143 return new Future.value(); |
| 2148 } | 2144 } |
| 2149 | 2145 |
| 2150 assert(loadedLibraries.containsLibrary(Compiler.DART_CORE)); | 2146 assert(loadedLibraries.containsLibrary(Uris.dart_core)); |
| 2151 assert(loadedLibraries.containsLibrary(DART_INTERCEPTORS)); | 2147 assert(loadedLibraries.containsLibrary(DART_INTERCEPTORS)); |
| 2152 assert(loadedLibraries.containsLibrary(DART_JS_HELPER)); | 2148 assert(loadedLibraries.containsLibrary(DART_JS_HELPER)); |
| 2153 | 2149 |
| 2154 if (jsInvocationMirrorClass != null) { | 2150 if (jsInvocationMirrorClass != null) { |
| 2155 jsInvocationMirrorClass.ensureResolved(compiler); | 2151 jsInvocationMirrorClass.ensureResolved(compiler); |
| 2156 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON); | 2152 invokeOnMethod = jsInvocationMirrorClass.lookupLocalMember(INVOKE_ON); |
| 2157 } | 2153 } |
| 2158 | 2154 |
| 2159 // [LinkedHashMap] is reexported from dart:collection and can therefore not | 2155 // [LinkedHashMap] is reexported from dart:collection and can therefore not |
| 2160 // be loaded from dart:core in [onLibraryScanned]. | 2156 // be loaded from dart:core in [onLibraryScanned]. |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3102 } | 3098 } |
| 3103 } | 3099 } |
| 3104 | 3100 |
| 3105 /// Records that [constant] is used by the element behind [registry]. | 3101 /// Records that [constant] is used by the element behind [registry]. |
| 3106 class Dependency { | 3102 class Dependency { |
| 3107 final ConstantValue constant; | 3103 final ConstantValue constant; |
| 3108 final Element annotatedElement; | 3104 final Element annotatedElement; |
| 3109 | 3105 |
| 3110 const Dependency(this.constant, this.annotatedElement); | 3106 const Dependency(this.constant, this.annotatedElement); |
| 3111 } | 3107 } |
| OLD | NEW |