Skip to content

Commit

Permalink
zeroing weak memory is now treated as weak memory since GC has been d…
Browse files Browse the repository at this point in the history
…ropped
  • Loading branch information
rfm committed Jul 21, 2024
1 parent d2fec6b commit 5699959
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Source/NSConcretePointerFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,24 @@ - (id) initWithOptions: (NSPointerFunctionsOptions)options
DESTROY(self);\
})

_x.options = options;
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
{
/* Garbage Collection is no longer supported, so we treat all weak
* memory the same way.
*/
_x.options = (options & 0xffffff00) | NSPointerFunctionsWeakMemory;
}
else
{
_x.options = options;
}

/* First we look at the memory management options to see which function
* should be used to relinquish contents of a container with these
* options.
*/
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
if (memoryType(options, NSPointerFunctionsWeakMemory)
|| memoryType(options, NSPointerFunctionsZeroingWeakMemory))

This comment has been minimized.

Copy link
@triplef

triplef Jul 22, 2024

Member

Aren’t we effectively replacing NSPointerFunctionsZeroingWeakMemory with NSPointerFunctionsWeakMemory above, and if so wouldn’t be sufficient to just check for NSPointerFunctionsWeakMemory here and below?

{
_x.relinquishFunction = 0;
}
Expand Down Expand Up @@ -234,7 +245,8 @@ - (id) initWithOptions: (NSPointerFunctionsOptions)options
}
else if (personalityType(options, NSPointerFunctionsObjectPointerPersonality))
{
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
if (memoryType(options, NSPointerFunctionsWeakMemory)
|| memoryType(options, NSPointerFunctionsZeroingWeakMemory))
{
_x.acquireFunction = 0;
}
Expand Down Expand Up @@ -284,7 +296,8 @@ - (id) initWithOptions: (NSPointerFunctionsOptions)options
}
else /* objects */
{
if (memoryType(options, NSPointerFunctionsZeroingWeakMemory))
if (memoryType(options, NSPointerFunctionsWeakMemory)
|| memoryType(options, NSPointerFunctionsZeroingWeakMemory))
{
_x.acquireFunction = 0;
}
Expand Down

3 comments on commit 5699959

@rfm
Copy link
Contributor Author

@rfm rfm commented on 5699959 Jul 22, 2024

Choose a reason for hiding this comment

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

Consider the changes a work in progress ...

@hmelder
Copy link
Contributor

Choose a reason for hiding this comment

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

work in progress

Then it should not be in master, right?

@rfm
Copy link
Contributor Author

@rfm rfm commented on 5699959 Jul 22, 2024

Choose a reason for hiding this comment

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

I'm a strong believer in getting improvements into master asap, and also in incremental improvement.
There's quite a lot of old code in base (most of which is fairly harmless), which should be cleaned up when we can do so without breaking backward compatibility.

Please sign in to comment.