[vala] Only generate depth-first list once per method in flow analyzer
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Only generate depth-first list once per method in flow analyzer
- Date: Wed, 23 Dec 2009 21:33:28 +0000 (UTC)
commit 3a0e6b265506c0af35d9fc4d05560eb6cd505085
Author: Jürg Billeter <j bitron ch>
Date: Wed Dec 23 20:36:55 2009 +0100
Only generate depth-first list once per method in flow analyzer
Improves performance.
vala/valaflowanalyzer.vala | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/vala/valaflowanalyzer.vala b/vala/valaflowanalyzer.vala
index 6e1d3b7..870a9e1 100644
--- a/vala/valaflowanalyzer.vala
+++ b/vala/valaflowanalyzer.vala
@@ -173,9 +173,11 @@ public class Vala.FlowAnalyzer : CodeVisitor {
}
void analyze_body (BasicBlock entry_block) {
- build_dominator_tree (entry_block);
- build_dominator_frontier (entry_block);
- insert_phi_functions (entry_block);
+ var block_list = get_depth_first_list (entry_block);
+
+ build_dominator_tree (block_list, entry_block);
+ build_dominator_frontier (block_list, entry_block);
+ insert_phi_functions (block_list, entry_block);
check_variables (entry_block);
}
@@ -195,10 +197,9 @@ public class Vala.FlowAnalyzer : CodeVisitor {
}
}
- void build_dominator_tree (BasicBlock entry_block) {
+ void build_dominator_tree (List<BasicBlock> block_list, BasicBlock entry_block) {
// set dom(n) = {E,1,2...,N,X} forall n
var dom = new HashMap<BasicBlock, Set<BasicBlock>> ();
- var block_list = get_depth_first_list (entry_block);
foreach (BasicBlock block in block_list) {
var block_set = new HashSet<BasicBlock> ();
foreach (BasicBlock b in block_list) {
@@ -283,8 +284,7 @@ public class Vala.FlowAnalyzer : CodeVisitor {
}
}
- void build_dominator_frontier (BasicBlock entry_block) {
- var block_list = get_depth_first_list (entry_block);
+ void build_dominator_frontier (List<BasicBlock> block_list, BasicBlock entry_block) {
for (int i = block_list.size - 1; i >= 0; i--) {
var block = block_list[i];
@@ -306,9 +306,9 @@ public class Vala.FlowAnalyzer : CodeVisitor {
}
}
- Map<LocalVariable, Set<BasicBlock>> get_assignment_map (BasicBlock entry_block) {
+ Map<LocalVariable, Set<BasicBlock>> get_assignment_map (List<BasicBlock> block_list, BasicBlock entry_block) {
var map = new HashMap<LocalVariable, Set<BasicBlock>> ();
- foreach (BasicBlock block in get_depth_first_list (entry_block)) {
+ foreach (BasicBlock block in block_list) {
var defined_variables = new ArrayList<LocalVariable> ();
foreach (CodeNode node in block.get_nodes ()) {
node.get_defined_variables (defined_variables);
@@ -326,15 +326,15 @@ public class Vala.FlowAnalyzer : CodeVisitor {
return map;
}
- void insert_phi_functions (BasicBlock entry_block) {
- var assign = get_assignment_map (entry_block);
+ void insert_phi_functions (List<BasicBlock> block_list, BasicBlock entry_block) {
+ var assign = get_assignment_map (block_list, entry_block);
int counter = 0;
var work_list = new ArrayList<BasicBlock> ();
var added = new HashMap<BasicBlock, int> ();
var phi = new HashMap<BasicBlock, int> ();
- foreach (BasicBlock block in get_depth_first_list (entry_block)) {
+ foreach (BasicBlock block in block_list) {
added.set (block, 0);
phi.set (block, 0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]