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

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

Issue 1334203002: Compute Compiler.proxyConstant on demand. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment Created 5 years, 3 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
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/resolution/members.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 js_backend; 5 part of js_backend;
6 6
7 const VERBOSE_OPTIMIZER_HINTS = false; 7 const VERBOSE_OPTIMIZER_HINTS = false;
8 8
9 class JavaScriptItemCompilationContext extends ItemCompilationContext { 9 class JavaScriptItemCompilationContext extends ItemCompilationContext {
10 final Set<HInstruction> boundsChecked = new Set<HInstruction>(); 10 final Set<HInstruction> boundsChecked = new Set<HInstruction>();
(...skipping 2973 matching lines...) Expand 10 before | Expand all | Expand 10 after
2984 } 2984 }
2985 2985
2986 void onTypeVariableExpression(Registry registry) { 2986 void onTypeVariableExpression(Registry registry) {
2987 assert(registry.isForResolution); 2987 assert(registry.isForResolution);
2988 registerBackendStaticInvocation(backend.getSetRuntimeTypeInfo(), registry); 2988 registerBackendStaticInvocation(backend.getSetRuntimeTypeInfo(), registry);
2989 registerBackendStaticInvocation(backend.getGetRuntimeTypeInfo(), registry); 2989 registerBackendStaticInvocation(backend.getGetRuntimeTypeInfo(), registry);
2990 backend.registerGetRuntimeTypeArgument(registry); 2990 backend.registerGetRuntimeTypeArgument(registry);
2991 registerBackendInstantiation(backend.compiler.listClass, registry); 2991 registerBackendInstantiation(backend.compiler.listClass, registry);
2992 registerBackendStaticInvocation(backend.getRuntimeTypeToString(), registry); 2992 registerBackendStaticInvocation(backend.getRuntimeTypeToString(), registry);
2993 registerBackendStaticInvocation(backend.getCreateRuntimeType(), registry); 2993 registerBackendStaticInvocation(backend.getCreateRuntimeType(), registry);
2994 needsInt(registry, 'Needed for accessing a type variable literal on this.');
2994 } 2995 }
2995 2996
2996 // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType]. 2997 // TODO(johnniwinther): Maybe split this into [onAssertType] and [onTestType].
2997 void onIsCheck(DartType type, Registry registry) { 2998 void onIsCheck(DartType type, Registry registry) {
2998 assert(registry.isForResolution); 2999 assert(registry.isForResolution);
2999 type = type.unalias(backend.compiler); 3000 type = type.unalias(backend.compiler);
3000 registerBackendInstantiation(backend.compiler.boolClass, registry); 3001 registerBackendInstantiation(backend.compiler.boolClass, registry);
3001 bool inCheckedMode = backend.compiler.enableTypeAssertions; 3002 bool inCheckedMode = backend.compiler.enableTypeAssertions;
3002 if (inCheckedMode) { 3003 if (inCheckedMode) {
3003 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); 3004 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 assert(registry.isForResolution); 3045 assert(registry.isForResolution);
3045 registerBackendStaticInvocation(backend.getThrowTypeError(), registry); 3046 registerBackendStaticInvocation(backend.getThrowTypeError(), registry);
3046 registerBackendStaticInvocation(backend.getAssertIsSubtype(), registry); 3047 registerBackendStaticInvocation(backend.getAssertIsSubtype(), registry);
3047 } 3048 }
3048 3049
3049 void onAbstractClassInstantiation(Registry registry) { 3050 void onAbstractClassInstantiation(Registry registry) {
3050 assert(registry.isForResolution); 3051 assert(registry.isForResolution);
3051 registerBackendStaticInvocation( 3052 registerBackendStaticInvocation(
3052 backend.getThrowAbstractClassInstantiationError(), registry); 3053 backend.getThrowAbstractClassInstantiationError(), registry);
3053 // Also register the types of the arguments passed to this method. 3054 // Also register the types of the arguments passed to this method.
3054 registerBackendInstantiation(backend.compiler.stringClass, registry); 3055 needsString(registry, '// Needed to encode the message.');
3055 } 3056 }
3056 3057
3057 void onFallThroughError(Registry registry) { 3058 void onFallThroughError(Registry registry) {
3058 assert(registry.isForResolution); 3059 assert(registry.isForResolution);
3059 registerBackendStaticInvocation(backend.getFallThroughError(), registry); 3060 registerBackendStaticInvocation(backend.getFallThroughError(), registry);
3060 } 3061 }
3061 3062
3062 void onAsCheck(DartType type, Registry registry) { 3063 void onAsCheck(DartType type, Registry registry) {
3063 assert(registry.isForResolution); 3064 assert(registry.isForResolution);
3064 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); 3065 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry);
3065 } 3066 }
3066 3067
3067 void onThrowNoSuchMethod(Registry registry) { 3068 void onThrowNoSuchMethod(Registry registry) {
3068 assert(registry.isForResolution); 3069 assert(registry.isForResolution);
3069 registerBackendStaticInvocation(backend.getThrowNoSuchMethod(), registry); 3070 registerBackendStaticInvocation(backend.getThrowNoSuchMethod(), registry);
3070 // Also register the types of the arguments passed to this method. 3071 // Also register the types of the arguments passed to this method.
3071 registerBackendInstantiation(backend.compiler.listClass, registry); 3072 needsList(registry,
3072 registerBackendInstantiation(backend.compiler.stringClass, registry); 3073 'Needed to encode the arguments for throw NoSuchMethodError.');
3074 needsString(registry,
3075 'Needed to encode the name for throw NoSuchMethodError.');
3073 } 3076 }
3074 3077
3075 void onThrowRuntimeError(Registry registry) { 3078 void onThrowRuntimeError(Registry registry) {
3076 assert(registry.isForResolution); 3079 assert(registry.isForResolution);
3077 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry); 3080 registerBackendStaticInvocation(backend.getThrowRuntimeError(), registry);
3078 // Also register the types of the arguments passed to this method. 3081 // Also register the types of the arguments passed to this method.
3079 registerBackendInstantiation(backend.compiler.stringClass, registry); 3082 registerBackendInstantiation(backend.compiler.stringClass, registry);
3080 } 3083 }
3081 3084
3082 void onCompileTimeError(Registry registry, ErroneousElement error) { 3085 void onCompileTimeError(Registry registry, ErroneousElement error) {
3083 if (backend.compiler.generateCodeWithCompileTimeErrors) { 3086 if (backend.compiler.generateCodeWithCompileTimeErrors) {
3084 // TODO(johnniwinther): This should have its own uncatchable error. 3087 // TODO(johnniwinther): This should have its own uncatchable error.
3085 onThrowRuntimeError(registry); 3088 onThrowRuntimeError(registry);
3086 } 3089 }
3087 } 3090 }
3088 3091
3089 void onSuperNoSuchMethod(Registry registry) { 3092 void onSuperNoSuchMethod(Registry registry) {
3090 assert(registry.isForResolution); 3093 assert(registry.isForResolution);
3091 registerBackendStaticInvocation( 3094 registerBackendStaticInvocation(
3092 backend.getCreateInvocationMirror(), registry); 3095 backend.getCreateInvocationMirror(), registry);
3093 registerBackendStaticInvocation( 3096 registerBackendStaticInvocation(
3094 backend.compiler.objectClass.lookupLocalMember( 3097 backend.compiler.objectClass.lookupLocalMember(
3095 Identifiers.noSuchMethod_), 3098 Identifiers.noSuchMethod_),
3096 registry); 3099 registry);
3097 registerBackendInstantiation(backend.compiler.listClass, registry); 3100 needsInt(registry,
3098 registerBackendInstantiation(backend.compiler.stringClass, registry); 3101 'Needed to encode the invocation kind of super.noSuchMethod.');
3102 needsList(registry,
3103 'Needed to encode the arguments of super.noSuchMethod.');
3104 needsString(registry,
3105 'Needed to encode the name of super.noSuchMethod.');
3099 } 3106 }
3100 3107
3101 void onMapLiteral(ResolutionRegistry registry, 3108 void onMapLiteral(ResolutionRegistry registry,
3102 DartType type, 3109 DartType type,
3103 bool isConstant) { 3110 bool isConstant) {
3104 assert(registry.isForResolution); 3111 assert(registry.isForResolution);
3105 void enqueue(String name) { 3112 void enqueue(String name) {
3106 Element e = backend.find(backend.jsHelperLibrary, name); 3113 Element e = backend.find(backend.jsHelperLibrary, name);
3107 registerBackendInstantiation(e, registry); 3114 registerBackendInstantiation(e, registry);
3108 } 3115 }
3109 3116
3110 if (isConstant) { 3117 if (isConstant) {
3111 enqueue(JavaScriptMapConstant.DART_CLASS); 3118 enqueue(JavaScriptMapConstant.DART_CLASS);
3112 enqueue(JavaScriptMapConstant.DART_PROTO_CLASS); 3119 enqueue(JavaScriptMapConstant.DART_PROTO_CLASS);
3113 enqueue(JavaScriptMapConstant.DART_STRING_CLASS); 3120 enqueue(JavaScriptMapConstant.DART_STRING_CLASS);
3114 enqueue(JavaScriptMapConstant.DART_GENERAL_CLASS); 3121 enqueue(JavaScriptMapConstant.DART_GENERAL_CLASS);
3115 } else { 3122 } else {
3116 registry.registerInstantiatedType(type); 3123 registry.registerInstantiatedType(type);
3117 } 3124 }
3118 } 3125 }
3119 3126
3120 /// Called when resolving the `Symbol` constructor. 3127 /// Called when resolving the `Symbol` constructor.
3121 void onSymbolConstructor(Registry registry) { 3128 void onSymbolConstructor(Registry registry) {
3122 assert(registry.isForResolution); 3129 assert(registry.isForResolution);
3123 // Make sure that _internals.Symbol.validated is registered. 3130 // Make sure that _internals.Symbol.validated is registered.
3124 assert(backend.compiler.symbolValidatedConstructor != null); 3131 assert(backend.compiler.symbolValidatedConstructor != null);
3125 registerBackendStaticInvocation( 3132 registerBackendStaticInvocation(
3126 backend.compiler.symbolValidatedConstructor, registry); 3133 backend.compiler.symbolValidatedConstructor, registry);
3127 } 3134 }
3135
3136 /// Called when resolving a prefix or postfix expression.
3137 void onIncDecOperation(Registry registry) {
3138 needsInt(registry, 'Needed for the `+ 1` or `- 1` operation of ++/--.');
3139 }
3140
3141 /// Helper for registering that `int` is needed.
3142 void needsInt(Registry registry, String reason) {
3143 // TODO(johnniwinther): Register [reason] for use in dump-info.
3144 registerBackendInstantiation(backend.compiler.intClass, registry);
3145 }
3146
3147 /// Helper for registering that `List` is needed.
3148 void needsList(Registry registry, String reason) {
3149 // TODO(johnniwinther): Register [reason] for use in dump-info.
3150 registerBackendInstantiation(backend.compiler.listClass, registry);
3151 }
3152
3153 /// Helper for registering that `String` is needed.
3154 void needsString(Registry registry, String reason) {
3155 // TODO(johnniwinther): Register [reason] for use in dump-info.
3156 registerBackendInstantiation(backend.compiler.stringClass, registry);
3157 }
3128 } 3158 }
3129 3159
3130 /// Records that [constant] is used by the element behind [registry]. 3160 /// Records that [constant] is used by the element behind [registry].
3131 class Dependency { 3161 class Dependency {
3132 final ConstantValue constant; 3162 final ConstantValue constant;
3133 final Element annotatedElement; 3163 final Element annotatedElement;
3134 3164
3135 const Dependency(this.constant, this.annotatedElement); 3165 const Dependency(this.constant, this.annotatedElement);
3136 } 3166 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compiler.dart ('k') | pkg/compiler/lib/src/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698