[Mesa-dev] [RFC PATCH 4/5] ralloc: Remove overloads of the placement new and delete operator.
Francisco Jerez
currojerez at riseup.net
Thu Oct 10 05:32:33 CEST 2013
---
src/glsl/ast.h | 4 ---
src/glsl/glsl_parser_extras.h | 2 --
src/glsl/glsl_symbol_table.cpp | 2 --
src/glsl/glsl_symbol_table.h | 30 ----------------------
src/glsl/ir_function_detect_recursion.cpp | 2 --
src/glsl/list.h | 4 ---
src/glsl/loop_analysis.h | 17 ------------
src/glsl/ralloc.h | 24 -----------------
src/mesa/drivers/dri/i965/brw_cfg.h | 4 ---
src/mesa/drivers/dri/i965/brw_fs.h | 6 -----
src/mesa/drivers/dri/i965/brw_fs_live_variables.h | 2 --
src/mesa/drivers/dri/i965/brw_vec4.h | 6 -----
.../drivers/dri/i965/brw_vec4_live_variables.h | 2 --
src/mesa/program/ir_to_mesa.cpp | 2 --
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 2 --
15 files changed, 109 deletions(-)
diff --git a/src/glsl/ast.h b/src/glsl/ast.h
index 97905c6..5e1febf 100644
--- a/src/glsl/ast.h
+++ b/src/glsl/ast.h
@@ -49,8 +49,6 @@ struct YYLTYPE;
*/
class ast_node {
public:
- DECLARE_RALLOC_CXX_OPERATORS(ast_node);
-
/**
* Print an AST node in something approximating the original GLSL code
*/
@@ -346,8 +344,6 @@ enum {
};
struct ast_type_qualifier {
- DECLARE_RALLOC_CXX_OPERATORS(ast_type_qualifier);
-
union {
struct {
unsigned invariant:1;
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 26841f5..350359b 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -73,8 +73,6 @@ struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
void *mem_ctx);
- DECLARE_RALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
-
/**
* Generate a string representing the GLSL version currently being compiled
* (useful for error messages).
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index a955780..8794ecc 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -26,8 +26,6 @@
class symbol_table_entry {
public:
- DECLARE_RALLOC_CXX_OPERATORS(symbol_table_entry);
-
bool add_interface(const glsl_type *i, enum ir_variable_mode mode)
{
const glsl_type **dest;
diff --git a/src/glsl/glsl_symbol_table.h b/src/glsl/glsl_symbol_table.h
index 62d26b8..14a7756 100644
--- a/src/glsl/glsl_symbol_table.h
+++ b/src/glsl/glsl_symbol_table.h
@@ -43,37 +43,7 @@ class symbol_table_entry;
* type safe and some symbol table invariants.
*/
struct glsl_symbol_table {
-private:
- static void
- _glsl_symbol_table_destructor (glsl_symbol_table *table)
- {
- table->~glsl_symbol_table();
- }
-
public:
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *table;
-
- table = ralloc_size(ctx, size);
- assert(table != NULL);
-
- ralloc_set_destructor(table, (void (*)(void*)) _glsl_symbol_table_destructor);
-
- return table;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. Here, C++ will have already called the
- * destructor so tell ralloc not to do that again. */
- static void operator delete(void *table)
- {
- ralloc_set_destructor(table, NULL);
- ralloc_free(table);
- }
-
glsl_symbol_table();
~glsl_symbol_table();
diff --git a/src/glsl/ir_function_detect_recursion.cpp b/src/glsl/ir_function_detect_recursion.cpp
index dce5008..70bcf12 100644
--- a/src/glsl/ir_function_detect_recursion.cpp
+++ b/src/glsl/ir_function_detect_recursion.cpp
@@ -141,8 +141,6 @@ public:
/* empty */
}
- DECLARE_RALLOC_CXX_OPERATORS(function)
-
ir_function_signature *sig;
/** List of functions called by this function. */
diff --git a/src/glsl/list.h b/src/glsl/list.h
index 5ac17cb..4bc9ebe 100644
--- a/src/glsl/list.h
+++ b/src/glsl/list.h
@@ -76,8 +76,6 @@ struct exec_node {
struct exec_node *prev;
#ifdef __cplusplus
- DECLARE_RALLOC_CXX_OPERATORS(exec_node)
-
exec_node() : next(NULL), prev(NULL)
{
/* empty */
@@ -268,8 +266,6 @@ struct exec_list {
struct exec_node *tail_pred;
#ifdef __cplusplus
- DECLARE_RALLOC_CXX_OPERATORS(exec_list)
-
exec_list()
{
make_empty();
diff --git a/src/glsl/loop_analysis.h b/src/glsl/loop_analysis.h
index 769d626..2545eff 100644
--- a/src/glsl/loop_analysis.h
+++ b/src/glsl/loop_analysis.h
@@ -140,23 +140,6 @@ public:
{
hash_table_dtor(this->var_hash);
}
-
- static void* operator new(size_t size, void *ctx)
- {
- void *lvs = ralloc_size(ctx, size);
- assert(lvs != NULL);
-
- ralloc_set_destructor(lvs, (void (*)(void*)) destructor);
-
- return lvs;
- }
-
-private:
- static void
- destructor(loop_variable_state *lvs)
- {
- lvs->~loop_variable_state();
- }
};
diff --git a/src/glsl/ralloc.h b/src/glsl/ralloc.h
index bc8d4de..52bfa87 100644
--- a/src/glsl/ralloc.h
+++ b/src/glsl/ralloc.h
@@ -461,28 +461,4 @@ void ralloc_delete(T *p)
#endif
-/**
- * Declare C++ new and delete operators which use ralloc.
- *
- * Placing this macro in the body of a class makes it possible to do:
- *
- * TYPE *var = new(mem_ctx) TYPE(...);
- * delete var;
- *
- * which is more idiomatic in C++ than calling ralloc.
- */
-#define DECLARE_RALLOC_CXX_OPERATORS(TYPE) \
- static void* operator new(size_t size, void *mem_ctx) \
- { \
- void *p = ralloc_size(mem_ctx, size); \
- assert(p != NULL); \
- return p; \
- } \
- \
- static void operator delete(void *p) \
- { \
- ralloc_free(p); \
- }
-
-
#endif
diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h
index ec5a3a0..db0ec4e 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.h
+++ b/src/mesa/drivers/dri/i965/brw_cfg.h
@@ -39,8 +39,6 @@ public:
class bblock_t {
public:
- DECLARE_RALLOC_CXX_OPERATORS(bblock_t)
-
bblock_link *make_list(void *mem_ctx);
bblock_t();
@@ -60,8 +58,6 @@ public:
class cfg_t {
public:
- DECLARE_RALLOC_CXX_OPERATORS(cfg_t)
-
cfg_t(backend_visitor *v);
cfg_t(void *mem_ctx, exec_list *instructions);
~cfg_t();
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 5c7089d..43be22e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -57,8 +57,6 @@ namespace {
class fs_reg {
public:
- DECLARE_RALLOC_CXX_OPERATORS(fs_reg)
-
void init();
fs_reg();
@@ -113,8 +111,6 @@ static const fs_reg reg_null_ud(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD));
class ip_record : public exec_node {
public:
- DECLARE_RALLOC_CXX_OPERATORS(ip_record)
-
ip_record(int ip)
{
this->ip = ip;
@@ -125,8 +121,6 @@ public:
class fs_inst : public backend_instruction {
public:
- DECLARE_RALLOC_CXX_OPERATORS(fs_inst)
-
void init();
fs_inst();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
index e227439..c93a55f 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.h
@@ -53,8 +53,6 @@ struct block_data {
class fs_live_variables {
public:
- DECLARE_RALLOC_CXX_OPERATORS(fs_live_variables)
-
fs_live_variables(fs_visitor *v, cfg_t *cfg);
~fs_live_variables();
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
index 91f1b64..c4e87e0 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -118,8 +118,6 @@ public:
class src_reg : public reg
{
public:
- DECLARE_RALLOC_CXX_OPERATORS(src_reg)
-
void init();
src_reg(register_file file, int reg, const glsl_type *type);
@@ -146,8 +144,6 @@ public:
class dst_reg : public reg
{
public:
- DECLARE_RALLOC_CXX_OPERATORS(dst_reg)
-
void init();
dst_reg();
@@ -168,8 +164,6 @@ with_writemask(dst_reg const &r, int mask);
class vec4_instruction : public backend_instruction {
public:
- DECLARE_RALLOC_CXX_OPERATORS(vec4_instruction)
-
vec4_instruction(vec4_visitor *v, enum opcode opcode,
dst_reg dst = dst_reg(),
src_reg src0 = src_reg(),
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h
index 296468a..db71f4c 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.h
@@ -52,8 +52,6 @@ struct block_data {
class vec4_live_variables {
public:
- DECLARE_RALLOC_CXX_OPERATORS(vec4_live_variables)
-
vec4_live_variables(vec4_visitor *v, cfg_t *cfg);
~vec4_live_variables();
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 740f1a1..7a92166 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -155,8 +155,6 @@ namespace {
class ir_to_mesa_instruction : public exec_node {
public:
- DECLARE_RALLOC_CXX_OPERATORS(ir_to_mesa_instruction)
-
enum prog_opcode op;
dst_reg dst;
src_reg src[3];
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 4c3a2ad..312b7b2 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -217,8 +217,6 @@ st_dst_reg::st_dst_reg(st_src_reg reg)
class glsl_to_tgsi_instruction : public exec_node {
public:
- DECLARE_RALLOC_CXX_OPERATORS(glsl_to_tgsi_instruction)
-
unsigned op;
st_dst_reg dst;
st_src_reg src[3];
--
1.8.3.4
More information about the mesa-dev
mailing list