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

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

Issue 1896843002: Store and serialize NativeBehavior in TreeElements. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comments. Created 4 years, 8 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) 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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 // Also register the types of the arguments passed to this method. 1287 // Also register the types of the arguments passed to this method.
1288 enqueueClass( 1288 enqueueClass(
1289 compiler.enqueuer.resolution, coreClasses.stringClass, registry); 1289 compiler.enqueuer.resolution, coreClasses.stringClass, registry);
1290 } 1290 }
1291 1291
1292 void registerNoSuchMethod(FunctionElement noSuchMethod) { 1292 void registerNoSuchMethod(FunctionElement noSuchMethod) {
1293 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); 1293 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod);
1294 } 1294 }
1295 1295
1296 /// Called when resolving a call to a foreign function. 1296 /// Called when resolving a call to a foreign function.
1297 void registerForeignCall(Send node, Element element, 1297 native.NativeBehavior resolveForeignCall(Send node, Element element,
1298 CallStructure callStructure, ForeignResolver resolver) { 1298 CallStructure callStructure, ForeignResolver resolver) {
1299 native.NativeResolutionEnqueuer nativeEnqueuer = 1299 native.NativeResolutionEnqueuer nativeEnqueuer =
1300 compiler.enqueuer.resolution.nativeEnqueuer; 1300 compiler.enqueuer.resolution.nativeEnqueuer;
1301 if (element.name == 'JS') { 1301 if (element.name == 'JS') {
1302 nativeEnqueuer.registerJsCall(node, resolver); 1302 return nativeEnqueuer.resolveJsCall(node, resolver);
1303 } else if (element.name == 'JS_EMBEDDED_GLOBAL') { 1303 } else if (element.name == 'JS_EMBEDDED_GLOBAL') {
1304 nativeEnqueuer.registerJsEmbeddedGlobalCall(node, resolver); 1304 return nativeEnqueuer.resolveJsEmbeddedGlobalCall(node, resolver);
1305 } else if (element.name == 'JS_BUILTIN') { 1305 } else if (element.name == 'JS_BUILTIN') {
1306 nativeEnqueuer.registerJsBuiltinCall(node, resolver); 1306 return nativeEnqueuer.resolveJsBuiltinCall(node, resolver);
1307 } else if (element.name == 'JS_INTERCEPTOR_CONSTANT') { 1307 } else if (element.name == 'JS_INTERCEPTOR_CONSTANT') {
1308 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names 1308 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names
1309 // a class that will be instantiated outside the program by attaching a 1309 // a class that will be instantiated outside the program by attaching a
1310 // native class dispatch record referencing the interceptor. 1310 // native class dispatch record referencing the interceptor.
1311 if (!node.argumentsNode.isEmpty) { 1311 if (!node.argumentsNode.isEmpty) {
1312 Node argument = node.argumentsNode.nodes.head; 1312 Node argument = node.argumentsNode.nodes.head;
1313 ConstantExpression constant = resolver.getConstant(argument); 1313 ConstantExpression constant = resolver.getConstant(argument);
1314 if (constant != null && constant.kind == ConstantExpressionKind.TYPE) { 1314 if (constant != null && constant.kind == ConstantExpressionKind.TYPE) {
1315 TypeConstantExpression typeConstant = constant; 1315 TypeConstantExpression typeConstant = constant;
1316 if (typeConstant.type is InterfaceType) { 1316 if (typeConstant.type is InterfaceType) {
1317 resolver.registerInstantiatedType(typeConstant.type); 1317 resolver.registerInstantiatedType(typeConstant.type);
1318 return; 1318 // No native behavior for this call.
1319 return null;
1319 } 1320 }
1320 } 1321 }
1321 } 1322 }
1322 reporter.reportErrorMessage( 1323 reporter.reportErrorMessage(
1323 node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); 1324 node, MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT);
1324 } 1325 }
1326 // No native behavior for this call.
1327 return null;
1325 } 1328 }
1326 1329
1327 void enableNoSuchMethod(Enqueuer world) { 1330 void enableNoSuchMethod(Enqueuer world) {
1328 enqueue(world, helpers.createInvocationMirror, compiler.globalDependencies); 1331 enqueue(world, helpers.createInvocationMirror, compiler.globalDependencies);
1329 world.registerDynamicUse(new DynamicUse(Selectors.noSuchMethod_, null)); 1332 world.registerDynamicUse(new DynamicUse(Selectors.noSuchMethod_, null));
1330 } 1333 }
1331 1334
1332 void enableIsolateSupport(Enqueuer enqueuer) { 1335 void enableIsolateSupport(Enqueuer enqueuer) {
1333 // TODO(floitsch): We should also ensure that the class IsolateMessage is 1336 // TODO(floitsch): We should also ensure that the class IsolateMessage is
1334 // instantiated. Currently, just enabling isolate support works. 1337 // instantiated. Currently, just enabling isolate support works.
(...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after
3005 3008
3006 @override 3009 @override
3007 void onImpactUsed(ImpactUseCase impactUse) { 3010 void onImpactUsed(ImpactUseCase impactUse) {
3008 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) { 3011 if (impactUse == DeferredLoadTask.IMPACT_USE && !supportSerialization) {
3009 // TODO(johnniwinther): Allow emptying when serialization has been 3012 // TODO(johnniwinther): Allow emptying when serialization has been
3010 // performed. 3013 // performed.
3011 resolution.emptyCache(); 3014 resolution.emptyCache();
3012 } 3015 }
3013 } 3016 }
3014 } 3017 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/inferrer/simple_types_inferrer.dart ('k') | pkg/compiler/lib/src/js_backend/backend_serialization.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698