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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/native_handler.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 library native; 5 library native;
6 6
7 import 'dart:uri'; 7 import 'dart:uri';
8 import 'dart2jslib.dart' hide SourceString; 8 import 'dart2jslib.dart' hide SourceString;
9 import 'elements/elements.dart'; 9 import 'elements/elements.dart';
10 import 'js_backend/js_backend.dart'; 10 import 'js_backend/js_backend.dart';
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 ClassElement _annotationCreatesClass; 98 ClassElement _annotationCreatesClass;
99 ClassElement _annotationReturnsClass; 99 ClassElement _annotationReturnsClass;
100 ClassElement _annotationJsNameClass; 100 ClassElement _annotationJsNameClass;
101 101
102 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. 102 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend.
103 NativeEnqueuerBase(this.world, this.compiler, this.enableLiveTypeAnalysis); 103 NativeEnqueuerBase(this.world, this.compiler, this.enableLiveTypeAnalysis);
104 104
105 void processNativeClasses(Collection<LibraryElement> libraries) { 105 void processNativeClasses(Collection<LibraryElement> libraries) {
106 libraries.forEach(processNativeClassesInLibrary); 106 libraries.forEach(processNativeClassesInLibrary);
107 processNativeClass(compiler.listClass);
108 processNativeClass(compiler.stringClass);
109 processNativeClass(compiler.intClass);
110 processNativeClass(compiler.doubleClass);
111 processNativeClass(compiler.nullClass);
112 if (!enableLiveTypeAnalysis) { 107 if (!enableLiveTypeAnalysis) {
113 nativeClasses.forEach((c) => enqueueClass(c, 'forced')); 108 nativeClasses.forEach((c) => enqueueClass(c, 'forced'));
114 flushQueue(); 109 flushQueue();
115 } 110 }
116 } 111 }
117 112
118 void processNativeClassesInLibrary(LibraryElement library) { 113 void processNativeClassesInLibrary(LibraryElement library) {
119 // Use implementation to ensure the inclusion of injected members. 114 // Use implementation to ensure the inclusion of injected members.
120 library.implementation.forEachLocalMember((Element element) { 115 library.implementation.forEachLocalMember((Element element) {
121 if (element.isClass() && element.isNative()) { 116 if (element.kind == ElementKind.CLASS) {
122 processNativeClass(element); 117 ClassElement classElement = element;
118 if (classElement.isNative()) {
119 nativeClasses.add(classElement);
120 unusedClasses.add(classElement);
121
122 // Resolve class to ensure the class has valid inheritance info.
123 classElement.ensureResolved(compiler);
124 }
123 } 125 }
124 }); 126 });
125 } 127 }
126 128
127 void processNativeClass(ClassElement classElement) {
128 nativeClasses.add(classElement);
129 unusedClasses.add(classElement);
130 // Resolve class to ensure the class has valid inheritance info.
131 classElement.ensureResolved(compiler);
132 }
133
134 ClassElement get annotationCreatesClass { 129 ClassElement get annotationCreatesClass {
135 findAnnotationClasses(); 130 findAnnotationClasses();
136 return _annotationCreatesClass; 131 return _annotationCreatesClass;
137 } 132 }
138 133
139 ClassElement get annotationReturnsClass { 134 ClassElement get annotationReturnsClass {
140 findAnnotationClasses(); 135 findAnnotationClasses();
141 return _annotationReturnsClass; 136 return _annotationReturnsClass;
142 } 137 }
143 138
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 flushQueue(); 304 flushQueue();
310 } 305 }
311 306
312 processNativeBehavior(NativeBehavior behavior, cause) { 307 processNativeBehavior(NativeBehavior behavior, cause) {
313 bool allUsedBefore = unusedClasses.isEmpty; 308 bool allUsedBefore = unusedClasses.isEmpty;
314 for (var type in behavior.typesInstantiated) { 309 for (var type in behavior.typesInstantiated) {
315 if (matchedTypeConstraints.contains(type)) continue; 310 if (matchedTypeConstraints.contains(type)) continue;
316 matchedTypeConstraints.add(type); 311 matchedTypeConstraints.add(type);
317 if (type is SpecialType) { 312 if (type is SpecialType) {
318 if (type == SpecialType.JsArray) { 313 if (type == SpecialType.JsArray) {
319 enqueueClass(compiler.listClass, 'core type'); 314 world.registerInstantiatedClass(compiler.listClass);
320 } else if (type == SpecialType.JsObject) { 315 } else if (type == SpecialType.JsObject) {
321 enqueueClass(compiler.objectClass, 'core type'); 316 world.registerInstantiatedClass(compiler.objectClass);
322 } 317 }
323 continue; 318 continue;
324 } 319 }
320 if (type is InterfaceType) {
321 if (type.element == compiler.intClass) {
322 world.registerInstantiatedClass(compiler.intClass);
323 } else if (type.element == compiler.doubleClass) {
324 world.registerInstantiatedClass(compiler.doubleClass);
325 } else if (type.element == compiler.numClass) {
326 world.registerInstantiatedClass(compiler.numClass);
327 } else if (type.element == compiler.stringClass) {
328 world.registerInstantiatedClass(compiler.stringClass);
329 } else if (type.element == compiler.nullClass) {
330 world.registerInstantiatedClass(compiler.nullClass);
331 } else if (type.element == compiler.boolClass) {
332 world.registerInstantiatedClass(compiler.boolClass);
333 }
334 }
325 assert(type is DartType); 335 assert(type is DartType);
326 enqueueUnusedClassesMatching( 336 enqueueUnusedClassesMatching(
327 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type), 337 (nativeClass) => compiler.types.isSubtype(nativeClass.thisType, type),
328 cause, 338 cause,
329 'subtypeof($type)'); 339 'subtypeof($type)');
330 } 340 }
331 341
332 // Give an info so that library developers can compile with -v to find why 342 // Give an info so that library developers can compile with -v to find why
333 // all the native classes are included. 343 // all the native classes are included.
334 if (unusedClasses.isEmpty && !allUsedBefore) { 344 if (unusedClasses.isEmpty && !allUsedBefore) {
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 builder.add(new HForeign( 888 builder.add(new HForeign(
879 new DartString.literal('${parameter.name.slowToString()} = #'), 889 new DartString.literal('${parameter.name.slowToString()} = #'),
880 const LiteralDartString('void'), 890 const LiteralDartString('void'),
881 <HInstruction>[jsClosure])); 891 <HInstruction>[jsClosure]));
882 } 892 }
883 }); 893 });
884 LiteralString jsCode = nativeBody.asLiteralString(); 894 LiteralString jsCode = nativeBody.asLiteralString();
885 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[])); 895 builder.push(new HForeign.statement(jsCode.dartString, <HInstruction>[]));
886 } 896 }
887 } 897 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698