Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
9079745
Discard some unused backtrace functions.
unkadoug Mar 3, 2017
facfe37
Merge branch 'master' into unwind-clean-2017
unkadoug Mar 3, 2017
46ee6b8
Delete hpcrun_dbg_generate_backtrace, as it is unused.
unkadoug Mar 3, 2017
beba927
Delete unused functions.
unkadoug Mar 3, 2017
ab9f319
Discard needless code around simulate_segv for x86.
unkadoug Mar 3, 2017
00bc758
Drop hpcrun_check_fence and incorporate it into its one caller.
unkadoug Mar 3, 2017
9dd8694
Drop unw_step_prefer_sp.
unkadoug Mar 3, 2017
36d2adc
Have a single declaration of hpcrun_set_real_siglongjmp.
unkadoug Mar 3, 2017
4b7ce53
Stop assigning to cursor->flags for x86, since the value is never read,
unkadoug Mar 3, 2017
e36f3e5
Remove unneeded extern declaration.
unkadoug Mar 4, 2017
3415638
In unwindr_info_t, replace the start/end pair with an interval, which…
unkadoug Mar 6, 2017
09a60bf
hpcrun_dump_intervals and hpcrun_dump_intervals_noisy are the same fu…
unkadoug Mar 6, 2017
90d4d12
The treestat should not be seen as forthcoming, since we wait here until
unkadoug Mar 7, 2017
1d542f4
Drop an unused struct definition.
unkadoug Mar 7, 2017
6d4afe5
Inline ildmod_stat_build into the one place that invokes it.
unkadoug Mar 7, 2017
0a56c4d
Drop ildmod_stat.c. Move the remaining (debug-only) functions to uw_…
unkadoug Mar 7, 2017
af1931f
Drop hpcrun_bt_beg, hpcrun_bt_last.
unkadoug Mar 7, 2017
1b43076
Don't cast a void* to a void*.
unkadoug Mar 7, 2017
149551f
Drop write-only variable.
unkadoug Mar 7, 2017
a023d56
backtrace_info_t has a member n_trolls and a member trolled, and
unkadoug Mar 7, 2017
578040f
Shrink backtrace_info_t by packing bools, enum into fewer bytes.
unkadoug Mar 7, 2017
e11df35
Drop a duplicated check of fence_stop.
unkadoug Mar 7, 2017
a24665c
Merge away uw_recipe.h, since only one file includes it.
unkadoug Mar 31, 2017
2a48a37
Restore main.c to what is it on master, restoring seemingly useless d…
unkadoug Apr 3, 2017
ecab168
Drop an unused function.
unkadoug Apr 3, 2017
c06afd3
Define a nextInsn instruction, as we do on ppc64, for composing
unkadoug Apr 4, 2017
16606a7
Separate x86 registers into their own struct, and pass a register set
unkadoug Apr 4, 2017
32d91a0
Fix problem introduced by x86 register changes. Eliminate some dupli…
unkadoug Apr 5, 2017
615685a
Eliminate some redundant calculation.
unkadoug Apr 6, 2017
b87c16f
Clean up no-trampoline.
unkadoug Apr 6, 2017
c047002
Merge remote-tracking branch 'origin' into unwind-clean-2017
unkadoug Apr 6, 2017
5cde599
Initialize the libunwind cursor with local_signal to address
unkadoug Apr 7, 2017
0d0d138
Catch up to master.
unkadoug Apr 9, 2017
abfbd2a
Restore correct ip update in x86 disassembly.
unkadoug Apr 10, 2017
7833d2e
Merge branch 'master' into unwind-clean-2017
unkadoug Apr 28, 2017
04ce2ad
Merge branch 'master' into unwind-clean-2017
unkadoug May 1, 2017
fc76e60
Remote link to hold tree together.
unkadoug May 5, 2017
278b01e
Using a modified libunwind, process dwarf content for a procedure
unkadoug May 5, 2017
aad9493
Merge branch 'master' into unwind-clean-2017
unkadoug May 10, 2017
c1d9b08
Merge branch 'master' into unwind-clean-2017
unkadoug May 11, 2017
010386a
Build unbalanced tree of intervals with the same rightward
unkadoug May 11, 2017
9d85199
Make an interval, not a pointer to an interval, a member of ildmod_st…
unkadoug May 11, 2017
fe1521f
fix typo
unkadoug May 11, 2017
fde1e1d
Make interval, not a pointer to interval, part of a uwi_t, the unwind
unkadoug May 11, 2017
1288e96
Drop unused function.
unkadoug May 11, 2017
22fdd15
Add a soothing typecast.
unkadoug May 12, 2017
5644c45
Allocate the recipe space and the interval space for the uwi in a
unkadoug May 12, 2017
19a5e8d
Factor out some duplicated code.
unkadoug May 15, 2017
3723cea
Handle the possibility that build_intervals will fail. Let the invok…
unkadoug May 15, 2017
4829dcc
Count the new unwind intervals created and give the count to
unkadoug May 16, 2017
2234179
Merge branch 'master' into unwind-clean-2017
unkadoug May 18, 2017
ce44f8f
Avoid an extra atomic load
unkadoug May 22, 2017
4d4c84c
drop some unused functions.
unkadoug May 22, 2017
2eea961
Drop unused function.
unkadoug May 30, 2017
4a4ac91
Drop some ununsed functions. Combine the allocation of tree pointers…
unkadoug May 30, 2017
4da53ca
Deleting a binary tree no longer requires a separate freeing of the n…
unkadoug May 30, 2017
c652e5c
Balance the tree of right children without data copying.
unkadoug May 31, 2017
0a316e7
Represent the thread-specific free lists of tree nodes
unkadoug Jun 1, 2017
ed52818
Drop unused function.
unkadoug Jun 1, 2017
88a1276
A fix to memory allocation size applied to libunw ought to have been
unkadoug Jun 1, 2017
c88420e
Fix interval count to consider the effect of coalescing intervals.
unkadoug Jun 1, 2017
a5ee784
Tweak the hack that lets me avoid special-casing the saving of the
unkadoug Jun 2, 2017
c8ec9de
Have a single call to hpc_set_real_siglongjmp.
unkadoug Jun 2, 2017
1d594d7
Consolidate some memory management functions. Add/drop header files …
unkadoug Jun 2, 2017
b93e378
Drop unused routines.
unkadoug Jun 5, 2017
b88cee9
Don't have a separate pointer field in ilmstat_btuwi_pair_t
unkadoug Jun 6, 2017
d0486a8
Use 'lm' for load module everywhere, instead of mixing lm, ldmod, etc.
unkadoug Jun 6, 2017
9195284
Drop ildmod_stat.h, and merge it info unwindr_info.h.
unkadoug Jun 6, 2017
5122e90
Only uw_recipe_map.c needs to see the ilmstat_btuwi_pair_t struct.
unkadoug Jun 6, 2017
16d7063
Eliminate ildmod_stat_t struct. Merge it into the ildmod_btuwi_pair …
unkadoug Jun 6, 2017
656a8b6
Drop unneeded clearing of field.
unkadoug Jun 6, 2017
b445bc4
Don't bother initializing ilmstat_btuwi fields for node going on the …
unkadoug Jun 6, 2017
90669d2
Delete authorship comments that no longer reflect who is responsible
unkadoug Jun 7, 2017
2d8e5d6
Make comparators static.
unkadoug Jun 7, 2017
fbfdccf
Apply struct change to ppc.
unkadoug Jun 7, 2017
c822367
Merge branch 'master' into unwind-clean-2017
unkadoug Jun 8, 2017
4d755aa
Drop unused fields from libunw cursor. Reorder the remaining fields …
unkadoug Jun 9, 2017
f732c78
Drop 2 more unused libunw cursor fields.
unkadoug Jun 9, 2017
d65991d
Drop another unused libunw cursor member.
unkadoug Jun 9, 2017
c537d83
Supply a missing function declaration.
unkadoug Jun 12, 2017
71ecbc2
For cold path fixup, walk the interval list from start to current,
unkadoug Jun 21, 2017
a90ffd0
Instead of marking a restored canonical in an x86 recipe, identify th…
unkadoug Jun 21, 2017
6f7cb08
Delete the remnants of UWI_PREV.
unkadoug Jun 21, 2017
1f5f00d
Merge branch 'master' into unwind-clean-2017
unkadoug Jun 27, 2017
98aae03
Fix merge glitches.
unkadoug Jun 27, 2017
8b81906
Merge branch 'master' into unwind-clean-2017
unkadoug Jun 29, 2017
94c12b1
Rerun autoreconf to solve a problem of missing dependencies.
unkadoug Jul 7, 2017
e7ed83e
Make a function static.
unkadoug Jul 7, 2017
e1ef051
Drop leftover call to bitree_uwi_finalize.
unkadoug Jul 10, 2017
8bc815b
A piece of merge-from-master introduces backwards pointers, which
unkadoug Jul 10, 2017
05b9496
Restore field to libunw cursor that aren't used by libunw unwinding,
unkadoug Jul 11, 2017
ef60bd7
Eliminate the use of unw_word_t outside of code working with libunwind.
unkadoug Jul 11, 2017
ee9c6bf
For whatever it's worth, set the fence value for libunwinding in the
unkadoug Jul 11, 2017
1cbbf18
Drop a debug message from backtrace.c, so that two fields can be dropped
unkadoug Jul 11, 2017
26ee4a3
Merge branch 'master' into unwind-clean-2017
unkadoug Aug 4, 2017
6daa3a3
Merge branch 'master' into unwind-clean-2017
unkadoug Aug 10, 2017
0d65c37
Handle the possibility that the last range that libunwind presents us
unkadoug Aug 16, 2017
adf8308
Merge branch 'master' into unwind-clean-2017
unkadoug Sep 7, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
176 changes: 44 additions & 132 deletions src/lib/prof-lean/binarytree.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,25 +103,6 @@ typedef struct binarytree_s {
// private operations
//******************************************************************************

// perform an in order traversal and collect nodes into a vector
static void
tree_to_vector_helper
(binarytree_t *nvec[],
binarytree_t *node,
int *count)
{
if (node) {
// add nodes in left subtree to vector
tree_to_vector_helper(nvec, node->left, count);

// add subtree root to vector
nvec[(*count)++] = node;

// add nodes in right subtree to vector
tree_to_vector_helper(nvec, node->right, count);
}
}

static void
subtree_tostr2(binarytree_t *subtree, val_tostr tostr, char valstr[],
char* left_lead, char result[])
Expand Down Expand Up @@ -157,13 +138,11 @@ subtree_tostr2(binarytree_t *subtree, val_tostr tostr, char valstr[],


binarytree_t *
binarytree_new(void *value, binarytree_t *left, binarytree_t *right,
mem_alloc m_alloc)
binarytree_new(size_t size, mem_alloc m_alloc)
{
binarytree_t *node = (binarytree_t *)m_alloc(sizeof(binarytree_t));
node->right = right;
node->left = left;
node->val = value;
binarytree_t *node = (binarytree_t *)m_alloc(sizeof(binarytree_t) + size);
node->right = NULL;
node->left = NULL;
return node;
}

Expand All @@ -173,9 +152,6 @@ void binarytree_del(binarytree_t **root, mem_free m_free)
if (*root) {
binarytree_del(&((*root)->left), m_free);
binarytree_del(&((*root)->right), m_free);
if ((*root)->val) {
m_free((*root)->val);
}
m_free(*root);
*root = NULL;
}
Expand Down Expand Up @@ -206,15 +182,6 @@ binarytree_rightsubtree(binarytree_t *tree)
return tree->right;
}

void
binarytree_set_rootval(
binarytree_t *tree,
void* rootval)
{
assert(tree != NULL);
tree->val = rootval;
}

void
binarytree_set_leftsubtree(
binarytree_t *tree,
Expand All @@ -240,46 +207,52 @@ binarytree_count(binarytree_t *tree)
binarytree_count(tree->left) + binarytree_count(tree->right) + 1: 0;
}

binarytree_t *
binarytree_list_to_tree(binarytree_t ** head, int count)
{
if (count == 0)
return NULL;
int mid = count >> 1;
binarytree_t *left = binarytree_list_to_tree(head, mid);
binarytree_t *root = *head;
root->left = left;
*head = (*head)->right;
root->right = binarytree_list_to_tree(head, count - mid - 1);
return root;
}

void
binarytree_to_vector(binarytree_t *nvec[], binarytree_t *tree)
binarytree_listify_helper(binarytree_t *root, binarytree_t **tail)
{
int count = 0;
tree_to_vector_helper(nvec, tree, &count);
if (root != NULL) {
binarytree_listify_helper(root->left, tail);
root->left = NULL;
*tail = root;
tail = &root->right;
binarytree_listify_helper(root->right, tail);
}
}

// post-condition: 0 <= |depth(left subtree) - depth(right subtree)| <= 1
binarytree_t *
vector_to_binarytree(binarytree_t *nvec[], int lo, int hi)
binarytree_listify(binarytree_t *root)
{
// the midpoint of the subvector is the root of the subtree
int mid = ((hi - lo) >> 1) + lo;
binarytree_t *root = nvec[mid];

// build left subtree, if any, from nodes to the left of the midpoint
root->left = (mid != lo) ? vector_to_binarytree(nvec, lo, mid - 1) : NULL;

// build right subtree, if any, from nodes to the right of the midpoint
root->right = (mid != hi) ? vector_to_binarytree(nvec, mid + 1, hi) : NULL;

return root;
binarytree_t *head;
binarytree_listify_helper(root, &head);
return head;
}

binarytree_t *
binarytree_rebalance(binarytree_t * root)
binarytree_listalloc(size_t elt_size, int num_elts, mem_alloc m_alloc)
{
if (!root) return root;

int n = binarytree_count(root);

// collect tree nodes in order into a vector
binarytree_t *vec[n];
binarytree_to_vector(vec, root);

// construct a balanced binary tree from an ordered vector of nodes
return vector_to_binarytree(vec, 0, n - 1);
binarytree_t *head;
binarytree_t **tail = &head;
while (num_elts--) {
*tail = binarytree_new(elt_size, m_alloc);
tail = &(*tail)->right;
}
return head;
}


binarytree_t *
binarytree_find(binarytree_t * root, val_cmp matches, void *val)
{
Expand Down Expand Up @@ -339,78 +312,17 @@ binarytree_height(binarytree_t *root)
return 0;
}

bool
binarytree_is_balanced(binarytree_t *root)
{
if (root) {
int ldepth = binarytree_height(root->left);
int rdepth = binarytree_height(root->right);
if (rdepth - ldepth > 1) return 0;
if (!binarytree_is_balanced(root->left)) return 0;
if (!binarytree_is_balanced(root->right)) return 0;
}
return 1;
}

bool
binarytree_is_inorder(binarytree_t *root, val_cmp compare)
{
if (!root) return true; // empty tree is trivially in order
if (root->left) {
// value at node is smaller than left child's
if (compare(root->left->val, root->val) >= 0) return false;
// left subtree is not in order
if (!binarytree_is_inorder(root->left, compare)) return false;
}
if (root->right) {
// value at node is larger than right child's
if (compare(root->right->val, root->val) <= 0) return false;
// right subtree is not in order
if (!binarytree_is_inorder(root->right, compare)) return false;
}
return true; // tree is in order
}

binarytree_t *
binarytree_insert(binarytree_t *root, val_cmp compare, void *val, mem_alloc m_alloc)
binarytree_insert(binarytree_t *root, val_cmp compare, binarytree_t *key)
{
if(!root) {
return binarytree_new(val, NULL, NULL, m_alloc); // empty tree case
return key; // empty tree case
}
else if (compare(root->val, val) > 0) {
root->left = binarytree_insert(root->left, compare, val, m_alloc);
else if (compare(root->val, key->val) > 0) {
root->left = binarytree_insert(root->left, compare, key);
}
else if (compare(root->val, val) < 0) {
root->right = binarytree_insert(root->right, compare, val, m_alloc);
else if (compare(root->val, key->val) < 0) {
root->right = binarytree_insert(root->right, compare, key);
}
return root;
}

binarytree_t*
binarytree_remove_leftmostleaf(binarytree_t **tree)
{
if (*tree == NULL) {
return NULL;
}
if ((*tree)->left){
return binarytree_remove_leftmostleaf(&((*tree)->left));
}
else if ((*tree)->right) {
return binarytree_remove_leftmostleaf(&((*tree)->right));
}
else {
binarytree_t *rml = *tree;
*tree = NULL;
return rml;
}
}

void
binarytree_leftmostleaf_to_root(binarytree_t **tree)
{
if (*tree) {
binarytree_t *lml = binarytree_remove_leftmostleaf(tree);
lml->left = *tree;
*tree = lml;
}
}
58 changes: 11 additions & 47 deletions src/lib/prof-lean/binarytree.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,14 @@ typedef struct binarytree_s binarytree_t;
typedef struct binarytree_s {
struct binarytree_s *left;
struct binarytree_s *right;
void* val;
char val[];
} binarytree_t;

#endif

// constructors
binarytree_t *
binarytree_new(void* value, binarytree_t *left, binarytree_t *right,
mem_alloc m_alloc);
binarytree_new(size_t size, mem_alloc m_alloc);

// destructor
void binarytree_del(binarytree_t **root, mem_free m_free);
Expand All @@ -131,11 +130,6 @@ binarytree_rightsubtree(binarytree_t *tree);
* Settors
*/
void
binarytree_set_rootval(
binarytree_t *tree,
void* rootval);

void
binarytree_set_leftsubtree(
binarytree_t *tree,
binarytree_t* subtree);
Expand All @@ -149,19 +143,18 @@ binarytree_set_rightsubtree(
int
binarytree_count(binarytree_t *node);

// linearize a binary tree in order traversal into a vector
void
binarytree_to_vector(binarytree_t *nvec[], binarytree_t *tree);
// given a tree that is a list, with all left children empty,
// restructure to make a balanced tree
binarytree_t *
binarytree_list_to_tree(binarytree_t ** head, int count);

// construct a balanced binary tree from a vector of nodes.
// post-condition: 0 <= |height(left subtree) - height(right subtree)| <= 1
// restructure a binary tree so that all its left children are null
binarytree_t *
vector_to_binarytree(binarytree_t *nvec[], int l, int u);
binarytree_listify(binarytree_t *root);

// perform bulk rebalancing by gathering nodes into a vector and
// rebuilding the tree from scratch using the same nodes.
// allocate a binary tree so that all its left children are null
binarytree_t *
binarytree_rebalance(binarytree_t *tree);
binarytree_listalloc(size_t elt_size, int num_elts, mem_alloc m_alloc);

// use binarytree_node_cmp to find a matching node in a binary search tree.
// NULL is returned
Expand All @@ -187,36 +180,7 @@ binarytree_tostring_indent(binarytree_t *tree, val_tostr tostr,
int
binarytree_height(binarytree_t *tree);

// an empty binary tree is balanced.
// a non-empty binary tree is balanced iff the difference in height between
// the left and right subtrees is less or equal to 1.
bool
binarytree_is_balanced(binarytree_t *tree);

// an empty binary tree is in order
// an non-empty binary tree is in order iff
// its left subtree is in order and all of its elements are < the root element
// its right subtree is in order and all of its elements are > the root element
bool
binarytree_is_inorder(binarytree_t *tree, val_cmp compare);


binarytree_t *
binarytree_insert(binarytree_t *tree, val_cmp compare, void *val, mem_alloc m_alloc);

/*
* if the tree is not NULL, remove the leftmost left node from the tree, make it
* the new root of the tree, and set its left subtree to the old tree.
* if the tree is NULL, do nothing.
*/
void
binarytree_leftmostleaf_to_root(binarytree_t **tree);

/*
* if the tree != NULL, remove and return the leftmost leaf node from the tree,
* otherwise return NULL.
*/
binarytree_t*
binarytree_remove_leftmostleaf(binarytree_t **tree);
binarytree_insert(binarytree_t *tree, val_cmp compare, binarytree_t *key);

#endif
3 changes: 1 addition & 2 deletions src/tool/hpcrun/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ UNW_UNIV_FILES = \
UNW_COMMON_FILES = \
$(UNW_UNIV_FILES) \
unwind/common/binarytree_uwi.c \
unwind/common/ildmod_stat.c \
unwind/common/interval_t.c \
unwind/common/stack_troll.c \
unwind/common/uw_recipe_map.c
Expand Down Expand Up @@ -234,7 +233,7 @@ UNW_PPC64_LD_FLAGS =
# configuration

UNW_LIBUNW_FILES = \
$(UNW_UNIV_FILES) \
$(UNW_COMMON_FILES) \
unwind/generic-libunwind/libunw-unwind.c \
unwind/common/default_validation_summary.c

Expand Down
Loading