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

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

Issue 10695106: Allow === and == to generate inputs at the use site when compiling to a single comparison (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cr fix Created 8 years, 5 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 | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | 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 /** 5 /**
6 * Instead of emitting each SSA instruction with a temporary variable 6 * Instead of emitting each SSA instruction with a temporary variable
7 * mark instructions that can be emitted at their use-site. 7 * mark instructions that can be emitted at their use-site.
8 * For example, in: 8 * For example, in:
9 * t0 = 4; 9 * t0 = 4;
10 * t1 = 3; 10 * t1 = 3;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 void visitIs(HIs instruction) {} 45 void visitIs(HIs instruction) {}
46 46
47 // A check method must not have its input generated at use site, 47 // A check method must not have its input generated at use site,
48 // because it's using it multiple times. 48 // because it's using it multiple times.
49 void visitCheck(HCheck instruction) {} 49 void visitCheck(HCheck instruction) {}
50 50
51 // A type guard should not generate its input at use site, otherwise 51 // A type guard should not generate its input at use site, otherwise
52 // they would not be alive. 52 // they would not be alive.
53 void visitTypeGuard(HTypeGuard instruction) {} 53 void visitTypeGuard(HTypeGuard instruction) {}
54 54
55 // If an equality operation is builtin it must not have its input generated at 55 // If an equality operation is builtin it must only have its inputs generated
56 // use site, because it's using it multiple times (because of null/undefined). 56 // at use site if it does not require an expression with repeated uses
57 // (because of null / undefined).
57 void visitEquals(HEquals instruction) { 58 void visitEquals(HEquals instruction) {
58 if (!instruction.builtin) super.visitEquals(instruction); 59 if (!instruction.builtin) super.visitEquals(instruction);
59 // Otherwise do nothing. 60 if (singleIdentityComparison(instruction.left, instruction.right) != null) {
61 super.visitEquals(instruction);
62 }
63 // Do nothing.
60 } 64 }
61 65
62 // Identity operations must not have its input generated at use site, because 66 // An identity operation must only have its inputs generated at use site if
63 // it's using it multiple times (because of null/undefined). 67 // does not require an expression with multiple uses (because of null /
64 void visitIdentity(HIdentity instruction) {} 68 // undefined).
69 void visitIdentity(HIdentity instruction) {
70 if (singleIdentityComparison(instruction.left, instruction.right) != null) {
71 super.visitIdentity(instruction);
72 }
73 // Do nothing.
74 }
65 75
66 void visitTypeConversion(HTypeConversion instruction) { 76 void visitTypeConversion(HTypeConversion instruction) {
67 if (!instruction.isChecked) { 77 if (!instruction.isChecked) {
68 markAsGenerateAtUseSite(instruction); 78 markAsGenerateAtUseSite(instruction);
69 } else if (instruction.isCheckedModeCheck) { 79 } else if (instruction.isCheckedModeCheck) {
70 // Checked mode checks compile to code that only use their input 80 // Checked mode checks compile to code that only use their input
71 // once, so we can safely visit them and try to merge the input. 81 // once, so we can safely visit them and try to merge the input.
72 visitInstruction(instruction); 82 visitInstruction(instruction);
73 } 83 }
74 } 84 }
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 }; 370 };
361 } 371 }
362 372
363 class JSBinaryOperatorPrecedence { 373 class JSBinaryOperatorPrecedence {
364 final int left; 374 final int left;
365 final int right; 375 final int right;
366 const JSBinaryOperatorPrecedence(this.left, this.right); 376 const JSBinaryOperatorPrecedence(this.left, this.right);
367 // All binary operators (excluding assignment) are left associative. 377 // All binary operators (excluding assignment) are left associative.
368 int get precedence() => left; 378 int get precedence() => left;
369 } 379 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/ssa/codegen.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698