Commit Graph

42028 Commits

Author SHA1 Message Date
Anton Bannykh 3f57c9b107 JS IR: use ByteBuffer for faster js ast deserialization 2023-01-11 15:56:58 +00:00
Anton Bannykh 698be0fddd JS IR: custom JS AST serialization 2023-01-11 15:56:57 +00:00
Ivan Kochurkin 978f937fa9 [FIR Serialization] Fix serialization of generated nested classifiers
^KT-55759 Fixed
2023-01-11 16:07:02 +01:00
Igor Chevdar 9c86532eb0 [K/N] Implemented cache orchestration machinery in the compiler 2023-01-11 14:13:01 +00:00
Svyatoslav Scherbina b1e3226ed5 K2: add KlibDeserializedContainerSource.isFromNativeInteropLibrary
This will be required when serializing IR symbols referring declarations
from interop libraries.
2023-01-11 11:47:45 +00:00
Svyatoslav Scherbina 6877b2fc55 K2: add KlibDeserializedContainerSource to packages too
^KT-55809
2023-01-11 11:47:45 +00:00
Svyatoslav Kuzmich 1564de5859 [Wasm] Support external vararg
Initial implementation copies Wasm array to JS array and spreads it
2023-01-11 10:35:36 +00:00
Kirill Rakhman 69f2e8826a FIR: fix a bunch of issues after DiagnosticsReporter refactoring related to reporting diagnostic on null source 2023-01-11 08:30:36 +00:00
Kirill Rakhman a7edf5b83e FIR: Throw if source is null in DiagnosticReporter.reportOn ^KT-55284 Fixed 2023-01-11 08:30:36 +00:00
aleksandrina-streltsova c6886fc779 [FIR] Use post-compute in typeAliasCache for deserialized symbols
^KTIJ-24156 Fixed
2023-01-10 20:15:28 +00:00
Alexander Udalov 3dc3ed4ca5 Exclude jdk.internal.* in backend debug tests
Otherwise `debug/stepping/enum.kt` starts failing as soon as we advance
default language version to 1.9, because with the introduction of enum
entries, enum's `<clinit>` now invokes LambdaMetafactory which invokes
its own bundled version of ASM located in
`jdk.internal.org.objectweb.asm`, so we end up stepping over a lot of
internal ASM code.

`jdk.internal.*` is also excluded by default in the debugger settings in
IntelliJ, so users will not observe this issue in practice.
2023-01-10 16:39:05 +00:00
Yahor Berdnikau 43eea47032 Mark compiler arguments that should generate deprecated kotlinOptions DSL
This will allow to keep backward compatiblity for deprecated
kotlinOptions DSL for already existing compiler arguments, but add a new
 one only into compilerOptions DSL.

^KT-53108 In Progress
2023-01-10 14:56:11 +00:00
pyos 308e1362ab Minor: FIR DFA: fix code style 2023-01-10 15:40:53 +02:00
pyos 5d4b44500a FIR CFA: remove direction from ControlFlowGraph.traverse.
If you care about direction, then you also care about labels.

3 out of 6 places that use `traverse` are incorrect, by the way.
Node order does not correspond to scoping boundaries.
2023-01-10 15:40:53 +02:00
pyos de105e602d FIR CFA: remove redundant entries from followingCfgNodes
Edges to subgraphs should now be correctly added, so there's no need to
look at them separately.
2023-01-10 15:40:52 +02:00
pyos da018e9d06 FIR CFA: align reading of labels with the way they're generated
UncaughtExceptionPath label out of a finally block matches every label
that is not handled by another edge, and a labeled edge from the middle
of a finally block aborts the jump and so should merge all available
data.
2023-01-10 15:40:52 +02:00
pyos d655147c8c FIR CFA: remove a redundant wrapper around PersistentMap 2023-01-10 15:40:52 +02:00
pyos 065ed46495 FIR CFA: require path awareness in fixed point iteration
It really doesn't make sense to collect control flow data without
checking paths, since that'll produce incorrect results for try-catch.
2023-01-10 15:40:52 +02:00
pyos 63ab9119f8 FIR: do not use CFG in FirPropertyInitializationChecker 2023-01-10 15:40:52 +02:00
pyos e86b87fe0b Test: FIR CFA: fix the names of some nodes 2023-01-10 15:40:52 +02:00
pyos fbd0908f0c FIR DFA: add smartcast invalidation for init block assignments 2023-01-10 15:40:51 +02:00
pyos c185bf60f8 Add a test for data flow with reassignments in local classes 2023-01-10 15:40:51 +02:00
pyos 1aae586238 FIR DFA: don't erase statements when entering non-call-in-place lambda
Instead, rely on the variable assignment analyzer to properly restrict
smart casts. This makes error messages more consistent, but otherwise
should have no effect.
2023-01-10 15:40:51 +02:00
pyos 5a79017879 FIR CFA: remove some redundant node stacks
Honestly the amount of mutable state in the builder makes me somewhat
uneasy.
2023-01-10 15:40:51 +02:00
pyos 60662663be FIR CFA: remove the id parameter from nodes 2023-01-10 15:40:51 +02:00
pyos dca6caaafa FIR CFA: add a hack for enum classes and LL API
No clue what's going on there.
2023-01-10 15:40:51 +02:00
pyos 377b7bdf5e FIR CFA: remove top-level graph
It should never have contained any nodes because it was not attached
to anything.
2023-01-10 15:40:50 +02:00
pyos b548473544 FIR CFA: automatically compute node levels 2023-01-10 15:40:50 +02:00
pyos 0dd949bb36 FIR DFA: route data flow through anonymous objects
^KT-44515 Fixed
2023-01-10 15:40:50 +02:00
pyos 17ee8f3a7b FIR CFA: put primary constructor before other class members 2023-01-10 15:40:50 +02:00
pyos c6e9afb788 FIR CFA: remove class initializer part nodes
Instead, attach subgraphs directly to the class enter node.
2023-01-10 15:40:50 +02:00
pyos b9f366af05 FIR CFA: remove infinite loops from toposort
Finally, no more tests getting stuck on `orderNodes`. Only took me what,
75 commits to fix enough things to make this actually work?
2023-01-10 15:40:50 +02:00
pyos 54f32a6fba Test: FIR CFA: index nodes in rendering order 2023-01-10 15:40:49 +02:00
pyos a9397b7b23 Test: FIR CFA: don't output two node fill colors 2023-01-10 15:40:49 +02:00
pyos 3887c80816 FIR CFA: ensure on API level that graphs have enter & exit
What's going on with script graphs?..
2023-01-10 15:40:49 +02:00
pyos e710edbd77 FIR CFA: use a common fake node for annotation calls and contracts
The graphs for both will be completely discarded and should never be
visited.
2023-01-10 15:40:49 +02:00
pyos 4bb7b1ac9f FIR DFA: use class enter node as data flow source for members
Also fix graphs for enums with specialized entries - since we don't
create property subgraphs for FirEnumEntry, there is no body to insert
AnonymousObjectEnterNode, AnonymousObjectExitNode, and
AnonymousObjectExpressionExitNode into.
2023-01-10 15:40:49 +02:00
pyos e6819e1295 FIR CFA: refactor handling of classes a bit
As usual, I'm leaving TODOs wherever I go...
2023-01-10 15:40:49 +02:00
pyos 4c6eff9174 FIR CFA: compute subgraph relationships automatically
No more `addSubGraph`. Also no more `owner` in graphs.

^KT-40526 Obsolete
^KT-40582 Obsolete
2023-01-10 15:40:48 +02:00
pyos 7ff5ad1ad0 FIR CFA: remove modes
They are only used in one place that can just as well use kinds.

Especially considering that "the one place" used them incorrectly and
would not attach local functions in property accessors as subgraphs.
2023-01-10 15:40:48 +02:00
pyos cb8cb1f610 FIR CFA: attach accessors and nested classes as class subgraphs 2023-01-10 15:40:48 +02:00
pyos 5d4fb3ead8 FIR CFA: add control flow between default parameter values
function enter -> default 1 -> default 2 -> rest of function
                   \----------^ \----------^

This probably has no effect (in non-stupid code, at least), but it makes
graph construction more architecturally correct (now value parameters'
subgraphs get attached to a node).
2023-01-10 15:40:48 +02:00
pyos 74758278d7 FIR CFA: attach method graphs to class exit node
Even for non-local classes. This ensures that the CFG edges in this case
will only go to a subgraph, not to an unrelated graph.
2023-01-10 15:40:48 +02:00
pyos aadea0e26f FIR CFA: properly visit subgraphs in checkers
Interpretation: a graph A is a subgraph of B if information available at
nodes of A depends on the paths taken in B. For example, local classes
are subgraphs of a graph in which they are declared, and members of
those classes are subgraphs of the local class itself - because these
members can reference captured values.

Consequences:

 * if graph G is a subgraph of node N, then G is a subgraph of N's
   owner;
 * `ControlFlowAnalysisDiagnosticComponent` will only visit root graphs;
 * `graph.traverse` will ignore subgraph boundaries, as if all subgraphs
   are inlined into one huge root graph;
 * if a control flow checker needs information from a declaration to
   which a graph is attached, it must look at subgraphs explicitly.

For example, consider the `callsInPlace` checker. When a function
has a `callsInPlace` contract and a local declaration, the checker must
visit that local declaration to ensure it does not capture the allegedly
called-in-place argument - hence `graph.traverse` will look at the
nodes. However, the local declaration can also be a function with its
own `callsInPlace` contracts, so the checker should also run for it in
isolation. If that sounds quadratic, that's because unfortunately it is.
2023-01-10 15:40:48 +02:00
pyos 5180e1f4a4 FIR DFA: fix mismatched calls to enter/exitProperty
Otherwise the graph stack becomes incorrect.
2023-01-10 15:40:48 +02:00
pyos bcc54deb64 FIR CFA: fix deadness of various nodes
* `do { continue } while (x)`: block exit is dead, condition is not;

 * `try { a?.incomplete() } catch (e) { x }`: when the call is completed
   and found to return `Nothing`, the safe call exit node is still live
   because `a` could still be null;

 * `f(a@{ g { return@a } }, x)`: if call to `g` is not completed, there
   should not be a dead data flow edge from the lambda to `f` because
   there's no such thing as a dead data flow edge (DeadForward is CF+DF).
2023-01-10 15:40:47 +02:00
pyos e7e5569539 FIR CFA: do not remove provideDelegate subgraphs when rolling back
The receiver of the provideDelegate call is the same FirExpression as
the delegate itself, so there's only one copy of the nodes in the first
place; trying to remove subgraphs completely detaches objects inside it
from the parent graph, which is not great for checkers.

Note that currently if provideDelegate is not selected, there will be a
stray FunctionCallExit node in the control flow graph. This commit *does
not change that*. It has been there for a while. Don't @ me. I'll try to
fix that. No promises.
2023-01-10 15:40:47 +02:00
pyos ef2fa01a8d FIR CFA: remove redundant "uncaught exception path" edges
These are not real, and in fact tricked the compiler into thinking some
blocks that do not terminate do somehow terminate.
2023-01-10 15:40:47 +02:00
pyos fa0ea1504e FIR CFA: remove CFGNode.outgoingEdges
If it's symmetric with incomingEdges, then what's the point?..
2023-01-10 15:40:47 +02:00
pyos 7feeb7cd4e FIR CFA: remove edge kind merging
There shouldn't be any duplicate edges anymore. There probably weren't
any before, either.
2023-01-10 15:40:47 +02:00