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

Side by Side Diff: frog/leg/ssa/codegen.dart

Issue 9667027: Collect is checks to only emit the ones that are needed. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/universe.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 SsaCodeGeneratorTask(Compiler compiler) : super(compiler); 6 SsaCodeGeneratorTask(Compiler compiler) : super(compiler);
7 String get name() => 'SSA code generator'; 7 String get name() => 'SSA code generator';
8 8
9 String generate(WorkItem work, HGraph graph) { 9 String generate(WorkItem work, HGraph graph) {
10 return measure(() { 10 return measure(() {
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 937
938 void checkNull(HInstruction input) { 938 void checkNull(HInstruction input) {
939 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE); 939 beginExpression(JSPrecedence.EQUALITY_PRECEDENCE);
940 use(input, JSPrecedence.EQUALITY_PRECEDENCE); 940 use(input, JSPrecedence.EQUALITY_PRECEDENCE);
941 buffer.add(" === (void 0)"); 941 buffer.add(" === (void 0)");
942 endExpression(JSPrecedence.EQUALITY_PRECEDENCE); 942 endExpression(JSPrecedence.EQUALITY_PRECEDENCE);
943 } 943 }
944 944
945 void visitIs(HIs node) { 945 void visitIs(HIs node) {
946 Element element = node.typeExpression; 946 Element element = node.typeExpression;
947 compiler.registerIsCheck(element);
947 LibraryElement coreLibrary = compiler.coreLibrary; 948 LibraryElement coreLibrary = compiler.coreLibrary;
948 ClassElement objectClass = coreLibrary.find(const SourceString('Object')); 949 ClassElement objectClass = coreLibrary.find(const SourceString('Object'));
949 HInstruction input = node.expression; 950 HInstruction input = node.expression;
950 if (node.nullOk) { 951 if (node.nullOk) {
951 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE); 952 beginExpression(JSPrecedence.LOGICAL_OR_PRECEDENCE);
952 checkNull(input); 953 checkNull(input);
953 buffer.add(' || '); 954 buffer.add(' || ');
954 } 955 }
955 if (element == objectClass) { 956 if (element == objectClass) {
956 // TODO(ahe): This probably belongs in the constant folder. 957 // TODO(ahe): This probably belongs in the constant folder.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 use(input, JSPrecedence.MEMBER_PRECEDENCE); 998 use(input, JSPrecedence.MEMBER_PRECEDENCE);
998 buffer.add('.'); 999 buffer.add('.');
999 buffer.add(compiler.namer.operatorIs(node.typeExpression)); 1000 buffer.add(compiler.namer.operatorIs(node.typeExpression));
1000 if (element.isClass() && (element.dynamic.isNative() 1001 if (element.isClass() && (element.dynamic.isNative()
1001 || isSupertypeOfNativeClass(element))) { 1002 || isSupertypeOfNativeClass(element))) {
1002 buffer.add(' || '); 1003 buffer.add(' || ');
1003 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); 1004 beginExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE);
1004 // First check if the object is not a Dart object. If the 1005 // First check if the object is not a Dart object. If the
1005 // object is a Dart object, we know the property check was 1006 // object is a Dart object, we know the property check was
1006 // sufficient. 1007 // sufficient.
1008 compiler.registerIsCheck(objectClass);
1007 buffer.add('!'); 1009 buffer.add('!');
1008 use(input, JSPrecedence.MEMBER_PRECEDENCE); 1010 use(input, JSPrecedence.MEMBER_PRECEDENCE);
1009 buffer.add('.'); 1011 buffer.add('.');
1010 buffer.add(compiler.namer.operatorIs(objectClass)); 1012 buffer.add(compiler.namer.operatorIs(objectClass));
1011 buffer.add(' && '); 1013 buffer.add(' && ');
1012 buffer.add(compiler.emitter.nativeEmitter.dynamicIsCheckName); 1014 buffer.add(compiler.emitter.nativeEmitter.dynamicIsCheckName);
1013 buffer.add('('); 1015 buffer.add('(');
1014 use(input, JSPrecedence.MEMBER_PRECEDENCE); 1016 use(input, JSPrecedence.MEMBER_PRECEDENCE);
1015 buffer.add(", '${compiler.namer.operatorIs(node.typeExpression)}')"); 1017 buffer.add(", '${compiler.namer.operatorIs(node.typeExpression)}')");
1016 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE); 1018 endExpression(JSPrecedence.LOGICAL_AND_PRECEDENCE);
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 startBailoutSwitch(); 1405 startBailoutSwitch();
1404 } 1406 }
1405 } 1407 }
1406 1408
1407 void endElse(HIf node) { 1409 void endElse(HIf node) {
1408 if (node.elseBlock.hasBailouts()) { 1410 if (node.elseBlock.hasBailouts()) {
1409 endBailoutSwitch(); 1411 endBailoutSwitch();
1410 } 1412 }
1411 } 1413 }
1412 } 1414 }
OLDNEW
« no previous file with comments | « frog/leg/emitter.dart ('k') | frog/leg/universe.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698