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

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

Issue 746993002: Avoid patching in dart2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('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 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 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR"); 9 const bool USE_CPS_IR = const bool.fromEnvironment("USE_CPS_IR");
10 10
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 333
334 /** 334 /**
335 * A set of members that are called from subclasses via super. 335 * A set of members that are called from subclasses via super.
336 */ 336 */
337 final Set<FunctionElement> aliasedSuperMembers = 337 final Set<FunctionElement> aliasedSuperMembers =
338 new Setlet<FunctionElement>(); 338 new Setlet<FunctionElement>();
339 339
340 List<CompilerTask> get tasks { 340 List<CompilerTask> get tasks {
341 List<CompilerTask> result = functionCompiler.tasks; 341 List<CompilerTask> result = functionCompiler.tasks;
342 result.add(emitter); 342 result.add(emitter);
343 result.add(patchResolverTask);
343 return result; 344 return result;
344 } 345 }
345 346
346 final RuntimeTypes rti; 347 final RuntimeTypes rti;
347 348
348 /// Holds the method "disableTreeShaking" in js_mirrors when 349 /// Holds the method "disableTreeShaking" in js_mirrors when
349 /// dart:mirrors has been loaded. 350 /// dart:mirrors has been loaded.
350 FunctionElement disableTreeShakingMarker; 351 FunctionElement disableTreeShakingMarker;
351 352
352 /// Holds the method "preserveNames" in js_mirrors when 353 /// Holds the method "preserveNames" in js_mirrors when
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 int preMirrorsMethodCount = 0; 441 int preMirrorsMethodCount = 0;
441 442
442 /// Resolution and codegen support for generating table of interceptors and 443 /// Resolution and codegen support for generating table of interceptors and
443 /// constructors for custom elements. 444 /// constructors for custom elements.
444 CustomElementsAnalysis customElementsAnalysis; 445 CustomElementsAnalysis customElementsAnalysis;
445 446
446 JavaScriptConstantTask constantCompilerTask; 447 JavaScriptConstantTask constantCompilerTask;
447 448
448 JavaScriptResolutionCallbacks resolutionCallbacks; 449 JavaScriptResolutionCallbacks resolutionCallbacks;
449 450
451 PatchResolverTask patchResolverTask;
452
450 JavaScriptBackend(Compiler compiler, bool generateSourceMap) 453 JavaScriptBackend(Compiler compiler, bool generateSourceMap)
451 : namer = determineNamer(compiler), 454 : namer = determineNamer(compiler),
452 oneShotInterceptors = new Map<String, Selector>(), 455 oneShotInterceptors = new Map<String, Selector>(),
453 interceptedElements = new Map<String, Set<Element>>(), 456 interceptedElements = new Map<String, Set<Element>>(),
454 rti = new RuntimeTypes(compiler), 457 rti = new RuntimeTypes(compiler),
455 specializedGetInterceptors = new Map<String, Set<ClassElement>>(), 458 specializedGetInterceptors = new Map<String, Set<ClassElement>>(),
456 super(compiler) { 459 super(compiler) {
457 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap); 460 emitter = new CodeEmitterTask(compiler, namer, generateSourceMap);
458 typeVariableHandler = new TypeVariableHandler(this); 461 typeVariableHandler = new TypeVariableHandler(this);
459 customElementsAnalysis = new CustomElementsAnalysis(this); 462 customElementsAnalysis = new CustomElementsAnalysis(this);
460 constantCompilerTask = new JavaScriptConstantTask(compiler); 463 constantCompilerTask = new JavaScriptConstantTask(compiler);
461 resolutionCallbacks = new JavaScriptResolutionCallbacks(this); 464 resolutionCallbacks = new JavaScriptResolutionCallbacks(this);
465 patchResolverTask = new PatchResolverTask(compiler);
462 functionCompiler = USE_CPS_IR 466 functionCompiler = USE_CPS_IR
463 ? new CspFunctionCompiler(compiler, this) 467 ? new CspFunctionCompiler(compiler, this)
464 : new SsaFunctionCompiler(this, generateSourceMap); 468 : new SsaFunctionCompiler(this, generateSourceMap);
465 } 469 }
466 470
467 ConstantSystem get constantSystem => constants.constantSystem; 471 ConstantSystem get constantSystem => constants.constantSystem;
468 472
469 /// Returns constant environment for the JavaScript interpretation of the 473 /// Returns constant environment for the JavaScript interpretation of the
470 /// constants. 474 /// constants.
471 JavaScriptConstantCompiler get constants { 475 JavaScriptConstantCompiler get constants {
472 return constantCompilerTask.jsConstantCompiler; 476 return constantCompilerTask.jsConstantCompiler;
473 } 477 }
474 478
479 FunctionElement resolveExternalFunction(FunctionElement element) {
480 return patchResolverTask.measure(() {
481 return patchResolverTask.resolveExternalFunction(element);
482 });
483 }
484
475 // TODO(karlklose): Split into findHelperFunction and findHelperClass and 485 // TODO(karlklose): Split into findHelperFunction and findHelperClass and
476 // add a check that the element has the expected kind. 486 // add a check that the element has the expected kind.
477 Element findHelper(String name) => find(jsHelperLibrary, name); 487 Element findHelper(String name) => find(jsHelperLibrary, name);
478 Element findInterceptor(String name) => find(interceptorsLibrary, name); 488 Element findInterceptor(String name) => find(interceptorsLibrary, name);
479 489
480 Element find(LibraryElement library, String name) { 490 Element find(LibraryElement library, String name) {
481 Element element = library.findLocal(name); 491 Element element = library.findLocal(name);
482 assert(invariant(library, element != null, 492 assert(invariant(library, element != null,
483 message: "Element '$name' not found in '${library.canonicalUri}'.")); 493 message: "Element '$name' not found in '${library.canonicalUri}'."));
484 return element; 494 return element;
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1690 closureClass = lookupHelperClass('Closure'); 1700 closureClass = lookupHelperClass('Closure');
1691 if (!missingHelperClasses.isEmpty) { 1701 if (!missingHelperClasses.isEmpty) {
1692 compiler.internalError(jsHelperLibrary, 1702 compiler.internalError(jsHelperLibrary,
1693 'dart:_js_helper library does not contain required classes: ' 1703 'dart:_js_helper library does not contain required classes: '
1694 '$missingHelperClasses'); 1704 '$missingHelperClasses');
1695 } 1705 }
1696 } 1706 }
1697 1707
1698 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) { 1708 Future onLibraryScanned(LibraryElement library, LibraryLoader loader) {
1699 return super.onLibraryScanned(library, loader).then((_) { 1709 return super.onLibraryScanned(library, loader).then((_) {
1710 if (library.isPlatformLibrary && !library.isPatched) {
1711 // Apply patch, if any.
1712 Uri patchUri = compiler.resolvePatchUri(library.canonicalUri.path);
1713 if (patchUri != null) {
1714 return compiler.patchParser.patchLibrary(loader, patchUri, library);
1715 }
1716 }
1717 }).then((_) {
1700 Uri uri = library.canonicalUri; 1718 Uri uri = library.canonicalUri;
1701 1719
1702 VariableElement findVariable(String name) { 1720 VariableElement findVariable(String name) {
1703 return find(library, name); 1721 return find(library, name);
1704 } 1722 }
1705 1723
1706 FunctionElement findMethod(String name) { 1724 FunctionElement findMethod(String name) {
1707 return find(library, name); 1725 return find(library, name);
1708 } 1726 }
1709 1727
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 } 2488 }
2471 } 2489 }
2472 2490
2473 /// Records that [constant] is used by the element behind [registry]. 2491 /// Records that [constant] is used by the element behind [registry].
2474 class Dependency { 2492 class Dependency {
2475 final ConstantValue constant; 2493 final ConstantValue constant;
2476 final Element annotatedElement; 2494 final Element annotatedElement;
2477 2495
2478 const Dependency(this.constant, this.annotatedElement); 2496 const Dependency(this.constant, this.annotatedElement);
2479 } 2497 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/enqueue.dart ('k') | pkg/compiler/lib/src/js_backend/js_backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698