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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ssa/variable_allocator.dart

Issue 11358217: Add a getter interceptor to the new interceptor scheme. Also cleanup the "this" that turns into a r… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month 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
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 part of ssa; 5 part of ssa;
6 6
7 /** 7 /**
8 * The [LiveRange] class covers a range where an instruction is live. 8 * The [LiveRange] class covers a range where an instruction is live.
9 */ 9 */
10 class LiveRange { 10 class LiveRange {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // Special case this instruction to use the name of its 509 // Special case this instruction to use the name of its
510 // input if it has one. 510 // input if it has one.
511 var temp = instruction; 511 var temp = instruction;
512 do { 512 do {
513 temp = temp.checkedInput; 513 temp = temp.checkedInput;
514 name = names.ownName[temp]; 514 name = names.ownName[temp];
515 } while (name == null && temp is HCheck); 515 } while (name == null && temp is HCheck);
516 if (name != null) return addAllocatedName(instruction, name); 516 if (name != null) return addAllocatedName(instruction, name);
517 } 517 }
518 518
519 if (instruction is HThis) { 519 if (instruction is HParameterValue
520 name = "this";
521 if (instruction.sourceElement != null) {
522 Element cls = instruction.sourceElement.getEnclosingClass();
523 // Change the name of [:this:] in a method of a foreign class
524 // to use the first parameter of the method, which is the
525 // actual receiver.
526 JavaScriptBackend backend = compiler.backend;
527 if (backend.isInterceptorClass(cls)) {
528 name = "primitive";
529 }
530 }
531 } else if (instruction is HParameterValue
532 && instruction.sourceElement.enclosingElement.isNative()) { 520 && instruction.sourceElement.enclosingElement.isNative()) {
533 // The dom/html libraries have inline JS code that reference 521 // The dom/html libraries have inline JS code that reference
534 // parameter names directly. Long-term such code will be rejected. 522 // parameter names directly. Long-term such code will be rejected.
535 // Now, just don't mangle the parameter name. 523 // Now, just don't mangle the parameter name.
536 name = instruction.sourceElement.name.slowToString(); 524 name = instruction.sourceElement.name.slowToString();
537 } else if (instruction.sourceElement != null) { 525 } else if (instruction.sourceElement != null) {
538 name = allocateWithHint(instruction.sourceElement.name.slowToString()); 526 name = allocateWithHint(instruction.sourceElement.name.slowToString());
539 } else { 527 } else {
540 // We could not find an element for the instruction. If the 528 // We could not find an element for the instruction. If the
541 // instruction is used by a phi, try to use the name of the phi. 529 // instruction is used by a phi, try to use the name of the phi.
542 // Otherwise, just allocate a temporary name. 530 // Otherwise, just allocate a temporary name.
543 HPhi phi = firstPhiUserWithElement(instruction); 531 HPhi phi = firstPhiUserWithElement(instruction);
544 if (phi != null) { 532 if (phi != null) {
545 name = allocateWithHint(phi.sourceElement.name.slowToString()); 533 name = allocateWithHint(phi.sourceElement.name.slowToString());
546 } else { 534 } else {
547 name = allocateTemporary(); 535 name = allocateTemporary();
548 } 536 }
549 } 537 }
550 return addAllocatedName(instruction, name); 538 return addAllocatedName(instruction, name);
551 } 539 }
552 540
553 String addAllocatedName(HInstruction instruction, String name) { 541 String addAllocatedName(HInstruction instruction, String name) {
554 if (instruction is HParameterValue && name != 'this') { 542 if (instruction is HParameterValue) {
555 parameterNames[instruction.sourceElement] = name; 543 parameterNames[instruction.sourceElement] = name;
556 } 544 }
557 usedNames.add(name); 545 usedNames.add(name);
558 names.addNameUsed(name); 546 names.addNameUsed(name);
559 names.ownName[instruction] = name; 547 names.ownName[instruction] = name;
560 return name; 548 return name;
561 } 549 }
562 550
563 /** 551 /**
564 * Frees [instruction]'s name so it can be used for other instructions. 552 * Frees [instruction]'s name so it can be used for other instructions.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 614 }
627 615
628 /** 616 /**
629 * Returns whether [instruction] needs a name. Instructions that 617 * Returns whether [instruction] needs a name. Instructions that
630 * have no users or that are generated at use site does not need a name. 618 * have no users or that are generated at use site does not need a name.
631 */ 619 */
632 bool needsName(HInstruction instruction) { 620 bool needsName(HInstruction instruction) {
633 // TODO(ngeoffray): locals/parameters are being generated at use site, 621 // TODO(ngeoffray): locals/parameters are being generated at use site,
634 // but we need a name for them. We should probably not make 622 // but we need a name for them. We should probably not make
635 // them generate at use site to make things simpler. 623 // them generate at use site to make things simpler.
624 if (instruction is HThis) return false;
636 if (instruction is HLocalValue) return true; 625 if (instruction is HLocalValue) return true;
637 if (instruction.usedBy.isEmpty) return false; 626 if (instruction.usedBy.isEmpty) return false;
638 if (generateAtUseSite.contains(instruction)) return false; 627 if (generateAtUseSite.contains(instruction)) return false;
639 // A [HCheck] instruction that has control flow needs a name only if its 628 // A [HCheck] instruction that has control flow needs a name only if its
640 // checked input needs a name (e.g. a check [HConstant] does not 629 // checked input needs a name (e.g. a check [HConstant] does not
641 // need a name). 630 // need a name).
642 if (instruction is HCheck && instruction.isControlFlow()) { 631 if (instruction is HCheck && instruction.isControlFlow()) {
643 HCheck check = instruction; 632 HCheck check = instruction;
644 return needsName(instruction.checkedInput); 633 return needsName(instruction.checkedInput);
645 } 634 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 if (!needsName(input)) { 679 if (!needsName(input)) {
691 names.addAssignment(predecessor, input, phi); 680 names.addAssignment(predecessor, input, phi);
692 } else { 681 } else {
693 names.addCopy(predecessor, input, phi); 682 names.addCopy(predecessor, input, phi);
694 } 683 }
695 } 684 }
696 685
697 namer.allocateName(phi); 686 namer.allocateName(phi);
698 } 687 }
699 } 688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698