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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1173403002: dart2js: Fix hints in code base. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Updated to latest revision Created 5 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
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 ssa; 5 part of ssa;
6 6
7 class SsaFunctionCompiler implements FunctionCompiler { 7 class SsaFunctionCompiler implements FunctionCompiler {
8 SsaCodeGeneratorTask generator; 8 SsaCodeGeneratorTask generator;
9 SsaBuilderTask builder; 9 SsaBuilderTask builder;
10 SsaOptimizerTask optimizer; 10 SsaOptimizerTask optimizer;
(...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 if (isNativeUpgradeFactory) { 2254 if (isNativeUpgradeFactory) {
2255 if (interceptor == null) { 2255 if (interceptor == null) {
2256 ConstantValue constant = 2256 ConstantValue constant =
2257 new InterceptorConstantValue(classElement.thisType); 2257 new InterceptorConstantValue(classElement.thisType);
2258 interceptor = graph.addConstant(constant, compiler); 2258 interceptor = graph.addConstant(constant, compiler);
2259 } 2259 }
2260 bodyCallInputs.add(interceptor); 2260 bodyCallInputs.add(interceptor);
2261 } 2261 }
2262 bodyCallInputs.add(newObject); 2262 bodyCallInputs.add(newObject);
2263 ResolvedAst resolvedAst = constructor.resolvedAst; 2263 ResolvedAst resolvedAst = constructor.resolvedAst;
2264 TreeElements elements = resolvedAst.elements;
2265 ast.Node node = resolvedAst.node; 2264 ast.Node node = resolvedAst.node;
2266 ClosureClassMap parameterClosureData = 2265 ClosureClassMap parameterClosureData =
2267 compiler.closureToClassMapper.getMappingForNestedFunction(node); 2266 compiler.closureToClassMapper.getMappingForNestedFunction(node);
2268 2267
2269 FunctionSignature functionSignature = body.functionSignature; 2268 FunctionSignature functionSignature = body.functionSignature;
2270 // Provide the parameters to the generative constructor body. 2269 // Provide the parameters to the generative constructor body.
2271 functionSignature.orderedForEachParameter((ParameterElement parameter) { 2270 functionSignature.orderedForEachParameter((ParameterElement parameter) {
2272 // If [parameter] is boxed, it will be a field in the box passed as the 2271 // If [parameter] is boxed, it will be a field in the box passed as the
2273 // last parameter. So no need to directly pass it. 2272 // last parameter. So no need to directly pass it.
2274 if (!localsHandler.isBoxed(parameter)) { 2273 if (!localsHandler.isBoxed(parameter)) {
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 2778
2780 if (bodyBlock != null) { 2779 if (bodyBlock != null) {
2781 continueHandlers.add(localsHandler); 2780 continueHandlers.add(localsHandler);
2782 bodyBlock.addSuccessor(updateBlock); 2781 bodyBlock.addSuccessor(updateBlock);
2783 } 2782 }
2784 2783
2785 open(updateBlock); 2784 open(updateBlock);
2786 localsHandler = 2785 localsHandler =
2787 continueHandlers[0].mergeMultiple(continueHandlers, updateBlock); 2786 continueHandlers[0].mergeMultiple(continueHandlers, updateBlock);
2788 2787
2789 HLabeledBlockInformation labelInfo;
2790 List<LabelDefinition> labels = jumpHandler.labels(); 2788 List<LabelDefinition> labels = jumpHandler.labels();
2791 JumpTarget target = elements.getTargetDefinition(loop); 2789 JumpTarget target = elements.getTargetDefinition(loop);
2792 if (!labels.isEmpty) { 2790 if (!labels.isEmpty) {
2793 beginBodyBlock.setBlockFlow( 2791 beginBodyBlock.setBlockFlow(
2794 new HLabeledBlockInformation( 2792 new HLabeledBlockInformation(
2795 new HSubGraphBlockInformation(bodyGraph), 2793 new HSubGraphBlockInformation(bodyGraph),
2796 jumpHandler.labels(), 2794 jumpHandler.labels(),
2797 isContinue: true), 2795 isContinue: true),
2798 updateBlock); 2796 updateBlock);
2799 } else if (target != null && target.isContinueTarget) { 2797 } else if (target != null && target.isContinueTarget) {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 } 2913 }
2916 visit(node.condition); 2914 visit(node.condition);
2917 return popBoolified(); 2915 return popBoolified();
2918 } 2916 }
2919 void buildUpdate() { 2917 void buildUpdate() {
2920 for (ast.Expression expression in node.update) { 2918 for (ast.Expression expression in node.update) {
2921 visit(expression); 2919 visit(expression);
2922 assert(!isAborted()); 2920 assert(!isAborted());
2923 // The result of the update instruction isn't used, and can just 2921 // The result of the update instruction isn't used, and can just
2924 // be dropped. 2922 // be dropped.
2925 HInstruction updateInstruction = pop(); 2923 pop();
2926 } 2924 }
2927 } 2925 }
2928 void buildBody() { 2926 void buildBody() {
2929 visit(node.body); 2927 visit(node.body);
2930 } 2928 }
2931 handleLoop(node, buildInitializer, buildCondition, buildUpdate, buildBody); 2929 handleLoop(node, buildInitializer, buildCondition, buildUpdate, buildBody);
2932 } 2930 }
2933 2931
2934 visitWhile(ast.While node) { 2932 visitWhile(ast.While node) {
2935 assert(isReachable); 2933 assert(isReachable);
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
3624 // (dartbug.com/7182). 3622 // (dartbug.com/7182).
3625 HInstruction buildTypeArgumentRepresentations(DartType type) { 3623 HInstruction buildTypeArgumentRepresentations(DartType type) {
3626 // Compute the representation of the type arguments, including access 3624 // Compute the representation of the type arguments, including access
3627 // to the runtime type information for type variables as instructions. 3625 // to the runtime type information for type variables as instructions.
3628 if (type.isTypeVariable) { 3626 if (type.isTypeVariable) {
3629 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]); 3627 return buildLiteralList(<HInstruction>[addTypeVariableReference(type)]);
3630 } else { 3628 } else {
3631 assert(type.element.isClass); 3629 assert(type.element.isClass);
3632 InterfaceType interface = type; 3630 InterfaceType interface = type;
3633 List<HInstruction> inputs = <HInstruction>[]; 3631 List<HInstruction> inputs = <HInstruction>[];
3634 bool first = true;
3635 List<js.Expression> templates = <js.Expression>[]; 3632 List<js.Expression> templates = <js.Expression>[];
3636 for (DartType argument in interface.typeArguments) { 3633 for (DartType argument in interface.typeArguments) {
3637 // As we construct the template in stages, we have to make sure that for 3634 // As we construct the template in stages, we have to make sure that for
3638 // each part the generated sub-template's holes match the index of the 3635 // each part the generated sub-template's holes match the index of the
3639 // inputs that are later used to instantiate it. We do this by starting 3636 // inputs that are later used to instantiate it. We do this by starting
3640 // the indexing with the number of inputs from previous sub-templates. 3637 // the indexing with the number of inputs from previous sub-templates.
3641 templates.add( 3638 templates.add(
3642 rti.getTypeRepresentationWithPlaceholders(argument, (variable) { 3639 rti.getTypeRepresentationWithPlaceholders(argument, (variable) {
3643 HInstruction runtimeType = addTypeVariableReference(variable); 3640 HInstruction runtimeType = addTypeVariableReference(variable);
3644 inputs.add(runtimeType); 3641 inputs.add(runtimeType);
(...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after
6522 6519
6523 InterfaceType type = elements.getType(node); 6520 InterfaceType type = elements.getType(node);
6524 InterfaceType expectedType = 6521 InterfaceType expectedType =
6525 functionElement.computeEffectiveTargetType(type); 6522 functionElement.computeEffectiveTargetType(type);
6526 expectedType = localsHandler.substInContext(expectedType); 6523 expectedType = localsHandler.substInContext(expectedType);
6527 6524
6528 ClassElement cls = constructor.enclosingClass; 6525 ClassElement cls = constructor.enclosingClass;
6529 6526
6530 if (backend.classNeedsRti(cls)) { 6527 if (backend.classNeedsRti(cls)) {
6531 List<HInstruction> typeInputs = <HInstruction>[]; 6528 List<HInstruction> typeInputs = <HInstruction>[];
6532 List<DartType> typeVariable = cls.typeVariables;
6533 expectedType.typeArguments.forEach((DartType argument) { 6529 expectedType.typeArguments.forEach((DartType argument) {
6534 typeInputs.add(analyzeTypeArgument(argument)); 6530 typeInputs.add(analyzeTypeArgument(argument));
6535 }); 6531 });
6536 6532
6537 // We lift this common call pattern into a helper function to save space 6533 // We lift this common call pattern into a helper function to save space
6538 // in the output. 6534 // in the output.
6539 if (typeInputs.every((HInstruction input) => input.isNull())) { 6535 if (typeInputs.every((HInstruction input) => input.isNull())) {
6540 if (listInputs.isEmpty) { 6536 if (listInputs.isEmpty) {
6541 constructor = backend.mapLiteralUntypedEmptyMaker; 6537 constructor = backend.mapLiteralUntypedEmptyMaker;
6542 } else { 6538 } else {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
6820 */ 6816 */
6821 void handleSwitch( 6817 void handleSwitch(
6822 ast.Node errorNode, 6818 ast.Node errorNode,
6823 JumpHandler jumpHandler, 6819 JumpHandler jumpHandler,
6824 HInstruction buildExpression(), 6820 HInstruction buildExpression(),
6825 var switchCases, 6821 var switchCases,
6826 Iterable<ConstantValue> getConstants(ast.SwitchCase switchCase), 6822 Iterable<ConstantValue> getConstants(ast.SwitchCase switchCase),
6827 bool isDefaultCase(ast.SwitchCase switchCase), 6823 bool isDefaultCase(ast.SwitchCase switchCase),
6828 void buildSwitchCase(ast.SwitchCase switchCase)) { 6824 void buildSwitchCase(ast.SwitchCase switchCase)) {
6829 6825
6830 Map<ast.CaseMatch, ConstantValue> constants =
6831 new Map<ast.CaseMatch, ConstantValue>();
6832
6833 HBasicBlock expressionStart = openNewBlock(); 6826 HBasicBlock expressionStart = openNewBlock();
6834 HInstruction expression = buildExpression(); 6827 HInstruction expression = buildExpression();
6835 if (switchCases.isEmpty) { 6828 if (switchCases.isEmpty) {
6836 return; 6829 return;
6837 } 6830 }
6838 6831
6839 HSwitch switchInstruction = new HSwitch(<HInstruction>[expression]); 6832 HSwitch switchInstruction = new HSwitch(<HInstruction>[expression]);
6840 HBasicBlock expressionEnd = close(switchInstruction); 6833 HBasicBlock expressionEnd = close(switchInstruction);
6841 LocalsHandler savedLocals = localsHandler; 6834 LocalsHandler savedLocals = localsHandler;
6842 6835
(...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after
7879 if (unaliased is TypedefType) throw 'unable to unalias $type'; 7872 if (unaliased is TypedefType) throw 'unable to unalias $type';
7880 unaliased.accept(this, builder); 7873 unaliased.accept(this, builder);
7881 } 7874 }
7882 7875
7883 void visitDynamicType(DynamicType type, SsaBuilder builder) { 7876 void visitDynamicType(DynamicType type, SsaBuilder builder) {
7884 JavaScriptBackend backend = builder.compiler.backend; 7877 JavaScriptBackend backend = builder.compiler.backend;
7885 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 7878 ClassElement cls = backend.findHelper('DynamicRuntimeType');
7886 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 7879 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
7887 } 7880 }
7888 } 7881 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698