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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 builder.compiler.internalError( | 369 builder.compiler.internalError( |
370 "Cannot find value $element", | 370 "Cannot find value $element", |
371 element: element); | 371 element: element); |
372 } | 372 } |
373 } | 373 } |
374 return directLocals[element]; | 374 return directLocals[element]; |
375 } else if (isStoredInClosureField(element)) { | 375 } else if (isStoredInClosureField(element)) { |
376 Element redirect = redirectionMapping[element]; | 376 Element redirect = redirectionMapping[element]; |
377 HInstruction receiver = readLocal(closureData.closureElement); | 377 HInstruction receiver = readLocal(closureData.closureElement); |
378 HInstruction fieldGet = new HFieldGet(redirect, receiver); | 378 HInstruction fieldGet = new HFieldGet(redirect, receiver); |
379 fieldGet.instructionType = builder.getTypeOfCapturedVariable(element); | 379 fieldGet.instructionType = builder.getTypeOfCapturedVariable(redirect); |
380 builder.add(fieldGet); | 380 builder.add(fieldGet); |
381 return fieldGet; | 381 return fieldGet; |
382 } else if (isBoxed(element)) { | 382 } else if (isBoxed(element)) { |
383 Element redirect = redirectionMapping[element]; | 383 Element redirect = redirectionMapping[element]; |
384 // In the function that declares the captured variable the box is | 384 // In the function that declares the captured variable the box is |
385 // accessed as direct local. Inside the nested closure the box is | 385 // accessed as direct local. Inside the nested closure the box is |
386 // accessed through a closure-field. | 386 // accessed through a closure-field. |
387 // Calling [readLocal] makes sure we generate the correct code to get | 387 // Calling [readLocal] makes sure we generate the correct code to get |
388 // the box. | 388 // the box. |
389 assert(redirect.enclosingElement.isVariable()); | 389 assert(redirect.enclosingElement.isVariable()); |
390 HInstruction box = readLocal(redirect.enclosingElement); | 390 HInstruction box = readLocal(redirect.enclosingElement); |
391 HInstruction lookup = new HFieldGet(redirect, box); | 391 HInstruction lookup = new HFieldGet(redirect, box); |
392 lookup.instructionType = builder.getTypeOfCapturedVariable(element); | 392 lookup.instructionType = builder.getTypeOfCapturedVariable(redirect); |
393 builder.add(lookup); | 393 builder.add(lookup); |
394 return lookup; | 394 return lookup; |
395 } else { | 395 } else { |
396 assert(isUsedInTry(element)); | 396 assert(isUsedInTry(element)); |
397 HLocalValue local = getLocal(element); | 397 HLocalValue local = getLocal(element); |
398 HInstruction variable = new HLocalGet(element, local); | 398 HInstruction variable = new HLocalGet(element, local); |
399 builder.add(variable); | 399 builder.add(variable); |
400 return variable; | 400 return variable; |
401 } | 401 } |
402 } | 402 } |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 } | 1007 } |
1008 cachedTypeOfThis = result; | 1008 cachedTypeOfThis = result; |
1009 } | 1009 } |
1010 return result; | 1010 return result; |
1011 } | 1011 } |
1012 | 1012 |
1013 Map<Element, HType> cachedTypesOfCapturedVariables = | 1013 Map<Element, HType> cachedTypesOfCapturedVariables = |
1014 new Map<Element, HType>(); | 1014 new Map<Element, HType>(); |
1015 | 1015 |
1016 HType getTypeOfCapturedVariable(Element element) { | 1016 HType getTypeOfCapturedVariable(Element element) { |
| 1017 assert(element.isField()); |
1017 return cachedTypesOfCapturedVariables.putIfAbsent(element, () { | 1018 return cachedTypesOfCapturedVariables.putIfAbsent(element, () { |
1018 return new HType.inferredTypeForElement(element, compiler); | 1019 return new HType.inferredTypeForElement(element, compiler); |
1019 }); | 1020 }); |
1020 } | 1021 } |
1021 | 1022 |
1022 /** | 1023 /** |
1023 * Documentation wanted -- johnniwinther | 1024 * Documentation wanted -- johnniwinther |
1024 * | 1025 * |
1025 * Invariant: [functionElement] must be an implementation element. | 1026 * Invariant: [functionElement] must be an implementation element. |
1026 */ | 1027 */ |
(...skipping 4379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5406 new HSubGraphBlockInformation(elseBranch.graph)); | 5407 new HSubGraphBlockInformation(elseBranch.graph)); |
5407 | 5408 |
5408 HBasicBlock conditionStartBlock = conditionBranch.block; | 5409 HBasicBlock conditionStartBlock = conditionBranch.block; |
5409 conditionStartBlock.setBlockFlow(info, joinBlock); | 5410 conditionStartBlock.setBlockFlow(info, joinBlock); |
5410 SubGraph conditionGraph = conditionBranch.graph; | 5411 SubGraph conditionGraph = conditionBranch.graph; |
5411 HIf branch = conditionGraph.end.last; | 5412 HIf branch = conditionGraph.end.last; |
5412 assert(branch is HIf); | 5413 assert(branch is HIf); |
5413 branch.blockInformation = conditionStartBlock.blockFlow; | 5414 branch.blockInformation = conditionStartBlock.blockFlow; |
5414 } | 5415 } |
5415 } | 5416 } |
OLD | NEW |