summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian <brian@yutani.localnet.net>2007-04-21 12:29:46 -0600
committerBrian <brian@yutani.localnet.net>2007-04-21 12:30:58 -0600
commite261d66d81d47c4a2380ffcb7b39164b8e191168 (patch)
tree311b36ca6bd99a64ebdc88fb444cd19714988e56 /src/mesa/shader
parentcd3e39340f057712fcf02a35dff85645e475053a (diff)
Remove all the USE_MEMPOOL debug code.
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c47
-rw-r--r--src/mesa/shader/slang/slang_compile.c113
-rw-r--r--src/mesa/shader/slang/slang_compile_function.c28
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.c42
-rw-r--r--src/mesa/shader/slang/slang_compile_struct.c33
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.c47
-rw-r--r--src/mesa/shader/slang/slang_emit.c8
-rw-r--r--src/mesa/shader/slang/slang_ir.c15
-rw-r--r--src/mesa/shader/slang/slang_label.c41
-rw-r--r--src/mesa/shader/slang/slang_mem.h2
-rw-r--r--src/mesa/shader/slang/slang_storage.c38
-rw-r--r--src/mesa/shader/slang/slang_typeinfo.c31
-rw-r--r--src/mesa/shader/slang/slang_utility.c19
-rw-r--r--src/mesa/shader/slang/slang_utility.h12
-rw-r--r--src/mesa/shader/slang/slang_vartable.c36
15 files changed, 78 insertions, 434 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 71ef132e38..ba97d6257b 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -460,11 +460,7 @@ static slang_ir_node *
new_node3(slang_ir_opcode op,
slang_ir_node *c0, slang_ir_node *c1, slang_ir_node *c2)
{
-#if USE_MEMPOOL
slang_ir_node *n = (slang_ir_node *) _slang_alloc(sizeof(slang_ir_node));
-#else
- slang_ir_node *n = (slang_ir_node *) calloc(1, sizeof(slang_ir_node));
-#endif
if (n) {
n->Opcode = op;
n->Children[0] = c0;
@@ -927,21 +923,12 @@ slang_inline_function_call(slang_assemble_ctx * A, slang_function *fun,
assert(fun->param_count == totalArgs);
/* allocate temporary arrays */
-#if USE_MEMPOOL
paramMode = (ParamMode *)
_slang_alloc(totalArgs * sizeof(ParamMode));
substOld = (slang_variable **)
_slang_alloc(totalArgs * sizeof(slang_variable *));
substNew = (slang_operation **)
_slang_alloc(totalArgs * sizeof(slang_operation *));
-#else
- paramMode = (ParamMode *)
- _mesa_calloc(totalArgs * sizeof(ParamMode));
- substOld = (slang_variable **)
- _mesa_calloc(totalArgs * sizeof(slang_variable *));
- substNew = (slang_operation **)
- _mesa_calloc(totalArgs * sizeof(slang_operation *));
-#endif
#if 0
printf("Inline call to %s (total vars=%d nparams=%d)\n",
@@ -1142,11 +1129,9 @@ slang_inline_function_call(slang_assemble_ctx * A, slang_function *fun,
}
}
-#if !USE_MEMPOOL
- _mesa_free(paramMode);
- _mesa_free(substOld);
- _mesa_free(substNew);
-#endif
+ _slang_free(paramMode);
+ _slang_free(substOld);
+ _slang_free(substNew);
#if 0
printf("Done Inline call to %s (total vars=%d nparams=%d)\n",
@@ -1204,9 +1189,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
/* Replace the function call with the inlined block */
slang_operation_destruct(oper);
*oper = *inlined;
-#if !USE_MEMPOOL
- _mesa_free(inlined);
-#endif
+ _slang_free(inlined);
#if 0
assert(inlined->locals);
@@ -1336,9 +1319,7 @@ _slang_gen_asm(slang_assemble_ctx *A, slang_operation *oper,
n->Store = n0->Store;
n->Writemask = writemask;
-#if !USE_MEMPOOL
- free(n0);
-#endif
+ _slang_free(n0);
}
return n;
@@ -1779,11 +1760,9 @@ _slang_gen_temporary(GLint size)
if (n) {
n->Store = store;
}
-#if !USE_MEMPOOL
else {
- free(store);
+ _slang_free(store);
}
-#endif
}
return n;
}
@@ -1892,13 +1871,6 @@ _slang_gen_logical_and(slang_assemble_ctx *A, slang_operation *oper)
select->children[2].literal_size = 1;
n = _slang_gen_select(A, select);
-
-#if !USE_MEMPOOL
- /* xxx wrong */
- free(select->children);
- free(select);
-#endif
-
return n;
}
@@ -1925,13 +1897,6 @@ _slang_gen_logical_or(slang_assemble_ctx *A, slang_operation *oper)
slang_operation_copy(&select->children[2], &oper->children[1]);
n = _slang_gen_select(A, select);
-
-#if !USE_MEMPOOL
- /* xxx wrong */
- free(select->children);
- free(select);
-#endif
-
return n;
}
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index d1c82a092d..f23a29633b 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -194,13 +194,9 @@ parse_float(slang_parse_ctx * C, float *number)
parse_identifier_str(C, &fractional);
parse_identifier_str(C, &exponent);
-#if USE_MEMPOOL
- whole = (char *) (_slang_alloc((_mesa_strlen(integral) +
-#else
- whole = (char *) (slang_alloc_malloc((_mesa_strlen(integral) +
-#endif
- _mesa_strlen(fractional) +
- _mesa_strlen(exponent) + 3) * sizeof(char)));
+ whole = (char *) _slang_alloc((_mesa_strlen(integral) +
+ _mesa_strlen(fractional) +
+ _mesa_strlen(exponent) + 3) * sizeof(char));
if (whole == NULL) {
slang_info_log_memory(C->L);
return 0;
@@ -214,11 +210,8 @@ parse_float(slang_parse_ctx * C, float *number)
*number = (float) (_mesa_strtod(whole, (char **) NULL));
-#if USE_MEMPOOL
_slang_free(whole);
-#else
- slang_alloc_free(whole);
-#endif
+
return 1;
}
@@ -297,11 +290,7 @@ convert_to_array(slang_parse_ctx * C, slang_variable * var,
* parse the expression */
var->type.specifier.type = SLANG_SPEC_ARRAY;
var->type.specifier._array = (slang_type_specifier *)
-#if USE_MEMPOOL
_slang_alloc(sizeof(slang_type_specifier));
-#else
- slang_alloc_malloc(sizeof(slang_type_specifier));
-#endif
if (var->type.specifier._array == NULL) {
slang_info_log_memory(C->L);
return GL_FALSE;
@@ -384,21 +373,13 @@ parse_struct(slang_parse_ctx * C, slang_output_ctx * O, slang_struct ** st)
}
/* set-up a new struct */
-#if USE_MEMPOOL
*st = (slang_struct *) _slang_alloc(sizeof(slang_struct));
-#else
- *st = (slang_struct *) slang_alloc_malloc(sizeof(slang_struct));
-#endif
if (*st == NULL) {
slang_info_log_memory(C->L);
return 0;
}
if (!slang_struct_construct(*st)) {
-#if USE_MEMPOOL
_slang_free(*st);
-#else
- slang_alloc_free(*st);
-#endif
*st = NULL;
slang_info_log_memory(C->L);
return 0;
@@ -424,15 +405,11 @@ parse_struct(slang_parse_ctx * C, slang_output_ctx * O, slang_struct ** st)
slang_struct *s;
O->structs->structs =
-#if USE_MEMPOOL
(slang_struct *) _slang_realloc(O->structs->structs,
-#else
- (slang_struct *) slang_alloc_realloc(O->structs->structs,
-#endif
- O->structs->num_structs *
- sizeof(slang_struct),
- (O->structs->num_structs +
- 1) * sizeof(slang_struct));
+ O->structs->num_structs
+ * sizeof(slang_struct),
+ (O->structs->num_structs + 1)
+ * sizeof(slang_struct));
if (O->structs->structs == NULL) {
slang_info_log_memory(C->L);
return 0;
@@ -641,22 +618,13 @@ parse_type_specifier(slang_parse_ctx * C, slang_output_ctx * O,
return 0;
}
- spec->_struct =
-#if USE_MEMPOOL
- (slang_struct *) _slang_alloc(sizeof(slang_struct));
-#else
- (slang_struct *) slang_alloc_malloc(sizeof(slang_struct));
-#endif
+ spec->_struct = (slang_struct *) _slang_alloc(sizeof(slang_struct));
if (spec->_struct == NULL) {
slang_info_log_memory(C->L);
return 0;
}
if (!slang_struct_construct(spec->_struct)) {
-#if USE_MEMPOOL
_slang_free(spec->_struct);
-#else
- slang_alloc_free(spec->_struct);
-#endif
spec->_struct = NULL;
return 0;
}
@@ -938,13 +906,9 @@ handle_nary_expression(slang_parse_ctx * C, slang_operation * op,
*total_ops -= n;
*ops = (slang_operation *)
-#if USE_MEMPOOL
_slang_realloc(*ops,
-#else
- slang_alloc_realloc(*ops,
-#endif
- (*total_ops + n) * sizeof(slang_operation),
- *total_ops * sizeof(slang_operation));
+ (*total_ops + n) * sizeof(slang_operation),
+ *total_ops * sizeof(slang_operation));
if (*ops == NULL) {
slang_info_log_memory(C->L);
return 0;
@@ -975,13 +939,9 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
/* allocate default operation, becomes a no-op if not used */
ops = (slang_operation *)
-#if USE_MEMPOOL
_slang_realloc(ops,
-#else
- slang_alloc_realloc(ops,
-#endif
- num_ops * sizeof(slang_operation),
- (num_ops + 1) * sizeof(slang_operation));
+ num_ops * sizeof(slang_operation),
+ (num_ops + 1) * sizeof(slang_operation));
if (ops == NULL) {
slang_info_log_memory(C->L);
return 0;
@@ -1223,11 +1183,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O,
slang_operation_destruct(oper);
*oper = *ops; /* struct copy */
-#if USE_MEMPOOL
_slang_free(ops);
-#else
- slang_alloc_free(ops);
-#endif
return 1;
}
@@ -1491,22 +1447,13 @@ parse_function_definition(slang_parse_ctx * C, slang_output_ctx * O,
return 0;
/* create function's body operation */
- func->body =
-#if USE_MEMPOOL
- (slang_operation *) _slang_alloc(sizeof(slang_operation));
-#else
- (slang_operation *) slang_alloc_malloc(sizeof(slang_operation));
-#endif
+ func->body = (slang_operation *) _slang_alloc(sizeof(slang_operation));
if (func->body == NULL) {
slang_info_log_memory(C->L);
return 0;
}
if (!slang_operation_construct(func->body)) {
-#if USE_MEMPOOL
_slang_free(func->body);
-#else
- slang_alloc_free(func->body);
-#endif
func->body = NULL;
slang_info_log_memory(C->L);
return 0;
@@ -1538,11 +1485,7 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var)
/* put the variable into operation's scope */
op_id.locals->variables =
-#if USE_MEMPOOL
(slang_variable **) _slang_alloc(sizeof(slang_variable *));
-#else
- (slang_variable **) slang_alloc_malloc(sizeof(slang_variable *));
-#endif
if (op_id.locals->variables == NULL) {
slang_operation_destruct(&op_id);
return GL_FALSE;
@@ -1558,11 +1501,7 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var)
}
op_assign.type = SLANG_OPER_ASSIGN;
op_assign.children =
-#if USE_MEMPOOL
(slang_operation *) _slang_alloc(2 * sizeof(slang_operation));
-#else
- (slang_operation *) slang_alloc_malloc(2 * sizeof(slang_operation));
-#endif
if (op_assign.children == NULL) {
slang_operation_destruct(&op_assign);
op_id.locals->num_variables = 0;
@@ -1577,11 +1516,7 @@ initialize_global(slang_assemble_ctx * A, slang_variable * var)
/* carefully destroy the operations */
op_assign.num_children = 0;
-#if USE_MEMPOOL
_slang_free(op_assign.children);
-#else
- slang_alloc_free(op_assign.children);
-#endif
op_assign.children = NULL;
slang_operation_destruct(&op_assign);
op_id.locals->num_variables = 0;
@@ -1642,21 +1577,13 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
if (!slang_type_specifier_copy(&var->type.specifier, &type->specifier))
return 0;
var->initializer =
-#if USE_MEMPOOL
(slang_operation *) _slang_alloc(sizeof(slang_operation));
-#else
- (slang_operation *) slang_alloc_malloc(sizeof(slang_operation));
-#endif
if (var->initializer == NULL) {
slang_info_log_memory(C->L);
return 0;
}
if (!slang_operation_construct(var->initializer)) {
-#if USE_MEMPOOL
_slang_free(var->initializer);
-#else
- slang_alloc_free(var->initializer);
-#endif
var->initializer = NULL;
slang_info_log_memory(C->L);
return 0;
@@ -1788,15 +1715,11 @@ parse_function(slang_parse_ctx * C, slang_output_ctx * O, int definition,
if (found_func == NULL) {
/* New function, add it to the function list */
O->funs->functions =
-#if USE_MEMPOOL
(slang_function *) _slang_realloc(O->funs->functions,
-#else
- (slang_function *) slang_alloc_realloc(O->funs->functions,
-#endif
- O->funs->num_functions *
- sizeof(slang_function),
- (O->funs->num_functions +
- 1) * sizeof(slang_function));
+ O->funs->num_functions
+ * sizeof(slang_function),
+ (O->funs->num_functions + 1)
+ * sizeof(slang_function));
if (O->funs->functions == NULL) {
slang_info_log_memory(C->L);
slang_function_destruct(&parsed_func);
diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c
index bb5be3feec..80769b33ae 100644
--- a/src/mesa/shader/slang/slang_compile_function.c
+++ b/src/mesa/shader/slang/slang_compile_function.c
@@ -44,11 +44,7 @@ slang_fixup_table_init(slang_fixup_table * fix)
void
slang_fixup_table_free(slang_fixup_table * fix)
{
-#if USE_MEMPOOL
_slang_free(fix->table);
-#else
- slang_alloc_free(fix->table);
-#endif
slang_fixup_table_init(fix);
}
@@ -59,13 +55,9 @@ GLboolean
slang_fixup_save(slang_fixup_table *fixups, GLuint address)
{
fixups->table = (GLuint *)
-#if USE_MEMPOOL
_slang_realloc(fixups->table,
-#else
- slang_alloc_realloc(fixups->table,
-#endif
- fixups->count * sizeof(GLuint),
- (fixups->count + 1) * sizeof(GLuint));
+ fixups->count * sizeof(GLuint),
+ (fixups->count + 1) * sizeof(GLuint));
if (fixups->table == NULL)
return GL_FALSE;
fixups->table[fixups->count] = address;
@@ -85,11 +77,7 @@ slang_function_construct(slang_function * func)
return 0;
func->parameters = (slang_variable_scope *)
-#if USE_MEMPOOL
_slang_alloc(sizeof(slang_variable_scope));
-#else
- slang_alloc_malloc(sizeof(slang_variable_scope));
-#endif
if (func->parameters == NULL) {
slang_variable_destruct(&func->header);
return 0;
@@ -108,18 +96,10 @@ slang_function_destruct(slang_function * func)
{
slang_variable_destruct(&func->header);
slang_variable_scope_destruct(func->parameters);
-#if USE_MEMPOOL
_slang_free(func->parameters);
-#else
- slang_alloc_free(func->parameters);
-#endif
if (func->body != NULL) {
slang_operation_destruct(func->body);
-#if USE_MEMPOOL
_slang_free(func->body);
-#else
- slang_alloc_free(func->body);
-#endif
}
slang_fixup_table_free(&func->fixups);
}
@@ -143,11 +123,7 @@ slang_function_scope_destruct(slang_function_scope * scope)
for (i = 0; i < scope->num_functions; i++)
slang_function_destruct(scope->functions + i);
-#if USE_MEMPOOL
_slang_free(scope->functions);
-#else
- slang_alloc_free(scope->functions);
-#endif
}
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c
index c19a1b101b..b18e08d2ae 100644
--- a/src/mesa/shader/slang/slang_compile_operation.c
+++ b/src/mesa/shader/slang/slang_compile_operation.c
@@ -61,11 +61,9 @@ slang_operation_destruct(slang_operation * oper)
for (i = 0; i < oper->num_children; i++)
slang_operation_destruct(oper->children + i);
-#if !USE_MEMPOOL
- slang_alloc_free(oper->children);
+ _slang_free(oper->children);
slang_variable_scope_destruct(oper->locals);
- slang_alloc_free(oper->locals);
-#endif
+ _slang_free(oper->locals);
oper->children = NULL;
oper->num_children = 0;
oper->locals = NULL;
@@ -85,11 +83,7 @@ slang_operation_copy(slang_operation * x, const slang_operation * y)
return GL_FALSE;
z.type = y->type;
z.children = (slang_operation *)
-#if USE_MEMPOOL
_slang_alloc(y->num_children * sizeof(slang_operation));
-#else
- slang_alloc_malloc(y->num_children * sizeof(slang_operation));
-#endif
if (z.children == NULL) {
slang_operation_destruct(&z);
return GL_FALSE;
@@ -135,11 +129,7 @@ slang_operation *
slang_operation_new(GLuint count)
{
slang_operation *ops
-#if USE_MEMPOOL
= (slang_operation *) _slang_alloc(count * sizeof(slang_operation));
-#else
- = (slang_operation *) _mesa_malloc(count * sizeof(slang_operation));
-#endif
assert(count > 0);
if (ops) {
GLuint i;
@@ -157,9 +147,7 @@ void
slang_operation_delete(slang_operation *oper)
{
slang_operation_destruct(oper);
-#if !USE_MEMPOOL
- _mesa_free(oper);
-#endif
+ _slang_free(oper);
}
@@ -169,19 +157,13 @@ slang_operation_grow(GLuint *numChildren, slang_operation **children)
slang_operation *ops;
ops = (slang_operation *)
-#if USE_MEMPOOL
_slang_realloc(*children,
-#else
- slang_alloc_realloc(*children,
-#endif
- *numChildren * sizeof(slang_operation),
- (*numChildren + 1) * sizeof(slang_operation));
+ *numChildren * sizeof(slang_operation),
+ (*numChildren + 1) * sizeof(slang_operation));
if (ops) {
slang_operation *newOp = ops + *numChildren;
if (!slang_operation_construct(newOp)) {
-#if !USE_MEMPOOL
- _mesa_free(ops);
-#endif
+ _slang_free(ops);
*children = NULL;
return NULL;
}
@@ -208,11 +190,7 @@ slang_operation_insert(GLuint *numElements, slang_operation **array,
assert(pos <= *numElements);
ops = (slang_operation *)
-#if USE_MEMPOOL
_slang_alloc((*numElements + 1) * sizeof(slang_operation));
-#else
- _mesa_malloc((*numElements + 1) * sizeof(slang_operation));
-#endif
if (ops) {
slang_operation *newOp;
newOp = ops + pos;
@@ -223,17 +201,13 @@ slang_operation_insert(GLuint *numElements, slang_operation **array,
(*numElements - pos) * sizeof(slang_operation));
if (!slang_operation_construct(newOp)) {
-#if !USE_MEMPOOL
- _mesa_free(ops);
-#endif
+ _slang_free(ops);
*numElements = 0;
*array = NULL;
return NULL;
}
-#if !USE_MEMPOOL
if (*array)
- _mesa_free(*array);
-#endif
+ _slang_free(*array);
*array = ops;
(*numElements)++;
return newOp;
diff --git a/src/mesa/shader/slang/slang_compile_struct.c b/src/mesa/shader/slang/slang_compile_struct.c
index 4a4773217a..97a34d24fe 100644
--- a/src/mesa/shader/slang/slang_compile_struct.c
+++ b/src/mesa/shader/slang/slang_compile_struct.c
@@ -48,11 +48,7 @@ slang_struct_scope_destruct(slang_struct_scope * scope)
for (i = 0; i < scope->num_structs; i++)
slang_struct_destruct(scope->structs + i);
-#if USE_MEMPOOL
_slang_free(scope->structs);
-#else
- slang_alloc_free(scope->structs);
-#endif
/* do not free scope->outer_scope */
}
@@ -63,13 +59,8 @@ slang_struct_scope_copy(slang_struct_scope * x, const slang_struct_scope * y)
GLuint i;
_slang_struct_scope_ctr(&z);
- z.structs =
-#if USE_MEMPOOL
- (slang_struct *) _slang_alloc(y->num_structs *
-#else
- (slang_struct *) slang_alloc_malloc(y->num_structs *
-#endif
- sizeof(slang_struct));
+ z.structs = (slang_struct *)
+ _slang_alloc(y->num_structs * sizeof(slang_struct));
if (z.structs == NULL) {
slang_struct_scope_destruct(&z);
return 0;
@@ -111,28 +102,16 @@ slang_struct_construct(slang_struct * stru)
{
stru->a_name = SLANG_ATOM_NULL;
stru->fields = (slang_variable_scope *)
-#if USE_MEMPOOL
_slang_alloc(sizeof(slang_variable_scope));
-#else
- slang_alloc_malloc(sizeof(slang_variable_scope));
-#endif
if (stru->fields == NULL)
return 0;
_slang_variable_scope_ctr(stru->fields);
stru->structs =
-#if USE_MEMPOOL
(slang_struct_scope *) _slang_alloc(sizeof(slang_struct_scope));
-#else
- (slang_struct_scope *) slang_alloc_malloc(sizeof(slang_struct_scope));
-#endif
if (stru->structs == NULL) {
slang_variable_scope_destruct(stru->fields);
-#if USE_MEMPOOL
_slang_free(stru->fields);
-#else
- slang_alloc_free(stru->fields);
-#endif
return 0;
}
_slang_struct_scope_ctr(stru->structs);
@@ -143,17 +122,9 @@ void
slang_struct_destruct(slang_struct * stru)
{
slang_variable_scope_destruct(stru->fields);
-#if USE_MEMPOOL
_slang_free(stru->fields);
-#else
- slang_alloc_free(stru->fields);
-#endif
slang_struct_scope_destruct(stru->structs);
-#if USE_MEMPOOL
_slang_free(stru->structs);
-#else
- slang_alloc_free(stru->structs);
-#endif
}
int
diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c
index aedf3d4663..d53255075f 100644
--- a/src/mesa/shader/slang/slang_compile_variable.c
+++ b/src/mesa/shader/slang/slang_compile_variable.c
@@ -135,16 +135,10 @@ slang_fully_specified_type_copy(slang_fully_specified_type * x,
static slang_variable *
slang_variable_new(void)
{
-#if USE_MEMPOOL
slang_variable *v = (slang_variable *) _slang_alloc(sizeof(slang_variable));
-#else
- slang_variable *v = (slang_variable *) malloc(sizeof(slang_variable));
-#endif
if (v) {
if (!slang_variable_construct(v)) {
-#if !USE_MEMPOOL
- free(v);
-#endif
+ _slang_free(v);
v = NULL;
}
}
@@ -156,9 +150,7 @@ static void
slang_variable_delete(slang_variable * var)
{
slang_variable_destruct(var);
-#if !USE_MEMPOOL
- free(var);
-#endif
+ _slang_free(var);
}
@@ -170,12 +162,9 @@ slang_variable_scope *
_slang_variable_scope_new(slang_variable_scope *parent)
{
slang_variable_scope *s;
-#if USE_MEMPOOL
s = (slang_variable_scope *) _slang_alloc(sizeof(slang_variable_scope));
-#else
- s = (slang_variable_scope *) _mesa_calloc(sizeof(slang_variable_scope));
-#endif
- s->outer_scope = parent;
+ if (s)
+ s->outer_scope = parent;
return s;
}
@@ -199,11 +188,7 @@ slang_variable_scope_destruct(slang_variable_scope * scope)
if (scope->variables[i])
slang_variable_delete(scope->variables[i]);
}
-#if USE_MEMPOOL
_slang_free(scope->variables);
-#else
- slang_alloc_free(scope->variables);
-#endif
/* do not free scope->outer_scope */
}
@@ -216,11 +201,7 @@ slang_variable_scope_copy(slang_variable_scope * x,
_slang_variable_scope_ctr(&z);
z.variables = (slang_variable **)
-#if USE_MEMPOOL
_slang_alloc(y->num_variables * sizeof(slang_variable *));
-#else
- _mesa_calloc(y->num_variables * sizeof(slang_variable *));
-#endif
if (z.variables == NULL) {
slang_variable_scope_destruct(&z);
return 0;
@@ -255,13 +236,9 @@ slang_variable_scope_grow(slang_variable_scope *scope)
{
const int n = scope->num_variables;
scope->variables = (slang_variable **)
-#if USE_MEMPOOL
_slang_realloc(scope->variables,
-#else
- slang_alloc_realloc(scope->variables,
-#endif
- n * sizeof(slang_variable *),
- (n + 1) * sizeof(slang_variable *));
+ n * sizeof(slang_variable *),
+ (n + 1) * sizeof(slang_variable *));
if (!scope->variables)
return NULL;
@@ -300,11 +277,7 @@ slang_variable_destruct(slang_variable * var)
slang_fully_specified_type_destruct(&var->type);
if (var->initializer != NULL) {
slang_operation_destruct(var->initializer);
-#if USE_MEMPOOL
_slang_free(var->initializer);
-#else
- slang_alloc_free(var->initializer);
-#endif
}
#if 0
if (var->aux) {
@@ -329,19 +302,13 @@ slang_variable_copy(slang_variable * x, const slang_variable * y)
z.array_len = y->array_len;
if (y->initializer != NULL) {
z.initializer
-#if USE_MEMPOOL
= (slang_operation *) _slang_alloc(sizeof(slang_operation));
-#else
- = (slang_operation *) slang_alloc_malloc(sizeof(slang_operation));
-#endif
if (z.initializer == NULL) {
slang_variable_destruct(&z);
return 0;
}
if (!slang_operation_construct(z.initializer)) {
-#if !USE_MEMPOOL
- slang_alloc_free(z.initializer);
-#endif
+ _slang_free(z.initializer);
slang_variable_destruct(&z);
return 0;
}
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index c668372019..7804e19236 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -127,11 +127,7 @@ slang_ir_storage *
_slang_new_ir_storage(enum register_file file, GLint index, GLint size)
{
slang_ir_storage *st;
-#if USE_MEMPOOL
st = (slang_ir_storage *) _slang_alloc(sizeof(slang_ir_storage));
-#else
- st = (slang_ir_storage *) _mesa_calloc(sizeof(slang_ir_storage));
-#endif
if (st) {
st->File = file;
st->Index = index;
@@ -156,11 +152,7 @@ alloc_temp_storage(slang_emit_info *emitInfo, slang_ir_node *n, GLint size)
if (!_slang_alloc_temp(emitInfo->vt, n->Store)) {
slang_info_log_error(emitInfo->log,
"Ran out of registers, too many temporaries");
-#if USE_MEMPOOL
_slang_free(n->Store);
-#else
- _mesa_free(n->Store);
-#endif
n->Store = NULL;
return GL_FALSE;
}
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index b99866761f..9517bdf29d 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -26,6 +26,7 @@
#include "imports.h"
#include "context.h"
#include "slang_ir.h"
+#include "slang_mem.h"
#include "prog_print.h"
@@ -113,6 +114,7 @@ _slang_ir_name(slang_ir_opcode opcode)
}
+#if 0 /* no longer needed with mempool */
/**
* Since many IR nodes might point to the same IR storage info, we need
* to be careful when deleting things.
@@ -131,6 +133,7 @@ _slang_refcount_storage(slang_ir_node *n)
for (i = 0; i < 3; i++)
_slang_refcount_storage(n->Children[i]);
}
+#endif
static void
@@ -140,22 +143,20 @@ _slang_free_ir(slang_ir_node *n)
if (!n)
return;
+#if 0
if (n->Store) {
n->Store->RefCount--;
if (n->Store->RefCount == 0) {
-#if !USE_MEMPOOL
- free(n->Store);
-#endif
+ _slang_free(n->Store);
n->Store = NULL;
}
}
+#endif
for (i = 0; i < 3; i++)
_slang_free_ir(n->Children[i]);
/* Do not free n->List since it's a child elsewhere */
-#if !USE_MEMPOOL
- free(n);
-#endif
+ _slang_free(n);
}
@@ -167,8 +168,8 @@ _slang_free_ir_tree(slang_ir_node *n)
{
#if 0
_slang_refcount_storage(n);
- _slang_free_ir(n);
#endif
+ _slang_free_ir(n);
}
diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c
index a4529be74f..1ca1ef0c7c 100644
--- a/src/mesa/shader/slang/slang_label.c
+++ b/src/mesa/shader/slang/slang_label.c
@@ -15,17 +15,9 @@
slang_label *
_slang_label_new(const char *name)
{
-#if !USE_MEMPOOL
- slang_label *l = (slang_label *) _mesa_calloc(sizeof(slang_label));
-#else
slang_label *l = (slang_label *) _slang_alloc(sizeof(slang_label));
-#endif
if (l) {
-#if !USE_MEMPOOL
- l->Name = _mesa_strdup(name);
-#else
l->Name = _slang_strdup(name);
-#endif
l->Location = -1;
}
return l;
@@ -38,17 +30,9 @@ slang_label *
_slang_label_new_unique(const char *name)
{
static int id = 1;
-#if !USE_MEMPOOL
- slang_label *l = (slang_label *) _mesa_calloc(sizeof(slang_label));
-#else
slang_label *l = (slang_label *) _slang_alloc(sizeof(slang_label));
-#endif
if (l) {
-#if !USE_MEMPOOL
- l->Name = (char *) _mesa_malloc(_mesa_strlen(name) + 10);
-#else
l->Name = (char *) _slang_alloc(_mesa_strlen(name) + 10);
-#endif
if (!l->Name) {
_mesa_free(l);
return NULL;
@@ -63,13 +47,15 @@ _slang_label_new_unique(const char *name)
void
_slang_label_delete(slang_label *l)
{
-#if !USE_MEMPOOL
- if (l->Name)
- _mesa_free(l->Name);
- if (l->References)
- _mesa_free(l->References);
- _mesa_free(l);
-#endif
+ if (l->Name) {
+ _slang_free(l->Name);
+ l->Name = NULL;
+ }
+ if (l->References) {
+ _slang_free(l->References);
+ l->References = NULL;
+ }
+ _slang_free(l);
}
@@ -78,13 +64,8 @@ _slang_label_add_reference(slang_label *l, GLuint inst)
{
const GLuint oldSize = l->NumReferences * sizeof(GLuint);
assert(l->Location < 0);
-#if !USE_MEMPOOL
- l->References = _mesa_realloc(l->References,
- oldSize, oldSize + sizeof(GLuint));
-#else
l->References = _slang_realloc(l->References,
oldSize, oldSize + sizeof(GLuint));
-#endif
if (l->References) {
l->References[l->NumReferences] = inst;
l->NumReferences++;
@@ -117,9 +98,7 @@ _slang_label_set_location(slang_label *l, GLint location,
}
if (l->References) {
-#if !USE_MEMPOOL
- _mesa_free(l->References);
-#endif
+ _slang_free(l->References);
l->References = NULL;
}
}
diff --git a/src/mesa/shader/slang/slang_mem.h b/src/mesa/shader/slang/slang_mem.h
index a91c2b8791..49885b6c98 100644
--- a/src/mesa/shader/slang/slang_mem.h
+++ b/src/mesa/shader/slang/slang_mem.h
@@ -52,6 +52,4 @@ extern void
_slang_free(void *addr);
-#define USE_MEMPOOL 1 /* XXX temporary */
-
#endif
diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c
index e7fb63c289..bc32aa4b02 100644
--- a/src/mesa/shader/slang/slang_storage.c
+++ b/src/mesa/shader/slang/slang_storage.c
@@ -48,11 +48,7 @@ slang_storage_array_destruct(slang_storage_array * arr)
{
if (arr->aggregate != NULL) {
slang_storage_aggregate_destruct(arr->aggregate);
-#if USE_MEMPOOL
_slang_free(arr->aggregate);
-#else
- slang_alloc_free(arr->aggregate);
-#endif
}
}
@@ -73,11 +69,7 @@ slang_storage_aggregate_destruct(slang_storage_aggregate * agg)
for (i = 0; i < agg->count; i++)
slang_storage_array_destruct(agg->arrays + i);
-#if USE_MEMPOOL
_slang_free(agg->arrays);
-#else
- slang_alloc_free(agg->arrays);
-#endif
}
static slang_storage_array *
@@ -86,13 +78,9 @@ slang_storage_aggregate_push_new(slang_storage_aggregate * agg)
slang_storage_array *arr = NULL;
agg->arrays = (slang_storage_array *)
-#if USE_MEMPOOL
_slang_realloc(agg->arrays,
-#else
- slang_alloc_realloc(agg->arrays,
-#endif
- agg->count * sizeof(slang_storage_array),
- (agg->count + 1) * sizeof(slang_storage_array));
+ agg->count * sizeof(slang_storage_array),
+ (agg->count + 1) * sizeof(slang_storage_array));
if (agg->arrays != NULL) {
arr = agg->arrays + agg->count;
if (!slang_storage_array_construct(arr))
@@ -125,21 +113,12 @@ aggregate_matrix(slang_storage_aggregate * agg, slang_storage_type basic_type,
return GL_FALSE;
arr->type = SLANG_STORE_AGGREGATE;
arr->length = columns;
- arr->aggregate =
- (slang_storage_aggregate *)
-#if USE_MEMPOOL
+ arr->aggregate = (slang_storage_aggregate *)
_slang_alloc(sizeof(slang_storage_aggregate));
-#else
- slang_alloc_malloc(sizeof(slang_storage_aggregate));
-#endif
if (arr->aggregate == NULL)
return GL_FALSE;
if (!slang_storage_aggregate_construct(arr->aggregate)) {
-#if USE_MEMPOOL
_slang_free(arr->aggregate);
-#else
- slang_alloc_free(arr->aggregate);
-#endif
arr->aggregate = NULL;
return GL_FALSE;
}
@@ -240,21 +219,12 @@ _slang_aggregate_variable(slang_storage_aggregate * agg,
if (arr == NULL)
return GL_FALSE;
arr->type = SLANG_STORE_AGGREGATE;
- arr->aggregate =
- (slang_storage_aggregate *)
-#if USE_MEMPOOL
+ arr->aggregate = (slang_storage_aggregate *)
_slang_alloc(sizeof(slang_storage_aggregate));
-#else
- slang_alloc_malloc(sizeof(slang_storage_aggregate));
-#endif
if (arr->aggregate == NULL)
return GL_FALSE;
if (!slang_storage_aggregate_construct(arr->aggregate)) {
-#if USE_MEMPOOL
_slang_free(arr->aggregate);
-#else
- slang_alloc_free(arr->aggregate);
-#endif
arr->aggregate = NULL;
return GL_FALSE;
}
diff --git a/src/mesa/shader/slang/slang_typeinfo.c b/src/mesa/shader/slang/slang_typeinfo.c
index c688423d8d..da0b32bc44 100644
--- a/src/mesa/shader/slang/slang_typeinfo.c
+++ b/src/mesa/shader/slang/slang_typeinfo.c
@@ -179,19 +179,11 @@ slang_type_specifier_dtr(slang_type_specifier * self)
{
if (self->_struct != NULL) {
slang_struct_destruct(self->_struct);
-#if USE_MEMPOOL
_slang_free(self->_struct);
-#else
- slang_alloc_free(self->_struct);
-#endif
}
if (self->_array != NULL) {
slang_type_specifier_dtr(self->_array);
-#if USE_MEMPOOL
_slang_free(self->_array);
-#else
- slang_alloc_free(self->_array);
-#endif
}
}
@@ -204,21 +196,13 @@ slang_type_specifier_copy(slang_type_specifier * x,
slang_type_specifier_ctr(&z);
z.type = y->type;
if (z.type == SLANG_SPEC_STRUCT) {
-#if USE_MEMPOOL
z._struct = (slang_struct *) _slang_alloc(sizeof(slang_struct));
-#else
- z._struct = (slang_struct *) slang_alloc_malloc(sizeof(slang_struct));
-#endif
if (z._struct == NULL) {
slang_type_specifier_dtr(&z);
return GL_FALSE;
}
if (!slang_struct_construct(z._struct)) {
-#if USE_MEMPOOL
_slang_free(z._struct);
-#else
- slang_alloc_free(z._struct);
-#endif
slang_type_specifier_dtr(&z);
return GL_FALSE;
}
@@ -228,13 +212,8 @@ slang_type_specifier_copy(slang_type_specifier * x,
}
}
else if (z.type == SLANG_SPEC_ARRAY) {
- z._array =
- (slang_type_specifier *)
-#if USE_MEMPOOL
+ z._array = (slang_type_specifier *)
_slang_alloc(sizeof(slang_type_specifier));
-#else
- slang_alloc_malloc(sizeof(slang_type_specifier));
-#endif
if (z._array == NULL) {
slang_type_specifier_dtr(&z);
return GL_FALSE;
@@ -617,19 +596,11 @@ _slang_typeof_operation_(slang_operation * op,
/* struct initializer */
ti->spec.type = SLANG_SPEC_STRUCT;
ti->spec._struct =
-#if USE_MEMPOOL
(slang_struct *) _slang_alloc(sizeof(slang_struct));
-#else
- (slang_struct *) slang_alloc_malloc(sizeof(slang_struct));
-#endif
if (ti->spec._struct == NULL)
return GL_FALSE;
if (!slang_struct_construct(ti->spec._struct)) {
-#if USE_MEMPOOL
_slang_free(ti->spec._struct);
-#else
- slang_alloc_free(ti->spec._struct);
-#endif
ti->spec._struct = NULL;
return GL_FALSE;
}
diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c
index 786b8990df..2a2dc8e54f 100644
--- a/src/mesa/shader/slang/slang_utility.c
+++ b/src/mesa/shader/slang/slang_utility.c
@@ -153,16 +153,9 @@ slang_atom_pool_destruct (slang_atom_pool * pool)
entry = pool->entries[i];
while (entry != NULL) {
- slang_atom_entry *next;
-
- next = entry->next;
-#if USE_MEMPOOL
+ slang_atom_entry *next = entry->next;
_slang_free(entry->id);
_slang_free(entry);
-#else
- slang_alloc_free(entry->id);
- slang_alloc_free(entry);
-#endif
entry = next;
}
}
@@ -210,11 +203,7 @@ slang_atom_pool_atom(slang_atom_pool * pool, const char * id)
/* Okay, we have not found an atom. Create a new entry for it.
* Note that the <entry> points to the last entry's <next> field.
*/
-#if USE_MEMPOOL
- *entry = (slang_atom_entry *) (_slang_alloc(sizeof(slang_atom_entry)));
-#else
- *entry = (slang_atom_entry *) (slang_alloc_malloc(sizeof(slang_atom_entry)));
-#endif
+ *entry = (slang_atom_entry *) _slang_alloc(sizeof(slang_atom_entry));
if (*entry == NULL)
return SLANG_ATOM_NULL;
@@ -223,11 +212,7 @@ slang_atom_pool_atom(slang_atom_pool * pool, const char * id)
* value.
*/
(**entry).next = NULL;
-#if USE_MEMPOOL
(**entry).id = _slang_strdup(id);
-#else
- (**entry).id = slang_string_duplicate(id);
-#endif
if ((**entry).id == NULL)
return SLANG_ATOM_NULL;
return (slang_atom) (**entry).id;
diff --git a/src/mesa/shader/slang/slang_utility.h b/src/mesa/shader/slang/slang_utility.h
index 98a4cd5991..032c561810 100644
--- a/src/mesa/shader/slang/slang_utility.h
+++ b/src/mesa/shader/slang/slang_utility.h
@@ -25,24 +25,15 @@
#ifndef SLANG_UTILITY_H
#define SLANG_UTILITY_H
-#include "slang_mem.h"
-
/* Compile-time assertions. If the expression is zero, try to declare an
* array of size [-1] to cause compilation error.
*/
#define static_assert(expr) do { int _array[(expr) ? 1 : -1]; (void) _array[0]; } while (0)
-#if !USE_MEMPOOL
-#define slang_alloc_free(ptr) _mesa_free (ptr)
-#define slang_alloc_malloc(size) _mesa_malloc (size)
-#define slang_alloc_realloc(ptr, old_size, size) _mesa_realloc (ptr, old_size, size)
-#endif
+
#define slang_string_compare(str1, str2) _mesa_strcmp (str1, str2)
#define slang_string_copy(dst, src) _mesa_strcpy (dst, src)
-#if !USE_MEMPOOL
-#define slang_string_duplicate(src) _mesa_strdup (src)
-#endif
#define slang_string_length(str) _mesa_strlen (str)
char *slang_string_concat (char *, const char *);
@@ -107,4 +98,3 @@ const char *slang_atom_pool_id (slang_atom_pool *, slang_atom);
#endif
-
diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c
index 27f8aeb4bd..5814481ea7 100644
--- a/src/mesa/shader/slang/slang_vartable.c
+++ b/src/mesa/shader/slang/slang_vartable.c
@@ -50,11 +50,7 @@ slang_var_table *
_slang_new_var_table(GLuint maxRegisters)
{
slang_var_table *vt
-#if USE_MEMPOOL
= (slang_var_table *) _slang_alloc(sizeof(slang_var_table));
-#else
- = (slang_var_table *) _mesa_calloc(sizeof(slang_var_table));
-#endif
if (vt) {
vt->MaxRegisters = maxRegisters;
}
@@ -69,9 +65,7 @@ _slang_delete_var_table(slang_var_table *vt)
_mesa_problem(NULL, "non-empty var table in _slang_delete_var_table()");
return;
}
-#if !USE_MEMPOOL
- _mesa_free(vt);
-#endif
+ _slang_free(vt);
}
@@ -84,11 +78,7 @@ _slang_delete_var_table(slang_var_table *vt)
void
_slang_push_var_table(slang_var_table *vt)
{
-#if USE_MEMPOOL
struct table *t = (struct table *) _slang_alloc(sizeof(struct table));
-#else
- struct table *t = (struct table *) _mesa_calloc(sizeof(struct table));
-#endif
if (t) {
t->Level = vt->CurLevel++;
t->Parent = vt->Top;
@@ -147,17 +137,13 @@ _slang_pop_var_table(slang_var_table *vt)
}
}
- if (t->Vars)
-#if USE_MEMPOOL
+ if (t->Vars) {
+ _slang_free(t->Vars);
t->Vars = NULL;
-#else
- free(t->Vars);
-#endif
+ }
vt->Top = t->Parent;
-#if !USE_MEMPOOL
- free(t);
-#endif
+ _slang_free(t);
vt->CurLevel--;
}
@@ -173,14 +159,10 @@ _slang_add_variable(slang_var_table *vt, slang_variable *v)
t = vt->Top;
assert(t);
if (dbg) printf("Adding var %s\n", (char *) v->a_name);
-#if USE_MEMPOOL
- t->Vars =
- (slang_variable **) _slang_realloc(t->Vars,
- t->NumVars * sizeof(slang_variable *),
- (t->NumVars + 1) * sizeof(slang_variable *));
-#else
- t->Vars = realloc(t->Vars, (t->NumVars + 1) * sizeof(slang_variable *));
-#endif
+ t->Vars = (slang_variable **)
+ _slang_realloc(t->Vars,
+ t->NumVars * sizeof(slang_variable *),
+ (t->NumVars + 1) * sizeof(slang_variable *));
t->Vars[t->NumVars] = v;
t->NumVars++;
}