Skip to content

Commit

Permalink
profile: directly access function body entries
Browse files Browse the repository at this point in the history
... instead of calling FuncSTARTLINE_FUNC
  • Loading branch information
fingolfin authored and ChrisJefferson committed Dec 1, 2017
1 parent 29b748c commit 9a73578
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
12 changes: 0 additions & 12 deletions src/calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,18 +345,6 @@ extern Obj NargError(Obj func, Int actual);
HDLR_XARGS(PROF_FUNC(f))(f,as)


/****************************************************************************
**
*F FuncFILENAME_FUNC(Obj self, Obj func) . . . . . . . filename of function
*F FuncSTARTLINE_FUNC(Obj self, Obj func) . . . . . start line of function
*F FuncENDLINE_FUNC(Obj self, Obj func) . . . . . . . end line of function
**
** These functions, usually exported to GAP, get information about GAP
** functions */
Obj FuncFILENAME_FUNC(Obj self, Obj func);
Obj FuncSTARTLINE_FUNC(Obj self, Obj func);
Obj FuncENDLINE_FUNC(Obj self, Obj func);

/****************************************************************************
**
*F * * * * * * * * * * * * * create a new function * * * * * * * * * * * * *
Expand Down
22 changes: 8 additions & 14 deletions src/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,17 @@ void HookedLineOutput(Obj func, char type)
HashLock(&profileState);
if(profileState_Active && profileState.OutputRepeats)
{
int startline_i = 0, endline_i = 0;
Obj startline = FuncSTARTLINE_FUNC(0, func);
Obj endline = FuncENDLINE_FUNC(0, func);
if(IS_INTOBJ(startline)) {
startline_i = INT_INTOBJ(startline);
}
if(IS_INTOBJ(endline)) {
endline_i = INT_INTOBJ(endline);
}
Obj body = BODY_FUNC(func);
UInt startline = GET_STARTLINE_BODY(body);
UInt endline = GET_ENDLINE_BODY(body);

Obj name = NAME_FUNC(func);
Char *name_c = ((UInt)name) ? (Char *)CHARS_STRING(name) : (Char *)"nameless";
const Char *name_c = name ? CSTR_STRING(name) : "nameless";

Obj filename = FuncFILENAME_FUNC(0, func);
Char *filename_c = (Char*)"<missing filename>";
Obj filename = GET_FILENAME_BODY(BODY_FUNC(func));
const Char *filename_c = "<missing filename>";
if(filename != Fail && filename != NULL)
filename_c = (Char *)CHARS_STRING(filename);
filename_c = CSTR_STRING(filename);

if(type == 'I' && profileState.lastNotOutputted.line != -1)
{
Expand All @@ -210,7 +204,7 @@ void HookedLineOutput(Obj func, char type)

fprintf(profileState.Stream,
"{\"Type\":\"%c\",\"Fun\":\"%s\",\"Line\":%d,\"EndLine\":%d,\"File\":\"%s\"}\n",
type, name_c, startline_i, endline_i, filename_c);
type, name_c, (int)startline, (int)endline, filename_c);
}
HashUnlock(&profileState);
}
Expand Down

0 comments on commit 9a73578

Please sign in to comment.