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

Side by Side Diff: pkg/compiler/lib/src/ssa/builder.dart

Issue 1880323002: dart2js cleanup: remove unused imports and variables (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge master 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
« no previous file with comments | « pkg/compiler/lib/src/source_file_provider.dart ('k') | pkg/compiler/lib/src/ssa/codegen.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 import 'dart:collection'; 5 import 'dart:collection';
6 6
7 import 'package:js_runtime/shared/embedded_names.dart'; 7 import 'package:js_runtime/shared/embedded_names.dart';
8 8
9 import '../closure.dart'; 9 import '../closure.dart';
10 import '../common.dart'; 10 import '../common.dart';
11 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 11 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
12 import '../common/names.dart' show Identifiers, Selectors; 12 import '../common/names.dart' show Identifiers, Selectors;
13 import '../common/tasks.dart' show CompilerTask; 13 import '../common/tasks.dart' show CompilerTask;
14 import '../compiler.dart' show Compiler; 14 import '../compiler.dart' show Compiler;
15 import '../constants/constant_system.dart'; 15 import '../constants/constant_system.dart';
16 import '../constants/expressions.dart'; 16 import '../constants/expressions.dart';
17 import '../constants/values.dart'; 17 import '../constants/values.dart';
18 import '../core_types.dart' show CoreClasses; 18 import '../core_types.dart' show CoreClasses;
19 import '../dart_types.dart'; 19 import '../dart_types.dart';
20 import '../diagnostics/messages.dart' show Message, MessageTemplate; 20 import '../diagnostics/messages.dart' show Message, MessageTemplate;
21 import '../dump_info.dart' show InfoReporter;
21 import '../elements/elements.dart'; 22 import '../elements/elements.dart';
22 import '../elements/modelx.dart' 23 import '../elements/modelx.dart' show ConstructorBodyElementX;
23 show ConstructorBodyElementX, ElementX, VariableElementX;
24 import '../io/source_information.dart'; 24 import '../io/source_information.dart';
25 import '../js/js.dart' as js; 25 import '../js/js.dart' as js;
26 import '../js_backend/backend_helpers.dart' show BackendHelpers; 26 import '../js_backend/backend_helpers.dart' show BackendHelpers;
27 import '../js_backend/js_backend.dart'; 27 import '../js_backend/js_backend.dart';
28 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter; 28 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter;
29 import '../native/native.dart' as native; 29 import '../native/native.dart' as native;
30 import '../resolution/operators.dart'; 30 import '../resolution/operators.dart';
31 import '../resolution/semantic_visitor.dart'; 31 import '../resolution/semantic_visitor.dart';
32 import '../resolution/tree_elements.dart' show TreeElements; 32 import '../resolution/tree_elements.dart' show TreeElements;
33 import '../tree/tree.dart' as ast; 33 import '../tree/tree.dart' as ast;
34 import '../types/types.dart'; 34 import '../types/types.dart';
35 import '../universe/call_structure.dart' show CallStructure; 35 import '../universe/call_structure.dart' show CallStructure;
36 import '../universe/selector.dart' show Selector; 36 import '../universe/selector.dart' show Selector;
37 import '../universe/side_effects.dart' show SideEffects; 37 import '../universe/side_effects.dart' show SideEffects;
38 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse; 38 import '../universe/use.dart' show DynamicUse, StaticUse, TypeUse;
39 import '../util/util.dart'; 39 import '../util/util.dart';
40 import '../world.dart' show ClassWorld, World; 40 import '../world.dart' show ClassWorld;
41 import '../dump_info.dart' show InfoReporter; 41 import 'codegen.dart';
42
43 import 'nodes.dart'; 42 import 'nodes.dart';
44 import 'codegen.dart';
45 import 'optimize.dart'; 43 import 'optimize.dart';
46 import 'types.dart'; 44 import 'types.dart';
47 45
48 class SsaFunctionCompiler implements FunctionCompiler { 46 class SsaFunctionCompiler implements FunctionCompiler {
49 final SsaCodeGeneratorTask generator; 47 final SsaCodeGeneratorTask generator;
50 final SsaBuilderTask builder; 48 final SsaBuilderTask builder;
51 final SsaOptimizerTask optimizer; 49 final SsaOptimizerTask optimizer;
52 final JavaScriptBackend backend; 50 final JavaScriptBackend backend;
53 51
54 SsaFunctionCompiler(JavaScriptBackend backend, 52 SsaFunctionCompiler(JavaScriptBackend backend,
(...skipping 3396 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 sourceInformationBuilder.buildGet(node); 3449 sourceInformationBuilder.buildGet(node);
3452 generateThrowNoSuchMethod( 3450 generateThrowNoSuchMethod(
3453 node, noSuchMethodTargetSymbolString(element, 'get'), 3451 node, noSuchMethodTargetSymbolString(element, 'get'),
3454 argumentNodes: const Link<ast.Node>(), 3452 argumentNodes: const Link<ast.Node>(),
3455 sourceInformation: sourceInformation); 3453 sourceInformation: sourceInformation);
3456 } 3454 }
3457 3455
3458 /// Generate read access of an unresolved static or top level entity. 3456 /// Generate read access of an unresolved static or top level entity.
3459 void generateStaticUnresolvedGet(ast.Send node, Element element) { 3457 void generateStaticUnresolvedGet(ast.Send node, Element element) {
3460 if (element is ErroneousElement) { 3458 if (element is ErroneousElement) {
3461 SourceInformation sourceInformation =
3462 sourceInformationBuilder.buildGet(node);
3463 // An erroneous element indicates an unresolved static getter. 3459 // An erroneous element indicates an unresolved static getter.
3464 handleInvalidStaticGet(node, element); 3460 handleInvalidStaticGet(node, element);
3465 } else { 3461 } else {
3466 // This happens when [element] has parse errors. 3462 // This happens when [element] has parse errors.
3467 assert(invariant(node, element == null || element.isMalformed)); 3463 assert(invariant(node, element == null || element.isMalformed));
3468 // TODO(ahe): Do something like the above, that is, emit a runtime 3464 // TODO(ahe): Do something like the above, that is, emit a runtime
3469 // error. 3465 // error.
3470 stack.add(graph.addConstantNull(compiler)); 3466 stack.add(graph.addConstantNull(compiler));
3471 } 3467 }
3472 } 3468 }
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
5539 ..sourceInformation = sourceInformation); 5535 ..sourceInformation = sourceInformation);
5540 } else if (selector.isSetter) { 5536 } else if (selector.isSetter) {
5541 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type) 5537 push(new HInvokeDynamicSetter(selector, mask, null, inputs, type)
5542 ..sourceInformation = sourceInformation); 5538 ..sourceInformation = sourceInformation);
5543 } else { 5539 } else {
5544 push(new HInvokeDynamicMethod(selector, mask, inputs, type, isIntercepted) 5540 push(new HInvokeDynamicMethod(selector, mask, inputs, type, isIntercepted)
5545 ..sourceInformation = sourceInformation); 5541 ..sourceInformation = sourceInformation);
5546 } 5542 }
5547 } 5543 }
5548 5544
5549 bool _hasNamedParameters(FunctionElement function) {
5550 FunctionSignature params = function.functionSignature;
5551 return params.optionalParameterCount > 0 &&
5552 params.optionalParametersAreNamed;
5553 }
5554
5555 HForeignCode invokeJsInteropFunction(FunctionElement element, 5545 HForeignCode invokeJsInteropFunction(FunctionElement element,
5556 List<HInstruction> arguments, SourceInformation sourceInformation) { 5546 List<HInstruction> arguments, SourceInformation sourceInformation) {
5557 assert(backend.isJsInterop(element)); 5547 assert(backend.isJsInterop(element));
5558 nativeEmitter.nativeMethods.add(element); 5548 nativeEmitter.nativeMethods.add(element);
5559 String templateString;
5560 5549
5561 if (element.isFactoryConstructor && 5550 if (element.isFactoryConstructor &&
5562 backend.jsInteropAnalysis 5551 backend.jsInteropAnalysis
5563 .hasAnonymousAnnotation(element.contextClass)) { 5552 .hasAnonymousAnnotation(element.contextClass)) {
5564 // Factory constructor that is syntactic sugar for creating a JavaScript 5553 // Factory constructor that is syntactic sugar for creating a JavaScript
5565 // object literal. 5554 // object literal.
5566 ConstructorElement constructor = element; 5555 ConstructorElement constructor = element;
5567 FunctionSignature params = constructor.functionSignature; 5556 FunctionSignature params = constructor.functionSignature;
5568 int i = 0; 5557 int i = 0;
5569 int positions = 0; 5558 int positions = 0;
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
6598 } else if (optionalParameter != null) { 6587 } else if (optionalParameter != null) {
6599 inputs.add(handleConstantForOptionalParameter(optionalParameter)); 6588 inputs.add(handleConstantForOptionalParameter(optionalParameter));
6600 } else { 6589 } else {
6601 // Wrong. 6590 // Wrong.
6602 inputs.add(graph.addConstantNull(compiler)); 6591 inputs.add(graph.addConstantNull(compiler));
6603 } 6592 }
6604 } 6593 }
6605 6594
6606 int position = 0; 6595 int position = 0;
6607 6596
6608 for (ParameterElement targetParameter in targetRequireds) { 6597 for (ParameterElement _ in targetRequireds) {
6609 loadPosition(position++, null); 6598 loadPosition(position++, null);
6610 } 6599 }
6611 6600
6612 if (targetOptionals.isNotEmpty) { 6601 if (targetOptionals.isNotEmpty) {
6613 if (targetSignature.optionalParametersAreNamed) { 6602 if (targetSignature.optionalParametersAreNamed) {
6614 for (ParameterElement parameter in targetOptionals) { 6603 for (ParameterElement parameter in targetOptionals) {
6615 ParameterElement redirectingParameter = redirectingOptionals 6604 ParameterElement redirectingParameter = redirectingOptionals
6616 .firstWhere((p) => p.name == parameter.name, orElse: () => null); 6605 .firstWhere((p) => p.name == parameter.name, orElse: () => null);
6617 if (redirectingParameter == null) { 6606 if (redirectingParameter == null) {
6618 inputs.add(handleConstantForOptionalParameter(parameter)); 6607 inputs.add(handleConstantForOptionalParameter(parameter));
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
6920 // The 'get iterator' selector for this node has the inferred receiver type. 6909 // The 'get iterator' selector for this node has the inferred receiver type.
6921 // If the receiver supports JavaScript indexing we generate an indexing loop 6910 // If the receiver supports JavaScript indexing we generate an indexing loop
6922 // instead of allocating an iterator object. 6911 // instead of allocating an iterator object.
6923 6912
6924 // This scheme recognizes for-in on direct lists. It does not recognize all 6913 // This scheme recognizes for-in on direct lists. It does not recognize all
6925 // uses of ArrayIterator. They still occur when the receiver is an Iterable 6914 // uses of ArrayIterator. They still occur when the receiver is an Iterable
6926 // with a `get iterator` method that delegate to another Iterable and the 6915 // with a `get iterator` method that delegate to another Iterable and the
6927 // method is inlined. We would require full scalar replacement in that 6916 // method is inlined. We would require full scalar replacement in that
6928 // case. 6917 // case.
6929 6918
6930 Selector selector = Selectors.iterator;
6931 TypeMask mask = elements.getIteratorTypeMask(node); 6919 TypeMask mask = elements.getIteratorTypeMask(node);
6932 6920
6933 ClassWorld classWorld = compiler.world; 6921 ClassWorld classWorld = compiler.world;
6934 if (mask != null && 6922 if (mask != null &&
6935 mask.satisfies(helpers.jsIndexableClass, classWorld) && 6923 mask.satisfies(helpers.jsIndexableClass, classWorld) &&
6936 // String is indexable but not iterable. 6924 // String is indexable but not iterable.
6937 !mask.satisfies(helpers.jsStringClass, classWorld)) { 6925 !mask.satisfies(helpers.jsStringClass, classWorld)) {
6938 return buildSyncForInIndexable(node, mask); 6926 return buildSyncForInIndexable(node, mask);
6939 } 6927 }
6940 buildSyncForInIterator(node); 6928 buildSyncForInIterator(node);
(...skipping 1640 matching lines...) Expand 10 before | Expand all | Expand 10 after
8581 const _LoopTypeVisitor(); 8569 const _LoopTypeVisitor();
8582 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP; 8570 int visitNode(ast.Node node) => HLoopBlockInformation.NOT_A_LOOP;
8583 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP; 8571 int visitWhile(ast.While node) => HLoopBlockInformation.WHILE_LOOP;
8584 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP; 8572 int visitFor(ast.For node) => HLoopBlockInformation.FOR_LOOP;
8585 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; 8573 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP;
8586 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 8574 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
8587 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 8575 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
8588 int visitSwitchStatement(ast.SwitchStatement node) => 8576 int visitSwitchStatement(ast.SwitchStatement node) =>
8589 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 8577 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
8590 } 8578 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/source_file_provider.dart ('k') | pkg/compiler/lib/src/ssa/codegen.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698