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

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

Issue 829913006: Optimize is-check to instanceof when it eliminates an interceptor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitBitAnd(HBitAnd node); 9 R visitBitAnd(HBitAnd node);
10 R visitBitNot(HBitNot node); 10 R visitBitNot(HBitNot node);
(...skipping 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2414 class HIs extends HInstruction { 2414 class HIs extends HInstruction {
2415 /// A check against a raw type: 'o is int', 'o is A'. 2415 /// A check against a raw type: 'o is int', 'o is A'.
2416 static const int RAW_CHECK = 0; 2416 static const int RAW_CHECK = 0;
2417 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'. 2417 /// A check against a type with type arguments: 'o is List<int>', 'o is C<T>'.
2418 static const int COMPOUND_CHECK = 1; 2418 static const int COMPOUND_CHECK = 1;
2419 /// A check against a single type variable: 'o is T'. 2419 /// A check against a single type variable: 'o is T'.
2420 static const int VARIABLE_CHECK = 2; 2420 static const int VARIABLE_CHECK = 2;
2421 2421
2422 final DartType typeExpression; 2422 final DartType typeExpression;
2423 final int kind; 2423 final int kind;
2424 final bool useInstanceOf;
2424 2425
2425 HIs.direct(DartType typeExpression, 2426 HIs.direct(DartType typeExpression,
2426 HInstruction expression, 2427 HInstruction expression,
2427 TypeMask type) 2428 TypeMask type)
2428 : this.internal(typeExpression, [expression], RAW_CHECK, type); 2429 : this.internal(typeExpression, [expression], RAW_CHECK, type);
2429 2430
2431 // Pre-verified that the check can be done using 'instanceof'.
2432 HIs.instanceOf(DartType typeExpression,
2433 HInstruction expression,
2434 TypeMask type)
2435 : this.internal(typeExpression, [expression], RAW_CHECK, type, true);
2436
2430 HIs.raw(DartType typeExpression, 2437 HIs.raw(DartType typeExpression,
2431 HInstruction expression, 2438 HInstruction expression,
2432 HInterceptor interceptor, 2439 HInterceptor interceptor,
2433 TypeMask type) 2440 TypeMask type)
2434 : this.internal( 2441 : this.internal(
2435 typeExpression, [expression, interceptor], RAW_CHECK, type); 2442 typeExpression, [expression, interceptor], RAW_CHECK, type);
2436 2443
2437 HIs.compound(DartType typeExpression, 2444 HIs.compound(DartType typeExpression,
2438 HInstruction expression, 2445 HInstruction expression,
2439 HInstruction call, 2446 HInstruction call,
2440 TypeMask type) 2447 TypeMask type)
2441 : this.internal(typeExpression, [expression, call], COMPOUND_CHECK, type); 2448 : this.internal(typeExpression, [expression, call], COMPOUND_CHECK, type);
2442 2449
2443 HIs.variable(DartType typeExpression, 2450 HIs.variable(DartType typeExpression,
2444 HInstruction expression, 2451 HInstruction expression,
2445 HInstruction call, 2452 HInstruction call,
2446 TypeMask type) 2453 TypeMask type)
2447 : this.internal(typeExpression, [expression, call], VARIABLE_CHECK, type); 2454 : this.internal(typeExpression, [expression, call], VARIABLE_CHECK, type);
2448 2455
2449 HIs.internal(this.typeExpression, List<HInstruction> inputs, this.kind, type) 2456 HIs.internal(this.typeExpression, List<HInstruction> inputs, this.kind,
2457 TypeMask type, [bool this.useInstanceOf = false])
floitsch 2015/01/16 14:14:34 I would make useInstanceOf a named argument.
sra1 2015/01/20 20:07:28 Done.
2450 : super(inputs, type) { 2458 : super(inputs, type) {
2451 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK); 2459 assert(kind >= RAW_CHECK && kind <= VARIABLE_CHECK);
2452 setUseGvn(); 2460 setUseGvn();
2453 } 2461 }
2454 2462
2455 HInstruction get expression => inputs[0]; 2463 HInstruction get expression => inputs[0];
2456 2464
2457 HInstruction get interceptor { 2465 HInstruction get interceptor {
2458 assert(kind == RAW_CHECK); 2466 assert(kind == RAW_CHECK);
2459 return inputs.length > 1 ? inputs[1] : null; 2467 return inputs.length > 1 ? inputs[1] : null;
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
3091 class HDynamicType extends HRuntimeType { 3099 class HDynamicType extends HRuntimeType {
3092 HDynamicType(DynamicType dartType, TypeMask instructionType) 3100 HDynamicType(DynamicType dartType, TypeMask instructionType)
3093 : super(const <HInstruction>[], dartType, instructionType); 3101 : super(const <HInstruction>[], dartType, instructionType);
3094 3102
3095 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3103 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3096 3104
3097 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3105 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3098 3106
3099 bool typeEquals(HInstruction other) => other is HDynamicType; 3107 bool typeEquals(HInstruction other) => other is HDynamicType;
3100 } 3108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698