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

Side by Side Diff: pkg/compiler/lib/src/ssa/optimize.dart

Issue 1762723002: Cleanup 1: split parts into their own libraries, remove unused imports (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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
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 import '../common/codegen.dart' show
6 CodegenRegistry,
7 CodegenWorkItem;
8 import '../common/tasks.dart' show
9 CompilerTask;
10 import '../compiler.dart' show
11 Compiler;
12 import '../constants/constant_system.dart';
13 import '../constants/values.dart';
14 import '../core_types.dart' show
15 CoreClasses;
16 import '../dart_types.dart';
17 import '../elements/elements.dart';
18 import '../js/js.dart' as js;
19 import '../js_backend/backend_helpers.dart' show
20 BackendHelpers;
21 import '../js_backend/js_backend.dart';
22 import '../native/native.dart' as native;
23 import '../tree/tree.dart' as ast;
24 import '../types/types.dart';
25 import '../universe/selector.dart' show
26 Selector;
27 import '../universe/side_effects.dart' show
28 SideEffects;
29 import '../util/util.dart';
30 import '../world.dart' show
31 ClassWorld,
32 World;
33
34 import 'nodes.dart';
35 import 'types_propagation.dart';
36 import 'types.dart';
37 import 'value_range_analyzer.dart';
38 import 'value_set.dart';
39 import 'interceptor_simplifier.dart';
6 40
7 abstract class OptimizationPhase { 41 abstract class OptimizationPhase {
8 String get name; 42 String get name;
9 void visitGraph(HGraph graph); 43 void visitGraph(HGraph graph);
10 } 44 }
11 45
12 class SsaOptimizerTask extends CompilerTask { 46 class SsaOptimizerTask extends CompilerTask {
13 final JavaScriptBackend backend; 47 final JavaScriptBackend backend;
14 SsaOptimizerTask(JavaScriptBackend backend) 48 SsaOptimizerTask(JavaScriptBackend backend)
15 : this.backend = backend, 49 : this.backend = backend,
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 if (argument.isString(compiler)) { 404 if (argument.isString(compiler)) {
371 target = helpers.jsStringSplit; 405 target = helpers.jsStringSplit;
372 } 406 }
373 } else if (applies(helpers.jsStringOperatorAdd)) { 407 } else if (applies(helpers.jsStringOperatorAdd)) {
374 // `operator+` is turned into a JavaScript '+' so we need to 408 // `operator+` is turned into a JavaScript '+' so we need to
375 // make sure the receiver and the argument are not null. 409 // make sure the receiver and the argument are not null.
376 // TODO(sra): Do this via [node.specializer]. 410 // TODO(sra): Do this via [node.specializer].
377 HInstruction argument = node.inputs[2]; 411 HInstruction argument = node.inputs[2];
378 if (argument.isString(compiler) 412 if (argument.isString(compiler)
379 && !input.canBeNull()) { 413 && !input.canBeNull()) {
380 return new HStringConcat(input, argument, null, 414 return new HStringConcat(input, argument, node.instructionType);
381 node.instructionType);
382 } 415 }
383 } else if (applies(helpers.jsStringToString) 416 } else if (applies(helpers.jsStringToString)
384 && !input.canBeNull()) { 417 && !input.canBeNull()) {
385 return input; 418 return input;
386 } 419 }
387 } 420 }
388 if (target != null) { 421 if (target != null) {
389 // TODO(ngeoffray): There is a strong dependency between codegen 422 // TODO(ngeoffray): There is a strong dependency between codegen
390 // and this optimization that the dynamic invoke does not need an 423 // and this optimization that the dynamic invoke does not need an
391 // interceptor. We currently need to keep a 424 // interceptor. We currently need to keep a
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 if (leftString.primitiveValue.length + rightString.primitiveValue.length > 989 if (leftString.primitiveValue.length + rightString.primitiveValue.length >
957 MAX_SHARED_CONSTANT_FOLDED_STRING_LENGTH) { 990 MAX_SHARED_CONSTANT_FOLDED_STRING_LENGTH) {
958 if (node.usedBy.length > 1) return node; 991 if (node.usedBy.length > 1) return node;
959 } 992 }
960 993
961 HInstruction folded = graph.addConstant( 994 HInstruction folded = graph.addConstant(
962 constantSystem.createString(new ast.DartString.concat( 995 constantSystem.createString(new ast.DartString.concat(
963 leftString.primitiveValue, rightString.primitiveValue)), 996 leftString.primitiveValue, rightString.primitiveValue)),
964 compiler); 997 compiler);
965 if (prefix == null) return folded; 998 if (prefix == null) return folded;
966 return new HStringConcat(prefix, folded, node.node, backend.stringType); 999 return new HStringConcat(prefix, folded, backend.stringType);
967 } 1000 }
968 1001
969 HInstruction visitStringify(HStringify node) { 1002 HInstruction visitStringify(HStringify node) {
970 HInstruction input = node.inputs[0]; 1003 HInstruction input = node.inputs[0];
971 if (input.isString(compiler)) return input; 1004 if (input.isString(compiler)) return input;
972 if (input.isConstant()) { 1005 if (input.isConstant()) {
973 HConstant constant = input; 1006 HConstant constant = input;
974 if (!constant.constant.isPrimitive) return node; 1007 if (!constant.constant.isPrimitive) return node;
975 if (constant.constant.isInt) { 1008 if (constant.constant.isInt) {
976 // Only constant-fold int.toString() when Dart and JS results the same. 1009 // Only constant-fold int.toString() when Dart and JS results the same.
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
2398 2431
2399 keyedValues.forEach((receiver, values) { 2432 keyedValues.forEach((receiver, values) {
2400 result.keyedValues[receiver] = 2433 result.keyedValues[receiver] =
2401 new Map<HInstruction, HInstruction>.from(values); 2434 new Map<HInstruction, HInstruction>.from(values);
2402 }); 2435 });
2403 2436
2404 result.nonEscapingReceivers.addAll(nonEscapingReceivers); 2437 result.nonEscapingReceivers.addAll(nonEscapingReceivers);
2405 return result; 2438 return result;
2406 } 2439 }
2407 } 2440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698