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

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

Issue 2937203002: Add J-elements (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 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
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' show LoopClosureRepresentationInfo; 7 import '../closure.dart' show LoopClosureRepresentationInfo;
8 import '../elements/jumps.dart'; 8 import '../elements/jumps.dart';
9 import '../io/source_information.dart'; 9 import '../io/source_information.dart';
10 import '../tree/tree.dart' as ast; 10 import '../tree/tree.dart' as ast;
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 /// a special "null handler" is returned. 301 /// a special "null handler" is returned.
302 /// 302 ///
303 /// [isLoopJump] is [:true:] when the jump handler is for a loop. This is used 303 /// [isLoopJump] is [:true:] when the jump handler is for a loop. This is used
304 /// to distinguish the synthesized loop created for a switch statement with 304 /// to distinguish the synthesized loop created for a switch statement with
305 /// continue statements from simple switch statements. 305 /// continue statements from simple switch statements.
306 JumpHandler createJumpHandler(T node, {bool isLoopJump}); 306 JumpHandler createJumpHandler(T node, {bool isLoopJump});
307 } 307 }
308 308
309 /// A loop handler for the builder that just uses AST nodes directly. 309 /// A loop handler for the builder that just uses AST nodes directly.
310 class SsaLoopHandler extends LoopHandler<ast.Node> { 310 class SsaLoopHandler extends LoopHandler<ast.Node> {
311 final SsaBuilder builder; 311 final SsaAstGraphBuilder builder;
312 312
313 SsaLoopHandler(SsaBuilder builder) 313 SsaLoopHandler(SsaAstGraphBuilder builder)
314 : this.builder = builder, 314 : this.builder = builder,
315 super(builder); 315 super(builder);
316 316
317 @override 317 @override
318 JumpTarget getTargetDefinition(ast.Node node) { 318 JumpTarget getTargetDefinition(ast.Node node) {
319 return builder.elements.getTargetDefinition(node); 319 return builder.elements.getTargetDefinition(node);
320 } 320 }
321 321
322 @override 322 @override
323 int loopKind(ast.Node node) => node.accept(const _SsaLoopTypeVisitor()); 323 int loopKind(ast.Node node) => node.accept(const _SsaLoopTypeVisitor());
(...skipping 15 matching lines...) Expand all
339 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP; 339 int visitDoWhile(ast.DoWhile node) => HLoopBlockInformation.DO_WHILE_LOOP;
340 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 340 int visitAsyncForIn(ast.AsyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
341 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP; 341 int visitSyncForIn(ast.SyncForIn node) => HLoopBlockInformation.FOR_IN_LOOP;
342 int visitSwitchStatement(ast.SwitchStatement node) => 342 int visitSwitchStatement(ast.SwitchStatement node) =>
343 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 343 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
344 } 344 }
345 345
346 // TODO(het): Since kernel simplifies loop breaks and continues, we should 346 // TODO(het): Since kernel simplifies loop breaks and continues, we should
347 // rewrite the loop handler from scratch to account for the simplified structure 347 // rewrite the loop handler from scratch to account for the simplified structure
348 class KernelLoopHandler extends LoopHandler<ir.TreeNode> { 348 class KernelLoopHandler extends LoopHandler<ir.TreeNode> {
349 final KernelSsaBuilder builder; 349 final KernelSsaGraphBuilder builder;
350 350
351 KernelAstAdapter get astAdapter => builder.astAdapter; 351 KernelAstAdapter get astAdapter => builder.astAdapter;
352 352
353 KernelLoopHandler(KernelSsaBuilder builder) 353 KernelLoopHandler(KernelSsaGraphBuilder builder)
354 : this.builder = builder, 354 : this.builder = builder,
355 super(builder); 355 super(builder);
356 356
357 @override 357 @override
358 JumpHandler createJumpHandler(ir.TreeNode node, {bool isLoopJump}) => 358 JumpHandler createJumpHandler(ir.TreeNode node, {bool isLoopJump}) =>
359 builder.createJumpHandler(node, isLoopJump: isLoopJump); 359 builder.createJumpHandler(node, isLoopJump: isLoopJump);
360 360
361 @override 361 @override
362 JumpTarget getTargetDefinition(ir.TreeNode node) => 362 JumpTarget getTargetDefinition(ir.TreeNode node) =>
363 builder.localsMap.getJumpTarget(node); 363 builder.localsMap.getJumpTarget(node);
(...skipping 22 matching lines...) Expand all
386 HLoopBlockInformation.DO_WHILE_LOOP; 386 HLoopBlockInformation.DO_WHILE_LOOP;
387 387
388 @override 388 @override
389 int visitForInStatement(ir.ForInStatement node) => 389 int visitForInStatement(ir.ForInStatement node) =>
390 HLoopBlockInformation.FOR_IN_LOOP; 390 HLoopBlockInformation.FOR_IN_LOOP;
391 391
392 @override 392 @override
393 int visitSwitchStatement(ir.SwitchStatement node) => 393 int visitSwitchStatement(ir.SwitchStatement node) =>
394 HLoopBlockInformation.SWITCH_CONTINUE_LOOP; 394 HLoopBlockInformation.SWITCH_CONTINUE_LOOP;
395 } 395 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/ssa/kernel_string_builder.dart ('k') | pkg/compiler/lib/src/ssa/rasta_ssa_builder_task.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698