Skip to content

Commit

Permalink
Give useful names to installed methods
Browse files Browse the repository at this point in the history
This makes these methods easier to understand when profiling.
We add a name both to the installed method, and the function
which calculates their rank, where present.
  • Loading branch information
ChrisJefferson committed May 8, 2019
1 parent 4a3108e commit ff2c1fd
Show file tree
Hide file tree
Showing 4 changed files with 710 additions and 59 deletions.
23 changes: 22 additions & 1 deletion lib/oper1.g
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ BIND_GLOBAL( "INSTALL_METHOD",
rank,
method,
oreqs,
req, reqs, match, j, k, imp, notmatch, lk;
req, reqs, match, j, k, imp, notmatch, lk, funcname;

if IsHPCGAP then
# TODO: once the GAP compiler supports 'atomic', use that
Expand Down Expand Up @@ -601,6 +601,27 @@ BIND_GLOBAL( "INSTALL_METHOD",
fi;
fi;

if IS_FUNCTION(method) and IsBound(HasNameFunction) and IsBound(TYPE_FUNCTION) and IsBound(TYPE_FUNCTION_WITH_NAME) and IsBound(TYPE_OPERATION_WITH_NAME) and not VAL_GVAR("HasNameFunction")(method) then
funcname := SHALLOW_COPY_OBJ(NAME_FUNC(opr));
APPEND_LIST_INTR(funcname, " ");
if info <> false then
APPEND_LIST_INTR(funcname, info);
else
APPEND_LIST_INTR(funcname, "method");
fi;
SET_NAME_FUNC(method, funcname);
fi;

if IS_FUNCTION(rank) and IsBound(HasNameFunction) and IsBound(TYPE_FUNCTION) and IsBound(TYPE_FUNCTION_WITH_NAME) and IsBound(TYPE_OPERATION_WITH_NAME) and not VAL_GVAR("HasNameFunction")(rank) then
funcname := "Priority calculation for ";
APPEND_LIST_INTR(funcname, NAME_FUNC(opr));
if info <> false then
APPEND_LIST_INTR(funcname, " ");
APPEND_LIST_INTR(funcname, info);
fi;
SET_NAME_FUNC(rank, funcname);
fi;

# Install the method in the operation.
INSTALL_METHOD_FLAGS( opr, info, rel, flags, rank, method );

Expand Down
Loading

0 comments on commit ff2c1fd

Please sign in to comment.