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

Unified Diff: lib/compiler/implementation/ssa/variable_allocator.dart

Issue 10543027: Fixes for checked mode and change buildbot script to run dart2js tests in checked mode also. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/compiler/implementation/ssa/tracer.dart ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/variable_allocator.dart
===================================================================
--- lib/compiler/implementation/ssa/variable_allocator.dart (revision 8378)
+++ lib/compiler/implementation/ssa/variable_allocator.dart (working copy)
@@ -115,19 +115,19 @@
// Special case the HCheck instruction to have the same live
// interval as the instruction it is checking.
if (instruction is HCheck) {
- HInstruction input = instruction.checkedInput;
+ var input = instruction.checkedInput;
while (input is HCheck) input = input.checkedInput;
liveIntervals.putIfAbsent(input, () => new LiveInterval());
liveIntervals.putIfAbsent(instruction, () => liveIntervals[input]);
- return;
+ } else {
+ LiveInterval range = liveIntervals.putIfAbsent(
+ instruction, () => new LiveInterval());
+ int lastId = liveInstructions[instruction];
+ // If [lastId] is null, then this instruction is not being used.
+ range.add(new LiveRange(id, lastId == null ? id : lastId));
+ // The instruction is defined at [id].
+ range.start = id;
}
- LiveInterval range = liveIntervals.putIfAbsent(
- instruction, () => new LiveInterval());
- int lastId = liveInstructions[instruction];
- // If [lastId] is null, then this instruction is not being used.
- range.add(new LiveRange(id, lastId == null ? id : lastId));
- // The instruction is defined at [id].
- range.start = id;
liveInstructions.remove(instruction);
}
@@ -136,12 +136,17 @@
* already in the set, we save the id where it dies.
*/
void add(HInstruction instruction, int userId) {
- // Special case the HCheck instruction to use the actual checked
- // instruction.
- while (instruction is HCheck) instruction = instruction.checkedInput;
// Note that we are visiting the grap in post-dominator order, so
// the first time we see a variable is when it dies.
liveInstructions.putIfAbsent(instruction, () => userId);
+ if (instruction is HCheck) {
+ // Special case the HCheck instruction to mark the actual
+ // checked instruction live.
+ liveInstructions.putIfAbsent(instruction, () => userId);
+ var input = instruction.checkedInput;
+ while (input is HCheck) input = input.checkedInput;
+ liveInstructions.putIfAbsent(input, () => userId);
+ }
}
/**
@@ -434,31 +439,34 @@
String allocateName(HInstruction instruction) {
String name;
if (instruction is HCheck) {
- // Special case the check instruction to use the name of its
- // checked instruction.
- HCheck check = instruction;
- name = names.ownName[check.checkedInput];
- // If the name is null, then the checked input is being
- // generated at use site, and we don't need a name for the check
- // instruction.
- if (name == null) return null;
- } else if (instruction is HParameterValue) {
- HParameterValue parameter = instruction;
- name = parameterNames[parameter.sourceElement];
- if (name == null) {
- name = allocateWithHint(parameter.sourceElement.name.slowToString());
- }
- } else if (instruction.sourceElement !== null) {
- name = allocateWithHint(instruction.sourceElement.name.slowToString());
- } else {
- // We could not find an element for the instruction. If the
- // instruction is used by a phi, try to use the name of the phi.
- // Otherwise, just allocate a temporary name.
- HPhi phi = firstPhiUserWithElement(instruction);
- if (phi !== null) {
- name = allocateWithHint(phi.sourceElement.name.slowToString());
+ // Special case this instruction to use the name of its
+ // input if it has one.
+ var temp = instruction;
+ do {
+ temp = temp.checkedInput;
+ name = names.ownName[temp];
+ } while (name == null && temp is HCheck);
+ }
+
+ if (name == null) {
+ if (instruction is HParameterValue) {
kasperl 2012/06/07 08:29:14 There's something a bit fishy about the control fl
ngeoffray 2012/06/07 09:02:42 Done.
+ HParameterValue parameter = instruction;
+ name = parameterNames[parameter.sourceElement];
+ if (name == null) {
+ name = allocateWithHint(parameter.sourceElement.name.slowToString());
+ }
+ } else if (instruction.sourceElement !== null) {
+ name = allocateWithHint(instruction.sourceElement.name.slowToString());
} else {
- name = allocateTemporary();
+ // We could not find an element for the instruction. If the
+ // instruction is used by a phi, try to use the name of the phi.
+ // Otherwise, just allocate a temporary name.
+ HPhi phi = firstPhiUserWithElement(instruction);
+ if (phi !== null) {
+ name = allocateWithHint(phi.sourceElement.name.slowToString());
+ } else {
+ name = allocateTemporary();
+ }
}
}
usedNames.add(name);
kasperl 2012/06/07 08:29:14 You could also create a helper function for this l
ngeoffray 2012/06/07 09:02:42 Done.
@@ -534,6 +542,13 @@
// them generate at use site to make things simpler.
if (instruction is HParameterValue && instruction is !HThis) return true;
if (generateAtUseSite.contains(instruction)) return false;
+ // A [HCheckStatement] instruction needs a name only if its
+ // checked input needs a name (e.g. a check [HConstant] does not
+ // need a name).
+ if (instruction is HCheckStatement) {
+ HCheck check = instruction;
+ return needsName(instruction.checkedInput);
+ }
return true;
}
« no previous file with comments | « lib/compiler/implementation/ssa/tracer.dart ('k') | tests/language/language_dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698