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

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

Issue 2925443002: Use failedAt in more places (ssa) (Closed)
Patch Set: Created 3 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry; 9 import '../common/codegen.dart' show CodegenRegistry;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 arguments.positional[positionalIndex++].accept(this); 468 arguments.positional[positionalIndex++].accept(this);
469 builtArguments.add(pop()); 469 builtArguments.add(pop());
470 }); 470 });
471 if (!signature.optionalParametersAreNamed) { 471 if (!signature.optionalParametersAreNamed) {
472 signature.forEachOptionalParameter((ParameterElement element) { 472 signature.forEachOptionalParameter((ParameterElement element) {
473 if (positionalIndex < arguments.positional.length) { 473 if (positionalIndex < arguments.positional.length) {
474 arguments.positional[positionalIndex++].accept(this); 474 arguments.positional[positionalIndex++].accept(this);
475 builtArguments.add(pop()); 475 builtArguments.add(pop());
476 } else { 476 } else {
477 var constantValue = constants.getConstantValue(element.constant); 477 var constantValue = constants.getConstantValue(element.constant);
478 assert(invariant(element, constantValue != null, 478 assert(constantValue != null,
479 message: 'No constant computed for $element')); 479 failedAt(element, 'No constant computed for $element'));
480 builtArguments.add(graph.addConstant(constantValue, closedWorld)); 480 builtArguments.add(graph.addConstant(constantValue, closedWorld));
481 } 481 }
482 }); 482 });
483 } else { 483 } else {
484 signature.orderedOptionalParameters.forEach((ParameterElement element) { 484 signature.orderedOptionalParameters.forEach((ParameterElement element) {
485 var correspondingNamed = arguments.named.firstWhere( 485 var correspondingNamed = arguments.named.firstWhere(
486 (named) => named.name == element.name, 486 (named) => named.name == element.name,
487 orElse: () => null); 487 orElse: () => null);
488 if (correspondingNamed != null) { 488 if (correspondingNamed != null) {
489 correspondingNamed.value.accept(this); 489 correspondingNamed.value.accept(this);
490 builtArguments.add(pop()); 490 builtArguments.add(pop());
491 } else { 491 } else {
492 var constantValue = constants.getConstantValue(element.constant); 492 var constantValue = constants.getConstantValue(element.constant);
493 assert(invariant(element, constantValue != null, 493 assert(constantValue != null,
494 message: 'No constant computed for $element')); 494 failedAt(element, 'No constant computed for $element'));
495 builtArguments.add(graph.addConstant(constantValue, closedWorld)); 495 builtArguments.add(graph.addConstant(constantValue, closedWorld));
496 } 496 }
497 }); 497 });
498 } 498 }
499 499
500 return builtArguments; 500 return builtArguments;
501 } 501 }
502 502
503 /// Creates localsHandler bindings for type parameters of a Supertype. 503 /// Creates localsHandler bindings for type parameters of a Supertype.
504 void _bindSupertypeTypeParameters(ir.Supertype supertype) { 504 void _bindSupertypeTypeParameters(ir.Supertype supertype) {
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
1094 HInstruction typeInfo, HInstruction newObject) { 1094 HInstruction typeInfo, HInstruction newObject) {
1095 // Set the runtime type information on the object. 1095 // Set the runtime type information on the object.
1096 FunctionEntity typeInfoSetterFn = _commonElements.setRuntimeTypeInfo; 1096 FunctionEntity typeInfoSetterFn = _commonElements.setRuntimeTypeInfo;
1097 // TODO(efortuna): Insert source information in this static invocation. 1097 // TODO(efortuna): Insert source information in this static invocation.
1098 _pushStaticInvocation(typeInfoSetterFn, <HInstruction>[newObject, typeInfo], 1098 _pushStaticInvocation(typeInfoSetterFn, <HInstruction>[newObject, typeInfo],
1099 commonMasks.dynamicType); 1099 commonMasks.dynamicType);
1100 1100
1101 // The new object will now be referenced through the 1101 // The new object will now be referenced through the
1102 // `setRuntimeTypeInfo` call. We therefore set the type of that 1102 // `setRuntimeTypeInfo` call. We therefore set the type of that
1103 // instruction to be of the object's type. 1103 // instruction to be of the object's type.
1104 assert(invariant(CURRENT_ELEMENT_SPANNABLE, 1104 assert(
1105 stack.last is HInvokeStatic || stack.last == newObject, 1105 stack.last is HInvokeStatic || stack.last == newObject,
1106 message: "Unexpected `stack.last`: Found ${stack.last}, " 1106 failedAt(
1107 CURRENT_ELEMENT_SPANNABLE,
1108 "Unexpected `stack.last`: Found ${stack.last}, "
1107 "expected ${newObject} or an HInvokeStatic. " 1109 "expected ${newObject} or an HInvokeStatic. "
1108 "State: typeInfo=$typeInfo, stack=$stack.")); 1110 "State: typeInfo=$typeInfo, stack=$stack."));
1109 stack.last.instructionType = newObject.instructionType; 1111 stack.last.instructionType = newObject.instructionType;
1110 return pop(); 1112 return pop();
1111 } 1113 }
1112 1114
1113 @override 1115 @override
1114 void visitWhileStatement(ir.WhileStatement whileStatement) { 1116 void visitWhileStatement(ir.WhileStatement whileStatement) {
1115 assert(isReachable); 1117 assert(isReachable);
1116 HInstruction buildCondition() { 1118 HInstruction buildCondition() {
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1727 // to create the phis in [joinBlock]. 1729 // to create the phis in [joinBlock].
1728 // If we never jump to the join block, [caseHandlers] will stay empty, and 1730 // If we never jump to the join block, [caseHandlers] will stay empty, and
1729 // the join block is never added to the graph. 1731 // the join block is never added to the graph.
1730 HBasicBlock joinBlock = new HBasicBlock(); 1732 HBasicBlock joinBlock = new HBasicBlock();
1731 List<LocalsHandler> caseHandlers = <LocalsHandler>[]; 1733 List<LocalsHandler> caseHandlers = <LocalsHandler>[];
1732 jumpHandler.forEachBreak((HBreak instruction, LocalsHandler locals) { 1734 jumpHandler.forEachBreak((HBreak instruction, LocalsHandler locals) {
1733 instruction.block.addSuccessor(joinBlock); 1735 instruction.block.addSuccessor(joinBlock);
1734 caseHandlers.add(locals); 1736 caseHandlers.add(locals);
1735 }); 1737 });
1736 jumpHandler.forEachContinue((HContinue instruction, LocalsHandler locals) { 1738 jumpHandler.forEachContinue((HContinue instruction, LocalsHandler locals) {
1737 assert(invariant( 1739 assert(
1738 _elementMap.getSpannable(targetElement, switchStatement), false, 1740 false,
1739 message: 'Continue cannot target a switch.')); 1741 failedAt(_elementMap.getSpannable(targetElement, switchStatement),
1742 'Continue cannot target a switch.'));
1740 }); 1743 });
1741 if (!isAborted()) { 1744 if (!isAborted()) {
1742 current.close(new HGoto()); 1745 current.close(new HGoto());
1743 lastOpenedBlock.addSuccessor(joinBlock); 1746 lastOpenedBlock.addSuccessor(joinBlock);
1744 caseHandlers.add(localsHandler); 1747 caseHandlers.add(localsHandler);
1745 } 1748 }
1746 if (!hasDefault) { 1749 if (!hasDefault) {
1747 // Always create a default case, to avoid a critical edge in the 1750 // Always create a default case, to avoid a critical edge in the
1748 // graph. 1751 // graph.
1749 HBasicBlock defaultCase = addNewBlock(); 1752 HBasicBlock defaultCase = addNewBlock();
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 stack.add(graph.addConstantNull(closedWorld)); 2560 stack.add(graph.addConstantNull(closedWorld));
2558 return; 2561 return;
2559 } 2562 }
2560 String globalName = _foreignConstantStringArgument( 2563 String globalName = _foreignConstantStringArgument(
2561 invocation, 1, 'JS_EMBEDDED_GLOBAL', 'second '); 2564 invocation, 1, 'JS_EMBEDDED_GLOBAL', 'second ');
2562 js.Template expr = js.js.expressionTemplateYielding( 2565 js.Template expr = js.js.expressionTemplateYielding(
2563 emitter.generateEmbeddedGlobalAccess(globalName)); 2566 emitter.generateEmbeddedGlobalAccess(globalName));
2564 2567
2565 native.NativeBehavior nativeBehavior = 2568 native.NativeBehavior nativeBehavior =
2566 _elementMap.getNativeBehaviorForJsEmbeddedGlobalCall(invocation); 2569 _elementMap.getNativeBehaviorForJsEmbeddedGlobalCall(invocation);
2567 assert(invariant(_elementMap.getSpannable(targetElement, invocation), 2570 assert(
2568 nativeBehavior != null, 2571 nativeBehavior != null,
2569 message: "No NativeBehavior for $invocation")); 2572 failedAt(_elementMap.getSpannable(targetElement, invocation),
2573 "No NativeBehavior for $invocation"));
2570 2574
2571 TypeMask ssaType = 2575 TypeMask ssaType =
2572 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld); 2576 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld);
2573 push(new HForeignCode(expr, ssaType, const <HInstruction>[], 2577 push(new HForeignCode(expr, ssaType, const <HInstruction>[],
2574 nativeBehavior: nativeBehavior)); 2578 nativeBehavior: nativeBehavior));
2575 } 2579 }
2576 2580
2577 void handleForeignJsBuiltin(ir.StaticInvocation invocation) { 2581 void handleForeignJsBuiltin(ir.StaticInvocation invocation) {
2578 if (_unexpectedForeignArguments(invocation, 2)) { 2582 if (_unexpectedForeignArguments(invocation, 2)) {
2579 // Result expected on stack. 2583 // Result expected on stack.
(...skipping 22 matching lines...) Expand all
2602 } 2606 }
2603 2607
2604 List<HInstruction> inputs = <HInstruction>[]; 2608 List<HInstruction> inputs = <HInstruction>[];
2605 for (ir.Expression argument in arguments.skip(2)) { 2609 for (ir.Expression argument in arguments.skip(2)) {
2606 argument.accept(this); 2610 argument.accept(this);
2607 inputs.add(pop()); 2611 inputs.add(pop());
2608 } 2612 }
2609 2613
2610 native.NativeBehavior nativeBehavior = 2614 native.NativeBehavior nativeBehavior =
2611 _elementMap.getNativeBehaviorForJsBuiltinCall(invocation); 2615 _elementMap.getNativeBehaviorForJsBuiltinCall(invocation);
2612 assert(invariant(_elementMap.getSpannable(targetElement, invocation), 2616 assert(
2613 nativeBehavior != null, 2617 nativeBehavior != null,
2614 message: "No NativeBehavior for $invocation")); 2618 failedAt(_elementMap.getSpannable(targetElement, invocation),
2619 "No NativeBehavior for $invocation"));
2615 2620
2616 TypeMask ssaType = 2621 TypeMask ssaType =
2617 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld); 2622 _typeInferenceMap.typeFromNativeBehavior(nativeBehavior, closedWorld);
2618 push(new HForeignCode(template, ssaType, inputs, 2623 push(new HForeignCode(template, ssaType, inputs,
2619 nativeBehavior: nativeBehavior)); 2624 nativeBehavior: nativeBehavior));
2620 } 2625 }
2621 2626
2622 void handleForeignJsGetFlag(ir.StaticInvocation invocation) { 2627 void handleForeignJsGetFlag(ir.StaticInvocation invocation) {
2623 if (_unexpectedForeignArguments(invocation, 1, 1)) { 2628 if (_unexpectedForeignArguments(invocation, 1, 1)) {
2624 stack.add( 2629 stack.add(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2670 2675
2671 void handleForeignJs(ir.StaticInvocation invocation) { 2676 void handleForeignJs(ir.StaticInvocation invocation) {
2672 if (_unexpectedForeignArguments(invocation, 2)) { 2677 if (_unexpectedForeignArguments(invocation, 2)) {
2673 // Result expected on stack. 2678 // Result expected on stack.
2674 stack.add(graph.addConstantNull(closedWorld)); 2679 stack.add(graph.addConstantNull(closedWorld));
2675 return; 2680 return;
2676 } 2681 }
2677 2682
2678 native.NativeBehavior nativeBehavior = 2683 native.NativeBehavior nativeBehavior =
2679 _elementMap.getNativeBehaviorForJsCall(invocation); 2684 _elementMap.getNativeBehaviorForJsCall(invocation);
2680 assert(invariant(_elementMap.getSpannable(targetElement, invocation), 2685 assert(
2681 nativeBehavior != null, 2686 nativeBehavior != null,
2682 message: "No NativeBehavior for $invocation")); 2687 failedAt(_elementMap.getSpannable(targetElement, invocation),
2688 "No NativeBehavior for $invocation"));
2683 2689
2684 List<HInstruction> inputs = <HInstruction>[]; 2690 List<HInstruction> inputs = <HInstruction>[];
2685 for (ir.Expression argument in invocation.arguments.positional.skip(2)) { 2691 for (ir.Expression argument in invocation.arguments.positional.skip(2)) {
2686 argument.accept(this); 2692 argument.accept(this);
2687 inputs.add(pop()); 2693 inputs.add(pop());
2688 } 2694 }
2689 2695
2690 if (nativeBehavior.codeTemplate.positionalArgumentCount != inputs.length) { 2696 if (nativeBehavior.codeTemplate.positionalArgumentCount != inputs.length) {
2691 reporter.reportErrorMessage( 2697 reporter.reportErrorMessage(
2692 _elementMap.getSpannable(targetElement, invocation), 2698 _elementMap.getSpannable(targetElement, invocation),
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
3413 enterBlock.setBlockFlow( 3419 enterBlock.setBlockFlow(
3414 new HTryBlockInformation( 3420 new HTryBlockInformation(
3415 kernelBuilder.wrapStatementGraph(bodyGraph), 3421 kernelBuilder.wrapStatementGraph(bodyGraph),
3416 exception, 3422 exception,
3417 kernelBuilder.wrapStatementGraph(catchGraph), 3423 kernelBuilder.wrapStatementGraph(catchGraph),
3418 kernelBuilder.wrapStatementGraph(finallyGraph)), 3424 kernelBuilder.wrapStatementGraph(finallyGraph)),
3419 exitBlock); 3425 exitBlock);
3420 kernelBuilder.inTryStatement = previouslyInTryStatement; 3426 kernelBuilder.inTryStatement = previouslyInTryStatement;
3421 } 3427 }
3422 } 3428 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698