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

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

Issue 2916353002: Support locals in compile_from_dill_test. (Closed)
Patch Set: Created 3 years, 6 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../elements/types.dart'; 9 import '../elements/types.dart';
10 import '../io/source_information.dart'; 10 import '../io/source_information.dart';
(...skipping 23 matching lines...) Expand all
34 new Map<Local, CapturedVariable>(); 34 new Map<Local, CapturedVariable>();
35 final GraphBuilder builder; 35 final GraphBuilder builder;
36 ClosureClassMap closureData; 36 ClosureClassMap closureData;
37 Map<TypeVariableType, TypeVariableLocal> typeVariableLocals = 37 Map<TypeVariableType, TypeVariableLocal> typeVariableLocals =
38 new Map<TypeVariableType, TypeVariableLocal>(); 38 new Map<TypeVariableType, TypeVariableLocal>();
39 final Entity executableContext; 39 final Entity executableContext;
40 final MemberEntity memberContext; 40 final MemberEntity memberContext;
41 41
42 /// The class that defines the current type environment or null if no type 42 /// The class that defines the current type environment or null if no type
43 /// variables are in scope. 43 /// variables are in scope.
44 final ClassElement contextClass; 44 final ClassEntity contextClass;
45 45
46 /// The type of the current instance, if concrete. 46 /// The type of the current instance, if concrete.
47 /// 47 ///
48 /// This allows for handling fixed type argument in case of inlining. For 48 /// This allows for handling fixed type argument in case of inlining. For
49 /// instance, checking `'foo'` against `String` instead of `T` in `main`: 49 /// instance, checking `'foo'` against `String` instead of `T` in `main`:
50 /// 50 ///
51 /// class Foo<T> { 51 /// class Foo<T> {
52 /// T field; 52 /// T field;
53 /// Foo(this.field); 53 /// Foo(this.field);
54 /// } 54 /// }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 /// Substituted type variables occurring in [type] into the context of 90 /// Substituted type variables occurring in [type] into the context of
91 /// [contextClass]. 91 /// [contextClass].
92 DartType substInContext(DartType type) { 92 DartType substInContext(DartType type) {
93 if (contextClass != null) { 93 if (contextClass != null) {
94 ClassElement typeContext = DartTypes.getClassContext(type); 94 ClassElement typeContext = DartTypes.getClassContext(type);
95 if (typeContext != null) { 95 if (typeContext != null) {
96 type = builder.types.substByContext( 96 type = builder.types.substByContext(
97 type, 97 type,
98 builder.types.asInstanceOf( 98 builder.types.asInstanceOf(
99 builder.types.getThisType(contextClass), typeContext)); 99 builder.types.getThisType(contextClass), typeContext));
100 //type = type.substByContext(contextClass.asInstanceOf(typeContext));
101 } 100 }
102 } 101 }
103 if (instanceType != null) { 102 if (instanceType != null) {
104 type = builder.types.substByContext(type, instanceType); 103 type = builder.types.substByContext(type, instanceType);
105 //type = type.substByContext(instanceType);
106 } 104 }
107 return type; 105 return type;
108 } 106 }
109 107
110 /// Creates a new [LocalsHandler] based on [other]. We only need to 108 /// Creates a new [LocalsHandler] based on [other]. We only need to
111 /// copy the [directLocals], since the other fields can be shared 109 /// copy the [directLocals], since the other fields can be shared
112 /// throughout the AST visit. 110 /// throughout the AST visit.
113 LocalsHandler.from(LocalsHandler other) 111 LocalsHandler.from(LocalsHandler other)
114 : directLocals = new Map<Local, HInstruction>.from(other.directLocals), 112 : directLocals = new Map<Local, HInstruction>.from(other.directLocals),
115 redirectionMapping = other.redirectionMapping, 113 redirectionMapping = other.redirectionMapping,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // context. 249 // context.
252 HThis thisInstruction = new HThis(closureData.thisLocal, getTypeOfThis()); 250 HThis thisInstruction = new HThis(closureData.thisLocal, getTypeOfThis());
253 builder.graph.thisInstruction = thisInstruction; 251 builder.graph.thisInstruction = thisInstruction;
254 builder.graph.entry.addAtEntry(thisInstruction); 252 builder.graph.entry.addAtEntry(thisInstruction);
255 directLocals[closureData.thisLocal] = thisInstruction; 253 directLocals[closureData.thisLocal] = thisInstruction;
256 } 254 }
257 255
258 // If this method is an intercepted method, add the extra 256 // If this method is an intercepted method, add the extra
259 // parameter to it, that is the actual receiver for intercepted 257 // parameter to it, that is the actual receiver for intercepted
260 // classes, or the same as [:this:] for non-intercepted classes. 258 // classes, or the same as [:this:] for non-intercepted classes.
261 ClassElement cls = element.enclosingClass; 259 ClassEntity cls = element.enclosingClass;
262 260
263 // When the class extends a native class, the instance is pre-constructed 261 // When the class extends a native class, the instance is pre-constructed
264 // and passed to the generative constructor factory function as a parameter. 262 // and passed to the generative constructor factory function as a parameter.
265 // Instead of allocating and initializing the object, the constructor 263 // Instead of allocating and initializing the object, the constructor
266 // 'upgrades' the native subclass object by initializing the Dart fields. 264 // 'upgrades' the native subclass object by initializing the Dart fields.
267 bool isNativeUpgradeFactory = element is ConstructorEntity && 265 bool isNativeUpgradeFactory = element is ConstructorEntity &&
268 element.isGenerativeConstructor && 266 element.isGenerativeConstructor &&
269 _nativeData.isNativeOrExtendsNative(cls); 267 _nativeData.isNativeOrExtendsNative(cls);
270 if (_interceptorData.isInterceptedMethod(element)) { 268 if (_interceptorData.isInterceptedMethod(element)) {
271 bool isInterceptedClass = _interceptorData.isInterceptedClass(cls); 269 bool isInterceptedClass = _interceptorData.isInterceptedClass(cls);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 final MemberEntity memberContext; 682 final MemberEntity memberContext;
685 683
686 // Avoid slow Object.hashCode. 684 // Avoid slow Object.hashCode.
687 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); 685 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30);
688 static int _nextHashCode = 0; 686 static int _nextHashCode = 0;
689 687
690 SyntheticLocal(this.name, this.executableContext, this.memberContext); 688 SyntheticLocal(this.name, this.executableContext, this.memberContext);
691 689
692 toString() => 'SyntheticLocal($name)'; 690 toString() => 'SyntheticLocal($name)';
693 } 691 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_ast_adapter.dart ('k') | tests/compiler/dart2js/kernel/compile_from_dill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698