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

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

Issue 10541170: Declare parameters of the bailout version in beginGraph, instead of setting them up in endGraph. (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/bailout.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/compiler/implementation/ssa/codegen.dart
===================================================================
--- lib/compiler/implementation/ssa/codegen.dart (revision 8654)
+++ lib/compiler/implementation/ssa/codegen.dart (working copy)
@@ -2639,7 +2639,6 @@
final StringBuffer newParameters;
final List<String> labels;
int labelId = 0;
- int maxBailoutParameters = 0;
SsaBailoutPropagator propagator;
HInstruction savedFirstInstruction;
@@ -2667,9 +2666,20 @@
HBasicBlock beginGraph(HGraph graph) {
propagator = new SsaBailoutPropagator(compiler, generateAtUseSite);
propagator.visitGraph(graph);
+ // TODO(ngeoffray): We could avoid generating the state at the
+ // call site for non-complex bailout methods.
+ newParameters.add('state');
if (propagator.hasComplexTypeGuards) {
startBailoutSwitch();
+
+ // Use generic parameters that will be assign to
floitsch 2012/06/14 15:29:39 assigned
ngeoffray 2012/06/14 15:31:47 Done.
+ // the right variables in the setup phase.
+ for (int i = 0; i < propagator.maxBailoutParameters; i++) {
+ String name = 'env$i';
+ declaredVariables.add(name);
+ newParameters.add(', $name');
+ }
// The setup phase of a bailout function sets up the environment for
// each bailout target. Each bailout target will populate this
@@ -2677,6 +2687,15 @@
setup.add(' switch (state) {\n');
return graph.entry;
} else {
+ // We have a simple type guard, so we can reuse the names that
+ // the type guard expects.
+ for (HInstruction input in propagator.firstTypeGuard.inputs) {
+ input = unwrap(input);
+ String name = variableNames.getName(input);
+ declaredVariables.add(name);
+ newParameters.add(', $name');
+ }
+
// We change the first instruction of the first guard to be the
// guard. We will change it back in the call to [endGraph].
HBasicBlock block = propagator.firstTypeGuard.block;
@@ -2699,27 +2718,14 @@
}
void endGraph(HGraph graph) {
- // TODO(ngeoffray): We could avoid generating the state at the
- // call site for non-complex bailout methods.
- newParameters.add('state');
-
- // TODO(ngeoffray): We should declare the parameters in
- // beginGraph, to avoid potentially redeclaring them with 'var'
- // in the method body.
- if (!propagator.hasComplexTypeGuards) {
- propagator.firstTypeGuard.block.first = savedFirstInstruction;
- for (HInstruction input in propagator.firstTypeGuard.inputs) {
- input = unwrap(input);
- newParameters.add(', ${variableNames.getName(input)}');
- }
- } else {
- for (int i = 0; i < maxBailoutParameters; i++) {
- newParameters.add(', env$i');
- }
+ if (propagator.hasComplexTypeGuards) {
indent--; // Close original case.
indent--;
addIndented('}\n'); // Close 'switch'.
setup.add(' }\n');
+ } else {
+ // Put back the original first instruction of the block.
+ propagator.firstTypeGuard.block.first = savedFirstInstruction;
}
}
@@ -2761,7 +2767,6 @@
setup.add('$name = env$i;\n');
i++;
}
- if (i > maxBailoutParameters) maxBailoutParameters = i;
setup.add(' break;\n');
}
« no previous file with comments | « lib/compiler/implementation/ssa/bailout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698