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

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

Issue 2280743003: implement kernel -> ssa for function that returns a constant (Closed)
Patch Set: Created 4 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/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 6
7 import '../common/codegen.dart' show CodegenWorkItem; 7 import '../common/codegen.dart' show CodegenWorkItem;
8 import '../common/tasks.dart' show CompilerTask; 8 import '../common/tasks.dart' show CompilerTask;
9 import '../compiler.dart'; 9 import '../compiler.dart';
10 import '../diagnostics/spannable.dart';
10 import '../elements/elements.dart'; 11 import '../elements/elements.dart';
11 import '../io/source_information.dart'; 12 import '../io/source_information.dart';
12 import '../js_backend/backend.dart' show JavaScriptBackend; 13 import '../js_backend/backend.dart' show JavaScriptBackend;
13 import '../kernel/kernel.dart'; 14 import '../kernel/kernel.dart';
14 import '../kernel/kernel_visitor.dart'; 15 import '../kernel/kernel_visitor.dart';
15 import '../resolution/tree_elements.dart'; 16 import '../resolution/tree_elements.dart';
16 import 'graph_builder.dart'; 17 import 'graph_builder.dart';
17 import 'locals_handler.dart'; 18 import 'locals_handler.dart';
18 import 'nodes.dart'; 19 import 'nodes.dart';
19 20
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 localsHandler.startFunction(functionElement, resolvedAst.node); 110 localsHandler.startFunction(functionElement, resolvedAst.node);
110 close(new HGoto()).addSuccessor(block); 111 close(new HGoto()).addSuccessor(block);
111 112
112 open(block); 113 open(block);
113 } 114 }
114 115
115 void closeFunction() { 116 void closeFunction() {
116 if (!isAborted()) closeAndGotoExit(new HGoto()); 117 if (!isAborted()) closeAndGotoExit(new HGoto());
117 graph.finalize(); 118 graph.finalize();
118 } 119 }
120
121 @override
122 void visitBlock(ir.Block block) {
123 assert(!isAborted());
124 for (ir.Statement statement in block.statements) {
125 statement.accept(this);
126 if (!isReachable) {
127 // The block has been aborted by a return or a throw.
128 if (stack.isNotEmpty) {
129 compiler.reporter.internalError(
130 NO_LOCATION_SPANNABLE, 'Non-empty instruction stack.');
131 }
132 return;
133 }
134 }
135 assert(!current.isClosed());
136 if (stack.isNotEmpty) {
137 compiler.reporter
138 .internalError(NO_LOCATION_SPANNABLE, 'Non-empty instruction stack');
139 }
140 }
141
142 @override
143 void visitReturnStatement(ir.ReturnStatement returnStatement) {
144 HInstruction value;
145 if (returnStatement.expression == null) {
146 value = graph.addConstantNull(compiler);
147 } else {
148 returnStatement.expression.accept(this);
149 value = pop();
150 // TODO(het): Check or trust the type of value
151 }
152 // TODO(het): Add source information
153 closeAndGotoExit(new HReturn(value, null));
Siggi Cherem (dart-lang) 2016/08/26 00:57:14 also add TODO that once we add inlining we would s
Harry Terkelsen 2016/08/26 17:29:06 Done.
154 }
155
156 @override
157 void visitIntLiteral(ir.IntLiteral intLiteral) {
158 stack.add(graph.addConstantInt(intLiteral.value, compiler));
159 }
119 } 160 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/builder.dart ('k') | pkg/compiler/lib/src/ssa/graph_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698