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

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

Issue 13019003: Enable full type-checks in checked mode. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix a bug. Created 7 years, 8 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 part of ssa; 5 part of ssa;
6 6
7 class SsaCodeGeneratorTask extends CompilerTask { 7 class SsaCodeGeneratorTask extends CompilerTask {
8 8
9 final JavaScriptBackend backend; 9 final JavaScriptBackend backend;
10 10
(...skipping 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2298 push(new js.Binary('&&', 2298 push(new js.Binary('&&',
2299 objectTest, 2299 objectTest,
2300 new js.Binary('||', arrayTest, pop()))); 2300 new js.Binary('||', arrayTest, pop())));
2301 } 2301 }
2302 2302
2303 void visitIs(HIs node) { 2303 void visitIs(HIs node) {
2304 DartType type = node.typeExpression; 2304 DartType type = node.typeExpression;
2305 world.registerIsCheck(type, work.resolutionTree); 2305 world.registerIsCheck(type, work.resolutionTree);
2306 HInstruction input = node.expression; 2306 HInstruction input = node.expression;
2307 2307
2308 if (node.isVariableCheck || node.isCompoundCheck) { 2308 if (node.isVariableCheck || node.isCompoundCheck ||
2309 node.isCheckedModeTest) {
2309 use(node.checkCall); 2310 use(node.checkCall);
2310 } else { 2311 } else {
2311 assert(node.isRawCheck); 2312 assert(node.isRawCheck);
2312 LibraryElement coreLibrary = compiler.coreLibrary; 2313 LibraryElement coreLibrary = compiler.coreLibrary;
2313 ClassElement objectClass = compiler.objectClass; 2314 ClassElement objectClass = compiler.objectClass;
2314 Element element = type.element; 2315 Element element = type.element;
2315 2316
2316 if (identical(element, objectClass) || 2317 if (identical(element, objectClass) ||
2317 identical(element, compiler.dynamicClass)) { 2318 identical(element, compiler.dynamicClass)) {
2318 // The constant folder also does this optimization, but we make 2319 // The constant folder also does this optimization, but we make
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 } else if (input.canBePrimitive(compiler) || input.canBeNull()) { 2361 } else if (input.canBePrimitive(compiler) || input.canBeNull()) {
2361 checkObject(input, '==='); 2362 checkObject(input, '===');
2362 js.Expression objectTest = pop(); 2363 js.Expression objectTest = pop();
2363 checkType(input, type); 2364 checkType(input, type);
2364 push(new js.Binary('&&', objectTest, pop()), node); 2365 push(new js.Binary('&&', objectTest, pop()), node);
2365 } else { 2366 } else {
2366 checkType(input, type); 2367 checkType(input, type);
2367 attachLocationToLast(node); 2368 attachLocationToLast(node);
2368 } 2369 }
2369 } 2370 }
2370 if (node.nullOk) { 2371 if (!node.isCheckedModeTest && node.nullOk) {
2371 checkNull(input); 2372 checkNull(input);
2372 push(new js.Binary('||', pop(), pop()), node); 2373 push(new js.Binary('||', pop(), pop()), node);
2373 } 2374 }
2374 } 2375 }
2375 2376
2376 void visitTypeConversion(HTypeConversion node) { 2377 void visitTypeConversion(HTypeConversion node) {
2377 if (node.isChecked) { 2378 if (node.isChecked) {
2378 if (node.isArgumentTypeCheck) { 2379 if (node.isArgumentTypeCheck) {
2379 if (node.isInteger()) { 2380 if (node.isInteger()) {
2380 checkInt(node.checkedInput, '!=='); 2381 checkInt(node.checkedInput, '!==');
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
2961 if (leftType.canBeNull() && rightType.canBeNull()) { 2962 if (leftType.canBeNull() && rightType.canBeNull()) {
2962 if (left.isConstantNull() || right.isConstantNull() || 2963 if (left.isConstantNull() || right.isConstantNull() ||
2963 (leftType.isPrimitive() && leftType == rightType)) { 2964 (leftType.isPrimitive() && leftType == rightType)) {
2964 return '=='; 2965 return '==';
2965 } 2966 }
2966 return null; 2967 return null;
2967 } else { 2968 } else {
2968 return '==='; 2969 return '===';
2969 } 2970 }
2970 } 2971 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698