May 06, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to jmh530 | On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
> On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
>>
>> I'm not sure, but one would think that @safe code wouldn't need any extra information about the union. I wouldn't know how to differentiate between them though during runtime. Probably someone with more experience with the compiler would know more about that kind of thing.
>
> You can identify safe functions with
> https://dlang.org/phobos/std_traits.html#isSafe
> or
> https://dlang.org/phobos/std_traits.html#functionAttributes
All I meant was that I don't know enough about what the compiler does with built in types to make this work. It almost sounds like we would need a safe union and unsafe union type and do some extra stuff for the unsafe union, but I'm just starting to learn about this stuff.
|
May 06, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeremy DeHaan | On 06-May-2016 05:37, Jeremy DeHaan wrote: > On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote: >> On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote: >>> >>> I'm not sure, but one would think that @safe code wouldn't need any >>> extra information about the union. I wouldn't know how to >>> differentiate between them though during runtime. Probably someone >>> with more experience with the compiler would know more about that >>> kind of thing. >> >> You can identify safe functions with >> https://dlang.org/phobos/std_traits.html#isSafe >> or >> https://dlang.org/phobos/std_traits.html#functionAttributes > > All I meant was that I don't know enough about what the compiler does > with built in types to make this work. It almost sounds like we would > need a safe union and unsafe union type and do some extra stuff for the > unsafe union, but I'm just starting to learn about this stuff. I'd note that a union without pointers doesn't hurt precise scanner, it's only the ones with pointers that are bad. -- Dmitry Olshansky |
May 06, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On 5/6/16 11:06 AM, Dmitry Olshansky wrote:
> On 06-May-2016 05:37, Jeremy DeHaan wrote:
>> On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
>>> On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
>>>>
>>>> I'm not sure, but one would think that @safe code wouldn't need any
>>>> extra information about the union. I wouldn't know how to
>>>> differentiate between them though during runtime. Probably someone
>>>> with more experience with the compiler would know more about that
>>>> kind of thing.
>>>
>>> You can identify safe functions with
>>> https://dlang.org/phobos/std_traits.html#isSafe
>>> or
>>> https://dlang.org/phobos/std_traits.html#functionAttributes
>>
>> All I meant was that I don't know enough about what the compiler does
>> with built in types to make this work. It almost sounds like we would
>> need a safe union and unsafe union type and do some extra stuff for the
>> unsafe union, but I'm just starting to learn about this stuff.
>
> I'd note that a union without pointers doesn't hurt precise scanner,
> it's only the ones with pointers that are bad.
>
Ones that have only pointers are probably OK too. Though I'm not sure if a precise scanner takes into account the type of the pointer. I would expect it to use embedded typeinfo in target block.
-Steve
|
May 06, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jeremy DeHaan | On Tuesday, 3 May 2016 at 18:15:20 UTC, Jeremy DeHaan wrote:
> Not sure if it is something I can get to in the course of my project though. Scanning only unions conservatively is still pretty good.
And the stack, and the CPU registers, but yeah, it should be a minority.
|
May 08, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Friday, 6 May 2016 at 09:31:08 UTC, Steven Schveighoffer wrote:
> On 5/6/16 11:06 AM, Dmitry Olshansky wrote:
>> On 06-May-2016 05:37, Jeremy DeHaan wrote:
>>> On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
>>>> On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
>>>>>
>>>>> I'm not sure, but one would think that @safe code wouldn't need any
>>>>> extra information about the union. I wouldn't know how to
>>>>> differentiate between them though during runtime. Probably someone
>>>>> with more experience with the compiler would know more about that
>>>>> kind of thing.
>>>>
>>>> You can identify safe functions with
>>>> https://dlang.org/phobos/std_traits.html#isSafe
>>>> or
>>>> https://dlang.org/phobos/std_traits.html#functionAttributes
>>>
>>> All I meant was that I don't know enough about what the compiler does
>>> with built in types to make this work. It almost sounds like we would
>>> need a safe union and unsafe union type and do some extra stuff for the
>>> unsafe union, but I'm just starting to learn about this stuff.
>>
>> I'd note that a union without pointers doesn't hurt precise scanner,
>> it's only the ones with pointers that are bad.
>>
>
> Ones that have only pointers are probably OK too. Though I'm not sure if a precise scanner takes into account the type of the pointer. I would expect it to use embedded typeinfo in target block.
>
> -Steve
Because of void* and classes, the GC MUST be able to find out what type was actually allocated, or at least its pointer bitmask.
|
May 08, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dmitry Olshansky | On Friday, 6 May 2016 at 09:06:59 UTC, Dmitry Olshansky wrote:
> On 06-May-2016 05:37, Jeremy DeHaan wrote:
>> On Wednesday, 4 May 2016 at 12:42:30 UTC, jmh530 wrote:
>>> On Wednesday, 4 May 2016 at 02:50:08 UTC, Jeremy DeHaan wrote:
>>>
>>> You can identify safe functions with
>>> https://dlang.org/phobos/std_traits.html#isSafe
>>> or
>>> https://dlang.org/phobos/std_traits.html#functionAttributes
>>
>> All I meant was that I don't know enough about what the compiler does
>> with built in types to make this work. It almost sounds like we would
>> need a safe union and unsafe union type and do some extra stuff for the
>> unsafe union, but I'm just starting to learn about this stuff.
>
> I'd note that a union without pointers doesn't hurt precise scanner, it's only the ones with pointers that are bad.
Union is an user-defined-kind value and only user codes can tell the difference. I believe this will also effect the reference count implementation. I suggest that when a type has a union member, it should create a function such as gcValues with a parameter of output range of record (offset: size_t, type: typeid). the function should return that info based on whatever the actual value of those pointer types. If that function is missing, use conservative approach as before
Cheers
Pham
|
May 09, 2016 Re: GSoC 2016 - Precise GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | On Sunday, 8 May 2016 at 11:16:56 UTC, deadalnix wrote:
>> Ones that have only pointers are probably OK too. Though I'm not sure if a precise scanner takes into account the type of the pointer. I would expect it to use embedded typeinfo in target block.
>>
>> -Steve
>
> Because of void* and classes, the GC MUST be able to find out what type was actually allocated, or at least its pointer bitmask.
Yep, and it does that by looking at metadata of the pointed object itself, it doesn't care about the type of pointer to that object. I mean if we have object x of class X in heap and pointers "X p1", "void* p2" and "Y p3" all having same value &x (pointing to the same address) then GC will have no problem in scanning x as long as it can access x's type info knowing the address of x in heap. Which means all p1, p2 and p3 might easily be just at one position in a union and that would not be a problem.
|
Copyright © 1999-2021 by the D Language Foundation