Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Compilers/Core/Portable/Serialization/ObjectWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,8 @@ private void WriteArray(Array array)
// don't blow the stack. 'LongRunning' ensures that we get a dedicated thread
// to do this work. That way we don't end up blocking the threadpool.
var task = Task.Factory.StartNew(
() => WriteArrayValues(array),
a => WriteArrayValues((Array)a),
Copy link
Member

Choose a reason for hiding this comment

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

wait... doesn't this still need to capture 'this'?

Copy link
Member Author

@davkean davkean Jul 11, 2017

Choose a reason for hiding this comment

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

@CyrusNajmabadi and I spoke offline. There's still an allocation of a delegate - it doesn't appear to be showing at all on the radar. I looked at the code gen and figured out why:

  • The first thing that the compiler does in the method is instantiate the capture class and "capture" array.
  • It then replaces all reads/writes of the parameter to the field in the capture class

Basically, in summary it looks like this method is always paying for the capture class regardless of the branch. That's why the delegate creation itself isn't showing - the branch is never hit.

array,
_cancellationToken,
TaskCreationOptions.LongRunning,
TaskScheduler.Default);
Expand Down