* src/tgba/tgbaproduct.hh, src/tgba/tgbaproduct.cc: Use
a fixed-size memory pool for product_state instances.
This commit is contained in:
parent
5d12152449
commit
c44b60f08f
3 changed files with 66 additions and 29 deletions
|
|
@ -1,3 +1,8 @@
|
||||||
|
2011-04-03 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
|
* src/tgba/tgbaproduct.hh, src/tgba/tgbaproduct.cc: Use
|
||||||
|
a fixed-size memory pool for product_state instances.
|
||||||
|
|
||||||
2011-04-03 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
2011-04-03 Alexandre Duret-Lutz <adl@lrde.epita.fr>
|
||||||
|
|
||||||
* iface/dve2/dve2.cc: Use a fixed-size memory pool for dve2_state
|
* iface/dve2/dve2.cc: Use a fixed-size memory pool for dve2_state
|
||||||
|
|
|
||||||
|
|
@ -33,19 +33,22 @@ namespace spot
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
// state_product
|
// state_product
|
||||||
|
|
||||||
state_product::state_product(const state_product& o)
|
|
||||||
: state(),
|
|
||||||
left_(o.left()->clone()),
|
|
||||||
right_(o.right()->clone())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
state_product::~state_product()
|
state_product::~state_product()
|
||||||
{
|
{
|
||||||
left_->destroy();
|
left_->destroy();
|
||||||
right_->destroy();
|
right_->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
state_product::destroy() const
|
||||||
|
{
|
||||||
|
if (--count_)
|
||||||
|
return;
|
||||||
|
fixed_size_pool* p = pool_;
|
||||||
|
this->~state_product();
|
||||||
|
p->deallocate(this);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
state_product::compare(const state* other) const
|
state_product::compare(const state* other) const
|
||||||
{
|
{
|
||||||
|
|
@ -67,7 +70,8 @@ namespace spot
|
||||||
state_product*
|
state_product*
|
||||||
state_product::clone() const
|
state_product::clone() const
|
||||||
{
|
{
|
||||||
return new state_product(*this);
|
++count_;
|
||||||
|
return const_cast<state_product*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
@ -80,8 +84,9 @@ namespace spot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tgba_succ_iterator_product_common(tgba_succ_iterator* left,
|
tgba_succ_iterator_product_common(tgba_succ_iterator* left,
|
||||||
tgba_succ_iterator* right)
|
tgba_succ_iterator* right,
|
||||||
: left_(left), right_(right)
|
fixed_size_pool* pool)
|
||||||
|
: left_(left), right_(right), pool_(pool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,13 +125,15 @@ namespace spot
|
||||||
|
|
||||||
state_product* current_state() const
|
state_product* current_state() const
|
||||||
{
|
{
|
||||||
return new state_product(left_->current_state(),
|
return new(pool_->allocate()) state_product(left_->current_state(),
|
||||||
right_->current_state());
|
right_->current_state(),
|
||||||
|
pool_);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
tgba_succ_iterator* left_;
|
tgba_succ_iterator* left_;
|
||||||
tgba_succ_iterator* right_;
|
tgba_succ_iterator* right_;
|
||||||
|
fixed_size_pool* pool_;
|
||||||
friend class spot::tgba_product;
|
friend class spot::tgba_product;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -138,8 +145,9 @@ namespace spot
|
||||||
tgba_succ_iterator_product(tgba_succ_iterator* left,
|
tgba_succ_iterator_product(tgba_succ_iterator* left,
|
||||||
tgba_succ_iterator* right,
|
tgba_succ_iterator* right,
|
||||||
bdd left_neg, bdd right_neg,
|
bdd left_neg, bdd right_neg,
|
||||||
bddPair* right_common_acc)
|
bddPair* right_common_acc,
|
||||||
: tgba_succ_iterator_product_common(left, right),
|
fixed_size_pool* pool)
|
||||||
|
: tgba_succ_iterator_product_common(left, right, pool),
|
||||||
left_neg_(left_neg),
|
left_neg_(left_neg),
|
||||||
right_neg_(right_neg),
|
right_neg_(right_neg),
|
||||||
right_common_acc_(right_common_acc)
|
right_common_acc_(right_common_acc)
|
||||||
|
|
@ -209,8 +217,9 @@ namespace spot
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
tgba_succ_iterator_product_kripke(tgba_succ_iterator* left,
|
tgba_succ_iterator_product_kripke(tgba_succ_iterator* left,
|
||||||
tgba_succ_iterator* right)
|
tgba_succ_iterator* right,
|
||||||
: tgba_succ_iterator_product_common(left, right)
|
fixed_size_pool* pool)
|
||||||
|
: tgba_succ_iterator_product_common(left, right, pool)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -268,7 +277,8 @@ namespace spot
|
||||||
// tgba_product
|
// tgba_product
|
||||||
|
|
||||||
tgba_product::tgba_product(const tgba* left, const tgba* right)
|
tgba_product::tgba_product(const tgba* left, const tgba* right)
|
||||||
: dict_(left->get_dict()), left_(left), right_(right)
|
: dict_(left->get_dict()), left_(left), right_(right),
|
||||||
|
pool_(sizeof(state_product))
|
||||||
{
|
{
|
||||||
assert(dict_ == right_->get_dict());
|
assert(dict_ == right_->get_dict());
|
||||||
|
|
||||||
|
|
@ -338,13 +348,26 @@ namespace spot
|
||||||
if (!left_kripke_)
|
if (!left_kripke_)
|
||||||
bdd_freepair(right_common_acc_);
|
bdd_freepair(right_common_acc_);
|
||||||
dict_->unregister_all_my_variables(this);
|
dict_->unregister_all_my_variables(this);
|
||||||
|
// Prevent these states from being destroyed by ~tgba(): they
|
||||||
|
// will be destroyed before when the pool is destructed.
|
||||||
|
if (last_support_conditions_input_)
|
||||||
|
{
|
||||||
|
last_support_conditions_input_->destroy();
|
||||||
|
last_support_conditions_input_ = 0;
|
||||||
|
}
|
||||||
|
if (last_support_variables_input_)
|
||||||
|
{
|
||||||
|
last_support_variables_input_->destroy();
|
||||||
|
last_support_variables_input_ = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state*
|
state*
|
||||||
tgba_product::get_init_state() const
|
tgba_product::get_init_state() const
|
||||||
{
|
{
|
||||||
return new state_product(left_->get_init_state(),
|
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
|
||||||
right_->get_init_state());
|
return new(p->allocate()) state_product(left_->get_init_state(),
|
||||||
|
right_->get_init_state(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
tgba_succ_iterator*
|
tgba_succ_iterator*
|
||||||
|
|
@ -369,13 +392,15 @@ namespace spot
|
||||||
tgba_succ_iterator* ri = right_->succ_iter(s->right(),
|
tgba_succ_iterator* ri = right_->succ_iter(s->right(),
|
||||||
global_state, global_automaton);
|
global_state, global_automaton);
|
||||||
|
|
||||||
|
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
|
||||||
if (left_kripke_)
|
if (left_kripke_)
|
||||||
return new tgba_succ_iterator_product_kripke(li, ri);
|
return new tgba_succ_iterator_product_kripke(li, ri, p);
|
||||||
else
|
else
|
||||||
return new tgba_succ_iterator_product(li, ri,
|
return new tgba_succ_iterator_product(li, ri,
|
||||||
left_acc_complement_,
|
left_acc_complement_,
|
||||||
right_acc_complement_,
|
right_acc_complement_,
|
||||||
right_common_acc_);
|
right_common_acc_,
|
||||||
|
p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bdd
|
bdd
|
||||||
|
|
@ -470,7 +495,9 @@ namespace spot
|
||||||
state*
|
state*
|
||||||
tgba_product_init::get_init_state() const
|
tgba_product_init::get_init_state() const
|
||||||
{
|
{
|
||||||
return new state_product(left_init_->clone(), right_init_->clone());
|
fixed_size_pool* p = const_cast<fixed_size_pool*>(&pool_);
|
||||||
|
return new(p->allocate()) state_product(left_init_->clone(),
|
||||||
|
right_init_->clone(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
# define SPOT_TGBA_TGBAPRODUCT_HH
|
# define SPOT_TGBA_TGBAPRODUCT_HH
|
||||||
|
|
||||||
#include "tgba.hh"
|
#include "tgba.hh"
|
||||||
|
#include "misc/fixpool.hh"
|
||||||
|
|
||||||
namespace spot
|
namespace spot
|
||||||
{
|
{
|
||||||
|
|
@ -40,18 +41,15 @@ namespace spot
|
||||||
/// \brief Constructor
|
/// \brief Constructor
|
||||||
/// \param left The state from the left automaton.
|
/// \param left The state from the left automaton.
|
||||||
/// \param right The state from the right automaton.
|
/// \param right The state from the right automaton.
|
||||||
|
/// \param pool The pool from which the state was allocated.
|
||||||
/// These states are acquired by spot::state_product, and will
|
/// These states are acquired by spot::state_product, and will
|
||||||
/// be destroyed on destruction.
|
/// be destroyed on destruction.
|
||||||
state_product(state* left, state* right)
|
state_product(state* left, state* right, fixed_size_pool* pool)
|
||||||
: left_(left),
|
: left_(left), right_(right), count_(1), pool_(pool)
|
||||||
right_(right)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Copy constructor
|
virtual void destroy() const;
|
||||||
state_product(const state_product& o);
|
|
||||||
|
|
||||||
virtual ~state_product();
|
|
||||||
|
|
||||||
state*
|
state*
|
||||||
left() const
|
left() const
|
||||||
|
|
@ -72,6 +70,11 @@ namespace spot
|
||||||
private:
|
private:
|
||||||
state* left_; ///< State from the left automaton.
|
state* left_; ///< State from the left automaton.
|
||||||
state* right_; ///< State from the right automaton.
|
state* right_; ///< State from the right automaton.
|
||||||
|
mutable unsigned count_;
|
||||||
|
fixed_size_pool* pool_;
|
||||||
|
|
||||||
|
virtual ~state_product();
|
||||||
|
state_product(const state_product& o); // No implementation.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -120,6 +123,8 @@ namespace spot
|
||||||
bdd all_acceptance_conditions_;
|
bdd all_acceptance_conditions_;
|
||||||
bdd neg_acceptance_conditions_;
|
bdd neg_acceptance_conditions_;
|
||||||
bddPair* right_common_acc_;
|
bddPair* right_common_acc_;
|
||||||
|
fixed_size_pool pool_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Disallow copy.
|
// Disallow copy.
|
||||||
tgba_product(const tgba_product&);
|
tgba_product(const tgba_product&);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue