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

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

Issue 2894893002: Add ElementCodegenWorldBuilder (Closed)
Patch Set: Updated cf. comments. Created 3 years, 7 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/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/ssa/ssa.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:math' as math; 5 import 'dart:math' as math;
6 import 'dart:collection' show Queue; 6 import 'dart:collection' show Queue;
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 8 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
9 import '../common/tasks.dart' show CompilerTask; 9 import '../common/tasks.dart' show CompilerTask;
10 import '../constants/constant_system.dart'; 10 import '../constants/constant_system.dart';
11 import '../constants/values.dart'; 11 import '../constants/values.dart';
12 import '../common_elements.dart' show CommonElements; 12 import '../common_elements.dart' show CommonElements;
13 import '../elements/elements.dart' 13 import '../elements/elements.dart'
14 show AsyncMarker, JumpTarget, LabelDefinition, MethodElement, ResolvedAst; 14 show AsyncMarker, JumpTarget, LabelDefinition, MethodElement, ResolvedAst;
15 import '../elements/entities.dart'; 15 import '../elements/entities.dart';
16 import '../elements/types.dart'; 16 import '../elements/types.dart';
17 import '../io/source_information.dart'; 17 import '../io/source_information.dart';
18 import '../js/js.dart' as js; 18 import '../js/js.dart' as js;
19 import '../js_backend/interceptor_data.dart'; 19 import '../js_backend/interceptor_data.dart';
20 import '../js_backend/backend.dart'; 20 import '../js_backend/backend.dart';
21 import '../js_backend/checked_mode_helpers.dart'; 21 import '../js_backend/checked_mode_helpers.dart';
22 import '../js_backend/element_strategy.dart' show ElementCodegenWorkItem;
22 import '../js_backend/native_data.dart'; 23 import '../js_backend/native_data.dart';
23 import '../js_backend/namer.dart'; 24 import '../js_backend/namer.dart';
24 import '../js_backend/runtime_types.dart'; 25 import '../js_backend/runtime_types.dart';
25 import '../js_emitter/code_emitter_task.dart'; 26 import '../js_emitter/code_emitter_task.dart';
26 import '../native/native.dart' as native; 27 import '../native/native.dart' as native;
27 import '../options.dart'; 28 import '../options.dart';
28 import '../types/types.dart'; 29 import '../types/types.dart';
29 import '../universe/call_structure.dart' show CallStructure; 30 import '../universe/call_structure.dart' show CallStructure;
30 import '../universe/selector.dart' show Selector; 31 import '../universe/selector.dart' show Selector;
31 import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse; 32 import '../universe/use.dart' show ConstantUse, DynamicUse, StaticUse, TypeUse;
(...skipping 24 matching lines...) Expand all
56 ? const js.AsyncModifier.syncStar() 57 ? const js.AsyncModifier.syncStar()
57 : const js.AsyncModifier.sync()); 58 : const js.AsyncModifier.sync());
58 59
59 return new js.Fun(parameters, body, asyncModifier: asyncModifier) 60 return new js.Fun(parameters, body, asyncModifier: asyncModifier)
60 .withSourceInformation(sourceInformationFactory 61 .withSourceInformation(sourceInformationFactory
61 .createBuilderForContext(resolvedAst) 62 .createBuilderForContext(resolvedAst)
62 .buildDeclaration(resolvedAst)); 63 .buildDeclaration(resolvedAst));
63 } 64 }
64 65
65 js.Expression generateCode( 66 js.Expression generateCode(
66 CodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) { 67 ElementCodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) {
67 if (work.element.isField) { 68 if (work.element.isField) {
68 return generateLazyInitializer(work, graph, closedWorld); 69 return generateLazyInitializer(work, graph, closedWorld);
69 } else { 70 } else {
70 return generateMethod(work, graph, closedWorld); 71 return generateMethod(work, graph, closedWorld);
71 } 72 }
72 } 73 }
73 74
74 js.Expression generateLazyInitializer( 75 js.Expression generateLazyInitializer(
75 CodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) { 76 ElementCodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) {
76 return measure(() { 77 return measure(() {
77 backend.tracer.traceGraph("codegen", graph); 78 backend.tracer.traceGraph("codegen", graph);
78 SourceInformation sourceInformation = sourceInformationFactory 79 SourceInformation sourceInformation = sourceInformationFactory
79 .createBuilderForContext(work.resolvedAst) 80 .createBuilderForContext(work.resolvedAst)
80 .buildDeclaration(work.resolvedAst); 81 .buildDeclaration(work.resolvedAst);
81 SsaCodeGenerator codegen = new SsaCodeGenerator( 82 SsaCodeGenerator codegen = new SsaCodeGenerator(
82 backend.compiler.options, 83 backend.compiler.options,
83 backend.emitter, 84 backend.emitter,
84 backend.nativeCodegenEnqueuer, 85 backend.nativeCodegenEnqueuer,
85 backend.checkedModeHelpers, 86 backend.checkedModeHelpers,
86 backend.oneShotInterceptorData, 87 backend.oneShotInterceptorData,
87 backend.rtiSubstitutions, 88 backend.rtiSubstitutions,
88 backend.rtiEncoder, 89 backend.rtiEncoder,
89 backend.namer, 90 backend.namer,
90 backend.superMemberData, 91 backend.superMemberData,
91 closedWorld, 92 closedWorld,
92 work); 93 work);
93 codegen.visitGraph(graph); 94 codegen.visitGraph(graph);
94 return new js.Fun(codegen.parameters, codegen.body) 95 return new js.Fun(codegen.parameters, codegen.body)
95 .withSourceInformation(sourceInformation); 96 .withSourceInformation(sourceInformation);
96 }); 97 });
97 } 98 }
98 99
99 js.Expression generateMethod( 100 js.Expression generateMethod(
100 CodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) { 101 ElementCodegenWorkItem work, HGraph graph, ClosedWorld closedWorld) {
101 return measure(() { 102 return measure(() {
102 MethodElement element = work.element; 103 MethodElement element = work.element;
103 if (element.asyncMarker != AsyncMarker.SYNC) { 104 if (element.asyncMarker != AsyncMarker.SYNC) {
104 work.registry.registerAsyncMarker(element.asyncMarker); 105 work.registry.registerAsyncMarker(element.asyncMarker);
105 } 106 }
106 SsaCodeGenerator codegen = new SsaCodeGenerator( 107 SsaCodeGenerator codegen = new SsaCodeGenerator(
107 backend.compiler.options, 108 backend.compiler.options,
108 backend.emitter, 109 backend.emitter,
109 backend.nativeCodegenEnqueuer, 110 backend.nativeCodegenEnqueuer,
110 backend.checkedModeHelpers, 111 backend.checkedModeHelpers,
(...skipping 2928 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 return _closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) { 3040 return _closedWorld.anyStrictSubclassOf(cls, (ClassEntity subclass) {
3040 return !_rtiSubstitutions.isTrivialSubstitution(subclass, cls); 3041 return !_rtiSubstitutions.isTrivialSubstitution(subclass, cls);
3041 }); 3042 });
3042 } 3043 }
3043 3044
3044 @override 3045 @override
3045 void visitRef(HRef node) { 3046 void visitRef(HRef node) {
3046 visit(node.value); 3047 visit(node.value);
3047 } 3048 }
3048 } 3049 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder_kernel.dart ('k') | pkg/compiler/lib/src/ssa/ssa.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698