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

Side by Side Diff: lib/src/compiler/code_generator.dart

Issue 2032903003: Switch how we track whether trackDdcProfile is set to reduce the performance impact. sra was seeing… (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/operations.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 import 'dart:collection' show HashMap, HashSet; 5 import 'dart:collection' show HashMap, HashSet;
6 import 'dart:math' show min, max; 6 import 'dart:math' show min, max;
7 7
8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator; 8 import 'package:analyzer/analyzer.dart' hide ConstantEvaluator;
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType; 10 import 'package:analyzer/dart/ast/token.dart' show Token, TokenType;
(...skipping 2691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 /// an expression. 2702 /// an expression.
2703 JS.Expression _emitFunctionCall(InvocationExpression node) { 2703 JS.Expression _emitFunctionCall(InvocationExpression node) {
2704 var fn = _visit(node.function); 2704 var fn = _visit(node.function);
2705 var args = _visit(node.argumentList) as List<JS.Expression>; 2705 var args = _visit(node.argumentList) as List<JS.Expression>;
2706 if (DynamicInvoke.get(node.function)) { 2706 if (DynamicInvoke.get(node.function)) {
2707 var typeArgs = _emitInvokeTypeArguments(node); 2707 var typeArgs = _emitInvokeTypeArguments(node);
2708 if (typeArgs != null) { 2708 if (typeArgs != null) {
2709 return js.call('dart.dgcall(#, #, #)', 2709 return js.call('dart.dgcall(#, #, #)',
2710 [fn, new JS.ArrayInitializer(typeArgs), args]); 2710 [fn, new JS.ArrayInitializer(typeArgs), args]);
2711 } else { 2711 } else {
2712 if (_inWhitelistCode(node)) { 2712 if (_inWhitelistCode(node, isCall: true)) {
2713 return new JS.Call(fn, args); 2713 return new JS.Call(fn, args);
2714 } 2714 }
2715 return js.call('dart.dcall(#, #)', [fn, args]); 2715 return js.call('dart.dcall(#, #)', [fn, args]);
2716 } 2716 }
2717 } else { 2717 } else {
2718 return new JS.Call(_applyInvokeTypeArguments(fn, node), args); 2718 return new JS.Call(_applyInvokeTypeArguments(fn, node), args);
2719 } 2719 }
2720 } 2720 }
2721 2721
2722 JS.Expression _applyInvokeTypeArguments( 2722 JS.Expression _applyInvokeTypeArguments(
(...skipping 1909 matching lines...) Expand 10 before | Expand all | Expand 10 after
4632 // TODO(leafp): The above only handles the case where the return type 4632 // TODO(leafp): The above only handles the case where the return type
4633 // is exactly Future/Stream/Iterable. Handle the subtype case. 4633 // is exactly Future/Stream/Iterable. Handle the subtype case.
4634 return DynamicTypeImpl.instance; 4634 return DynamicTypeImpl.instance;
4635 } 4635 }
4636 } 4636 }
4637 4637
4638 /// Maps whitelisted files to a list of whitelisted methods 4638 /// Maps whitelisted files to a list of whitelisted methods
4639 /// within the file. 4639 /// within the file.
4640 /// 4640 ///
4641 /// If the value is null, the entire file is whitelisted. 4641 /// If the value is null, the entire file is whitelisted.
4642 static Map<String, List<String>> _uncheckedWhitelist = {}; 4642 static Map<String, List<String>> _uncheckedWhitelist = {
4643 'dom_renderer.dart': ['moveNodesAfterSibling',],
4644 'template_ref.dart': ['createEmbeddedView'],
4645 'ng_class.dart': ['_applyIterableChanges'],
4646 'ng_for.dart': ['_bulkRemove', '_bulkInsert'],
4647 'view_container_ref.dart': ['createEmbeddedView'],
4648 'default_iterable_differ.dart': null,
4649 };
4643 4650
4644 bool _inWhitelistCode(AstNode node) { 4651 static Set<String> _uncheckedWhitelistCalls = new Set()
4652 ..add('ng_zone_impl.dart')
4653 ..add('stack_zone_specification.dart')
4654 ..add('view_manager.dart')
4655 ..add('view.dart');
4656
4657 bool _inWhitelistCode(AstNode node, {isCall: false}) {
4645 if (!options.useAngular2Whitelist) return false; 4658 if (!options.useAngular2Whitelist) return false;
4646 var path = _loader.currentElement.source.fullName; 4659 var path = _loader.currentElement.source.fullName;
4647 var filename = path.split("/").last; 4660 var filename = path.split("/").last;
4648 if (_uncheckedWhitelist.containsKey(filename)) { 4661 if (_uncheckedWhitelist.containsKey(filename)) {
4649 var whitelisted = _uncheckedWhitelist[filename]; 4662 var whitelisted = _uncheckedWhitelist[filename];
4650 if (whitelisted == null) return true; 4663 if (whitelisted == null) return true;
4651 var enclosing = node; 4664 var enclosing = node;
4652 while (enclosing != null && 4665 while (enclosing != null &&
4653 !(enclosing is ClassMember || enclosing is FunctionDeclaration)) { 4666 !(enclosing is ClassMember || enclosing is FunctionDeclaration)) {
4654 enclosing = enclosing.parent; 4667 enclosing = enclosing.parent;
4655 } 4668 }
4656 String name = (enclosing as dynamic)?.element?.name; 4669 String name = (enclosing as dynamic)?.element?.name;
4657 if (name != null) { 4670 if (name != null) {
4658 return whitelisted.contains(name); 4671 return whitelisted.contains(name);
4659 } 4672 }
4660 } 4673 }
4674
4675 // Dynamic calls are less risky so there is no need to whitelist at the
4676 // method level.
4677 if (isCall && _uncheckedWhitelistCalls.contains(filename)) return true;
4678
4661 return path.endsWith(".template.dart"); 4679 return path.endsWith(".template.dart");
4662 } 4680 }
4663 } 4681 }
4664 4682
4665 /// Choose a canonical name from the library element. 4683 /// Choose a canonical name from the library element.
4666 /// This never uses the library's name (the identifier in the `library` 4684 /// This never uses the library's name (the identifier in the `library`
4667 /// declaration) as it doesn't have any meaningful rules enforced. 4685 /// declaration) as it doesn't have any meaningful rules enforced.
4668 String jsLibraryName(String buildRoot, LibraryElement library) { 4686 String jsLibraryName(String buildRoot, LibraryElement library) {
4669 var uri = library.source.uri; 4687 var uri = library.source.uri;
4670 if (uri.scheme == 'dart') { 4688 if (uri.scheme == 'dart') {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
4712 } 4730 }
4713 4731
4714 bool isLibraryPrefix(Expression node) => 4732 bool isLibraryPrefix(Expression node) =>
4715 node is SimpleIdentifier && node.staticElement is PrefixElement; 4733 node is SimpleIdentifier && node.staticElement is PrefixElement;
4716 4734
4717 LibraryElement _getLibrary(AnalysisContext c, String uri) => 4735 LibraryElement _getLibrary(AnalysisContext c, String uri) =>
4718 c.computeLibraryElement(c.sourceFactory.forUri(uri)); 4736 c.computeLibraryElement(c.sourceFactory.forUri(uri));
4719 4737
4720 bool _isDartRuntime(LibraryElement l) => 4738 bool _isDartRuntime(LibraryElement l) =>
4721 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; 4739 l.isInSdk && l.source.uri.toString() == 'dart:_runtime';
OLDNEW
« no previous file with comments | « lib/runtime/dart_sdk.js ('k') | tool/input_sdk/private/ddc_runtime/operations.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698