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

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

Issue 1346093003: Revert "Add optional message to assert in Dart2js - continued" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 final SsaCodeGeneratorTask generator; 8 final SsaCodeGeneratorTask generator;
9 final SsaBuilderTask builder; 9 final SsaBuilderTask builder;
10 final SsaOptimizerTask optimizer; 10 final SsaOptimizerTask optimizer;
(...skipping 2590 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 void visit(ast.Node node) { 2601 void visit(ast.Node node) {
2602 if (node != null) node.accept(this); 2602 if (node != null) node.accept(this);
2603 } 2603 }
2604 2604
2605 /// Visit [node] and pop the resulting [HInstruction]. 2605 /// Visit [node] and pop the resulting [HInstruction].
2606 HInstruction visitAndPop(ast.Node node) { 2606 HInstruction visitAndPop(ast.Node node) {
2607 node.accept(this); 2607 node.accept(this);
2608 return pop(); 2608 return pop();
2609 } 2609 }
2610 2610
2611 visitAssert(ast.Assert node) {
2612 if (!compiler.enableUserAssertions) return;
2613
2614 if (!node.hasMessage) {
2615 // Generate:
2616 //
2617 // assertHelper(condition);
2618 //
2619 visit(node.condition);
2620 pushInvokeStatic(node, backend.assertHelperMethod, [pop()]);
2621 pop();
2622 return;
2623 }
2624 // Assert has message. Generate:
2625 //
2626 // if (assertTest(condition)) assertThrow(message);
2627 //
2628 void buildCondition() {
2629 visit(node.condition);
2630 pushInvokeStatic(node, backend.assertTestMethod, [pop()]);
2631 }
2632 void fail() {
2633 visit(node.message);
2634 pushInvokeStatic(node, backend.assertThrowMethod, [pop()]);
2635 pop();
2636 }
2637 handleIf(node,
2638 visitCondition: buildCondition,
2639 visitThen: fail);
2640 }
2641
2642 visitBlock(ast.Block node) { 2611 visitBlock(ast.Block node) {
2643 assert(!isAborted()); 2612 assert(!isAborted());
2644 if (!isReachable) return; // This can only happen when inlining. 2613 if (!isReachable) return; // This can only happen when inlining.
2645 for (Link<ast.Node> link = node.statements.nodes; 2614 for (Link<ast.Node> link = node.statements.nodes;
2646 !link.isEmpty; 2615 !link.isEmpty;
2647 link = link.tail) { 2616 link = link.tail) {
2648 visit(link.head); 2617 visit(link.head);
2649 if (!isReachable) { 2618 if (!isReachable) {
2650 // The block has been aborted by a return or a throw. 2619 // The block has been aborted by a return or a throw.
2651 if (!stack.isEmpty) { 2620 if (!stack.isEmpty) {
(...skipping 2555 matching lines...) Expand 10 before | Expand all | Expand 10 after
5207 DartType instance = type.asInstanceOf(supertype.element); 5176 DartType instance = type.asInstanceOf(supertype.element);
5208 compiler.types.checkTypeVariableBounds(instance, 5177 compiler.types.checkTypeVariableBounds(instance,
5209 addTypeVariableBoundCheck); 5178 addTypeVariableBoundCheck);
5210 if (definitelyFails) { 5179 if (definitelyFails) {
5211 return true; 5180 return true;
5212 } 5181 }
5213 } 5182 }
5214 return false; 5183 return false;
5215 } 5184 }
5216 5185
5186 @override
5187 visitAssert(ast.Send node, ast.Node expression, _) {
5188 if (!compiler.enableUserAssertions) {
5189 stack.add(graph.addConstantNull(compiler));
5190 return;
5191 }
5192 assert(invariant(node, node.arguments.tail.isEmpty,
5193 message: "Invalid assertion: $node"));
5194 generateStaticFunctionInvoke(
5195 node, backend.assertMethod, CallStructure.ONE_ARG);
5196 }
5197
5217 visitStaticSend(ast.Send node) { 5198 visitStaticSend(ast.Send node) {
5218 internalError(node, "Unexpected visitStaticSend"); 5199 internalError(node, "Unexpected visitStaticSend");
5219 } 5200 }
5220 5201
5221 /// Generate an invocation to the static or top level [function]. 5202 /// Generate an invocation to the static or top level [function].
5222 void generateStaticFunctionInvoke( 5203 void generateStaticFunctionInvoke(
5223 ast.Send node, 5204 ast.Send node,
5224 FunctionElement function, 5205 FunctionElement function,
5225 CallStructure callStructure) { 5206 CallStructure callStructure) {
5226 List<HInstruction> inputs = makeStaticArgumentList( 5207 List<HInstruction> inputs = makeStaticArgumentList(
(...skipping 3096 matching lines...) Expand 10 before | Expand all | Expand 10 after
8323 void visitConstantInvoke( 8304 void visitConstantInvoke(
8324 ast.Send node, 8305 ast.Send node,
8325 ConstantExpression constant, 8306 ConstantExpression constant,
8326 ast.NodeList arguments, 8307 ast.NodeList arguments,
8327 CallStructure callStreucture, 8308 CallStructure callStreucture,
8328 _) { 8309 _) {
8329 visitNode(node); 8310 visitNode(node);
8330 } 8311 }
8331 8312
8332 @override 8313 @override
8314 void errorInvalidAssert(
8315 ast.Send node,
8316 ast.NodeList arguments,
8317 _) {
8318 visitNode(node);
8319 }
8320
8321 @override
8333 void errorUndefinedBinaryExpression( 8322 void errorUndefinedBinaryExpression(
8334 ast.Send node, 8323 ast.Send node,
8335 ast.Node left, 8324 ast.Node left,
8336 ast.Operator operator, 8325 ast.Operator operator,
8337 ast.Node right, 8326 ast.Node right,
8338 _) { 8327 _) {
8339 visitNode(node); 8328 visitNode(node);
8340 } 8329 }
8341 8330
8342 @override 8331 @override
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
8951 if (unaliased is TypedefType) throw 'unable to unalias $type'; 8940 if (unaliased is TypedefType) throw 'unable to unalias $type';
8952 unaliased.accept(this, builder); 8941 unaliased.accept(this, builder);
8953 } 8942 }
8954 8943
8955 void visitDynamicType(DynamicType type, SsaBuilder builder) { 8944 void visitDynamicType(DynamicType type, SsaBuilder builder) {
8956 JavaScriptBackend backend = builder.compiler.backend; 8945 JavaScriptBackend backend = builder.compiler.backend;
8957 ClassElement cls = backend.findHelper('DynamicRuntimeType'); 8946 ClassElement cls = backend.findHelper('DynamicRuntimeType');
8958 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld))); 8947 builder.push(new HDynamicType(type, new TypeMask.exact(cls, classWorld)));
8959 } 8948 }
8960 } 8949 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/tree_elements.dart ('k') | pkg/compiler/lib/src/tree/nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698