Commit 2a281178 by Martin Liska Committed by Martin Liska

Code refactoring for call_summary.

2018-06-08  Martin Liska  <mliska@suse.cz>

	* symbol-summary.h (release): Move definition out of class
	declaration.
	(symtab_removal): Likewise.
	(symtab_duplication): Likewise.

From-SVN: r261308
parent ef2ceb10
2018-06-08 Martin Liska <mliska@suse.cz> 2018-06-08 Martin Liska <mliska@suse.cz>
* symbol-summary.h (release): Move definition out of class
declaration.
(symtab_removal): Likewise.
(symtab_duplication): Likewise.
2018-06-08 Martin Liska <mliska@suse.cz>
* symbol-summary.h (function_summary): Move constructor * symbol-summary.h (function_summary): Move constructor
implementation out of class declaration. implementation out of class declaration.
(release): Likewise. (release): Likewise.
......
...@@ -330,21 +330,7 @@ public: ...@@ -330,21 +330,7 @@ public:
} }
/* Destruction method that can be called for GGT purpose. */ /* Destruction method that can be called for GGT purpose. */
void release () void release ();
{
if (m_released)
return;
m_symtab->remove_edge_removal_hook (m_symtab_removal_hook);
m_symtab->remove_edge_duplication_hook (m_symtab_duplication_hook);
/* Release all summaries. */
typedef typename hash_map <map_hash, T *>::iterator map_iterator;
for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
release ((*it).second);
m_released = true;
}
/* Traverses all summarys with a function F called with /* Traverses all summarys with a function F called with
ARG as argument. */ ARG as argument. */
...@@ -369,16 +355,7 @@ public: ...@@ -369,16 +355,7 @@ public:
} }
/* Release an item that is stored within map. */ /* Release an item that is stored within map. */
void release (T *item) void release (T *item);
{
if (m_ggc)
{
item->~T ();
ggc_free (item);
}
else
delete item;
}
/* Getter for summary callgraph edge pointer. */ /* Getter for summary callgraph edge pointer. */
T* get (cgraph_edge *edge) T* get (cgraph_edge *edge)
...@@ -399,37 +376,11 @@ public: ...@@ -399,37 +376,11 @@ public:
} }
/* Symbol removal hook that is registered to symbol table. */ /* Symbol removal hook that is registered to symbol table. */
static void symtab_removal (cgraph_edge *edge, void *data) static void symtab_removal (cgraph_edge *edge, void *data);
{
call_summary *summary = (call_summary <T *> *) (data);
int h_uid = summary->hashable_uid (edge);
T **v = summary->m_map.get (h_uid);
if (v)
{
summary->remove (edge, *v);
summary->release (*v);
summary->m_map.remove (h_uid);
}
}
/* Symbol duplication hook that is registered to symbol table. */ /* Symbol duplication hook that is registered to symbol table. */
static void symtab_duplication (cgraph_edge *edge1, cgraph_edge *edge2, static void symtab_duplication (cgraph_edge *edge1, cgraph_edge *edge2,
void *data) void *data);
{
call_summary *summary = (call_summary <T *> *) (data);
T **v = summary->m_map.get (summary->hashable_uid (edge1));
if (v)
{
/* This load is necessary, because we insert a new value! */
T *data = *v;
T *duplicate = summary->allocate_new ();
summary->m_map.put (summary->hashable_uid (edge2), duplicate);
summary->duplicate (edge1, edge2, data, duplicate);
}
}
protected: protected:
/* Indication if we use ggc summary. */ /* Indication if we use ggc summary. */
...@@ -475,6 +426,72 @@ private: ...@@ -475,6 +426,72 @@ private:
template <typename T> template <typename T>
void void
call_summary<T *>::release ()
{
if (m_released)
return;
m_symtab->remove_edge_removal_hook (m_symtab_removal_hook);
m_symtab->remove_edge_duplication_hook (m_symtab_duplication_hook);
/* Release all summaries. */
typedef typename hash_map <map_hash, T *>::iterator map_iterator;
for (map_iterator it = m_map.begin (); it != m_map.end (); ++it)
release ((*it).second);
m_released = true;
}
template <typename T>
void
call_summary<T *>::release (T *item)
{
if (m_ggc)
{
item->~T ();
ggc_free (item);
}
else
delete item;
}
template <typename T>
void
call_summary<T *>::symtab_removal (cgraph_edge *edge, void *data)
{
call_summary *summary = (call_summary <T *> *) (data);
int h_uid = summary->hashable_uid (edge);
T **v = summary->m_map.get (h_uid);
if (v)
{
summary->remove (edge, *v);
summary->release (*v);
summary->m_map.remove (h_uid);
}
}
template <typename T>
void
call_summary<T *>::symtab_duplication (cgraph_edge *edge1,
cgraph_edge *edge2, void *data)
{
call_summary *summary = (call_summary <T *> *) (data);
T **v = summary->m_map.get (summary->hashable_uid (edge1));
if (v)
{
/* This load is necessary, because we insert a new value! */
T *data = *v;
T *duplicate = summary->allocate_new ();
summary->m_map.put (summary->hashable_uid (edge2), duplicate);
summary->duplicate (edge1, edge2, data, duplicate);
}
}
template <typename T>
void
gt_ggc_mx(call_summary<T *>* const &summary) gt_ggc_mx(call_summary<T *>* const &summary)
{ {
gcc_checking_assert (summary->m_ggc); gcc_checking_assert (summary->m_ggc);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment