| 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 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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 element: element); | 387 element: element); |
| 388 } | 388 } |
| 389 return directLocals[element]; | 389 return directLocals[element]; |
| 390 } else if (isStoredInClosureField(element)) { | 390 } else if (isStoredInClosureField(element)) { |
| 391 Element redirect = redirectionMapping[element]; | 391 Element redirect = redirectionMapping[element]; |
| 392 // We must not use the [LocalsHandler.readThis()] since that could | 392 // We must not use the [LocalsHandler.readThis()] since that could |
| 393 // point to a captured this which would be stored in a closure-field | 393 // point to a captured this which would be stored in a closure-field |
| 394 // itself. | 394 // itself. |
| 395 HInstruction receiver = new HThis(); | 395 HInstruction receiver = new HThis(); |
| 396 builder.add(receiver); | 396 builder.add(receiver); |
| 397 HInstruction fieldGet = new HFieldGet(redirect, receiver); | 397 HInstruction fieldGet = new HFieldGet(redirect.name, receiver); |
| 398 builder.add(fieldGet); | 398 builder.add(fieldGet); |
| 399 return fieldGet; | 399 return fieldGet; |
| 400 } else if (isBoxed(element)) { | 400 } else if (isBoxed(element)) { |
| 401 Element redirect = redirectionMapping[element]; | 401 Element redirect = redirectionMapping[element]; |
| 402 // In the function that declares the captured variable the box is | 402 // In the function that declares the captured variable the box is |
| 403 // accessed as direct local. Inside the nested closure the box is | 403 // accessed as direct local. Inside the nested closure the box is |
| 404 // accessed through a closure-field. | 404 // accessed through a closure-field. |
| 405 // Calling [readLocal] makes sure we generate the correct code to get | 405 // Calling [readLocal] makes sure we generate the correct code to get |
| 406 // the box. | 406 // the box. |
| 407 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); | 407 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); |
| 408 HInstruction box = readLocal(redirect.enclosingElement); | 408 HInstruction box = readLocal(redirect.enclosingElement); |
| 409 HInstruction lookup = new HFieldGet(redirect, box); | 409 HInstruction lookup = new HFieldGet(redirect.name, box); |
| 410 builder.add(lookup); | 410 builder.add(lookup); |
| 411 return lookup; | 411 return lookup; |
| 412 } else { | 412 } else { |
| 413 assert(isUsedInTry(element)); | 413 assert(isUsedInTry(element)); |
| 414 HInstruction variable = new HFieldGet.fromActivation(element); | 414 HInstruction variable = new HFieldGet.fromActivation(element.name); |
| 415 builder.add(variable); | 415 builder.add(variable); |
| 416 return variable; | 416 return variable; |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 | 419 |
| 420 HType cachedTypeOfThis; | 420 HType cachedTypeOfThis; |
| 421 | 421 |
| 422 HInstruction readThis() { | 422 HInstruction readThis() { |
| 423 HInstruction res = readLocal(closureData.thisElement); | 423 HInstruction res = readLocal(closureData.thisElement); |
| 424 if (res.guaranteedType === null) { | 424 if (res.guaranteedType === null) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 441 void updateLocal(Element element, HInstruction value) { | 441 void updateLocal(Element element, HInstruction value) { |
| 442 if (isAccessedDirectly(element)) { | 442 if (isAccessedDirectly(element)) { |
| 443 directLocals[element] = value; | 443 directLocals[element] = value; |
| 444 } else if (isStoredInClosureField(element)) { | 444 } else if (isStoredInClosureField(element)) { |
| 445 Element redirect = redirectionMapping[element]; | 445 Element redirect = redirectionMapping[element]; |
| 446 // We must not use the [LocalsHandler.readThis()] since that could | 446 // We must not use the [LocalsHandler.readThis()] since that could |
| 447 // point to a captured this which would be stored in a closure-field | 447 // point to a captured this which would be stored in a closure-field |
| 448 // itself. | 448 // itself. |
| 449 HInstruction receiver = new HThis(); | 449 HInstruction receiver = new HThis(); |
| 450 builder.add(receiver); | 450 builder.add(receiver); |
| 451 builder.add(new HFieldSet(redirect, receiver, value)); | 451 builder.add(new HFieldSet(redirect.name, receiver, value)); |
| 452 } else if (isBoxed(element)) { | 452 } else if (isBoxed(element)) { |
| 453 Element redirect = redirectionMapping[element]; | 453 Element redirect = redirectionMapping[element]; |
| 454 // The box itself could be captured, or be local. A local variable that | 454 // The box itself could be captured, or be local. A local variable that |
| 455 // is captured will be boxed, but the box itself will be a local. | 455 // is captured will be boxed, but the box itself will be a local. |
| 456 // Inside the closure the box is stored in a closure-field and cannot | 456 // Inside the closure the box is stored in a closure-field and cannot |
| 457 // be accessed directly. | 457 // be accessed directly. |
| 458 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); | 458 assert(redirect.enclosingElement.kind == ElementKind.VARIABLE); |
| 459 HInstruction box = readLocal(redirect.enclosingElement); | 459 HInstruction box = readLocal(redirect.enclosingElement); |
| 460 builder.add(new HFieldSet(redirect, box, value)); | 460 builder.add(new HFieldSet(redirect.name, box, value)); |
| 461 } else { | 461 } else { |
| 462 assert(isUsedInTry(element)); | 462 assert(isUsedInTry(element)); |
| 463 builder.add(new HFieldSet.fromActivation(element,value)); | 463 builder.add(new HFieldSet.fromActivation(element.name, value)); |
| 464 } | 464 } |
| 465 } | 465 } |
| 466 | 466 |
| 467 /** | 467 /** |
| 468 * This function must be called before visiting any children of the loop. In | 468 * This function must be called before visiting any children of the loop. In |
| 469 * particular it needs to be called before executing the initializers. | 469 * particular it needs to be called before executing the initializers. |
| 470 * | 470 * |
| 471 * The [LocalsHandler] will make the boxes and updates at the right moment. | 471 * The [LocalsHandler] will make the boxes and updates at the right moment. |
| 472 * The builder just needs to call [enterLoopBody] and [enterLoopUpdates] (for | 472 * The builder just needs to call [enterLoopBody] and [enterLoopUpdates] (for |
| 473 * [For] loops) at the correct places. For phi-handling [beginLoopHeader] and | 473 * [For] loops) at the correct places. For phi-handling [beginLoopHeader] and |
| (...skipping 2837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3311 <HInstruction>[target, input], | 3311 <HInstruction>[target, input], |
| 3312 HType.STRING)); | 3312 HType.STRING)); |
| 3313 return builder.pop(); | 3313 return builder.pop(); |
| 3314 } | 3314 } |
| 3315 | 3315 |
| 3316 HInstruction result() { | 3316 HInstruction result() { |
| 3317 flushLiterals(); | 3317 flushLiterals(); |
| 3318 return prefix; | 3318 return prefix; |
| 3319 } | 3319 } |
| 3320 } | 3320 } |
| OLD | NEW |