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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 17315012: Generate less code when importing dart:mirrors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/compiler.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 registerGetOfStaticFunction(function.element); 49 registerGetOfStaticFunction(function.element);
50 } else if (constant.isInterceptor()) { 50 } else if (constant.isInterceptor()) {
51 // An interceptor constant references the class's prototype chain. 51 // An interceptor constant references the class's prototype chain.
52 InterceptorConstant interceptor = constant; 52 InterceptorConstant interceptor = constant;
53 registerInstantiatedClass(interceptor.dispatchedType.element, elements); 53 registerInstantiatedClass(interceptor.dispatchedType.element, elements);
54 } 54 }
55 compiledConstants.add(constant); 55 compiledConstants.add(constant);
56 } 56 }
57 57
58 void registerInstantiatedClass(ClassElement element, TreeElements elements) { 58 void registerInstantiatedClass(ClassElement element, TreeElements elements) {
59 if (isMetadata) return; 59 if (isMetadata) {
60 compiler.backend.registerMetadataInstantiatedClass(element, elements);
61 return;
62 }
60 compiler.enqueuer.codegen.registerInstantiatedClass(element, elements); 63 compiler.enqueuer.codegen.registerInstantiatedClass(element, elements);
61 } 64 }
62 65
63 void registerStaticUse(Element element) { 66 void registerStaticUse(Element element) {
64 if (isMetadata) return; 67 if (isMetadata) {
68 compiler.backend.registerMetadataStaticUse(element);
69 return;
70 }
65 compiler.analyzeElement(element.declaration); 71 compiler.analyzeElement(element.declaration);
66 compiler.enqueuer.codegen.registerStaticUse(element); 72 compiler.enqueuer.codegen.registerStaticUse(element);
67 } 73 }
68 74
69 void registerGetOfStaticFunction(FunctionElement element) { 75 void registerGetOfStaticFunction(FunctionElement element) {
70 if (isMetadata) return; 76 if (isMetadata) {
77 compiler.backend.registerMetadataGetOfStaticFunction(element);
78 return;
79 }
71 compiler.analyzeElement(element.declaration); 80 compiler.analyzeElement(element.declaration);
72 compiler.enqueuer.codegen.registerGetOfStaticFunction(element); 81 compiler.enqueuer.codegen.registerGetOfStaticFunction(element);
73 } 82 }
74 83
75 void registerStringInstance(TreeElements elements) { 84 void registerStringInstance(TreeElements elements) {
76 registerInstantiatedClass(compiler.stringClass, elements); 85 registerInstantiatedClass(compiler.stringClass, elements);
77 } 86 }
78 87
79 void registerCreateRuntimeTypeFunction() { 88 void registerCreateRuntimeTypeFunction() {
80 if (createRuntimeTypeFunction != null) return; 89 if (createRuntimeTypeFunction != null) return;
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 StringConstant partString = evaluate(part.string); 446 StringConstant partString = evaluate(part.string);
438 if (partString == null) return null; 447 if (partString == null) return null;
439 accumulator = new DartString.concat(accumulator, partString.value); 448 accumulator = new DartString.concat(accumulator, partString.value);
440 }; 449 };
441 handler.registerStringInstance(elements); 450 handler.registerStringInstance(elements);
442 return constantSystem.createString(accumulator, node); 451 return constantSystem.createString(accumulator, node);
443 } 452 }
444 453
445 Constant makeTypeConstant(Element element) { 454 Constant makeTypeConstant(Element element) {
446 DartType elementType = element.computeType(compiler).asRaw(); 455 DartType elementType = element.computeType(compiler).asRaw();
447 if (compiler.mirrorsEnabled) { 456 compiler.backend.registerTypeLiteral(element, elements);
448 handler.registerInstantiatedClass(element, elements);
449 }
450 DartType constantType = 457 DartType constantType =
451 compiler.backend.typeImplementation.computeType(compiler); 458 compiler.backend.typeImplementation.computeType(compiler);
452 Constant constant = new TypeConstant(elementType, constantType); 459 Constant constant = new TypeConstant(elementType, constantType);
453 // If we use a type literal in a constant, the compile time 460 // If we use a type literal in a constant, the compile time
454 // constant emitter will generate a call to the createRuntimeType 461 // constant emitter will generate a call to the createRuntimeType
455 // helper so we register a use of that. 462 // helper so we register a use of that.
456 handler.registerCreateRuntimeTypeFunction(); 463 handler.registerCreateRuntimeTypeFunction();
457 handler.registerCompileTimeConstant(constant, elements); 464 handler.registerCompileTimeConstant(constant, elements);
458 return constant; 465 return constant;
459 } 466 }
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 if (fieldValue == null) { 897 if (fieldValue == null) {
891 // Use the default value. 898 // Use the default value.
892 fieldValue = handler.compileConstant(field); 899 fieldValue = handler.compileConstant(field);
893 } 900 }
894 jsNewArguments.add(fieldValue); 901 jsNewArguments.add(fieldValue);
895 }, 902 },
896 includeSuperAndInjectedMembers: true); 903 includeSuperAndInjectedMembers: true);
897 return jsNewArguments; 904 return jsNewArguments;
898 } 905 }
899 } 906 }
OLDNEW
« no previous file with comments | « no previous file | dart/sdk/lib/_internal/compiler/implementation/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698