Repository navigation
[LSP] Document explicit compiler pool scopes - #678
Conversation
Design rationale: retain compiler context, support ordinary host calls
Why the ambient pool must still winAn object's owner and the compiler's current working pool are not interchangeable. Cross-pool operations deliberately bind context so that well-known constants and type operations resolve in that context. Replacing every read with The rule is therefore Boundaries reviewers should preserveThis is a targeted audit of readers that have a meaningful owner. It is not a blanket replacement of every ambient-pool access. Existing There is no dependency on I1 or the later listener/embedding API changes. The independent regression uses the current Validation performedEleven tests executed with zero failures, errors, or skips: three ./gradlew :javatools:test \
--tests org.xvm.asm.ConstantPoolAmbientTest \
--tests org.xvm.asm.constants.MethodBodyAmbientPoolTest \
--tests org.xvm.asm.ConstantPoolDiagnosticsTest \
--tests org.xvm.asm.FloatingConstantPoolTest \
spotlessCheck :xdk:installDist \
--rerun-tasks --no-build-cache --console=plain --quietThe focused tests distinguish absent context from an intentionally bound alternate pool. The full module build checks that normal compilation still completes. A normalized binary-output comparison was not repeated on this master base, so the acceptance claim is successful tests and compilation, not proven byte-for-byte equivalence. Review and validation boundaryTested commit: This is I2 in the foundation series. I1 addresses diagnostic identity; I2 addresses missing ambient constant-pool context. Both target |
|
I should add that I have several valid reproducers in the LSP that proves that this is a problem, and I believe this is the architecturally correct way to fix it. I have also run extensive testing on all existing scenarior to make sure they are still sound and working. |
|
As usual, this can also be backed out as a single self contained commit if something about this doesn't work quite right. When I have the compiler LSP server in you can satisfy that the ownership relations are corrected by this PR by looking at before and after logs. I am very sure I haven't compromised anything else. |
6c6720f to
dd136d3
Compare
|
(And this has to do with the slighty more esoteric modes of compilation that we need to use in the LSP - but rest assure that nothing else gets the wrong pool, defaults to a pool it didn't default o before or has any changed lookup semantics. I have even run fuzzing on this to make sure that the existing functionality is 1-1 preserved) |
|
I'm not sure what the failure scenario is, but I believe this is an incorrect way to go. Our design assumption is that any entrance into the compiler world needs to start with this preamble: My only explanation is that the offending code is not following this. |
ggleyzer
left a comment
There was a problem hiding this comment.
Our design assumption is that any entrance into the compiler world needs to start with this preamble:
try (var _ = ConstantPool.withPool(pool)) {
// whatever you do here will always have ConstantPool.getCurrentPool();
}
My only explanation is that the offending code is not following this.
|
BTW, some of the places you changed are probably old not quite correct code; I will verify/fix |
|
Gene, you are right about the boundary contract. I have withdrawn the owner-fallback design rather than asking you to accept it as an LSP prerequisite. The historical reproducer was an inspection/assertion-formatting operation outside a pool scope. The broader replacement of eighteen reads was preventative, not eighteen separately demonstrated compiler-adapter defects. Preserving an already bound pool made that proposal compatible with the exercised compilation paths, but did not establish that its fallback behavior was necessary. My earlier rationale overstated that conclusion.
The correction commit removes I checked the actual downstream consumer before making this change. The current compiler adapter already wraps semantic extraction, dependency capture and partial semantic inspection in explicit pool scopes, then exposes detached facts to request threads. In an isolated checkout of the full working branch I removed all of I2's production fallbacks and ran the entire adapter-package suite: 1,785 executed tests passed, zero failures/errors; two existing Tree-sitter navigation placeholders were disabled. This includes the compiler navigation/refactoring/partial-analysis suites, concurrent detached-snapshot queries and the 120-cycle retention workload. I also inspected the packaged server bytecode to verify that neither fallback helper was present. Six additional downstream cases passed for successful compilation plus snapshot/artifact extraction, failed compilation, and partial member inspection, each from an unbound caller and an unrelated bound caller. They check semantic results and restoration of the caller pool. The six revised Java scope tests also passed without skips. No adapter production workaround or change was needed for these results. Your follow-up about auditing older call sites remains separate: this PR now leaves those implementations exactly as on the base. Any actual missing scope found there should be fixed at its operation boundary with its own reproducer. The packaged compiler-server protocol suite then passed all 82 cases, with zero failures/errors/skips. Root and LSP formatting checks passed. The fallback-free acceptance used the working LSP tree at Reproduction commands for the full downstream checkout: ./gradlew :lang:lsp-server:test --tests 'org.xvm.lsp.adapter.*' \
--rerun-tasks --no-build-cache \
-PincludeBuildLang=true -PincludeBuildAttachLang=true --console=plain --quiet
./gradlew :lang:lsp-server:test --tests org.xvm.lsp.adapter.CompilerPoolScopeTest \
:lang:lsp-server:compilerStdioTest \
:javatools:test --tests org.xvm.asm.ConstantPoolAmbientTest \
--tests org.xvm.asm.constants.MethodBodyAmbientPoolTest \
spotlessCheck :lang:lsp-server:spotlessCheck \
--rerun-tasks --no-build-cache \
-PincludeBuildLang=true -PincludeBuildAttachLang=true -Plsp.adapter=compiler \
--console=plain --quietI have updated the PR title and description to supersede the original fallback rationale. Please re-review the reduced scope; I am leaving your changes-requested review in place. |
ggleyzer
left a comment
There was a problem hiding this comment.
The new doc is good; the tests have no value IMHO
Preserve the bound compiler pool when present and use each constant's owning pool on unbound host threads. Adapt the independent regression to the current normalized-type API. Re-extracted on master f442ace. Eleven focused tests pass without skips, all 24 XDK modules build and install, and SpotlessCheck passes.
Withdraw the currentOr and poolInUse changes in response to review. Document the existing host boundary contract and exercise scope restoration, executor isolation, cross-pool operations, and scoped method inspection without changing production behavior.
6d33951 to
d8652a5
Compare
Why?
Compiler hosts need the existing working-pool scope contract documented at the API boundary. A constant's owning pool is not necessarily the working pool, and dispatched work must establish its own context.
How?
Document the existing
getCurrentPool()andwithPool(pool)behavior: nullable current context, operation-wide try-with-resources scopes, same-thread restoration, and explicit scopes on worker threads.Implications
This is documentation-only: no production behavior or API changes, and no new tests. It is not a production prerequisite for the compiler adapter.
Changes
javatools/src/main/java/org/xvm/asm/ConstantPool.java: Javadoc only, +11/-1 lines.Following Gene's review, both added Java scope-test classes have been removed in
6d3395101. The same removal is mirrored on the lsp mono-code branch; its tests of actual adapter compilation, partial analysis, and caller-pool restoration remain with that consumer.Validation
./gradlew spotlessCheck --console=plain --quietpassed on the documentation-only revision. The final diff was inspected to confirm that it contains only Javadoc; no new functional test run is claimed for this revision.The earlier fallback-free downstream acceptance remains evidence for the adapter's compatibility: 1,785 adapter cases and all 82 packaged compiler-server protocol cases passed, with two existing disabled adapter tests. The six actual adapter boundary cases also passed. Those results and exact revisions are recorded in the earlier review response; they are not additional files or behavior in this PR.