summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-06-24 15:18:39 -0700
committerEric Anholt <eric@anholt.net>2010-06-24 15:18:39 -0700
commit6b01b50888d22ee330df44240591051cb55cf2a9 (patch)
tree51bdeade4b0f6e086a1cd43f692fb1d4ba7c3b6f
parente33c10328caec29616a5433b1d1df9088f3a84df (diff)
Move the talloc_parent lookup down in a few hot paths.
talloc_parent is still 80% of our runtime, but likely talloc_parent lookups will be reduced as we improve the handling of memory ownership.
-rw-r--r--ir_constant_expression.cpp4
-rw-r--r--ir_dead_code.cpp3
-rw-r--r--ir_vec_index_to_swizzle.cpp2
3 files changed, 5 insertions, 4 deletions
diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp
index 4010e46267..3408f5256a 100644
--- a/ir_constant_expression.cpp
+++ b/ir_constant_expression.cpp
@@ -127,7 +127,6 @@ ir_constant_visitor::visit(ir_function *ir)
void
ir_constant_visitor::visit(ir_expression *ir)
{
- void *ctx = talloc_parent(ir);
value = NULL;
ir_constant *op[2];
unsigned int operand, c;
@@ -498,6 +497,7 @@ ir_constant_visitor::visit(ir_expression *ir)
return;
}
+ void *ctx = talloc_parent(ir);
this->value = new(ctx) ir_constant(ir->type, &data);
}
@@ -514,7 +514,6 @@ ir_constant_visitor::visit(ir_texture *ir)
void
ir_constant_visitor::visit(ir_swizzle *ir)
{
- void *ctx = talloc_parent(ir);
ir_constant *v = ir->val->constant_expression_value();
this->value = NULL;
@@ -536,6 +535,7 @@ ir_constant_visitor::visit(ir_swizzle *ir)
}
}
+ void *ctx = talloc_parent(ir);
this->value = new(ctx) ir_constant(ir->type, &data);
}
}
diff --git a/ir_dead_code.cpp b/ir_dead_code.cpp
index 01b7d2d832..8821304682 100644
--- a/ir_dead_code.cpp
+++ b/ir_dead_code.cpp
@@ -77,7 +77,6 @@ public:
variable_entry *
ir_dead_code_visitor::get_variable_entry(ir_variable *var)
{
- void *ctx = talloc_parent(var);
assert(var);
foreach_iter(exec_list_iterator, iter, this->variable_list) {
variable_entry *entry = (variable_entry *)iter.get();
@@ -85,6 +84,8 @@ ir_dead_code_visitor::get_variable_entry(ir_variable *var)
return entry;
}
+ void *ctx = talloc_parent(var);
+
variable_entry *entry = new(ctx) variable_entry(var);
this->variable_list.push_tail(entry);
return entry;
diff --git a/ir_vec_index_to_swizzle.cpp b/ir_vec_index_to_swizzle.cpp
index bbd873791a..abeb43cd68 100644
--- a/ir_vec_index_to_swizzle.cpp
+++ b/ir_vec_index_to_swizzle.cpp
@@ -60,7 +60,6 @@ public:
ir_rvalue *
ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir)
{
- void *ctx = talloc_parent(ir);
ir_dereference_array *deref = ir->as_dereference_array();
ir_constant *ir_constant;
@@ -75,6 +74,7 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir)
if (!ir_constant)
return ir;
+ void *ctx = talloc_parent(ir);
this->progress = true;
return new(ctx) ir_swizzle(deref->array,
ir_constant->value.i[0], 0, 0, 0, 1);