From 9544cb516d03c2a5fd5e4c1a98bf9d638727ffb9 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sun, 24 Nov 2013 14:35:05 -0800 Subject: [PATCH 1/4] Fix some compile warnings --- elab_expr.cc | 4 ++-- t-dll-api.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index d8f6ac313..4999dcd5a 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -2538,7 +2538,7 @@ unsigned PEFNumber::test_width(Design*, NetScope*, width_mode_t&) return expr_width_; } -NetExpr* PEFNumber::elaborate_expr(Design*, NetScope*, ivl_type_t type, unsigned) const +NetExpr* PEFNumber::elaborate_expr(Design*, NetScope*, ivl_type_t, unsigned) const { NetECReal*tmp = new NetECReal(*value_); tmp->set_line(*this); @@ -4932,7 +4932,7 @@ unsigned PEString::test_width(Design*, NetScope*, width_mode_t&) return expr_width_; } -NetEConst* PEString::elaborate_expr(Design*, NetScope*, ivl_type_t type, unsigned)const +NetEConst* PEString::elaborate_expr(Design*, NetScope*, ivl_type_t, unsigned)const { verinum val(value()); NetEConst*tmp = new NetEConst(val); diff --git a/t-dll-api.cc b/t-dll-api.cc index a4189d6d1..4fcd623f8 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -1575,7 +1575,7 @@ extern "C" ivl_event_t ivl_lpm_trigger(ivl_lpm_t net) /* * Deprecated */ -extern "C" ivl_expr_t ivl_lval_mux(ivl_lval_t net) +extern "C" ivl_expr_t ivl_lval_mux(ivl_lval_t) { return 0; } From ae90da995154030d7a7c2252588b1d3baacf4e10 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 3 Dec 2013 09:14:18 -0800 Subject: [PATCH 2/4] Improve the classs cleanup code when using valgrind --- vvp/class_type.cc | 6 ++++++ vvp/class_type.h | 1 + vvp/vpi_scope.cc | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vvp/class_type.cc b/vvp/class_type.cc index 38768aa03..3e4a41f77 100644 --- a/vvp/class_type.cc +++ b/vvp/class_type.cc @@ -387,6 +387,12 @@ class_type::class_type(const string&nam, size_t nprop) instance_size_ = 0; } +class_type::~class_type() +{ + for (size_t idx = 0 ; idx < properties_.size() ; idx += 1) + delete properties_[idx].type; +} + void class_type::set_property(size_t idx, const string&name, const string&type) { assert(idx < properties_.size()); diff --git a/vvp/class_type.h b/vvp/class_type.h index efce1925e..8304f812e 100644 --- a/vvp/class_type.h +++ b/vvp/class_type.h @@ -39,6 +39,7 @@ class class_type : public __vpiHandle { public: explicit class_type(const std::string&nam, size_t nprop); + ~class_type(); // This is the name of the class type. inline const std::string&class_name(void) const { return class_name_; } diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index f18aea030..f7dc5f313 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -132,8 +132,8 @@ void root_table_delete(void) for (unsigned idx = 0; idx < vpip_root_table_cnt; idx += 1) { struct __vpiScope *scope = static_cast<__vpiScope *> (vpip_root_table_ptr[idx]); - delete_sub_scopes(scope); vthreads_delete(scope); + delete_sub_scopes(scope); delete scope; } free(vpip_root_table_ptr); From 5a0f9f4604999e11e7760227809563f9ca97cbc0 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 3 Dec 2013 10:10:42 -0800 Subject: [PATCH 3/4] Fix CXX variable in tgt-blif/Makefile.in --- tgt-blif/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgt-blif/Makefile.in b/tgt-blif/Makefile.in index c45d8885e..f09b0eca4 100644 --- a/tgt-blif/Makefile.in +++ b/tgt-blif/Makefile.in @@ -29,7 +29,7 @@ bindir = @bindir@ libdir = @libdir@ CC = @CC@ -CC = @CXX@ +CXX = @CXX@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ From 7e55babb6204fd0fd7c6b0e9b57d5f727f4e23b1 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 3 Dec 2013 17:19:35 -0800 Subject: [PATCH 4/4] Fix leaks in the object stack This patch fixes some leaks in the object stack when getting various class properties. With this fix an assert can be added to verify that the object stack is clean when a thread is exiting. --- tgt-vvp/eval_expr.c | 1 + tgt-vvp/eval_object.c | 3 ++- tgt-vvp/eval_real.c | 1 + tgt-vvp/eval_string.c | 1 + vvp/opcodes.txt | 6 ++---- vvp/vthread.cc | 1 + 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 37cf68aa9..c315039bc 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -2121,6 +2121,7 @@ static struct vector_info draw_property_expr(ivl_expr_t expr, unsigned wid) fprintf(vvp_out, " %%load/obj v%p_0;\n", sig); fprintf(vvp_out, " %%prop/v %u, %u, %u;\n", pidx, res.base, wid); + fprintf(vvp_out, " %%pop/obj 1, 0;\n"); return res; } diff --git a/tgt-vvp/eval_object.c b/tgt-vvp/eval_object.c index 332f519ae..e343fb3a1 100644 --- a/tgt-vvp/eval_object.c +++ b/tgt-vvp/eval_object.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 2012-2013 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -173,6 +173,7 @@ static int eval_object_property(ivl_expr_t expr) fprintf(vvp_out, " %%load/obj v%p_0;\n", sig); fprintf(vvp_out, " %%prop/obj %u;\n", pidx); + fprintf(vvp_out, " %%pop/obj 1, 1;\n"); return 0; } diff --git a/tgt-vvp/eval_real.c b/tgt-vvp/eval_real.c index b4a9073d3..854a2670a 100644 --- a/tgt-vvp/eval_real.c +++ b/tgt-vvp/eval_real.c @@ -172,6 +172,7 @@ static void draw_property_real(ivl_expr_t expr) fprintf(vvp_out, " %%load/obj v%p_0;\n", sig); fprintf(vvp_out, " %%prop/r %u;\n", pidx); + fprintf(vvp_out, " %%pop/obj 1, 0;\n"); } static void draw_realnum_real(ivl_expr_t expr) diff --git a/tgt-vvp/eval_string.c b/tgt-vvp/eval_string.c index e477229f2..723d1faee 100644 --- a/tgt-vvp/eval_string.c +++ b/tgt-vvp/eval_string.c @@ -67,6 +67,7 @@ static void string_ex_property(ivl_expr_t expr) fprintf(vvp_out, " %%load/obj v%p_0;\n", sig); fprintf(vvp_out, " %%prop/str %u;\n", pidx); + fprintf(vvp_out, " %%pop/obj 1, 0;\n"); } static void string_ex_signal(ivl_expr_t expr) diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index 27aa2b6ec..3251c5015 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -897,11 +897,9 @@ the result. * %prop/str Read a vector (/v) or real value (/r) or string (/str) or object from -the property number of the class object on the stop of the +the property number of the class object on the top of the object stack. Push the resulting value to the appropriate stack. The -object that is the source is NOT popped from from object stack. - -The class object stack is NOT popped. +class object that is the source is NOT popped from the object stack. * %pushi/real , diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 4f355d509..f5d2a96a2 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -236,6 +236,7 @@ struct vthread_s { bits4 = vvp_vector4_t(); assert(stack_real_.empty()); assert(stack_str_.empty()); + assert(stack_obj_size_ == 0); } };