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

Side by Side Diff: lib/compiler/implementation/ssa/closure.dart

Issue 10108019: Revert "Reapply "Don't try to box immutable objects." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | samples/tests/samples/samples-leg.status » ('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 ClosureFieldElement extends Element { 5 class ClosureFieldElement extends Element {
6 ClosureFieldElement(SourceString name, ClassElement enclosing) 6 ClosureFieldElement(SourceString name, ClassElement enclosing)
7 : super(name, ElementKind.FIELD, enclosing); 7 : super(name, ElementKind.FIELD, enclosing);
8 8
9 bool isInstanceMember() => true; 9 bool isInstanceMember() => true;
10 bool isAssignable() => false; 10 bool isAssignable() => false;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 233 }
234 234
235 // If variables that are declared in the [node] scope are captured and need 235 // If variables that are declared in the [node] scope are captured and need
236 // to be boxed create a box-element and update the [capturingScopes] in the 236 // to be boxed create a box-element and update the [capturingScopes] in the
237 // current [closureData]. 237 // current [closureData].
238 // The boxed variables are updated in the [capturedVariableMapping]. 238 // The boxed variables are updated in the [capturedVariableMapping].
239 void attachCapturedScopeVariables(Node node) { 239 void attachCapturedScopeVariables(Node node) {
240 Element box = null; 240 Element box = null;
241 Map<Element, Element> scopeMapping = new Map<Element, Element>(); 241 Map<Element, Element> scopeMapping = new Map<Element, Element>();
242 for (Element element in scopeVariables) { 242 for (Element element in scopeVariables) {
243 // No need to box non-assignable elements.
244 if (!element.isAssignable()) continue;
245 if (capturedVariableMapping.containsKey(element)) { 243 if (capturedVariableMapping.containsKey(element)) {
246 if (box == null) { 244 if (box == null) {
247 // TODO(floitsch): construct better box names. 245 // TODO(floitsch): construct better box names.
248 SourceString boxName = new SourceString("box${boxCounter++}"); 246 SourceString boxName = new SourceString("box${boxCounter++}");
249 box = new Element(boxName, 247 box = new Element(boxName,
250 ElementKind.VARIABLE, 248 ElementKind.VARIABLE,
251 currentFunctionElement); 249 currentFunctionElement);
252 } 250 }
253 // TODO(floitsch): construct better boxed names. 251 // TODO(floitsch): construct better boxed names.
254 String elementName = element.name.slowToString(); 252 String elementName = element.name.slowToString();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 thisEnclosingElement = body.constructor; 347 thisEnclosingElement = body.constructor;
350 } 348 }
351 thisElement = new Element(const SourceString("this"), 349 thisElement = new Element(const SourceString("this"),
352 ElementKind.PARAMETER, 350 ElementKind.PARAMETER,
353 thisEnclosingElement); 351 thisEnclosingElement);
354 } 352 }
355 closureData = new ClosureData(null, null, null, thisElement); 353 closureData = new ClosureData(null, null, null, thisElement);
356 } 354 }
357 scopeVariables = new List<Element>(); 355 scopeVariables = new List<Element>();
358 356
357 // TODO(floitsch): a named function is visible from inside itself. Add
358 // the element to the block.
359
359 // We have to declare the implicit 'this' parameter. 360 // We have to declare the implicit 'this' parameter.
360 if (!insideClosure && closureData.thisElement !== null) { 361 if (!insideClosure && closureData.thisElement !== null) {
361 declareLocal(closureData.thisElement); 362 declareLocal(closureData.thisElement);
362 } 363 }
363 // If we are inside a named closure we have to declare ourselve. For 364 // If we are inside a named closure we have to declare ourselve. For
364 // simplicity we declare the local even if the closure does not have a name 365 // simplicity we declare the local even if the closure does not have a name
365 // It will simply not be used. 366 // It will simply not be used.
366 if (insideClosure) { 367 if (insideClosure) {
367 declareLocal(element); 368 declareLocal(element);
368 } 369 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 declareLocal(elements[node]); 408 declareLocal(elements[node]);
408 } 409 }
409 410
410 visitTryStatement(TryStatement node) { 411 visitTryStatement(TryStatement node) {
411 // TODO(ngeoffray): implement finer grain state. 412 // TODO(ngeoffray): implement finer grain state.
412 inTryCatchOrFinally = true; 413 inTryCatchOrFinally = true;
413 node.visitChildren(this); 414 node.visitChildren(this);
414 inTryCatchOrFinally = false; 415 inTryCatchOrFinally = false;
415 } 416 }
416 } 417 }
OLDNEW
« no previous file with comments | « no previous file | samples/tests/samples/samples-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698