Skip to content

[Evaluator] Separate formation of a request from evaluation of that request #17643

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

Merged

Conversation

DougGregor
Copy link
Member

The bundling of the form of a request (e.g., the storage that makes up a request)
with the function that evaluates the request value requires us to perform
ad hoc indirection to address the AST —> Sema layering violation. For
example, ClassDecl::getSuperclass() calls through the LazyResolver (when
available) to form the appropriate request. This means that we cannot
use the the request-evaluator’s cache when LazyResolver is NULL, forcing
all cached state into the AST.

Provide the evaluator with a zone-based registration system, where each
request “zone” (e.g., the type checker’s requests) registers
callbacks to evaluate each kind of request within that zone. The
evaluator indirects through this table of function pointers, allowing
the request classes themselves to be available at a lower level (AST)
than the functions that perform the computation when the value isn’t
in the cache (e.g., Sema).

Leverage this separation so that the AST library can form type-check requests, which are evaluated by the Sema library. We'll still end up jumping through the LazyResolver when we need the type checker... but it's much more localized, and only happens in the "no cached result yet" case.

…ached().

We had duplicated logic for stats recording and pretty stack traces, including
missing one pretty stack trace. Eliminate duplication.
…te table.

The bundling of the form of a request (e.g., the storage that makes up a request)
with the function that evaluates the request value requires us to perform
ad hoc indirection to address the AST —> Sema layering violation. For
example, ClassDecl::getSuperclass() calls through the LazyResolver (when
available) to form the appropriate request. This means that we cannot
use the the request-evaluator’s cache when LazyResolver is null, forcing
all cached state into the AST.

Provide the evaluator with a zone-based registration system, where each
request “zone” (e.g., the type checker’s requests) registers
callbacks to evaluate each kind of request within that zone. The
evaluator indirects through this table of function pointers, allowing
the request classes themselves to be available at a lower level (AST)
than the functions that perform the computation when the value isn’t
in the cache (e.g., Sema).

We are not taking advantage of the indirection yet; that’ll come in a
follow-up commit.
Sink the type checker request classes into the AST library, so that
various functions in the AST library can form type-checking requests.
The actual evaluator functions for these requests continue to live
in the Sema library, called via indirection through the function
pointer tables registered with the request-evaluator.
Rather than call through the LazyResolver (when available) to satisfy
queries that may require type checking, call into the evaluator
directly: it will make use of the type checker (via the lazy resolver)
when necessary. This change should allow us to use the
request-evaluator’s cache for state rather than mutable AST state,
as well as the ability to see requests that were evaluated after
type checking.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@slavapestov slavapestov merged commit 1a8a70e into swiftlang:master Jun 30, 2018
@DougGregor DougGregor deleted the evaluator-indirect-evaluation branch June 30, 2018 01:18
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.

2 participants