Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh] add -profile="gc" switch #4621

Merged
merged 1 commit into from May 1, 2015
Merged

Conversation

WalterBright
Copy link
Member

This is the start of a memory profiler, i.e. throw the switch and the compiler emits code to log all calls to allocate memory. This one only does it for calls to new a class. The following shows how it works:

import core.stdc.stdio;

class C { }

void main() {
    auto b = new C();
}

extern (C) Object _d_newclass(const ClassInfo ci);

extern (C) Object _d_newclassTrace(string file, int line, string funcname, const ClassInfo ci) {
    printf("_d_newclassTrace class = %s file = '%.*s' line = %d function = '%.*s'\n",
    cast(char *)ci.name,
    file.length, file.ptr,
    line,
    funcname.length, funcname.ptr
    );
    return _d_newclass(ci);
}

@WalterBright
Copy link
Member Author

Corresponding issue:
https://issues.dlang.org/show_bug.cgi?id=14527

@WalterBright
Copy link
Member Author

The failure is another heisenbug, nothing to do with this PR.

@yebblies
Copy link
Member

If you go on this page and click the 'deprecate' link it will re-run it.

@WalterBright
Copy link
Member Author

Where is that link? I can't find it.

@WalterBright WalterBright changed the title [Enh] add -profilenew switch [Enh] add -profile="gc" switch May 1, 2015
@yebblies
Copy link
Member

yebblies commented May 1, 2015

Where is that link? I can't find it.

Are you logged into the autotester? It should be there, although it disappears once clicked.

image

@WalterBright
Copy link
Member Author

Here's what I see:
foo

@yebblies
Copy link
Member

yebblies commented May 1, 2015

Yes, the "Deleted: 1" means that it has already been done (happens automatically when the branch is pushed to). Opening a more recent run should show the deprecate link.

@WalterBright
Copy link
Member Author

Makes sense. Thanks for the tip.

@andralex
Copy link
Member

andralex commented May 1, 2015

noice

@andralex
Copy link
Member

andralex commented May 1, 2015

Auto-merge toggled on

andralex added a commit that referenced this pull request May 1, 2015
@andralex andralex merged commit 4de2176 into dlang:master May 1, 2015
@WalterBright WalterBright deleted the newprofile branch May 1, 2015 08:25
@MartinNowak MartinNowak added changelog_v2.068 Needs Changelog A changelog entry needs to be added to /changelog labels Aug 7, 2015
@@ -1384,7 +1385,13 @@ elem *toElem(Expression *e, IRState *irs)
else
{
Symbol *csym = toSymbol(cd);
ex = el_bin(OPcall,TYnptr,el_var(rtlsym[RTLSYM_NEWCLASS]),el_ptr(csym));
if (global.params.tracegc && ne->loc.filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does a NewExpression not have a location? It kind of defeats the point when some allocations aren't accounted for.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes internally generated code doesn't have a location that would make any sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Changelog A changelog entry needs to be added to /changelog
Projects
None yet
4 participants