| OLD | NEW |
| 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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 void registerCheckDeferredIsLoaded(Registry registry) { | 1342 void registerCheckDeferredIsLoaded(Registry registry) { |
| 1343 enqueueInResolution(getCheckDeferredIsLoaded(), registry); | 1343 enqueueInResolution(getCheckDeferredIsLoaded(), registry); |
| 1344 // Also register the types of the arguments passed to this method. | 1344 // Also register the types of the arguments passed to this method. |
| 1345 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); | 1345 enqueueClass(compiler.enqueuer.resolution, compiler.stringClass, registry); |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 void registerNoSuchMethod(FunctionElement noSuchMethod) { | 1348 void registerNoSuchMethod(FunctionElement noSuchMethod) { |
| 1349 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); | 1349 noSuchMethodRegistry.registerNoSuchMethod(noSuchMethod); |
| 1350 } | 1350 } |
| 1351 | 1351 |
| 1352 /// Called when resolving a call to a foreign function. |
| 1353 void registerForeignCall(Send node, |
| 1354 Element element, |
| 1355 CallStructure callStructure, |
| 1356 ForeignResolver resolver) { |
| 1357 native.NativeResolutionEnqueuer nativeEnqueuer = |
| 1358 compiler.enqueuer.resolution.nativeEnqueuer; |
| 1359 if (element.name == 'JS') { |
| 1360 nativeEnqueuer.registerJsCall(node, resolver); |
| 1361 } else if (element.name == 'JS_EMBEDDED_GLOBAL') { |
| 1362 nativeEnqueuer.registerJsEmbeddedGlobalCall(node, resolver); |
| 1363 } else if (element.name == 'JS_BUILTIN') { |
| 1364 nativeEnqueuer.registerJsBuiltinCall(node, resolver); |
| 1365 } else if (element.name == 'JS_INTERCEPTOR_CONSTANT') { |
| 1366 // The type constant that is an argument to JS_INTERCEPTOR_CONSTANT names |
| 1367 // a class that will be instantiated outside the program by attaching a |
| 1368 // native class dispatch record referencing the interceptor. |
| 1369 if (!node.argumentsNode.isEmpty) { |
| 1370 Node argument = node.argumentsNode.nodes.head; |
| 1371 ConstantExpression constant = resolver.getConstant(argument); |
| 1372 if (constant != null && constant.kind == ConstantExpressionKind.TYPE) { |
| 1373 TypeConstantExpression typeConstant = constant; |
| 1374 if (typeConstant.type is InterfaceType) { |
| 1375 resolver.registerInstantiatedType(typeConstant.type); |
| 1376 return; |
| 1377 } |
| 1378 } |
| 1379 } |
| 1380 compiler.reportErrorMessage( |
| 1381 node, |
| 1382 MessageKind.WRONG_ARGUMENT_FOR_JS_INTERCEPTOR_CONSTANT); |
| 1383 } |
| 1384 } |
| 1385 |
| 1352 void enableNoSuchMethod(Enqueuer world) { | 1386 void enableNoSuchMethod(Enqueuer world) { |
| 1353 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); | 1387 enqueue(world, getCreateInvocationMirror(), compiler.globalDependencies); |
| 1354 world.registerInvocation( | 1388 world.registerInvocation( |
| 1355 new UniverseSelector(Selectors.noSuchMethod_, null)); | 1389 new UniverseSelector(Selectors.noSuchMethod_, null)); |
| 1356 } | 1390 } |
| 1357 | 1391 |
| 1358 void enableIsolateSupport(Enqueuer enqueuer) { | 1392 void enableIsolateSupport(Enqueuer enqueuer) { |
| 1359 // TODO(floitsch): We should also ensure that the class IsolateMessage is | 1393 // TODO(floitsch): We should also ensure that the class IsolateMessage is |
| 1360 // instantiated. Currently, just enabling isolate support works. | 1394 // instantiated. Currently, just enabling isolate support works. |
| 1361 if (compiler.mainFunction != null) { | 1395 if (compiler.mainFunction != null) { |
| (...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3201 } | 3235 } |
| 3202 } | 3236 } |
| 3203 | 3237 |
| 3204 /// Records that [constant] is used by the element behind [registry]. | 3238 /// Records that [constant] is used by the element behind [registry]. |
| 3205 class Dependency { | 3239 class Dependency { |
| 3206 final ConstantValue constant; | 3240 final ConstantValue constant; |
| 3207 final Element annotatedElement; | 3241 final Element annotatedElement; |
| 3208 | 3242 |
| 3209 const Dependency(this.constant, this.annotatedElement); | 3243 const Dependency(this.constant, this.annotatedElement); |
| 3210 } | 3244 } |
| OLD | NEW |