-
Notifications
You must be signed in to change notification settings - Fork 1
Optionally use VarHandles for Lazy Vals when targeting JDK 9+ #637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lts-3.3
Are you sure you want to change the base?
Changes from 2 commits
837e74f
9d180f7
56faa64
cc1e052
cc769a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,7 +9,7 @@ import core.Contexts.* | |||||
| import core.Decorators.* | ||||||
| import core.DenotTransformers.IdentityDenotTransformer | ||||||
| import core.Flags.* | ||||||
| import core.NameKinds.{ExpandedName, LazyBitMapName, LazyLocalInitName, LazyLocalName} | ||||||
| import core.NameKinds.{ExpandedName, LazyBitMapName, LazyLocalInitName, LazyLocalName, LazyVarHandleName} | ||||||
| import core.StdNames.nme | ||||||
| import core.Symbols.* | ||||||
| import core.Types.* | ||||||
|
|
@@ -27,8 +27,10 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer { | |||||
| * The map contains the list of the offset trees. | ||||||
| */ | ||||||
| class OffsetInfo(var defs: List[Tree], var ord: Int = 0) | ||||||
| class VarHandleInfo(var defs: List[Tree]) | ||||||
|
|
||||||
| private val appendOffsetDefs = mutable.Map.empty[Symbol, OffsetInfo] | ||||||
| private val appendVarHandleDefs = mutable.Map.empty[Symbol, VarHandleInfo] | ||||||
|
|
||||||
| override def phaseName: String = LazyVals.name | ||||||
|
|
||||||
|
|
@@ -108,12 +110,19 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer { | |||||
| */ | ||||||
| override def transformTemplate(template: Template)(using Context): Tree = { | ||||||
| val cls = ctx.owner.asClass | ||||||
| appendOffsetDefs.get(cls) match { | ||||||
| case None => template | ||||||
| case Some(data) => | ||||||
| data.defs.foreach(defin => defin.symbol.addAnnotation(Annotation(defn.ScalaStaticAnnot, defin.symbol.span))) | ||||||
| cpy.Template(template)(body = addInFront(data.defs, template.body)) | ||||||
| } | ||||||
| if !selectImpl.useVarHandles then //ctx.settings.YlegacyLazyVals.value then | ||||||
|
||||||
| if !selectImpl.useVarHandles then //ctx.settings.YlegacyLazyVals.value then | |
| if !selectImpl.useVarHandles then |
is this needed still?
WojciechMazur marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's plenty of usages, the check might allocate on each usage mostly due to .toInt or .toIntOption conversions, so let's skip redundant calculations - unlikely to change
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -java-output-version:8 | ||
| -Ylegacy-lazy-vals:false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to explicitlly guard these on JDK8: their usage is not reachable on JDK8