Mesa (master): i965: Handle deallocation of some private ralloc contexts explicitly.

Francisco Jerez currojerez at kemper.freedesktop.org
Tue Oct 29 19:45:40 UTC 2013


Module: Mesa
Branch: master
Commit: db47074ac02e2b822dd118f4837b32732941b78b
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=db47074ac02e2b822dd118f4837b32732941b78b

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Wed Oct 23 11:16:26 2013 -0700

i965: Handle deallocation of some private ralloc contexts explicitly.

These ralloc contexts belong to a specific object and are being
deallocated manually from the class destructor.  Now that we've hooked
up destructors to ralloc there's no reason for them to be children of
any other context, and doing so might to lead to double frees under
some circumstances.  The class destructor has all the responsibility
of freeing class memory resources now.

---

 src/mesa/drivers/dri/i965/brw_cfg.cpp              |    2 +-
 .../drivers/dri/i965/brw_fs_live_variables.cpp     |    2 +-
 .../drivers/dri/i965/brw_schedule_instructions.cpp |    2 +-
 .../drivers/dri/i965/brw_vec4_live_variables.cpp   |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp
index 33097eb..e9d2bb8 100644
--- a/src/mesa/drivers/dri/i965/brw_cfg.cpp
+++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp
@@ -80,7 +80,7 @@ cfg_t::cfg_t(void *mem_ctx, exec_list *instructions)
 void
 cfg_t::create(void *parent_mem_ctx, exec_list *instructions)
 {
-   mem_ctx = ralloc_context(parent_mem_ctx);
+   mem_ctx = ralloc_context(NULL);
    block_list.make_empty();
    blocks = NULL;
    num_blocks = 0;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
index 213a0fd..21b2618 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
@@ -246,7 +246,7 @@ fs_live_variables::var_from_reg(fs_reg *reg)
 fs_live_variables::fs_live_variables(fs_visitor *v, cfg_t *cfg)
    : v(v), cfg(cfg)
 {
-   mem_ctx = this;
+   mem_ctx = ralloc_context(NULL);
 
    num_vgrfs = v->virtual_grf_count;
    num_vars = 0;
diff --git a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
index a1ecfde..27de0e6 100644
--- a/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
+++ b/src/mesa/drivers/dri/i965/brw_schedule_instructions.cpp
@@ -347,7 +347,7 @@ public:
    instruction_scheduler(backend_visitor *v, int grf_count, bool post_reg_alloc)
    {
       this->bv = v;
-      this->mem_ctx = ralloc_context(v->mem_ctx);
+      this->mem_ctx = ralloc_context(NULL);
       this->grf_count = grf_count;
       this->instructions.make_empty();
       this->instructions_to_schedule = 0;
diff --git a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
index c568f75..3adda09 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
@@ -156,7 +156,7 @@ vec4_live_variables::compute_live_variables()
 vec4_live_variables::vec4_live_variables(vec4_visitor *v, cfg_t *cfg)
    : v(v), cfg(cfg)
 {
-   mem_ctx = ralloc_context(cfg->mem_ctx);
+   mem_ctx = ralloc_context(NULL);
 
    num_vars = v->virtual_grf_count * 4;
    bd = rzalloc_array(mem_ctx, struct block_data, cfg->num_blocks);




More information about the mesa-commit mailing list