| OLD | NEW |
| 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 part of ssa; | 5 part of ssa; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A special element for the extra parameter taken by intercepted | 8 * A special element for the extra parameter taken by intercepted |
| 9 * methods. We need to override [Element.computeType] because our | 9 * methods. We need to override [Element.computeType] because our |
| 10 * optimizers may look at its declared type. | 10 * optimizers may look at its declared type. |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } else { | 362 } else { |
| 363 builder.compiler.internalError( | 363 builder.compiler.internalError( |
| 364 "Cannot find value $element", | 364 "Cannot find value $element", |
| 365 element: element); | 365 element: element); |
| 366 } | 366 } |
| 367 } | 367 } |
| 368 return directLocals[element]; | 368 return directLocals[element]; |
| 369 } else if (isStoredInClosureField(element)) { | 369 } else if (isStoredInClosureField(element)) { |
| 370 Element redirect = redirectionMapping[element]; | 370 Element redirect = redirectionMapping[element]; |
| 371 HInstruction receiver = readLocal(closureData.closureElement); | 371 HInstruction receiver = readLocal(closureData.closureElement); |
| 372 HInstruction fieldGet = new HFieldGet( | 372 HType type = (element.kind == ElementKind.VARIABLE_LIST) |
| 373 redirect, receiver, builder.getTypeOfCapturedVariable(redirect)); | 373 ? builder.backend.nonNullType |
| 374 : builder.getTypeOfCapturedVariable(redirect); |
| 375 assert(element.kind != ElementKind.VARIABLE_LIST |
| 376 || element is BoxElement); |
| 377 HInstruction fieldGet = new HFieldGet(redirect, receiver, type); |
| 374 builder.add(fieldGet); | 378 builder.add(fieldGet); |
| 375 return fieldGet; | 379 return fieldGet; |
| 376 } else if (isBoxed(element)) { | 380 } else if (isBoxed(element)) { |
| 377 Element redirect = redirectionMapping[element]; | 381 Element redirect = redirectionMapping[element]; |
| 378 // In the function that declares the captured variable the box is | 382 // In the function that declares the captured variable the box is |
| 379 // accessed as direct local. Inside the nested closure the box is | 383 // accessed as direct local. Inside the nested closure the box is |
| 380 // accessed through a closure-field. | 384 // accessed through a closure-field. |
| 381 // Calling [readLocal] makes sure we generate the correct code to get | 385 // Calling [readLocal] makes sure we generate the correct code to get |
| 382 // the box. | 386 // the box. |
| 383 assert(redirect.enclosingElement.isVariable()); | 387 assert(redirect.enclosingElement is BoxElement); |
| 384 HInstruction box = readLocal(redirect.enclosingElement); | 388 HInstruction box = readLocal(redirect.enclosingElement); |
| 385 HInstruction lookup = new HFieldGet( | 389 HInstruction lookup = new HFieldGet( |
| 386 redirect, box, builder.getTypeOfCapturedVariable(redirect)); | 390 redirect, box, builder.getTypeOfCapturedVariable(redirect)); |
| 387 builder.add(lookup); | 391 builder.add(lookup); |
| 388 return lookup; | 392 return lookup; |
| 389 } else { | 393 } else { |
| 390 assert(isUsedInTry(element)); | 394 assert(isUsedInTry(element)); |
| 391 HLocalValue local = getLocal(element); | 395 HLocalValue local = getLocal(element); |
| 392 HInstruction variable = new HLocalGet( | 396 HInstruction variable = new HLocalGet( |
| 393 element, local, builder.backend.dynamicType); | 397 element, local, builder.backend.dynamicType); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 void updateLocal(Element element, HInstruction value) { | 431 void updateLocal(Element element, HInstruction value) { |
| 428 assert(!isStoredInClosureField(element)); | 432 assert(!isStoredInClosureField(element)); |
| 429 if (isAccessedDirectly(element)) { | 433 if (isAccessedDirectly(element)) { |
| 430 directLocals[element] = value; | 434 directLocals[element] = value; |
| 431 } else if (isBoxed(element)) { | 435 } else if (isBoxed(element)) { |
| 432 Element redirect = redirectionMapping[element]; | 436 Element redirect = redirectionMapping[element]; |
| 433 // The box itself could be captured, or be local. A local variable that | 437 // The box itself could be captured, or be local. A local variable that |
| 434 // is captured will be boxed, but the box itself will be a local. | 438 // is captured will be boxed, but the box itself will be a local. |
| 435 // Inside the closure the box is stored in a closure-field and cannot | 439 // Inside the closure the box is stored in a closure-field and cannot |
| 436 // be accessed directly. | 440 // be accessed directly. |
| 437 assert(redirect.enclosingElement.isVariable()); | 441 assert(redirect.enclosingElement is BoxElement); |
| 438 HInstruction box = readLocal(redirect.enclosingElement); | 442 HInstruction box = readLocal(redirect.enclosingElement); |
| 439 builder.add(new HFieldSet(redirect, box, value)); | 443 builder.add(new HFieldSet(redirect, box, value)); |
| 440 } else { | 444 } else { |
| 441 assert(isUsedInTry(element)); | 445 assert(isUsedInTry(element)); |
| 442 HLocalValue local = getLocal(element); | 446 HLocalValue local = getLocal(element); |
| 443 builder.add(new HLocalSet(element, local, value)); | 447 builder.add(new HLocalSet(element, local, value)); |
| 444 } | 448 } |
| 445 } | 449 } |
| 446 | 450 |
| 447 /** | 451 /** |
| (...skipping 5274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5722 new HSubGraphBlockInformation(elseBranch.graph)); | 5726 new HSubGraphBlockInformation(elseBranch.graph)); |
| 5723 | 5727 |
| 5724 HBasicBlock conditionStartBlock = conditionBranch.block; | 5728 HBasicBlock conditionStartBlock = conditionBranch.block; |
| 5725 conditionStartBlock.setBlockFlow(info, joinBlock); | 5729 conditionStartBlock.setBlockFlow(info, joinBlock); |
| 5726 SubGraph conditionGraph = conditionBranch.graph; | 5730 SubGraph conditionGraph = conditionBranch.graph; |
| 5727 HIf branch = conditionGraph.end.last; | 5731 HIf branch = conditionGraph.end.last; |
| 5728 assert(branch is HIf); | 5732 assert(branch is HIf); |
| 5729 branch.blockInformation = conditionStartBlock.blockFlow; | 5733 branch.blockInformation = conditionStartBlock.blockFlow; |
| 5730 } | 5734 } |
| 5731 } | 5735 } |
| OLD | NEW |