bug icon indicating copy to clipboard operation
bug copied to clipboard

Make AnyVals Easier To Use

Open scabug opened this issue 10 years ago • 1 comments

Proposal: Add a compiler flag that makes it easier to know when an AnyVal allocation occurs.

AnyVals can radically improve performance, but allocations can occur in surprising places (removing any performance gains). SIP-15 documents the conditions under which allocation occurs, but that can be hard to remember when browsing a complicated program. Compiler support for detecting allocations would help a lot.

A couple of possible flags are:

  • Warning - Generate a compiler warning when a use-site will require an AnyVal to be allocated.
  • Throw on Allocate - Add a flag that causes an exception to be thrown when an AnyVal is allocated. The resulting stack trace should allow the programmer to track down the allocation easily.

scabug avatar Oct 05 '15 16:10 scabug

Imported From: https://issues.scala-lang.org/browse/SI-9504?orig=1 Reporter: Justin Bailey (m4dc4p)

scabug avatar Oct 05 '15 16:10 scabug

@som-snytt did you do a thing like this under -Wperformance?

SethTisue avatar Feb 07 '23 18:02 SethTisue

I see the linked (duplicating) ticket links to the -Wperformance PR which warns for Ref heapification which is not all boxing.

som-snytt avatar Feb 07 '23 18:02 som-snytt

I'll let @SethTisue choose which ticket to close. It's nice to honor earlier reports, like being the first to name a species, but the other ticket has slightly more attention due its high-profile reporter.

som-snytt avatar Feb 07 '23 18:02 som-snytt

consolidating at #12271

SethTisue avatar Feb 07 '23 21:02 SethTisue