Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 dart2js.ir_builder; | 5 part of dart2js.ir_builder; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * This task iterates through all resolved elements and builds [ir.Node]s. The | 8 * This task iterates through all resolved elements and builds [ir.Node]s. The |
| 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and | 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and |
| 10 * [getIr]. | 10 * [getIr]. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 <Element, ir.FunctionDefinition>{}; | 26 <Element, ir.FunctionDefinition>{}; |
| 27 | 27 |
| 28 IrBuilderTask(Compiler compiler) : super(compiler); | 28 IrBuilderTask(Compiler compiler) : super(compiler); |
| 29 | 29 |
| 30 String get name => 'IR builder'; | 30 String get name => 'IR builder'; |
| 31 | 31 |
| 32 bool hasIr(Element element) => nodes.containsKey(element.implementation); | 32 bool hasIr(Element element) => nodes.containsKey(element.implementation); |
| 33 | 33 |
| 34 ir.FunctionDefinition getIr(Element element) => nodes[element.implementation]; | 34 ir.FunctionDefinition getIr(Element element) => nodes[element.implementation]; |
| 35 | 35 |
| 36 ir.FunctionDefinition buildNode(AstElement element) { | |
| 37 if (!canBuild(element)) return null; | |
| 38 TreeElements elementsMapping = element.resolvedAst.elements; | |
| 39 element = element.implementation; | |
| 40 return compiler.withCurrentElement(element, () { | |
| 41 SourceFile sourceFile = elementSourceFile(element); | |
| 42 IrBuilderVisitor builder = | |
| 43 new IrBuilderVisitor(elementsMapping, compiler, sourceFile); | |
| 44 ir.FunctionDefinition function; | |
| 45 function = builder.buildFunction(element); | |
| 46 | |
| 47 if (function != null) { | |
| 48 compiler.tracer.traceCompilation(element.name, null); | |
| 49 compiler.tracer.traceGraph("IR Builder", function); | |
| 50 } | |
| 51 return function; | |
| 52 }); | |
| 53 } | |
| 54 | |
| 36 void buildNodes({bool useNewBackend: false}) { | 55 void buildNodes({bool useNewBackend: false}) { |
| 37 if (!irEnabled(useNewBackend: useNewBackend)) return; | 56 if (!irEnabled(useNewBackend: useNewBackend)) return; |
|
floitsch
2014/11/12 11:03:19
Why does the builder need to know about backends?
sigurdm
2014/11/13 08:29:41
I agree - I removed it - it was only used from tes
| |
| 38 measure(() { | 57 measure(() { |
| 39 Set<Element> resolved = compiler.enqueuer.resolution.resolvedElements; | 58 Set<Element> resolved = compiler.enqueuer.resolution.resolvedElements; |
| 40 resolved.forEach((AstElement element) { | 59 resolved.forEach((AstElement element) { |
| 41 if (canBuild(element)) { | 60 ir.FunctionDefinition functionDefinition = buildNode(element); |
| 42 TreeElements elementsMapping = element.resolvedAst.elements; | 61 if (functionDefinition != null) { |
| 43 element = element.implementation; | 62 nodes[element] = functionDefinition; |
| 44 compiler.withCurrentElement(element, () { | |
| 45 SourceFile sourceFile = elementSourceFile(element); | |
| 46 IrBuilderVisitor builder = | |
| 47 new IrBuilderVisitor(elementsMapping, compiler, sourceFile); | |
| 48 ir.FunctionDefinition function; | |
| 49 function = builder.buildFunction(element); | |
| 50 | |
| 51 if (function != null) { | |
| 52 nodes[element] = function; | |
| 53 compiler.tracer.traceCompilation(element.name, null); | |
| 54 compiler.tracer.traceGraph("IR Builder", function); | |
| 55 } | |
| 56 }); | |
| 57 } | 63 } |
| 58 }); | 64 }); |
| 59 }); | 65 }); |
| 60 } | 66 } |
| 61 | 67 |
| 62 bool irEnabled({bool useNewBackend: false}) { | 68 bool irEnabled({bool useNewBackend: false}) { |
| 63 // TODO(sigurdm,kmillikin): Support checked-mode checks. | 69 // TODO(sigurdm,kmillikin): Support checked-mode checks. |
| 64 return (useNewBackend || const bool.fromEnvironment('USE_NEW_BACKEND')) && | 70 return (useNewBackend || const bool.fromEnvironment('USE_NEW_BACKEND')) && |
| 65 compiler.backend is DartBackend && | 71 compiler.backend is DartBackend && |
| 66 !compiler.enableTypeAssertions && | 72 !compiler.enableTypeAssertions && |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 node.visitChildren(this); | 891 node.visitChildren(this); |
| 886 } | 892 } |
| 887 | 893 |
| 888 visitFunctionExpression(ast.FunctionExpression node) { | 894 visitFunctionExpression(ast.FunctionExpression node) { |
| 889 FunctionElement oldFunction = currentFunction; | 895 FunctionElement oldFunction = currentFunction; |
| 890 currentFunction = elements[node]; | 896 currentFunction = elements[node]; |
| 891 visit(node.body); | 897 visit(node.body); |
| 892 currentFunction = oldFunction; | 898 currentFunction = oldFunction; |
| 893 } | 899 } |
| 894 } | 900 } |
| OLD | NEW |