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

Side by Side Diff: pkg/compiler/lib/src/js_backend/codegen/glue.dart

Issue 1385423002: dart2js cps_ir: Use interceptors for is-checks (version 2) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: fix analyzer warnings Created 5 years, 2 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library code_generator_dependencies; 5 library code_generator_dependencies;
6 6
7 import '../js_backend.dart'; 7 import '../js_backend.dart';
8 import '../../common/registry.dart' show 8 import '../../common/registry.dart' show
9 Registry; 9 Registry;
10 import '../../common/codegen.dart' show
11 CodegenRegistry;
10 import '../../compiler.dart' show 12 import '../../compiler.dart' show
11 Compiler; 13 Compiler;
12 import '../../constants/values.dart'; 14 import '../../constants/values.dart';
13 import '../../dart_types.dart' show 15 import '../../dart_types.dart' show
14 DartType, 16 DartType,
15 TypeVariableType, 17 TypeVariableType,
16 InterfaceType; 18 InterfaceType;
17 import '../../diagnostics/diagnostic_listener.dart' show 19 import '../../diagnostics/diagnostic_listener.dart' show
18 DiagnosticReporter; 20 DiagnosticReporter;
19 import '../../diagnostics/spannable.dart' show 21 import '../../diagnostics/spannable.dart' show
20 CURRENT_ELEMENT_SPANNABLE; 22 CURRENT_ELEMENT_SPANNABLE;
21 import '../../enqueue.dart' show 23 import '../../enqueue.dart' show
22 CodegenEnqueuer; 24 CodegenEnqueuer;
23 import '../../elements/elements.dart'; 25 import '../../elements/elements.dart';
24 import '../../js_emitter/js_emitter.dart'; 26 import '../../js_emitter/js_emitter.dart';
25 import '../../js/js.dart' as js; 27 import '../../js/js.dart' as js;
28 import '../../native/native.dart' show NativeBehavior;
26 import '../../universe/selector.dart' show 29 import '../../universe/selector.dart' show
27 Selector; 30 Selector;
28 import '../../world.dart' show 31 import '../../world.dart' show
29 ClassWorld; 32 ClassWorld;
30 33
31 34
32 /// Encapsulates the dependencies of the function-compiler to the compiler, 35 /// Encapsulates the dependencies of the function-compiler to the compiler,
33 /// backend and emitter. 36 /// backend and emitter.
34 // TODO(sigurdm): Should be refactored when we have a better feeling for the 37 // TODO(sigurdm): Should be refactored when we have a better feeling for the
35 // interface. 38 // interface.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 128 }
126 129
127 bool isInterceptorClass(ClassElement element) { 130 bool isInterceptorClass(ClassElement element) {
128 return element.isSubclassOf(_backend.jsInterceptorClass); 131 return element.isSubclassOf(_backend.jsInterceptorClass);
129 } 132 }
130 133
131 Set<ClassElement> getInterceptedClassesOn(Selector selector) { 134 Set<ClassElement> getInterceptedClassesOn(Selector selector) {
132 return _backend.getInterceptedClassesOn(selector.name); 135 return _backend.getInterceptedClassesOn(selector.name);
133 } 136 }
134 137
138 Set<ClassElement> get interceptedClasses {
139 return _backend.interceptedClasses;
140 }
141
135 void registerSpecializedGetInterceptor(Set<ClassElement> classes) { 142 void registerSpecializedGetInterceptor(Set<ClassElement> classes) {
136 _backend.registerSpecializedGetInterceptor(classes); 143 _backend.registerSpecializedGetInterceptor(classes);
137 } 144 }
138 145
139 js.Expression constructorAccess(ClassElement element) { 146 js.Expression constructorAccess(ClassElement element) {
140 return _backend.emitter.constructorAccess(element); 147 return _backend.emitter.constructorAccess(element);
141 } 148 }
142 149
143 js.Name instanceFieldPropertyName(Element field) { 150 js.Name instanceFieldPropertyName(Element field) {
144 return _namer.instanceFieldPropertyName(field); 151 return _namer.instanceFieldPropertyName(field);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 ClassWorld classWorld = _compiler.world; 234 ClassWorld classWorld = _compiler.world;
228 if (classWorld.isUsedAsMixin(cls)) return true; 235 if (classWorld.isUsedAsMixin(cls)) return true;
229 236
230 Iterable<ClassElement> subclasses = _compiler.world.strictSubclassesOf(cls); 237 Iterable<ClassElement> subclasses = _compiler.world.strictSubclassesOf(cls);
231 return subclasses.any((ClassElement subclass) { 238 return subclasses.any((ClassElement subclass) {
232 return !_backend.rti.isTrivialSubstitution(subclass, cls); 239 return !_backend.rti.isTrivialSubstitution(subclass, cls);
233 }); 240 });
234 } 241 }
235 242
236 js.Expression generateTypeRepresentation(DartType dartType, 243 js.Expression generateTypeRepresentation(DartType dartType,
237 List<js.Expression> arguments) { 244 List<js.Expression> arguments,
245 CodegenRegistry registry) {
238 int variableIndex = 0; 246 int variableIndex = 0;
239 js.Expression representation = _backend.rti.getTypeRepresentation( 247 js.Expression representation = _backend.rti.getTypeRepresentation(
240 dartType, 248 dartType,
241 (_) => arguments[variableIndex++]); 249 (_) => arguments[variableIndex++]);
242 assert(variableIndex == arguments.length); 250 assert(variableIndex == arguments.length);
251 // Representation contains JavaScript Arrays.
252 registry.registerInstantiatedClass(_backend.jsArrayClass);
243 return representation; 253 return representation;
244 } 254 }
245 255
246 void registerIsCheck(DartType type, Registry registry) { 256 void registerIsCheck(DartType type, Registry registry) {
247 _enqueuer.registerIsCheck(type); 257 _enqueuer.registerIsCheck(type);
248 _backend.registerIsCheckForCodegen(type, _enqueuer, registry); 258 _backend.registerIsCheckForCodegen(type, _enqueuer, registry);
249 } 259 }
250 260
251 js.Name getTypeTestTag(DartType type) { 261 js.Name getTypeTestTag(DartType type) {
252 return _backend.namer.operatorIsType(type); 262 return _backend.namer.operatorIsType(type);
253 } 263 }
254 264
255 js.Name getTypeSubstitutionTag(ClassElement element) { 265 js.Name getTypeSubstitutionTag(ClassElement element) {
256 return _backend.namer.substitutionName(element); 266 return _backend.namer.substitutionName(element);
257 } 267 }
258 268
259 bool operatorEqHandlesNullArgument(FunctionElement element) { 269 bool operatorEqHandlesNullArgument(FunctionElement element) {
260 return _backend.operatorEqHandlesNullArgument(element); 270 return _backend.operatorEqHandlesNullArgument(element);
261 } 271 }
262 272
263 bool hasStrictSubtype(ClassElement element) { 273 bool hasStrictSubtype(ClassElement element) {
264 return _compiler.world.hasAnyStrictSubtype(element); 274 return _compiler.world.hasAnyStrictSubtype(element);
265 } 275 }
266 276
277 ClassElement get jsFixedArrayClass => _backend.jsFixedArrayClass;
267 ClassElement get jsExtendableArrayClass => _backend.jsExtendableArrayClass; 278 ClassElement get jsExtendableArrayClass => _backend.jsExtendableArrayClass;
279 ClassElement get jsUnmodifiableArrayClass =>
280 _backend.jsUnmodifiableArrayClass;
268 ClassElement get jsMutableArrayClass => _backend.jsMutableArrayClass; 281 ClassElement get jsMutableArrayClass => _backend.jsMutableArrayClass;
269 282
270 bool isStringClass(ClassElement classElement) => 283 bool isStringClass(ClassElement classElement) =>
271 classElement == _backend.jsStringClass || 284 classElement == _backend.jsStringClass ||
272 classElement == _compiler.stringClass; 285 classElement == _compiler.stringClass;
273 286
274 bool isBoolClass(ClassElement classElement) => 287 bool isBoolClass(ClassElement classElement) =>
275 classElement == _backend.jsBoolClass || 288 classElement == _backend.jsBoolClass ||
276 classElement == _compiler.boolClass; 289 classElement == _compiler.boolClass;
290
291 // TODO(sra): Should this be part of CodegenRegistry?
292 void registerNativeBehavior(NativeBehavior nativeBehavior, node) {
293 if (nativeBehavior == null) return;
294 _enqueuer.nativeEnqueuer.registerNativeBehavior(nativeBehavior, node);
295 }
277 } 296 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/codegen/codegen.dart ('k') | pkg/compiler/lib/src/js_backend/codegen/unsugar.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698