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

Side by Side Diff: dart/frog/leg/ssa/builder.dart

Issue 9836022: No globals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | dart/frog/leg/ssa/closure.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 class Interceptors { 5 class Interceptors {
6 Compiler compiler; 6 Compiler compiler;
7 Interceptors(Compiler this.compiler); 7 Interceptors(Compiler this.compiler);
8 8
9 SourceString mapOperatorToMethodName(Operator op) { 9 SourceString mapOperatorToMethodName(Operator op) {
10 String name = op.source.stringValue; 10 String name = op.source.stringValue;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 Element getEqualsInterceptor() { 105 Element getEqualsInterceptor() {
106 return compiler.findHelper(const SourceString('eq')); 106 return compiler.findHelper(const SourceString('eq'));
107 } 107 }
108 108
109 Element getMapMaker() { 109 Element getMapMaker() {
110 return compiler.findHelper(const SourceString('makeLiteralMap')); 110 return compiler.findHelper(const SourceString('makeLiteralMap'));
111 } 111 }
112 } 112 }
113 113
114 class SsaBuilderTask extends CompilerTask { 114 class SsaBuilderTask extends CompilerTask {
115 final Interceptors interceptors;
116 final Map<Node, ClosureData> closureDataCache;
117
118 String get name() => 'SSA builder';
119
115 SsaBuilderTask(Compiler compiler) 120 SsaBuilderTask(Compiler compiler)
116 : super(compiler), interceptors = new Interceptors(compiler); 121 : interceptors = new Interceptors(compiler),
117 String get name() => 'SSA builder'; 122 closureDataCache = new HashMap<Node, ClosureData>(),
118 Interceptors interceptors; 123 super(compiler);
119 124
120 HGraph build(WorkItem work) { 125 HGraph build(WorkItem work) {
121 return measure(() { 126 return measure(() {
122 FunctionElement element = work.element; 127 FunctionElement element = work.element;
123 HInstruction.idCounter = 0; 128 HInstruction.idCounter = 0;
124 SsaBuilder builder = new SsaBuilder(compiler, work); 129 SsaBuilder builder = new SsaBuilder(compiler, work);
125 HGraph graph; 130 HGraph graph;
126 switch (element.kind) { 131 switch (element.kind) {
127 case ElementKind.GENERATIVE_CONSTRUCTOR: 132 case ElementKind.GENERATIVE_CONSTRUCTOR:
128 graph = compileConstructor(builder, work); 133 graph = compileConstructor(builder, work);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 updateLocal(boxElement, newBox); 269 updateLocal(boxElement, newBox);
265 updateLocal(boxedVariable, oldValue); 270 updateLocal(boxedVariable, oldValue);
266 } 271 }
267 updateLocal(boxElement, newBox); 272 updateLocal(boxElement, newBox);
268 } 273 }
269 274
270 void startFunction(FunctionElement function, 275 void startFunction(FunctionElement function,
271 FunctionExpression node) { 276 FunctionExpression node) {
272 277
273 ClosureTranslator translator = 278 ClosureTranslator translator =
274 new ClosureTranslator(builder.compiler, builder.elements); 279 new ClosureTranslator(builder.compiler, builder.elements,
280 builder.closureDataCache);
275 closureData = translator.translate(node); 281 closureData = translator.translate(node);
276 282
277 FunctionParameters params = function.computeParameters(builder.compiler); 283 FunctionParameters params = function.computeParameters(builder.compiler);
278 params.forEachParameter((Element element) { 284 params.forEachParameter((Element element) {
279 HParameterValue parameter = new HParameterValue(element); 285 HParameterValue parameter = new HParameterValue(element);
280 builder.add(parameter); 286 builder.add(parameter);
281 directLocals[element] = parameter; 287 directLocals[element] = parameter;
282 }); 288 });
283 if (closureData.thisElement !== null) { 289 if (closureData.thisElement !== null) {
284 // Once closures have been mapped to classes their instance members might 290 // Once closures have been mapped to classes their instance members might
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 717
712 class SsaBuilder implements Visitor { 718 class SsaBuilder implements Visitor {
713 final Compiler compiler; 719 final Compiler compiler;
714 TreeElements elements; 720 TreeElements elements;
715 final Interceptors interceptors; 721 final Interceptors interceptors;
716 final WorkItem work; 722 final WorkItem work;
717 bool methodInterceptionEnabled; 723 bool methodInterceptionEnabled;
718 HGraph graph; 724 HGraph graph;
719 LocalsHandler localsHandler; 725 LocalsHandler localsHandler;
720 HInstruction rethrowableException; 726 HInstruction rethrowableException;
727 final Map<Node, ClosureData> closureDataCache;
ngeoffray 2012/03/23 07:57:02 Since that guy is only used once in this file, I'd
ahe 2012/03/23 09:09:40 I don't understand your concern. I think the field
ngeoffray 2012/03/23 09:16:28 My concern is: I don't like introducing fields, IM
ahe 2012/03/23 09:35:48 Perhaps I should have said: I assume you want me t
721 728
722 Map<TargetElement, JumpHandler> jumpTargets; 729 Map<TargetElement, JumpHandler> jumpTargets;
723 730
724 // We build the Ssa graph by simulating a stack machine. 731 // We build the Ssa graph by simulating a stack machine.
725 List<HInstruction> stack; 732 List<HInstruction> stack;
726 733
727 // The current block to add instructions to. Might be null, if we are 734 // The current block to add instructions to. Might be null, if we are
728 // visiting dead code. 735 // visiting dead code.
729 HBasicBlock current; 736 HBasicBlock current;
730 // The most recently opened block. Has the same value as [current] while 737 // The most recently opened block. Has the same value as [current] while
731 // the block is open, but unlike [current], it isn't cleared when the current 738 // the block is open, but unlike [current], it isn't cleared when the current
732 // block is closed. 739 // block is closed.
733 HBasicBlock lastOpenedBlock; 740 HBasicBlock lastOpenedBlock;
734 741
735 LibraryElement get currentLibrary() => work.element.getLibrary(); 742 LibraryElement get currentLibrary() => work.element.getLibrary();
736 743
737 SsaBuilder(Compiler compiler, WorkItem work) 744 SsaBuilder(Compiler compiler, WorkItem work)
738 : this.compiler = compiler, 745 : this.compiler = compiler,
739 this.work = work, 746 this.work = work,
740 interceptors = compiler.builder.interceptors, 747 interceptors = compiler.builder.interceptors,
748 closureDataCache = compiler.builder.closureDataCache,
741 methodInterceptionEnabled = true, 749 methodInterceptionEnabled = true,
742 elements = work.resolutionTree, 750 elements = work.resolutionTree,
743 graph = new HGraph(), 751 graph = new HGraph(),
744 stack = new List<HInstruction>(), 752 stack = new List<HInstruction>(),
745 jumpTargets = new Map<TargetElement, JumpHandler>() { 753 jumpTargets = new Map<TargetElement, JumpHandler>() {
746 localsHandler = new LocalsHandler(this); 754 localsHandler = new LocalsHandler(this);
747 } 755 }
748 756
749 void disableMethodInterception() { 757 void disableMethodInterception() {
750 assert(methodInterceptionEnabled); 758 assert(methodInterceptionEnabled);
(...skipping 2130 matching lines...) Expand 10 before | Expand all | Expand 10 after
2881 false, 2889 false,
2882 <HInstruction>[target, input])); 2890 <HInstruction>[target, input]));
2883 return builder.pop(); 2891 return builder.pop();
2884 } 2892 }
2885 2893
2886 HInstruction result() { 2894 HInstruction result() {
2887 flushLiterals(); 2895 flushLiterals();
2888 return prefix; 2896 return prefix;
2889 } 2897 }
2890 } 2898 }
OLDNEW
« no previous file with comments | « no previous file | dart/frog/leg/ssa/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698