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

Side by Side Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 10905235: Check boolean conversion in checked mode. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
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 class SsaCodeGeneratorTask extends CompilerTask { 5 class SsaCodeGeneratorTask extends CompilerTask {
6 6
7 final JavaScriptBackend backend; 7 final JavaScriptBackend backend;
8 8
9 SsaCodeGeneratorTask(JavaScriptBackend backend) 9 SsaCodeGeneratorTask(JavaScriptBackend backend)
10 : this.backend = backend, 10 : this.backend = backend,
(...skipping 2426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 js.Expression test = pop(); 2437 js.Expression test = pop();
2438 js.Block oldContainer = currentContainer; 2438 js.Block oldContainer = currentContainer;
2439 js.Statement body = new js.Block.empty(); 2439 js.Statement body = new js.Block.empty();
2440 currentContainer = body; 2440 currentContainer = body;
2441 generateThrowWithHelper('iae', node.checkedInput); 2441 generateThrowWithHelper('iae', node.checkedInput);
2442 currentContainer = oldContainer; 2442 currentContainer = oldContainer;
2443 body = unwrapStatement(body); 2443 body = unwrapStatement(body);
2444 pushStatement(new js.If.noElse(test, body), node); 2444 pushStatement(new js.If.noElse(test, body), node);
2445 return; 2445 return;
2446 } 2446 }
2447 assert(node.isCheckedModeCheck || node.isCastTypeCheck);
2447 2448
2448 assert(node.isCheckedModeCheck || node.isCastTypeCheck); 2449 SourceString helper;
2449 SourceString helper = backend.getCheckedModeHelper(type); 2450 if (node.isBooleanConversionCheck) {
2450 String additionalArgument = backend.namer.operatorIs(element); 2451 helper = const SourceString('boolConversionCheck');
2451 if (node.isCastTypeCheck) { 2452 } else {
2452 helper = castNames[helper.stringValue]; 2453 helper = backend.getCheckedModeHelper(type);
2454 if (node.isCastTypeCheck) {
2455 helper = castNames[helper.stringValue];
2456 }
2453 } 2457 }
2454 Element helperElement = compiler.findHelper(helper); 2458 Element helperElement = compiler.findHelper(helper);
2455 world.registerStaticUse(helperElement); 2459 world.registerStaticUse(helperElement);
2456 List<js.Expression> arguments = <js.Expression>[]; 2460 List<js.Expression> arguments = <js.Expression>[];
2457 use(node.checkedInput); 2461 use(node.checkedInput);
2458 arguments.add(pop()); 2462 arguments.add(pop());
2463 String additionalArgument = backend.namer.operatorIs(element);
2459 arguments.add(new js.LiteralString("'$additionalArgument'")); 2464 arguments.add(new js.LiteralString("'$additionalArgument'"));
2460 String helperName = backend.namer.isolateAccess(helperElement); 2465 String helperName = backend.namer.isolateAccess(helperElement);
2461 push(new js.Call(new js.VariableUse(helperName), arguments)); 2466 push(new js.Call(new js.VariableUse(helperName), arguments));
2462 } else { 2467 } else {
2463 use(node.checkedInput); 2468 use(node.checkedInput);
2464 } 2469 }
2465 } 2470 }
2466 } 2471 }
2467 2472
2468 class SsaOptimizedCodeGenerator extends SsaCodeGenerator { 2473 class SsaOptimizedCodeGenerator extends SsaCodeGenerator {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
2982 if (leftType.canBeNull() && rightType.canBeNull()) { 2987 if (leftType.canBeNull() && rightType.canBeNull()) {
2983 if (left.isConstantNull() || right.isConstantNull() || 2988 if (left.isConstantNull() || right.isConstantNull() ||
2984 (leftType.isPrimitive() && leftType == rightType)) { 2989 (leftType.isPrimitive() && leftType == rightType)) {
2985 return '=='; 2990 return '==';
2986 } 2991 }
2987 return null; 2992 return null;
2988 } else { 2993 } else {
2989 return '==='; 2994 return '===';
2990 } 2995 }
2991 } 2996 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698