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

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

Issue 11543017: Revert r16032: it revealed a bug in our bailout environment computation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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 HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBailoutTarget(HBailoutTarget node); 9 R visitBailoutTarget(HBailoutTarget node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 visitExitTry(HExitTry node) => visitControlFlow(node); 282 visitExitTry(HExitTry node) => visitControlFlow(node);
283 visitFieldGet(HFieldGet node) => visitFieldAccess(node); 283 visitFieldGet(HFieldGet node) => visitFieldAccess(node);
284 visitFieldSet(HFieldSet node) => visitFieldAccess(node); 284 visitFieldSet(HFieldSet node) => visitFieldAccess(node);
285 visitForeign(HForeign node) => visitInstruction(node); 285 visitForeign(HForeign node) => visitInstruction(node);
286 visitForeignNew(HForeignNew node) => visitForeign(node); 286 visitForeignNew(HForeignNew node) => visitForeign(node);
287 visitGoto(HGoto node) => visitControlFlow(node); 287 visitGoto(HGoto node) => visitControlFlow(node);
288 visitGreater(HGreater node) => visitRelational(node); 288 visitGreater(HGreater node) => visitRelational(node);
289 visitGreaterEqual(HGreaterEqual node) => visitRelational(node); 289 visitGreaterEqual(HGreaterEqual node) => visitRelational(node);
290 visitIdentity(HIdentity node) => visitRelational(node); 290 visitIdentity(HIdentity node) => visitRelational(node);
291 visitIf(HIf node) => visitConditionalBranch(node); 291 visitIf(HIf node) => visitConditionalBranch(node);
292 visitIndex(HIndex node) => visitInstruction(node); 292 visitIndex(HIndex node) => visitInvokeStatic(node);
293 visitIndexAssign(HIndexAssign node) => visitInvokeStatic(node); 293 visitIndexAssign(HIndexAssign node) => visitInvokeStatic(node);
294 visitIntegerCheck(HIntegerCheck node) => visitCheck(node); 294 visitIntegerCheck(HIntegerCheck node) => visitCheck(node);
295 visitInterceptor(HInterceptor node) => visitInstruction(node); 295 visitInterceptor(HInterceptor node) => visitInstruction(node);
296 visitInvokeClosure(HInvokeClosure node) 296 visitInvokeClosure(HInvokeClosure node)
297 => visitInvokeDynamic(node); 297 => visitInvokeDynamic(node);
298 visitInvokeDynamicMethod(HInvokeDynamicMethod node) 298 visitInvokeDynamicMethod(HInvokeDynamicMethod node)
299 => visitInvokeDynamic(node); 299 => visitInvokeDynamic(node);
300 visitInvokeDynamicGetter(HInvokeDynamicGetter node) 300 visitInvokeDynamicGetter(HInvokeDynamicGetter node)
301 => visitInvokeDynamicField(node); 301 => visitInvokeDynamicField(node);
302 visitInvokeDynamicSetter(HInvokeDynamicSetter node) 302 visitInvokeDynamicSetter(HInvokeDynamicSetter node)
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 1313
1314 class HInvokeClosure extends HInvokeDynamic { 1314 class HInvokeClosure extends HInvokeDynamic {
1315 HInvokeClosure(Selector selector, List<HInstruction> inputs) 1315 HInvokeClosure(Selector selector, List<HInstruction> inputs)
1316 : super(selector, null, inputs); 1316 : super(selector, null, inputs);
1317 accept(HVisitor visitor) => visitor.visitInvokeClosure(this); 1317 accept(HVisitor visitor) => visitor.visitInvokeClosure(this);
1318 } 1318 }
1319 1319
1320 class HInvokeDynamicMethod extends HInvokeDynamic { 1320 class HInvokeDynamicMethod extends HInvokeDynamic {
1321 HInvokeDynamicMethod(Selector selector, List<HInstruction> inputs) 1321 HInvokeDynamicMethod(Selector selector, List<HInstruction> inputs)
1322 : super(selector, null, inputs); 1322 : super(selector, null, inputs);
1323 String toString() => 'invoke dynamic method: $selector'; 1323 toString() => 'invoke dynamic method: $selector';
1324 accept(HVisitor visitor) => visitor.visitInvokeDynamicMethod(this); 1324 accept(HVisitor visitor) => visitor.visitInvokeDynamicMethod(this);
1325
1326 bool isIndexOperatorOnIndexablePrimitive(HTypeMap types) {
1327 return isInterceptorCall
1328 && selector.kind == SelectorKind.INDEX
1329 && inputs[1].isIndexablePrimitive(types);
1330 }
1331
1332 HType computeDesiredTypeForInput(HInstruction input,
1333 HTypeMap types,
1334 Compiler compiler) {
1335 // TODO(ngeoffray): Move this logic into a different class that
1336 // will know what type it wants for a given selector.
1337 if (selector.kind != SelectorKind.INDEX) return HType.UNKNOWN;
1338 if (!isInterceptorCall) return HType.UNKNOWN;
1339
1340 HInstruction index = inputs[2];
1341 if (input == inputs[1] &&
1342 (index.isTypeUnknown(types) || index.isNumber(types))) {
1343 return HType.INDEXABLE_PRIMITIVE;
1344 }
1345 // The index should be an int when the receiver is a string or array.
1346 // However it turns out that inserting an integer check in the optimized
1347 // version is cheaper than having another bailout case. This is true,
1348 // because the integer check will simply throw if it fails.
1349 return HType.UNKNOWN;
1350 }
1351 } 1325 }
1352 1326
1353 abstract class HInvokeDynamicField extends HInvokeDynamic { 1327 abstract class HInvokeDynamicField extends HInvokeDynamic {
1354 final bool isSideEffectFree; 1328 final bool isSideEffectFree;
1355 HInvokeDynamicField( 1329 HInvokeDynamicField(
1356 Selector selector, Element element, List<HInstruction> inputs, 1330 Selector selector, Element element, List<HInstruction> inputs,
1357 this.isSideEffectFree) 1331 this.isSideEffectFree)
1358 : super(selector, element, inputs); 1332 : super(selector, element, inputs);
1359 toString() => 'invoke dynamic field: $selector'; 1333 toString() => 'invoke dynamic field: $selector';
1360 } 1334 }
(...skipping 1097 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 toString() => 'literal list'; 2432 toString() => 'literal list';
2459 accept(HVisitor visitor) => visitor.visitLiteralList(this); 2433 accept(HVisitor visitor) => visitor.visitLiteralList(this);
2460 2434
2461 HType get guaranteedType => HType.EXTENDABLE_ARRAY; 2435 HType get guaranteedType => HType.EXTENDABLE_ARRAY;
2462 2436
2463 void prepareGvn(HTypeMap types) { 2437 void prepareGvn(HTypeMap types) {
2464 assert(!hasSideEffects(types)); 2438 assert(!hasSideEffects(types));
2465 } 2439 }
2466 } 2440 }
2467 2441
2468 class HIndex extends HInstruction { 2442 class HIndex extends HInvokeStatic {
2469 HIndex(HInstruction receiver, HInstruction index) 2443 HIndex(HStatic target, HInstruction receiver, HInstruction index)
2470 : super(<HInstruction>[receiver, index]); 2444 : super(<HInstruction>[target, receiver, index]);
2471 String toString() => 'index operator'; 2445 toString() => 'index operator';
2472 accept(HVisitor visitor) => visitor.visitIndex(this); 2446 accept(HVisitor visitor) => visitor.visitIndex(this);
2473 2447
2474 void prepareGvn(HTypeMap types) { 2448 void prepareGvn(HTypeMap types) {
2475 clearAllSideEffects(); 2449 clearAllSideEffects();
2476 setDependsOnIndexStore(); 2450 if (isBuiltin(types)) {
2477 setUseGvn(); 2451 setDependsOnIndexStore();
2452 setUseGvn();
2453 } else {
2454 setAllSideEffects();
2455 }
2478 } 2456 }
2479 2457
2480 HInstruction get receiver => inputs[0]; 2458 HInstruction get receiver => inputs[1];
2481 HInstruction get index => inputs[1]; 2459 HInstruction get index => inputs[2];
2460
2461 HType computeDesiredTypeForNonTargetInput(HInstruction input,
2462 HTypeMap types,
2463 Compiler compiler) {
2464 if (input == receiver &&
2465 (index.isTypeUnknown(types) || index.isNumber(types))) {
2466 return HType.INDEXABLE_PRIMITIVE;
2467 }
2468 // The index should be an int when the receiver is a string or array.
2469 // However it turns out that inserting an integer check in the optimized
2470 // version is cheaper than having another bailout case. This is true,
2471 // because the integer check will simply throw if it fails.
2472 return HType.UNKNOWN;
2473 }
2474
2475 bool isBuiltin(HTypeMap types)
2476 => receiver.isIndexablePrimitive(types) && index.isInteger(types);
2482 2477
2483 int typeCode() => HInstruction.INDEX_TYPECODE; 2478 int typeCode() => HInstruction.INDEX_TYPECODE;
2484 bool typeEquals(HInstruction other) => other is HIndex; 2479 bool typeEquals(HInstruction other) => other is HIndex;
2485 bool dataEquals(HIndex other) => true; 2480 bool dataEquals(HIndex other) => true;
2486 } 2481 }
2487 2482
2488 class HIndexAssign extends HInvokeStatic { 2483 class HIndexAssign extends HInvokeStatic {
2489 HIndexAssign(HStatic target, 2484 HIndexAssign(HStatic target,
2490 HInstruction receiver, 2485 HInstruction receiver,
2491 HInstruction index, 2486 HInstruction index,
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 HBasicBlock get start => expression.start; 2942 HBasicBlock get start => expression.start;
2948 HBasicBlock get end { 2943 HBasicBlock get end {
2949 // We don't create a switch block if there are no cases. 2944 // We don't create a switch block if there are no cases.
2950 assert(!statements.isEmpty); 2945 assert(!statements.isEmpty);
2951 return statements.last.end; 2946 return statements.last.end;
2952 } 2947 }
2953 2948
2954 bool accept(HStatementInformationVisitor visitor) => 2949 bool accept(HStatementInformationVisitor visitor) =>
2955 visitor.visitSwitchInfo(this); 2950 visitor.visitSwitchInfo(this);
2956 } 2951 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698