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

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

Issue 13940015: Allow using native JS []= on typed data lists. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // instructions. 46 // instructions.
47 new SsaNonSpeculativeTypePropagator(compiler), 47 new SsaNonSpeculativeTypePropagator(compiler),
48 new SsaCheckInserter(backend, work, context.boundsChecked), 48 new SsaCheckInserter(backend, work, context.boundsChecked),
49 new SsaRedundantPhiEliminator(), 49 new SsaRedundantPhiEliminator(),
50 new SsaDeadPhiEliminator(), 50 new SsaDeadPhiEliminator(),
51 new SsaConstantFolder(constantSystem, backend, work), 51 new SsaConstantFolder(constantSystem, backend, work),
52 new SsaNonSpeculativeTypePropagator(compiler), 52 new SsaNonSpeculativeTypePropagator(compiler),
53 new SsaReceiverSpecialization(compiler), 53 new SsaReceiverSpecialization(compiler),
54 new SsaGlobalValueNumberer(compiler), 54 new SsaGlobalValueNumberer(compiler),
55 new SsaCodeMotion(), 55 new SsaCodeMotion(),
56 new SsaValueRangeAnalyzer(constantSystem, work), 56 new SsaValueRangeAnalyzer(compiler, constantSystem, work),
57 // Previous optimizations may have generated new 57 // Previous optimizations may have generated new
58 // opportunities for constant folding. 58 // opportunities for constant folding.
59 new SsaConstantFolder(constantSystem, backend, work), 59 new SsaConstantFolder(constantSystem, backend, work),
60 new SsaSimplifyInterceptors(constantSystem), 60 new SsaSimplifyInterceptors(constantSystem),
61 new SsaDeadCodeEliminator()]; 61 new SsaDeadCodeEliminator()];
62 runPhases(graph, phases); 62 runPhases(graph, phases);
63 if (!speculative) { 63 if (!speculative) {
64 runPhase(graph, new SsaConstructionFieldTypes(backend, work)); 64 runPhase(graph, new SsaConstructionFieldTypes(backend, work));
65 } 65 }
66 }); 66 });
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 if (operand is HConstant) { 227 if (operand is HConstant) {
228 HConstant receiver = operand; 228 HConstant receiver = operand;
229 Constant folded = operation.fold(receiver.constant); 229 Constant folded = operation.fold(receiver.constant);
230 if (folded != null) return graph.addConstant(folded); 230 if (folded != null) return graph.addConstant(folded);
231 } 231 }
232 return null; 232 return null;
233 } 233 }
234 234
235 HInstruction tryOptimizeLengthInterceptedGetter(HInvokeDynamic node) { 235 HInstruction tryOptimizeLengthInterceptedGetter(HInvokeDynamic node) {
236 HInstruction actualReceiver = node.inputs[1]; 236 HInstruction actualReceiver = node.inputs[1];
237 237 if (actualReceiver.isIndexable(compiler)) {
238 // TODO(kasperl): Get rid of HType.isIndexablePrimitive() and use
239 // something like this everywhere instead.
240 TypeMask mask = actualReceiver.instructionType.computeMask(compiler);
241 DartType base = backend.jsIndexableClass.computeType(compiler);
242 TypeMask indexable = new TypeMask.nonNullSubtype(base);
243 TypeMask union = indexable.union(mask, compiler);
244 bool isIndexable = (union == indexable);
245
246 if (isIndexable) {
247 if (actualReceiver.isConstantString()) { 238 if (actualReceiver.isConstantString()) {
248 HConstant constantInput = actualReceiver; 239 HConstant constantInput = actualReceiver;
249 StringConstant constant = constantInput.constant; 240 StringConstant constant = constantInput.constant;
250 return graph.addConstantInt(constant.length, constantSystem); 241 return graph.addConstantInt(constant.length, constantSystem);
251 } else if (actualReceiver.isConstantList()) { 242 } else if (actualReceiver.isConstantList()) {
252 HConstant constantInput = actualReceiver; 243 HConstant constantInput = actualReceiver;
253 ListConstant constant = constantInput.constant; 244 ListConstant constant = constantInput.constant;
254 return graph.addConstantInt(constant.length, constantSystem); 245 return graph.addConstantInt(constant.length, constantSystem);
255 } 246 }
256 Element element = backend.jsIndexableLength; 247 Element element = backend.jsIndexableLength;
(...skipping 1463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 HBasicBlock block = user.block; 1711 HBasicBlock block = user.block;
1721 block.addAfter(user, interceptor); 1712 block.addAfter(user, interceptor);
1722 block.rewrite(user, interceptor); 1713 block.rewrite(user, interceptor);
1723 block.remove(user); 1714 block.remove(user);
1724 1715
1725 // The interceptor will be removed in the dead code elimination 1716 // The interceptor will be removed in the dead code elimination
1726 // phase. Note that removing it here would not work because of how 1717 // phase. Note that removing it here would not work because of how
1727 // the [visitBasicBlock] is implemented. 1718 // the [visitBasicBlock] is implemented.
1728 } 1719 }
1729 } 1720 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698