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

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

Issue 2932023003: Refactor LoopHandler to avoid calling KernelAstAdapter.getNode (Closed)
Patch Set: 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 '../closure.dart'; 5 import '../closure.dart';
6 import '../common.dart'; 6 import '../common.dart';
7 import '../elements/elements.dart'; 7 import '../elements/elements.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 import '../elements/types.dart'; 9 import '../elements/types.dart';
10 import '../io/source_information.dart'; 10 import '../io/source_information.dart';
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 /// We solve this by emitting the following code (only for [ast.For] loops): 466 /// We solve this by emitting the following code (only for [ast.For] loops):
467 /// <Create box> <== move the first box creation outside the loop. 467 /// <Create box> <== move the first box creation outside the loop.
468 /// <initializer>; 468 /// <initializer>;
469 /// loop-entry: 469 /// loop-entry:
470 /// if (!<condition>) goto loop-exit; 470 /// if (!<condition>) goto loop-exit;
471 /// <body> 471 /// <body>
472 /// <update box> // create a new box and copy the captured loop-variables. 472 /// <update box> // create a new box and copy the captured loop-variables.
473 /// <updates> 473 /// <updates>
474 /// goto loop-entry; 474 /// goto loop-entry;
475 /// loop-exit: 475 /// loop-exit:
476 void startLoop(ast.Node node) { 476 void startLoop(ClosureScope scopeData) {
477 ClosureScope scopeData = closureData.capturingScopes[node]; 477 //ClosureScope scopeData = closureData.capturingScopes[node];
Emily Fortuna 2017/06/09 20:12:27 delete line?
478 if (scopeData == null) return; 478 if (scopeData == null) return;
479 if (scopeData.hasBoxedLoopVariables()) { 479 if (scopeData.hasBoxedLoopVariables()) {
480 // If there are boxed loop variables then we set up the box and 480 // If there are boxed loop variables then we set up the box and
481 // redirections already now. This way the initializer can write its 481 // redirections already now. This way the initializer can write its
482 // values into the box. 482 // values into the box.
483 // For other loops the box will be created when entering the body. 483 // For other loops the box will be created when entering the body.
484 enterScope(scopeData); 484 enterScope(scopeData);
485 } 485 }
486 } 486 }
487 487
(...skipping 13 matching lines...) Expand all
501 new HPhi.singleInput(local, instruction, commonMasks.dynamicType); 501 new HPhi.singleInput(local, instruction, commonMasks.dynamicType);
502 loopEntry.addPhi(phi); 502 loopEntry.addPhi(phi);
503 directLocals[local] = phi; 503 directLocals[local] = phi;
504 } else { 504 } else {
505 directLocals[local] = instruction; 505 directLocals[local] = instruction;
506 } 506 }
507 } 507 }
508 }); 508 });
509 } 509 }
510 510
511 void enterLoopBody(ast.Node node) { 511 void enterLoopBody(ClosureScope scopeData) {
512 ClosureScope scopeData = closureData.capturingScopes[node]; 512 //ClosureScope scopeData = closureData.capturingScopes[node];
Emily Fortuna 2017/06/09 20:12:27 same here
513 if (scopeData == null) return; 513 if (scopeData == null) return;
514 // If there are no declared boxed loop variables then we did not create the 514 // If there are no declared boxed loop variables then we did not create the
515 // box before the initializer and we have to create the box now. 515 // box before the initializer and we have to create the box now.
516 if (!scopeData.hasBoxedLoopVariables()) { 516 if (!scopeData.hasBoxedLoopVariables()) {
517 enterScope(scopeData); 517 enterScope(scopeData);
518 } 518 }
519 } 519 }
520 520
521 void enterLoopUpdates(ast.Node node) { 521 void enterLoopUpdates(ClosureScope scopeData) {
522 // If there are declared boxed loop variables then the updates might have 522 // If there are declared boxed loop variables then the updates might have
523 // access to the box and we must switch to a new box before executing the 523 // access to the box and we must switch to a new box before executing the
524 // updates. 524 // updates.
525 // In all other cases a new box will be created when entering the body of 525 // In all other cases a new box will be created when entering the body of
526 // the next iteration. 526 // the next iteration.
527 ClosureScope scopeData = closureData.capturingScopes[node]; 527 //ClosureScope scopeData = closureData.capturingScopes[node];
Emily Fortuna 2017/06/09 20:12:27 ditto
528 if (scopeData == null) return; 528 if (scopeData == null) return;
529 if (scopeData.hasBoxedLoopVariables()) { 529 if (scopeData.hasBoxedLoopVariables()) {
530 updateCaptureBox(scopeData.boxElement, scopeData.boxedLoopVariables); 530 updateCaptureBox(scopeData.boxElement, scopeData.boxedLoopVariables);
531 } 531 }
532 } 532 }
533 533
534 /// Goes through the phis created in beginLoopHeader entry and adds the 534 /// Goes through the phis created in beginLoopHeader entry and adds the
535 /// input from the back edge (from the current value of directLocals) to them. 535 /// input from the back edge (from the current value of directLocals) to them.
536 void endLoop(HBasicBlock loopEntry) { 536 void endLoop(HBasicBlock loopEntry) {
537 // If the loop has an aborting body, we don't update the loop 537 // If the loop has an aborting body, we don't update the loop
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 final MemberEntity memberContext; 676 final MemberEntity memberContext;
677 677
678 // Avoid slow Object.hashCode. 678 // Avoid slow Object.hashCode.
679 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30); 679 final int hashCode = _nextHashCode = (_nextHashCode + 1).toUnsigned(30);
680 static int _nextHashCode = 0; 680 static int _nextHashCode = 0;
681 681
682 SyntheticLocal(this.name, this.executableContext, this.memberContext); 682 SyntheticLocal(this.name, this.executableContext, this.memberContext);
683 683
684 toString() => 'SyntheticLocal($name)'; 684 toString() => 'SyntheticLocal($name)';
685 } 685 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698