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

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

Issue 1057753002: Redo "Avoid getInterceptor calls in cases were the interceptor would be constant if it were not `nu… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix assert fail Created 5 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 HVisitor<R> { 7 abstract class HVisitor<R> {
8 R visitAdd(HAdd node); 8 R visitAdd(HAdd node);
9 R visitAwait(HAwait node); 9 R visitAwait(HAwait node);
10 R visitBitAnd(HBitAnd node); 10 R visitBitAnd(HBitAnd node);
(...skipping 2282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 int typeCode() => HInstruction.STATIC_TYPECODE; 2293 int typeCode() => HInstruction.STATIC_TYPECODE;
2294 bool typeEquals(other) => other is HStatic; 2294 bool typeEquals(other) => other is HStatic;
2295 bool dataEquals(HStatic other) => element == other.element; 2295 bool dataEquals(HStatic other) => element == other.element;
2296 bool isCodeMotionInvariant() => !element.isAssignable; 2296 bool isCodeMotionInvariant() => !element.isAssignable;
2297 } 2297 }
2298 2298
2299 class HInterceptor extends HInstruction { 2299 class HInterceptor extends HInstruction {
2300 // This field should originally be null to allow GVN'ing all 2300 // This field should originally be null to allow GVN'ing all
2301 // [HInterceptor] on the same input. 2301 // [HInterceptor] on the same input.
2302 Set<ClassElement> interceptedClasses; 2302 Set<ClassElement> interceptedClasses;
2303
2304 // inputs[0] is initially the only input, the receiver.
2305
2306 // inputs[1] is a constant interceptor when the interceptor is a constant
2307 // except for a `null` receiver. This is used when the receiver can't be
2308 // falsy, except for `null`, allowing the generation of code like
2309 //
2310 // (a && C.JSArray_methods).get$first(a)
2311 //
2312
2303 HInterceptor(HInstruction receiver, TypeMask type) 2313 HInterceptor(HInstruction receiver, TypeMask type)
2304 : super(<HInstruction>[receiver], type) { 2314 : super(<HInstruction>[receiver], type) {
2305 sideEffects.clearAllSideEffects(); 2315 sideEffects.clearAllSideEffects();
2306 sideEffects.clearAllDependencies(); 2316 sideEffects.clearAllDependencies();
2307 setUseGvn(); 2317 setUseGvn();
2308 } 2318 }
2319
2309 String toString() => 'interceptor on $interceptedClasses'; 2320 String toString() => 'interceptor on $interceptedClasses';
2310 accept(HVisitor visitor) => visitor.visitInterceptor(this); 2321 accept(HVisitor visitor) => visitor.visitInterceptor(this);
2311 HInstruction get receiver => inputs[0]; 2322 HInstruction get receiver => inputs[0];
2323
2324 bool get isConditionalConstantInterceptor => inputs.length == 2;
2325 HInstruction get conditionalConstantInterceptor => inputs[1];
2326 void set conditionalConstantInterceptor(HConstant constant) {
2327 assert(!isConditionalConstantInterceptor);
2328 inputs.add(constant);
2329 }
2330
2312 bool isInterceptor(Compiler compiler) => true; 2331 bool isInterceptor(Compiler compiler) => true;
2313 2332
2314 int typeCode() => HInstruction.INTERCEPTOR_TYPECODE; 2333 int typeCode() => HInstruction.INTERCEPTOR_TYPECODE;
2315 bool typeEquals(other) => other is HInterceptor; 2334 bool typeEquals(other) => other is HInterceptor;
2316 bool dataEquals(HInterceptor other) { 2335 bool dataEquals(HInterceptor other) {
2317 return interceptedClasses == other.interceptedClasses 2336 return interceptedClasses == other.interceptedClasses
2318 || (interceptedClasses.length == other.interceptedClasses.length 2337 || (interceptedClasses.length == other.interceptedClasses.length
2319 && interceptedClasses.containsAll(other.interceptedClasses)); 2338 && interceptedClasses.containsAll(other.interceptedClasses));
2320 } 2339 }
2321 } 2340 }
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
3131 class HDynamicType extends HRuntimeType { 3150 class HDynamicType extends HRuntimeType {
3132 HDynamicType(DynamicType dartType, TypeMask instructionType) 3151 HDynamicType(DynamicType dartType, TypeMask instructionType)
3133 : super(const <HInstruction>[], dartType, instructionType); 3152 : super(const <HInstruction>[], dartType, instructionType);
3134 3153
3135 accept(HVisitor visitor) => visitor.visitDynamicType(this); 3154 accept(HVisitor visitor) => visitor.visitDynamicType(this);
3136 3155
3137 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE; 3156 int typeCode() => HInstruction.DYNAMIC_TYPE_TYPECODE;
3138 3157
3139 bool typeEquals(HInstruction other) => other is HDynamicType; 3158 bool typeEquals(HInstruction other) => other is HDynamicType;
3140 } 3159 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/interceptor_simplifier.dart ('k') | tests/compiler/dart2js/interceptor_almost_constant_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698