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

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

Issue 23496037: Turn a Dart String + String into a JavaScript String + String. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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 part of ssa; 5 part of ssa;
6 6
7 abstract class OptimizationPhase { 7 abstract class OptimizationPhase {
8 String get name; 8 String get name;
9 void visitGraph(HGraph graph); 9 void visitGraph(HGraph graph);
10 } 10 }
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 279
280 // Try converting the instruction to a builtin instruction. 280 // Try converting the instruction to a builtin instruction.
281 HInstruction instruction = 281 HInstruction instruction =
282 node.specializer.tryConvertToBuiltin(node, compiler); 282 node.specializer.tryConvertToBuiltin(node, compiler);
283 if (instruction != null) return instruction; 283 if (instruction != null) return instruction;
284 284
285 Selector selector = node.selector; 285 Selector selector = node.selector;
286 HInstruction input = node.inputs[1]; 286 HInstruction input = node.inputs[1];
287 287
288 if (selector.isCall()) { 288 if (selector.isCall() || selector.isOperator()) {
289 Element target; 289 Element target;
290 if (input.isExtendableArray(compiler)) { 290 if (input.isExtendableArray(compiler)) {
291 if (selector.applies(backend.jsArrayRemoveLast, compiler)) { 291 if (selector.applies(backend.jsArrayRemoveLast, compiler)) {
292 target = backend.jsArrayRemoveLast; 292 target = backend.jsArrayRemoveLast;
293 } else if (selector.applies(backend.jsArrayAdd, compiler)) { 293 } else if (selector.applies(backend.jsArrayAdd, compiler)) {
294 // The codegen special cases array calls, but does not 294 // The codegen special cases array calls, but does not
295 // inline argument type checks. 295 // inline argument type checks.
296 if (!compiler.enableTypeAssertions) { 296 if (!compiler.enableTypeAssertions) {
297 target = backend.jsArrayAdd; 297 target = backend.jsArrayAdd;
298 } 298 }
299 } 299 }
300 } else if (input.isString(compiler)) { 300 } else if (input.isString(compiler)) {
301 if (selector.applies(backend.jsStringSplit, compiler)) { 301 if (selector.applies(backend.jsStringSplit, compiler)) {
302 if (node.inputs[2].isString(compiler)) { 302 if (node.inputs[2].isString(compiler)) {
303 target = backend.jsStringSplit; 303 target = backend.jsStringSplit;
304 } 304 }
305 } else if (selector.applies(backend.jsStringConcat, compiler)) { 305 } else if (selector.applies(backend.jsStringOperatorAdd, compiler)) {
306 // `concat` is turned into a JavaScript '+' so we need to 306 // `operator+` is turned into a JavaScript '+' so we need to
307 // make sure the receiver is not null. 307 // make sure the receiver is not null.
308 if (node.inputs[2].isString(compiler) && !input.canBeNull()) { 308 if (node.inputs[2].isString(compiler) && !input.canBeNull()) {
309 target = backend.jsStringConcat; 309 target = backend.jsStringOperatorAdd;
310 } 310 }
311 } else if (selector.applies(backend.jsStringToString, compiler) 311 } else if (selector.applies(backend.jsStringToString, compiler)
312 && !input.canBeNull()) { 312 && !input.canBeNull()) {
313 return input; 313 return input;
314 } 314 }
315 } 315 }
316 if (target != null) { 316 if (target != null) {
317 // TODO(ngeoffray): There is a strong dependency between codegen 317 // TODO(ngeoffray): There is a strong dependency between codegen
318 // and this optimization that the dynamic invoke does not need an 318 // and this optimization that the dynamic invoke does not need an
319 // interceptor. We currently need to keep a 319 // interceptor. We currently need to keep a
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 // that knows it is not of a specific Type. 1504 // that knows it is not of a specific Type.
1505 } 1505 }
1506 1506
1507 for (HIf ifUser in notIfUsers) { 1507 for (HIf ifUser in notIfUsers) {
1508 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); 1508 changeUsesDominatedBy(ifUser.elseBlock, input, convertedType);
1509 // TODO(ngeoffray): Also change uses for the then block on a HType 1509 // TODO(ngeoffray): Also change uses for the then block on a HType
1510 // that knows it is not of a specific Type. 1510 // that knows it is not of a specific Type.
1511 } 1511 }
1512 } 1512 }
1513 } 1513 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/codegen.dart ('k') | tests/compiler/dart2js/string_add_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698