Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Issue 13404 - heap-allocating a struct passes TypeInfo_Pointer to the GC, not TypeInfo_struct #941

Merged
merged 1 commit into from Aug 31, 2014

Conversation

rainers
Copy link
Member

@rainers rainers commented Aug 30, 2014

When allocating a struct with "new", do not pass the pointer type info to the GC, but the struct type info.

The fix also provides a small performance improvement as it no longer calls the virtual function TypeInfo.next() multiple times.

https://issues.dlang.org/show_bug.cgi?id=13404

This PR depends on dlang/dmd#3935

@Safety0ff
Copy link
Contributor

LGTM.

@Orvid
Copy link
Contributor

Orvid commented Aug 30, 2014

LGTM

@yebblies
Copy link
Member

Why do it here instead of change the compiler to pass the correct typeid?

@rainers
Copy link
Member Author

rainers commented Aug 30, 2014

Why do it here instead of change the compiler to pass the correct typeid?

Depends on the definition of "correct" ;-) Maybe the passed type info contains some more info like shared or immutable which might be used later?

@yebblies
Copy link
Member

I would assume the correct type is the type being new'd. And why would it matter what the tail type of the pointer is?

@yebblies
Copy link
Member

I mean the head type, I think.

@rainers
Copy link
Member Author

rainers commented Aug 30, 2014

If modifiers are not stripped from the type, removing the pointer type should be fine. But I'd say it should be in another PR (both in dmd and druntime). This just wants to fix the call to the GC.

…o to the runtime, but the struct type info.

The fix also provides a small performance improvement as it no longer calls the virtual function TypeInfo.next() multiple times
@rainers
Copy link
Member Author

rainers commented Aug 31, 2014

Ok, I made the respective changes here and to dmd: dlang/dmd#3935

@yebblies
Copy link
Member

Here goes...

yebblies added a commit that referenced this pull request Aug 31, 2014
Issue 13404 - heap-allocating a struct passes TypeInfo_Pointer to the GC, not TypeInfo_struct
@yebblies yebblies merged commit d0bba64 into dlang:master Aug 31, 2014
@rainers
Copy link
Member Author

rainers commented Aug 31, 2014

Here goes...

Thanks. I cannot wait for the result of the auto-tester now, so in case I blew it, please revert.

@yebblies
Copy link
Member

Thanks. I cannot wait for the result of the auto-tester now, so in case I blew it, please revert.

It's all good.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
4 participants