Skip to content
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

Exclusive Capabilities #22577

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c1e47df
Add Mutable classes and ReadOnly capabilities
odersky Jan 10, 2025
060464f
Drop special handling of functions with pure arguments in Existential…
odersky Dec 15, 2024
b77ad3e
Implement fresh capabilities
odersky Jan 11, 2025
d4e5be7
Separation checking for applications
odersky Jan 11, 2025
16439af
Separation checking for blocks
odersky Jan 12, 2025
f41140e
Address review comments
odersky Jan 19, 2025
24e941e
Use deep capturesets for separation checking.
odersky Jan 20, 2025
061562d
Cache derived reach, readOnly, and maybe capabilities
odersky Jan 20, 2025
d24bf82
Avoid forming intersections of capture sets on refined type lookup
odersky Jan 21, 2025
eb0fe69
Check separation of different parts of a declared type.
odersky Jan 24, 2025
ad6be5b
Check that hidden parameters are annotated @consume
odersky Jan 25, 2025
ffcb9e5
Check that only @consume parameters flow to @consume parameters
odersky Jan 26, 2025
9b5f992
Check that SharedCapabilities don't capture `cap`.
odersky Jan 26, 2025
0672e42
Turn separation checking on by default
odersky Jan 26, 2025
1114c4b
Make sure fresh results of methods only hide local refs
odersky Jan 27, 2025
1c2c5e0
Make sure parameters are not used again after they are consumed
odersky Jan 28, 2025
3c995df
Check accesses to non-local this in hidden sets
odersky Jan 28, 2025
26b1056
Check that @consumed prefix capabilities are not re-used
odersky Jan 29, 2025
01a54cf
Allow SharableCapablity anywhere on a path
odersky Jan 30, 2025
78370ea
Polishings
odersky Jan 31, 2025
623c864
Polish and document separation checker (2)
odersky Feb 7, 2025
f276d72
Address review comments
odersky Feb 7, 2025
28ca79a
chore: Increase the code cache limit
hamzaremmal Feb 10, 2025
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
2 changes: 1 addition & 1 deletion .jvmopts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
-Xms512m
-Xmx4096m
-XX:MaxInlineLevel=35
-XX:ReservedCodeCacheSize=512m
-XX:ReservedCodeCacheSize=1024m
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class BTypesFromSymbols[I <: DottyBackendInterface](val int: I, val frontendAcce
// tests/run/serialize.scala and https://github.com/typelevel/cats-effect/pull/2360).
val privateFlag = !sym.isClass && (sym.is(Private) || (sym.isPrimaryConstructor && sym.owner.isTopLevelModuleClass))

val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.is(Mutable, butNot = Accessor) && !sym.enclosingClass.is(Trait)
val finalFlag = sym.is(Final) && !toDenot(sym).isClassConstructor && !sym.isMutableVar && !sym.enclosingClass.is(Trait)

import asm.Opcodes.*
import GenBCodeOps.addFlagIf
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,8 @@ object desugar {
New(ref(defn.RepeatedAnnot.typeRef), Nil :: Nil))
else if op.name == nme.CC_REACH then
Apply(ref(defn.Caps_reachCapability), t :: Nil)
else if op.name == nme.CC_READONLY then
Apply(ref(defn.Caps_readOnlyCapability), t :: Nil)
else
assert(ctx.mode.isExpr || ctx.reporter.errorsReported || ctx.mode.is(Mode.Interactive), ctx.mode)
Select(t, op.name)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
*/
def isVariableOrGetter(tree: Tree)(using Context): Boolean = {
def sym = tree.symbol
def isVar = sym.is(Mutable)
def isVar = sym.isMutableVarOrAccessor
def isGetter =
mayBeVarGetter(sym) && sym.owner.info.member(sym.name.asTermName.setterName).exists

Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/untpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

case class Var()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)

case class Mut()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Mutable)

case class Implicit()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Implicit)

case class Given()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Given)
Expand Down Expand Up @@ -332,6 +334,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {

def isEnumCase: Boolean = isEnum && is(Case)
def isEnumClass: Boolean = isEnum && !is(Case)
def isMutableVar: Boolean = is(Mutable) && mods.exists(_.isInstanceOf[Mod.Var])
}

@sharable val EmptyModifiers: Modifiers = Modifiers()
Expand Down
Loading
Loading