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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_task.dart

Issue 1196433002: Create and test source mapping for invocations. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Handle the new Name class in the JS Printer. Created 5 years, 5 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) 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 library dart2js.ir_builder_task; 5 library dart2js.ir_builder_task;
6 6
7 import '../closure.dart' as closurelib; 7 import '../closure.dart' as closurelib;
8 import '../closure.dart' hide ClosureScope; 8 import '../closure.dart' hide ClosureScope;
9 import '../constants/expressions.dart'; 9 import '../constants/expressions.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 25 matching lines...) Expand all
36 import '../constants/values.dart'; 36 import '../constants/values.dart';
37 37
38 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode); 38 typedef void IrBuilderCallback(Element element, ir.FunctionDefinition irNode);
39 39
40 /// This task provides the interface to build IR nodes from [ast.Node]s, which 40 /// This task provides the interface to build IR nodes from [ast.Node]s, which
41 /// is used from the [CpsFunctionCompiler] to generate code. 41 /// is used from the [CpsFunctionCompiler] to generate code.
42 /// 42 ///
43 /// This class is mainly there to correctly measure how long building the IR 43 /// This class is mainly there to correctly measure how long building the IR
44 /// takes. 44 /// takes.
45 class IrBuilderTask extends CompilerTask { 45 class IrBuilderTask extends CompilerTask {
46 final SourceInformationFactory sourceInformationFactory; 46 final SourceInformationStrategy sourceInformationStrategy;
47 47
48 String bailoutMessage = null; 48 String bailoutMessage = null;
49 49
50 /// If not null, this function will be called with for each 50 /// If not null, this function will be called with for each
51 /// [ir.FunctionDefinition] node that has been built. 51 /// [ir.FunctionDefinition] node that has been built.
52 IrBuilderCallback builderCallback; 52 IrBuilderCallback builderCallback;
53 53
54 IrBuilderTask(Compiler compiler, this.sourceInformationFactory, 54 IrBuilderTask(Compiler compiler, this.sourceInformationStrategy,
55 [this.builderCallback]) 55 [this.builderCallback])
56 : super(compiler); 56 : super(compiler);
57 57
58 String get name => 'IR builder'; 58 String get name => 'IR builder';
59 59
60 ir.FunctionDefinition buildNode(AstElement element) { 60 ir.FunctionDefinition buildNode(AstElement element) {
61 return measure(() { 61 return measure(() {
62 bailoutMessage = null; 62 bailoutMessage = null;
63 63
64 TreeElements elementsMapping = element.resolvedAst.elements; 64 TreeElements elementsMapping = element.resolvedAst.elements;
65 element = element.implementation; 65 element = element.implementation;
66 return compiler.withCurrentElement(element, () { 66 return compiler.withCurrentElement(element, () {
67 SourceInformationBuilder sourceInformationBuilder = 67 SourceInformationBuilder sourceInformationBuilder =
68 sourceInformationFactory.forContext(element); 68 sourceInformationStrategy.createBuilderForContext(element);
69 69
70 IrBuilderVisitor builder = 70 IrBuilderVisitor builder =
71 new JsIrBuilderVisitor( 71 new JsIrBuilderVisitor(
72 elementsMapping, compiler, sourceInformationBuilder); 72 elementsMapping, compiler, sourceInformationBuilder);
73 ir.FunctionDefinition irNode = builder.buildExecutable(element); 73 ir.FunctionDefinition irNode = builder.buildExecutable(element);
74 if (irNode == null) { 74 if (irNode == null) {
75 bailoutMessage = builder.bailoutMessage; 75 bailoutMessage = builder.bailoutMessage;
76 } else if (builderCallback != null) { 76 } else if (builderCallback != null) {
77 builderCallback(element, irNode); 77 builderCallback(element, irNode);
78 } 78 }
(...skipping 2925 matching lines...) Expand 10 before | Expand all | Expand 10 after
3004 CallStructure callStructure) { 3004 CallStructure callStructure) {
3005 Element element = backend.isolateHelperLibrary.find(helperName); 3005 Element element = backend.isolateHelperLibrary.find(helperName);
3006 if (element == null) { 3006 if (element == null) {
3007 compiler.internalError(node, 3007 compiler.internalError(node,
3008 'Isolate library and compiler mismatch.'); 3008 'Isolate library and compiler mismatch.');
3009 } 3009 }
3010 List<ir.Primitive> arguments = translateStaticArguments(argumentList, 3010 List<ir.Primitive> arguments = translateStaticArguments(argumentList,
3011 element, CallStructure.TWO_ARGS); 3011 element, CallStructure.TWO_ARGS);
3012 return irBuilder.buildStaticFunctionInvocation(element, 3012 return irBuilder.buildStaticFunctionInvocation(element,
3013 CallStructure.TWO_ARGS, arguments, 3013 CallStructure.TWO_ARGS, arguments,
3014 sourceInformation: sourceInformationBuilder.buildCall(node)); 3014 sourceInformation:
3015 sourceInformationBuilder.buildCall(node, node.selector));
3015 } 3016 }
3016 3017
3017 /// Lookup the value of the enum described by [node]. 3018 /// Lookup the value of the enum described by [node].
3018 getEnumValue(ast.Node node, EnumClassElement enumClass, List values) { 3019 getEnumValue(ast.Node node, EnumClassElement enumClass, List values) {
3019 Element element = elements[node]; 3020 Element element = elements[node];
3020 if (element is! FieldElement || element.enclosingClass != enumClass) { 3021 if (element is! FieldElement || element.enclosingClass != enumClass) {
3021 internalError(node, 'expected a JsBuiltin enum value'); 3022 internalError(node, 'expected a JsBuiltin enum value');
3022 } 3023 }
3023 3024
3024 int index = enumClass.enumValues.indexOf(element); 3025 int index = enumClass.enumValues.indexOf(element);
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
3190 ir.Primitive handleStaticFunctionInvoke(ast.Send node, 3191 ir.Primitive handleStaticFunctionInvoke(ast.Send node,
3191 MethodElement function, 3192 MethodElement function,
3192 ast.NodeList argumentList, 3193 ast.NodeList argumentList,
3193 CallStructure callStructure, 3194 CallStructure callStructure,
3194 _) { 3195 _) {
3195 if (compiler.backend.isForeign(function)) { 3196 if (compiler.backend.isForeign(function)) {
3196 return handleForeignCode(node, function, argumentList, callStructure); 3197 return handleForeignCode(node, function, argumentList, callStructure);
3197 } else { 3198 } else {
3198 return irBuilder.buildStaticFunctionInvocation(function, callStructure, 3199 return irBuilder.buildStaticFunctionInvocation(function, callStructure,
3199 translateStaticArguments(argumentList, function, callStructure), 3200 translateStaticArguments(argumentList, function, callStructure),
3200 sourceInformation: sourceInformationBuilder.buildCall(node)); 3201 sourceInformation:
3202 sourceInformationBuilder.buildCall(node, node.selector));
3201 } 3203 }
3202 } 3204 }
3203 } 3205 }
3204 3206
3205 /// Perform simple post-processing on the initial CPS-translated root term. 3207 /// Perform simple post-processing on the initial CPS-translated root term.
3206 /// 3208 ///
3207 /// This pass performs backend-independent post-processing on the translated 3209 /// This pass performs backend-independent post-processing on the translated
3208 /// term. It is implemented separately from the optimization passes because 3210 /// term. It is implemented separately from the optimization passes because
3209 /// it is required for correctness of the implementation. 3211 /// it is required for correctness of the implementation.
3210 /// 3212 ///
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 } 3254 }
3253 3255
3254 processSetStatic(ir.SetStatic node) { 3256 processSetStatic(ir.SetStatic node) {
3255 node.body = replacementFor(node.body); 3257 node.body = replacementFor(node.body);
3256 } 3258 }
3257 3259
3258 processContinuation(ir.Continuation node) { 3260 processContinuation(ir.Continuation node) {
3259 node.body = replacementFor(node.body); 3261 node.body = replacementFor(node.body);
3260 } 3262 }
3261 } 3263 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698