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

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

Issue 2619683002: dart2js-kernel: do not initialize static fields in constructor (Closed)
Patch Set: Created 3 years, 11 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 | « no previous file | no next file » | 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 '../closure.dart'; 7 import '../closure.dart';
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem; 9 import '../common/codegen.dart' show CodegenRegistry, CodegenWorkItem;
10 import '../common/names.dart'; 10 import '../common/names.dart';
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 hasRtiInput: false); 283 hasRtiInput: false);
284 284
285 add(create); 285 add(create);
286 286
287 // Generate calls to the constructor bodies. 287 // Generate calls to the constructor bodies.
288 288
289 closeAndGotoExit(new HReturn(create, null)); 289 closeAndGotoExit(new HReturn(create, null));
290 closeFunction(); 290 closeFunction();
291 } 291 }
292 292
293 /// Maps the fields of a class to their SSA values. 293 /// Maps the instance fields of a class to their SSA values.
294 Map<ir.Field, HInstruction> _collectFieldValues(ir.Class clazz) { 294 Map<ir.Field, HInstruction> _collectFieldValues(ir.Class clazz) {
295 final fieldValues = <ir.Field, HInstruction>{}; 295 final fieldValues = <ir.Field, HInstruction>{};
296 296
297 for (var field in clazz.fields) { 297 for (var field in clazz.fields) {
298 if (field.initializer == null) { 298 if (field.isInstanceMember) {
299 fieldValues[field] = graph.addConstantNull(closedWorld); 299 if (field.initializer == null) {
300 } else { 300 fieldValues[field] = graph.addConstantNull(closedWorld);
301 // Gotta update the resolvedAst when we're looking at field values 301 } else {
302 // outside the constructor. 302 // Gotta update the resolvedAst when we're looking at field values
303 astAdapter.pushResolvedAst(field); 303 // outside the constructor.
304 field.initializer.accept(this); 304 astAdapter.pushResolvedAst(field);
305 fieldValues[field] = pop(); 305 field.initializer.accept(this);
306 astAdapter.popResolvedAstStack(); 306 fieldValues[field] = pop();
307 astAdapter.popResolvedAstStack();
308 }
307 } 309 }
308 } 310 }
309 311
310 return fieldValues; 312 return fieldValues;
311 } 313 }
312 314
313 /// Collects field initializers all the way up the inheritance chain. 315 /// Collects field initializers all the way up the inheritance chain.
314 void _buildInitializers( 316 void _buildInitializers(
315 ir.Constructor constructor, Map<ir.Field, HInstruction> fieldValues) { 317 ir.Constructor constructor, Map<ir.Field, HInstruction> fieldValues) {
316 var foundSuperOrRedirectCall = false; 318 var foundSuperOrRedirectCall = false;
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 kernelBuilder.open(exitBlock); 2486 kernelBuilder.open(exitBlock);
2485 enterBlock.setBlockFlow( 2487 enterBlock.setBlockFlow(
2486 new HTryBlockInformation( 2488 new HTryBlockInformation(
2487 kernelBuilder.wrapStatementGraph(bodyGraph), 2489 kernelBuilder.wrapStatementGraph(bodyGraph),
2488 exception, 2490 exception,
2489 kernelBuilder.wrapStatementGraph(catchGraph), 2491 kernelBuilder.wrapStatementGraph(catchGraph),
2490 kernelBuilder.wrapStatementGraph(finallyGraph)), 2492 kernelBuilder.wrapStatementGraph(finallyGraph)),
2491 exitBlock); 2493 exitBlock);
2492 } 2494 }
2493 } 2495 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698