| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 | 504 |
| 505 SourceInformationStrategy sourceInformationStrategy; | 505 SourceInformationStrategy sourceInformationStrategy; |
| 506 | 506 |
| 507 JavaScriptBackendSerialization serialization; | 507 JavaScriptBackendSerialization serialization; |
| 508 | 508 |
| 509 final NativeData nativeData = new NativeData(); | 509 final NativeData nativeData = new NativeData(); |
| 510 | 510 |
| 511 final BackendHelpers helpers; | 511 final BackendHelpers helpers; |
| 512 final BackendImpacts impacts; | 512 final BackendImpacts impacts; |
| 513 | 513 |
| 514 final JSFrontendAccess frontend; |
| 515 |
| 514 JavaScriptBackend(Compiler compiler, | 516 JavaScriptBackend(Compiler compiler, |
| 515 {bool generateSourceMap: true, | 517 {bool generateSourceMap: true, |
| 516 bool useStartupEmitter: false, | 518 bool useStartupEmitter: false, |
| 517 bool useNewSourceInfo: false}) | 519 bool useNewSourceInfo: false}) |
| 518 : namer = determineNamer(compiler), | 520 : namer = determineNamer(compiler), |
| 519 oneShotInterceptors = new Map<jsAst.Name, Selector>(), | 521 oneShotInterceptors = new Map<jsAst.Name, Selector>(), |
| 520 interceptedElements = new Map<String, Set<Element>>(), | 522 interceptedElements = new Map<String, Set<Element>>(), |
| 521 rti = new _RuntimeTypes(compiler), | 523 rti = new _RuntimeTypes(compiler), |
| 522 rtiEncoder = new _RuntimeTypesEncoder(compiler), | 524 rtiEncoder = new _RuntimeTypesEncoder(compiler), |
| 523 specializedGetInterceptors = new Map<jsAst.Name, Set<ClassElement>>(), | 525 specializedGetInterceptors = new Map<jsAst.Name, Set<ClassElement>>(), |
| 524 annotations = new Annotations(compiler), | 526 annotations = new Annotations(compiler), |
| 525 this.sourceInformationStrategy = generateSourceMap | 527 this.sourceInformationStrategy = generateSourceMap |
| 526 ? (useNewSourceInfo | 528 ? (useNewSourceInfo |
| 527 ? new PositionSourceInformationStrategy() | 529 ? new PositionSourceInformationStrategy() |
| 528 : const StartEndSourceInformationStrategy()) | 530 : const StartEndSourceInformationStrategy()) |
| 529 : const JavaScriptSourceInformationStrategy(), | 531 : const JavaScriptSourceInformationStrategy(), |
| 530 helpers = new BackendHelpers(compiler), | 532 helpers = new BackendHelpers(compiler), |
| 531 impacts = new BackendImpacts(compiler), | 533 impacts = new BackendImpacts(compiler), |
| 534 frontend = new JSFrontendAccess(compiler), |
| 532 super(compiler) { | 535 super(compiler) { |
| 533 emitter = new CodeEmitterTask( | 536 emitter = new CodeEmitterTask( |
| 534 compiler, namer, generateSourceMap, useStartupEmitter); | 537 compiler, namer, generateSourceMap, useStartupEmitter); |
| 535 typeVariableHandler = new TypeVariableHandler(compiler); | 538 typeVariableHandler = new TypeVariableHandler(compiler); |
| 536 customElementsAnalysis = new CustomElementsAnalysis(this); | 539 customElementsAnalysis = new CustomElementsAnalysis(this); |
| 537 lookupMapAnalysis = new LookupMapAnalysis(this, reporter); | 540 lookupMapAnalysis = new LookupMapAnalysis(this, reporter); |
| 538 jsInteropAnalysis = new JsInteropAnalysis(this); | 541 jsInteropAnalysis = new JsInteropAnalysis(this); |
| 539 | 542 |
| 540 noSuchMethodRegistry = new NoSuchMethodRegistry(this); | 543 noSuchMethodRegistry = new NoSuchMethodRegistry(this); |
| 541 constantCompilerTask = new JavaScriptConstantTask(compiler); | 544 constantCompilerTask = new JavaScriptConstantTask(compiler); |
| (...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2468 {bool supportDeferredLoad: true, | 2471 {bool supportDeferredLoad: true, |
| 2469 bool supportDumpInfo: true, | 2472 bool supportDumpInfo: true, |
| 2470 bool supportSerialization: true}) { | 2473 bool supportSerialization: true}) { |
| 2471 return new JavaScriptImpactStrategy(resolution, compiler.dumpInfoTask, | 2474 return new JavaScriptImpactStrategy(resolution, compiler.dumpInfoTask, |
| 2472 supportDeferredLoad: supportDeferredLoad, | 2475 supportDeferredLoad: supportDeferredLoad, |
| 2473 supportDumpInfo: supportDumpInfo, | 2476 supportDumpInfo: supportDumpInfo, |
| 2474 supportSerialization: supportSerialization); | 2477 supportSerialization: supportSerialization); |
| 2475 } | 2478 } |
| 2476 } | 2479 } |
| 2477 | 2480 |
| 2481 class JSFrontendAccess implements Frontend { |
| 2482 final Compiler compiler; |
| 2483 |
| 2484 JSFrontendAccess(this.compiler); |
| 2485 |
| 2486 Resolution get resolution => compiler.resolution; |
| 2487 |
| 2488 @override |
| 2489 ResolutionImpact getResolutionImpact(Element element) { |
| 2490 return resolution.getResolutionImpact(element); |
| 2491 } |
| 2492 |
| 2493 @override |
| 2494 ResolvedAst getResolvedAst(Element element) { |
| 2495 if (element is SynthesizedCallMethodElementX) { |
| 2496 return element.resolvedAst; |
| 2497 } else if (element is ConstructorBodyElementX) { |
| 2498 return element.resolvedAst; |
| 2499 } else { |
| 2500 assert(invariant(element, resolution.hasResolvedAst(element.declaration), |
| 2501 message: 'No ResolvedAst for $element')); |
| 2502 return resolution.getResolvedAst(element.declaration); |
| 2503 } |
| 2504 } |
| 2505 } |
| 2506 |
| 2478 /// Handling of special annotations for tests. | 2507 /// Handling of special annotations for tests. |
| 2479 class Annotations { | 2508 class Annotations { |
| 2480 static final Uri PACKAGE_EXPECT = | 2509 static final Uri PACKAGE_EXPECT = |
| 2481 new Uri(scheme: 'package', path: 'expect/expect.dart'); | 2510 new Uri(scheme: 'package', path: 'expect/expect.dart'); |
| 2482 | 2511 |
| 2483 final Compiler compiler; | 2512 final Compiler compiler; |
| 2484 | 2513 |
| 2485 ClassElement expectNoInlineClass; | 2514 ClassElement expectNoInlineClass; |
| 2486 ClassElement expectTrustTypeAnnotationsClass; | 2515 ClassElement expectTrustTypeAnnotationsClass; |
| 2487 ClassElement expectAssumeDynamicClass; | 2516 ClassElement expectAssumeDynamicClass; |
| (...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2976 | 3005 |
| 2977 @override | 3006 @override |
| 2978 void onImpactUsed(ImpactUseCase impactUse) { | 3007 void onImpactUsed(ImpactUseCase impactUse) { |
| 2979 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { | 3008 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { |
| 2980 // TODO(johnniwinther): Allow emptying when serialization has been | 3009 // TODO(johnniwinther): Allow emptying when serialization has been |
| 2981 // performed. | 3010 // performed. |
| 2982 resolution.emptyCache(); | 3011 resolution.emptyCache(); |
| 2983 } | 3012 } |
| 2984 } | 3013 } |
| 2985 } | 3014 } |
| OLD | NEW |