Skip to content

Conversation

Keno
Copy link
Member

@Keno Keno commented Jun 13, 2024

This is a re-worked extraction of #54654, adjusted to support the new semantics arrived at over the course of that thread. Note that this is the data-structure change only. The semantics in this PR still match current master to the greatest extent possible.

The core idea here is to split Binding in two: A new Binding with minimal data and a BindingPartition that holds all data that is world-age partitioned. In the present PR, these are always in 1:1 correspondednce, but after #54654, there will be multiple BindingPartitions for every Binding.

Essentially the owner and ty fields have been merged into a new restriction field of BindingPartition, which may also hold the value of a constant (consistent with the final semantics reached in #54654). The non-partitioned binding->value field is now used exclusively for non-constant globals. The disambiguation for how to interpret the restriction field happens via flags. ->imported grew to 2 bits and can now be one of NONE/IMPLICIT/ EXPLICIT/GUARD. GUARD corresponds to the old b->owner == NULL case. NONE corresponds to the old b->owner == b case, while IMPLICIT/EXPLICIT correspond to b->owner != b and the old imported flag. Other than that, the behavior of the flags is unchanged.

Additionally, fields are provided for min_world/max_world/next, but these are unused in this PR and prepratory only.

@Keno Keno requested review from vtjnash and topolarity June 13, 2024 05:51
@Keno Keno mentioned this pull request Jun 13, 2024
14 tasks
src/codegen.cpp Outdated
jl_value_t *ty = jl_atomic_load_relaxed(&bnd->ty);
jl_binding_partition_t *bpart = jl_get_binding_partition(bnd, ctx.max_world);
if (bpart && !bpart->constp) {
jl_value_t *ty = bpart->restriction;
if (ty != nullptr) {
Copy link
Member

Choose a reason for hiding this comment

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

I believe this needs additional guards now, for this case:

julia> global x::Int64
julia> foo() = (global x; x)
julia> foo() # emits code w/ stores/loads directly to binding->value
julia> const x = 15 # does not update binding->value any more
julia> foo() # should be 15

Copy link
Member Author

Choose a reason for hiding this comment

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

Invalidation will take care of this.

@Keno Keno force-pushed the kf/constgloballowerrefactor branch 3 times, most recently from df97a48 to dfaa660 Compare June 14, 2024 06:40
src/julia.h Outdated
* First look at ->imported (see above). If NONE, but `->constp`, this holds the
* value of the constant. Otherwise this is a global and holds the type restriction.
*/
jl_value_t *restriction;
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth using Core.Const(...) here, instead of the constp logic?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that would be semantically consistent and reasonable, but there isn't really any benefit to doing so.

// ->restriction does not hold any import-related data.
BINDING_IMPORT_NONE = 0x0,
// Implicit: The binding was implicitly import from a `using`'d module.
// ->restriction holds the imported binding
Copy link
Member

Choose a reason for hiding this comment

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

Is this still a short-circuit link to the defining module, or is it now the immediate module involved in the local using/import?

I'm assuming that we're expecting to maintain backlinks from all the intermediate modules that a binding was resolved through, so that a change to any of them splits all downstream binding partitions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it short circuits. I haven't worked out the backedges yet.

Copy link
Member Author

Choose a reason for hiding this comment

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

I changed my mind on this. It no longer short circuits in the latest version.

src/julia.h Outdated
uint8_t constp:1;
uint8_t exportp:1; // `public foo` sets `publicp`, `export foo` sets both `publicp` and `exportp`
uint8_t publicp:1; // exportp without publicp is not allowed.
uint8_t imported:1;
uint8_t imported:2; // enum jl_binding_import
uint8_t usingfailed:1;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this should be BINDING_IMPORT_FAILED now

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

@Keno Keno force-pushed the kf/constgloballowerrefactor branch 3 times, most recently from 499eed2 to f00f2e6 Compare June 19, 2024 23:33
Base automatically changed from kf/constgloballowerrefactor to master June 23, 2024 13:57
@Keno Keno force-pushed the kf/bindingstructrefactor branch 4 times, most recently from 890e668 to c2cc636 Compare June 26, 2024 21:01
@Keno
Copy link
Member Author

Keno commented Jun 26, 2024

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Jun 27, 2024

@nanosoldier runtests(["Tricks", "ComputationalResources", "ModuleInterfaceTools", "MultilineStrings", "ImportAll", "ForceImport", "InvariantsCore", "Syslogs", "TranscodingStreams", "EulerAngles", "MarkdownAST", "MD5", "StrFormat", "MiniLoggers", "JACC", "Invariants", "Automa", "BufferedStreams", "Setfield", "ClimaUtilities", "OctreeBH", "NonNegLeastSquaresMLJInterface", "HolidayCalendars", "KiwiConstraintSolver", "MixedStructTypes", "DistributedArrays", "MLJTSVDInterface", "HMMER", "CryptographicHashFunctions", "FASTX", "Neighborhood", "ShuffleProofs", "HOHQMesh", "Rocket", "JSON3", "TypedFASTX", "StrEntities", "OutlierDetectionTrees", "QuantumAlgebra", "SelfOrganizingMaps", "OneRule", "MLJDecisionTreeInterface", "LinearFold", "PAndQ", "ArtGallery", "OutlierDetectionNeighbors", "PkgJogger", "MultivariateMoments", "OnlineTechnicalIndicators", "ParallelKMeans", "ModuleInfo", "CharacteristicInvFourier", "MetaGraphsNext", "Strs", "BioRecordsProcessing", "GFF3", "ToolipsSession", "DataGraphs", "GAP", "BurrowsWheelerAligner", "TerminalUserInterfaces", "MLJClusteringInterface", "PreprocessMD", "InferenceObjects", "BibParser", "LazyAlgebra", "Bibliography", "CitationRecipes", "ChunkedCSV", "Infernal", "Logomaker", "NLopt", "CUBScout", "BlackBoxOptim", "MLJGLMInterface", "ExtendableGrids", "AbstractPPL", "StateSpaceEcon", "StaticWebPages", "DocumenterCitations", "KroneckerProductKernels", "Microbiome", "AbstractLogic", "Gaugefields", "COBREXA", "ScikitLearn", "BaytesOptim", "Bijectors", "Gtk", "DoseCalculators", "MLJLinearModels", "TwoDots", "MEstimation", "TuringCallbacks", "GtkSourceWidget", "MLJNaiveBayesInterface", "StatsLearnModels", "SliceSampling", "Ripserer", "MLJXGBoostInterface", "Baytes", "PhyloCoalSimulations", "DrugInteractions", "NonconvexMMA", "ClimaCoreSpectra", "MetidaNLopt", "QuartetNetworkGoodnessFit", "ProfileView", "ClimaCoreVTK", "OutlierDetectionNetworks", "TwoDotsModels", "PsychomotorVigilanceTask", "MLJEnsembles", "PhyloPlots", "MLJText", "MGVI", "MLJTestInterface", "OutlierDetectionTest", "MLJIteration", "ClimaCoreTempestRemap", "OutlierDetection", "PhyloGaussianBeliefProp", "RandomFeatures", "MLJParticleSwarmOptimization", "MCMCTempering", "YAXArrays", "MLJSerialization", "SpikeSorting", "MLJTuning", "ITensorGaussianMPS", "GenerativeTopographicMapping", "TenNetLib", "MicroCanonicalHMC", "EvoLinear", "PhyloDiamond", "GMMParameterEstimation", "PowerPlots", "ITensorVisualizationBase", "MAGEMinApp", "DecomposingPolynomialSystems", "MLJTestIntegration", "JointEnergyModels", "TrajGWAS", "MLJ", "BellDiagonalQudits", "GameTheory", "NonconvexJuniper", "NonconvexIpopt", "NonconvexPavito", "EqualitySampler", "RFFMakie", "PolynomialGTM", "SeisMakie", "GtkUtilities", "SimpleCrop", "SpectralStatistics", "PhyNEST", "ProbabilisticEchoInversion", "LeafGasExchange", "Garlic", "TaijaData", "ObservableCortex", "DiskArrayEngine", "MendelImpute", "SharedArrays", "QuadraticProgramNetworks"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Jun 27, 2024

@nanosoldier runtests(["ModuleInterfaceTools", "Tricks", "Syslogs", "ComputationalResources", "JACC", "OctreeBH", "MarkdownAST", "Invariants", "StrFormat", "InvariantsCore", "HolidayCalendars", "KiwiConstraintSolver", "Neighborhood", "MiniLoggers", "FASTX", "ArtGallery", "CryptographicHashFunctions", "Automa", "TypedFASTX", "MultilineStrings", "ShuffleProofs", "ToolipsSession", "MD5", "TranscodingStreams", "TerminalUserInterfaces", "MixedStructTypes", "BurrowsWheelerAligner", "BioRecordsProcessing", "CitationRecipes", "ModuleInfo", "BibParser", "CUBScout", "AbstractPPL", "OutlierDetectionTrees", "LinearFold", "GFF3", "AbstractLogic", "Bibliography", "StaticWebPages", "PAndQ", "Strs", "Gtk", "DoseCalculators", "Setfield", "QuantumAlgebra", "TwoDots", "PkgJogger", "DataGraphs", "GtkSourceWidget", "OneRule", "NonNegLeastSquaresMLJInterface", "BlackBoxOptim", "MLJClusteringInterface", "MEstimation", "MLJTSVDInterface", "DrugInteractions", "Microbiome", "KroneckerProductKernels", "PreprocessMD", "PsychomotorVigilanceTask", "MetaGraphsNext", "TwoDotsModels", "ParallelKMeans", "Rocket", "Logomaker", "OutlierDetectionNeighbors", "ProfileView", "MLJTestInterface", "BaytesOptim", "MLJDecisionTreeInterface", "SelfOrganizingMaps", "HMMER", "MLJText", "DocumenterCitations", "MLJNaiveBayesInterface", "SpikeSorting", "MultivariateMoments", "OutlierDetectionTest", "MLJSerialization", "DistributedArrays", "Infernal", "PhyloCoalSimulations", "PhyloPlots", "ChunkedCSV", "MLJXGBoostInterface", "MLJGLMInterface", "QuartetNetworkGoodnessFit", "ExtendableGrids", "HOHQMesh", "StateSpaceEcon", "MLJIteration", "MLJParticleSwarmOptimization", "MLJTestIntegration", "Gaugefields", "SliceSampling", "MGVI", "MetidaNLopt", "OutlierDetection", "NLopt", "GMMParameterEstimation", "InferenceObjects", "MLJEnsembles", "SharedArrays", "DecomposingPolynomialSystems", "GtkUtilities", "COBREXA", "PhyloDiamond", "ScikitLearn", "ITensorGaussianMPS", "Bijectors", "MLJLinearModels", "EvoLinear", "PhyloGaussianBeliefProp", "JSON3", "NonconvexMMA", "YAXArrays", "BellDiagonalQudits", "MAGEMinApp", "MLJTuning", "LazyAlgebra", "StatsLearnModels", "TuringCallbacks", "OutlierDetectionNetworks", "GenerativeTopographicMapping", "TenNetLib", "ITensorVisualizationBase", "Ripserer", "MCMCTempering", "PhyNEST", "SeisMakie", "RandomFeatures", "JointEnergyModels", "EqualitySampler", "TaijaData", "ObservableCortex", "DiskArrayEngine", "SpectralStatistics", "NonconvexPavito", "MendelImpute", "LeafGasExchange", "RFFMakie", "PowerPlots", "SimpleCrop", "MLJ", "TrajGWAS", "Garlic", "GameTheory", "NonconvexJuniper", "NonconvexIpopt"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno Keno force-pushed the kf/bindingstructrefactor branch from aa4b302 to d1d842e Compare August 4, 2024 03:05
@Keno
Copy link
Member Author

Keno commented Aug 4, 2024

@nanosoldier runtests(["Tricks", "ComputationalResources", "Syslogs", "JACC", "OctreeBH", "Neighborhood", "ToolipsSession", "Automa", "MixedStructTypes", "AbstractLogic", "TwoDots", "DoseCalculators", "GtkSourceWidget", "QuantumAlgebra", "Gtk", "PkgJogger", "TwoDotsModels", "MEstimation", "PsychomotorVigilanceTask", "DrugInteractions", "BlackBoxOptim", "Rocket", "ProfileView", "SpikeSorting", "ExtendableGrids", "MultivariateMoments", "DistributedArrays", "StateSpaceEcon", "MGVI", "SharedArrays", "GtkUtilities", "NonconvexMMA", "NLopt", "MetidaNLopt", "Gaugefields", "ScikitLearn", "LazyAlgebra", "JSON3", "RandomFeatures", "MLJTuning", "COBREXA", "BellDiagonalQudits", "TrajGWAS", "EqualitySampler", "PowerPlots", "MendelImpute", "GameTheory"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Aug 4, 2024

@nanosoldier runtests(["Tricks", "Syslogs", "ComputationalResources", "JACC", "OctreeBH", "Neighborhood", "ToolipsSession", "Gtk", "DoseCalculators", "AbstractLogic", "Automa", "SharedArrays", "MEstimation", "MixedStructTypes", "DrugInteractions", "TwoDotsModels", "PsychomotorVigilanceTask", "SpikeSorting", "ProfileView", "BlackBoxOptim", "GtkUtilities", "PkgJogger", "MetidaNLopt", "NonconvexMMA", "MGVI", "Rocket", "StateSpaceEcon", "ScikitLearn", "BellDiagonalQudits", "Gaugefields", "NLopt", "COBREXA", "DistributedArrays", "PowerPlots", "TrajGWAS", "MultivariateMoments", "GameTheory", "ExtendableGrids", "MLJTuning", "EqualitySampler", "RandomFeatures", "LazyAlgebra", "MendelImpute", "JSON3", "QuantumAlgebra"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Aug 10, 2024

@nanosoldier runtests(["Tricks", "Syslogs", "ComputationalResources", "JACC", "OctreeBH", "ToolipsSession", "SharedArrays", "MixedStructTypes", "PkgJogger", "MetidaNLopt", "NonconvexMMA", "BellDiagonalQudits", "ScikitLearn", "Gaugefields", "NLopt", "COBREXA", "DistributedArrays", "RandomFeatures", "GameTheory", "ExtendableGrids", "TrajGWAS", "PowerPlots", "MendelImpute", "JSON3", "QuantumAlgebra"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Aug 12, 2024

Alright, I've restored all the old semantics, with the exception of

const x = 2
x = 3

and other attempts to redefine constants using setglobal!, which is now an error (and will be after full partition). Constant redefinition using the keyword, i.e.

const x = 2
const x = 3

and remains undefined behavior (for now).

I'm planning to address the atomics concerns and then merge this in the near future.

@Keno
Copy link
Member Author

Keno commented Aug 29, 2024

I think this should be good to go now. I've gone through and addressed the review comments. I'll run another round of pkgeval. Unless there's something pressing, I think I'll take anything additional post-commit since this is one of those branches that keeps accumulating conflicts and I need to keep the full partition branch up-to-date as well.

For compat with current semantics.
@Keno
Copy link
Member Author

Keno commented Aug 29, 2024

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

Your job failed. Consult the server logs for more details (cc @maleadt).

@Keno
Copy link
Member Author

Keno commented Aug 29, 2024

@nanosoldier runtests()

@maleadt

This comment was marked as resolved.

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno Keno merged commit 7ea8a9a into master Aug 29, 2024
6 of 8 checks passed
@Keno Keno deleted the kf/bindingstructrefactor branch August 29, 2024 17:21
@nsajko
Copy link
Contributor

nsajko commented Aug 30, 2024

This seems to break CI consistently: #55642

EDIT: also, the PkgEval above seems to find an "unreachable reached" situation in one or two packages

KristofferC pushed a commit that referenced this pull request Sep 12, 2024
This codepath is odd. It derives a method name from the slotname
metadata and then does an implicit assignment to that slot. Worse, as
the comment indicates, the codepath is missing from the interpreter,
which will crash if it were to ever encounter such a piece of code. I
suspect this pattern is unused - I accidentally broke it badly in (the
as of yet unmerged PR) #54788 and neither tests nor pkgeval noticed. So
let's try removing it on master. If it turns out something does depend
on it, we can go the opposite way and implement it properly in all the
places that look at :method.
KristofferC pushed a commit that referenced this pull request Sep 12, 2024
This is a re-worked extraction of #54654, adjusted to support the new
semantics arrived at over the course of that thread. Note that this is
the data-structure change only. The semantics in this PR still match
current master to the greatest extent possible.

The core idea here is to split `Binding` in two: A new `Binding` with
minimal data and a `BindingPartition` that holds all data that is
world-age partitioned. In the present PR, these are always in 1:1
correspondednce, but after #54654, there will be multiple
`BindingPartition`s for every `Binding`.

Essentially the `owner` and `ty` fields have been merged into a new
`restriction` field of `BindingPartition`, which may also hold the value
of a constant (consistent with the final semantics reached in #54654).
The non-partitioned binding->value field is now used exclusively for
non-constant globals. The disambiguation for how to interpret the
`restriction` field happens via flags. `->imported` grew to 2 bits and
can now be one of `NONE`/`IMPLICIT`/ `EXPLICIT`/`GUARD`. `GUARD`
corresponds to the old `b->owner == NULL` case. `NONE` corresponds to
the old `b->owner == b` case, while IMPLICIT/EXPLICIT correspond to
`b->owner != b` and the old `imported` flag. Other than that, the
behavior of the flags is unchanged.

Additionally, fields are provided for `min_world`/`max_world`/`next`,
but these are unused in this PR and prepratory only.
maleadt added a commit to JuliaGPU/GPUCompiler.jl that referenced this pull request Sep 17, 2024
maleadt added a commit to JuliaGPU/GPUCompiler.jl that referenced this pull request Sep 17, 2024
maleadt added a commit to JuliaGPU/GPUCompiler.jl that referenced this pull request Sep 17, 2024
mlechu added a commit to mlechu/JuliaLowering.jl that referenced this pull request Apr 18, 2025
Adapt to Core.Binding changes in JuliaLang/julia#54788.  Also remove
     `is_defined_nothrow_global` (JuliaLang/julia#56746)
aviatesk pushed a commit to aviatesk/JuliaLowering.jl that referenced this pull request Jun 14, 2025
Adapt to Core.Binding changes in JuliaLang/julia#54788.  Also remove
     `is_defined_nothrow_global` (JuliaLang/julia#56746)
aviatesk pushed a commit to aviatesk/JuliaLowering.jl that referenced this pull request Jun 14, 2025
Adapt to Core.Binding changes in JuliaLang/julia#54788.  Also remove
     `is_defined_nothrow_global` (JuliaLang/julia#56746)
aviatesk pushed a commit to aviatesk/JuliaLowering.jl that referenced this pull request Jul 2, 2025
Adapt to Core.Binding changes in JuliaLang/julia#54788.  Also remove
     `is_defined_nothrow_global` (JuliaLang/julia#56746)
aviatesk pushed a commit to aviatesk/JuliaLowering.jl that referenced this pull request Jul 2, 2025
Adapt to Core.Binding changes in JuliaLang/julia#54788.  Also remove
     `is_defined_nothrow_global` (JuliaLang/julia#56746)
mlechu added a commit to mlechu/JuliaLowering.jl that referenced this pull request Jul 29, 2025
mlechu added a commit to mlechu/JuliaLowering.jl that referenced this pull request Jul 29, 2025
mlechu added a commit to mlechu/JuliaLowering.jl that referenced this pull request Jul 30, 2025
mlechu added a commit to mlechu/JuliaLowering.jl that referenced this pull request Aug 2, 2025
mlechu added a commit to c42f/JuliaLowering.jl that referenced this pull request Aug 4, 2025
* Update CodeInfo struct and handling

Co-authored-by: Claire Foster <[email protected]>

* Don't produce raw symbol from globalref

This used to implicitly refer to a module-level name, but lowering is now
expected to wrap it in a `globalref`. Part of JuliaLang/julia#54772

* Updates to const and global lowering; add K"constdecl"; omit `wrap`

JuliaLang/julia#54773, JuliaLang/julia#56713, JuliaLang/julia#57470. Some
     changes omitted from `expand-decls` and `expand-assignment`.

Note that the two-argument IR "const" is K"constdecl", whereas the one-argument
    K"const" only appears in the AST.

Also note that the `wrap` parameter is omitted throughout assignment desugaring.
      As far as I'm aware, all this plumbing was just to support `const a,b,c =
     1,2,3` having `b` and `c` inherit the `const`.  TODO: find a better way of
     doing the same thing (a ScopedValue might be a clean solution; we currently
     throw an error).

The check for `let; const x = 1; end`, (which should throw) is in scope
     analysis (lisp has it in `compile`).

Co-authored-by: Claire Foster <[email protected]>

* Add `isdefinedglobal` builtin

JuliaLang/julia#54999, JuliaLang/julia#56985

* :global no longer valid_ir_argument; rm `is_defined_nothrow_global`

JuliaLang/julia#56746.  Also call :slot and :static_parameter valid (for now)

* Fix `is_defined_and_owned_global` (Core.Binding changes)

Adapt to bpart changes in JuliaLang/julia#54788

* Struct desugaring: "Undo decision to publish incomplete types..."

JuliaLang/julia#56497; Add self-referencing struct shim

I have doubts about how long this solution will stay in the base repository, and
     how complete it is (doesn't seem to work with M1.M2.S), but we are testing
     for it here.

Also change the expected value of a test changed in the same PR.

* Emit `latestworld` world age increments

For method defs, `latestworld` is produced in desugaring rather than closure
conversion for now (our closure conversion doesn't seem to cover the same
cases as lisp lowering yet).

Covers JuliaLang/julia#56523, JuliaLang/julia#56509, JuliaLang/julia#57299.

Also includes changes from JuliaLang/julia#57102 (bpart: Start enforcing minimum
world age for const bparts) and JuliaLang/julia#57150 (bpart: Start enforcing
min_world for global variable definitions) since the lowering changes from those
appear to be amendments to the changes above (missing world age increments).

Co-authored-by: Claire Foster <[email protected]>

* bpart changes: `Core._typebody!` signature

`Core._typebody!` now takes a new "prev" argument, which we don't use yet here.
 Changes from JuliaLang/julia#57253

* bpart changes: struct desugaring

Changes from JuliaLang/julia#57253 (bpart: Fully switch to partitioned
     semantics).  This fixes one failing test and realigns struct desugaring to
     match lisp for now.

Also changed: the expected result of redefining a primitive type (now allowed).

* Additional argument in `new_opaque_closure`

Fix segfaulting test.  Thanks for the TODO

* Adapt to different `GeneratedFunctionStub` signature

Signature changed in JuliaLang/julia#57230.  Thanks @aviatesk for the help!

* Fix `public` and `export`

As of JuliaLang/julia#57765, `jl_module_public` is no longer exported.  Change
our runtime to handle it like `public` and `export` like we handle `import`
or `using` for now

* Fix modules.jl test

I believe this was a world age issue

* Regenerate IR tests

Too many to count.

* Update README to known-good julia, JuliaSyntax versions

Latest julia works.  Changes are needed to work with the latest JuliaSyntax, but
     that isn't in base julia yet, and more changes are likely to come.

* Fix small bug from #16 so tests pass

The change lifted the scope of `note`, so it was being changed in the loop

* Changes from code review: const/global lowering

Ping me if you'd like this squashed into the original const/global commit!

Co-authored-by: Claire Foster <[email protected]>

* Remove a special case

No longer needed since we no longer put `global` or `local` forms back into the
     expand_forms machine.  Some error messages change slightly as a result.

* Changes from code review

Co-authored-by: Claire Foster <[email protected]>

* Fix + test for assignment in value but not tail position

* Disallow `static_parameter` as `valid_ir_argument`

See added comment, and discussion at
    #10 (comment)

Co-authored-by: Claire Foster <[email protected]>

* Change printing of `K"latestworld"`

Parens are nice, but it wasn't consistent.

Also make it a leaf (remaining non-leaves are deleted in the next commit.)

* Move most `latestworld`s to linearization

From the docs:
```
The following statements raise the current world age:
    1. An explicit invocation of Core.@latestworld
    2. The start of every top-level statement
    3. The start of every REPL prompt
    4. Any type or struct definition
    5. Any method definition
    6. Any constant declaration
    7. Any global variable declaration (but not a global variable assignment)
    8. Any using, import, export or public statement
    9. Certain other macros like eval (depends on the macro implementation)
```

This commit handles each case as follows:

```
    1. = 9
    2. I'm not sure this actually happens (or needs to happen, unless we're
       being defensive? Doing it after each world-changing operation should
       suffice).  But if we need it, this would just be emitting once at the
       beginning of every lowered output.
    3. = 2
    4. = 6
    5. Emit seeing `method` in linearize
    6. Emit seeing `constdecl` in linearize
    7. Emit seeing `global` or `globaldecl` in linearize
    8. We just defer to `eval`, but should probably go in desugaring later
       - using/import recently became builtin calls, and I haven't
         updated JL to use them yet.  Base._import_using has an expr-based
         API that may change, and our importpath destructuring is worth keeping.
       - export and public (special forms) are handled in toplevel.c
    9. Done for us
```

Other quirks:

- `JuliaLowering.eval_closure_type` calls eval to assign a const, so we still
    need to deal with that in closure conversion.

- The `include` hack isn't mentioned in the docs, but can stay in desugaring.
      I'm not certain why we don't do the same for non-macro `eval`.

---------

Co-authored-by: Claire Foster <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants