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

Side by Side Diff: pkg/compiler/lib/src/js_backend/backend.dart

Issue 1927963002: Support compilation of Hello World (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes 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
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 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 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 if (kind == ElementKind.TYPEDEF) { 1467 if (kind == ElementKind.TYPEDEF) {
1468 return const WorldImpact(); 1468 return const WorldImpact();
1469 } 1469 }
1470 if (element.isConstructor && 1470 if (element.isConstructor &&
1471 element.enclosingClass == helpers.jsNullClass) { 1471 element.enclosingClass == helpers.jsNullClass) {
1472 // Work around a problem compiling JSNull's constructor. 1472 // Work around a problem compiling JSNull's constructor.
1473 return const CodegenImpact(); 1473 return const CodegenImpact();
1474 } 1474 }
1475 if (kind.category == ElementCategory.VARIABLE) { 1475 if (kind.category == ElementCategory.VARIABLE) {
1476 VariableElement variableElement = element; 1476 VariableElement variableElement = element;
1477 ConstantValue initialValue = 1477 ConstantExpression constant = variableElement.constant;
1478 constants.getConstantValue(variableElement.constant); 1478 if (constant != null) {
1479 if (initialValue != null) { 1479 ConstantValue initialValue = constants.getConstantValue(constant);
1480 registerCompileTimeConstant(initialValue, work.registry); 1480 registerCompileTimeConstant(initialValue, work.registry);
1481 addCompileTimeConstantForEmission(initialValue); 1481 addCompileTimeConstantForEmission(initialValue);
1482 // We don't need to generate code for static or top-level 1482 // We don't need to generate code for static or top-level
1483 // variables. For instance variables, we may need to generate 1483 // variables. For instance variables, we may need to generate
1484 // the checked setter. 1484 // the checked setter.
1485 if (Elements.isStaticOrTopLevel(element)) { 1485 if (Elements.isStaticOrTopLevel(element)) {
1486 return impactTransformer 1486 return impactTransformer
1487 .transformCodegenImpact(work.registry.worldImpact); 1487 .transformCodegenImpact(work.registry.worldImpact);
1488 } 1488 }
1489 } else { 1489 } else {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 1844
1845 void onLibraryCreated(LibraryElement library) { 1845 void onLibraryCreated(LibraryElement library) {
1846 helpers.onLibraryCreated(library); 1846 helpers.onLibraryCreated(library);
1847 } 1847 }
1848 1848
1849 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { 1849 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) {
1850 return super.onLibraryScanned(library, loader).then((_) { 1850 return super.onLibraryScanned(library, loader).then((_) {
1851 if (library.isPlatformLibrary && 1851 if (library.isPlatformLibrary &&
1852 // Don't patch library currently disallowed. 1852 // Don't patch library currently disallowed.
1853 !library.isSynthesized && 1853 !library.isSynthesized &&
1854 !library.isPatched) { 1854 !library.isPatched &&
1855 // Don't patch deserialized libraries.
1856 !compiler.serialization.isDeserialized(library)) {
1855 // Apply patch, if any. 1857 // Apply patch, if any.
1856 Uri patchUri = compiler.resolvePatchUri(library.canonicalUri.path); 1858 Uri patchUri = compiler.resolvePatchUri(library.canonicalUri.path);
1857 if (patchUri != null) { 1859 if (patchUri != null) {
1858 return compiler.patchParser.patchLibrary(loader, patchUri, library); 1860 return compiler.patchParser.patchLibrary(loader, patchUri, library);
1859 } 1861 }
1860 } 1862 }
1861 }).then((_) { 1863 }).then((_) {
1862 helpers.onLibraryScanned(library); 1864 helpers.onLibraryScanned(library);
1863 Uri uri = library.canonicalUri; 1865 Uri uri = library.canonicalUri;
1864 if (uri == Uris.dart_html) { 1866 if (uri == Uris.dart_html) {
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
2503 ResolutionImpact getResolutionImpact(Element element) { 2505 ResolutionImpact getResolutionImpact(Element element) {
2504 return resolution.getResolutionImpact(element); 2506 return resolution.getResolutionImpact(element);
2505 } 2507 }
2506 2508
2507 @override 2509 @override
2508 ResolvedAst getResolvedAst(Element element) { 2510 ResolvedAst getResolvedAst(Element element) {
2509 if (element is SynthesizedCallMethodElementX) { 2511 if (element is SynthesizedCallMethodElementX) {
2510 return element.resolvedAst; 2512 return element.resolvedAst;
2511 } else if (element is ConstructorBodyElementX) { 2513 } else if (element is ConstructorBodyElementX) {
2512 return element.resolvedAst; 2514 return element.resolvedAst;
2515 } else if (element is FieldElementX) {
2516 // TODO(johnniwinther): Find a good invariant for resolution of fields.
2517 // Currently some but not all are resolved (maybe it has to do with
2518 // initializers?)
2519 return element.resolvedAst;
2513 } else { 2520 } else {
2514 assert(invariant(element, resolution.hasResolvedAst(element.declaration), 2521 assert(invariant(element, resolution.hasResolvedAst(element.declaration),
2515 message: 'No ResolvedAst for $element')); 2522 message: 'No ResolvedAst for $element'));
2516 return resolution.getResolvedAst(element.declaration); 2523 return resolution.getResolvedAst(element.declaration);
2517 } 2524 }
2518 } 2525 }
2519 } 2526 }
2520 2527
2521 /// Handling of special annotations for tests. 2528 /// Handling of special annotations for tests.
2522 class Annotations { 2529 class Annotations {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
3019 3026
3020 @override 3027 @override
3021 void onImpactUsed(ImpactUseCase impactUse) { 3028 void onImpactUsed(ImpactUseCase impactUse) {
3022 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { 3029 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) {
3023 // TODO(johnniwinther): Allow emptying when serialization has been 3030 // TODO(johnniwinther): Allow emptying when serialization has been
3024 // performed. 3031 // performed.
3025 resolution.emptyCache(); 3032 resolution.emptyCache();
3026 } 3033 }
3027 } 3034 }
3028 } 3035 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698