Commit Graph

1335 Commits

Author SHA1 Message Date
Roman Artemev e4585730d6 [IR] Add platform-agnostic builtin to throw linkage error 2021-11-19 01:16:33 +03:00
Anton Bannykh 56e1c4e38f [JS IR] IrFactory which saves signatures for declarations created in BE 2021-11-19 00:39:12 +03:00
Svyatoslav Scherbina e11ffc75e4 IR: remove default undefined offsets from createTemporaryVariableDeclaration
Scope.createTemporaryVariableDeclaration has default values for
startOffset and endOffset parameters, which are UNDEFINED_OFFSET.

This is error-prone. Caller should typically be able to pass proper
offsets. If not, let using undefined offsets at least be explicit.

Remove default values for startOffset and endOffset parameters in
Scope.createTemporaryVariableDeclaration
2021-11-16 11:59:56 +00:00
Svyatoslav Scherbina 2f5706597a IR: fix offsets in irTemporary
The variable generated by IrStatementBuilder.irTemporary doesn't inherit
startOffset and endOffset from the builder. In particular, as a result,
temporary variables generated for elvis operator left operand have
UNDEFINED_OFFSET.

Additionally, ProvisionalFunctionExpressionLowering copies the offsets
of a variable to lowered lambda in the variable initializer. With the
problem described above, this causes invalid debug information in
Kotlin/Native, see KT-49360.

Fix irTemporary by using builder's offsets for the variable.

^KT-49360 Fixed
2021-11-16 11:59:55 +00:00
Kristoffer Andersen 771b79d045 [EE-IR] Use reflection to avoid the need for accessors when compiling
evaluator fragments

- Refactor JvmIrCodegenFactory to allow for caller's choice of
  lowerings.

- Refactor of SyntheticAccessorLowering to expose the accessibility
  check used to determine the need for accessors.

- Replacement of field, method and constructor uses with corresponding
  java.lang.reflection API via additional lowering running _before_
  the existing IR pipeline.

- Emulating super calls in the context of class methods via new
  compiler intrinsic.

- psi2ir: Add support for `_field` suffix on properties in the
  evaluator for accessing underlying fields when applicable.

- Add `JvmGeneratorExtensions` point for determining whether a
  property accessor has a user-supplied body in order to predict how
  they are ultimately compiled for the JVM.
2021-11-14 21:50:13 +01:00
Alexander Udalov 27cfcb9b3d IR: fix thisReceiver parameter type for function classes
Incorrect builder was used at line 269, which led to non-sensible type
in `IrClass.thisReceiver` for function types, such as
`SuspendFunction1<SuspendFunction1, SuspendFunction1>` in the linked
issue.

Avoid creating types manually completely to simplify this code and fix
the bug.

 #KT-49168 Fixed
2021-11-10 21:58:41 +01:00
Mikhail Glukhikh 5b6e21690b FIR2IR: call fake overrides properly #KT-49288 Fixed 2021-11-09 21:04:35 +03:00
Ivan Kylchik 68c9156053 Add possibility to get line offsets from PsiIrFileEntry
This is needed for tests to be able to get offsets without explicit
file on disk.
2021-11-08 23:50:34 +03:00
Pavel Kunyavskiy 948dc4f374 Fix annotation class modality in stubs
^KT-49428
2021-11-03 07:22:28 +00:00
Pavel Kunyavskiy d127815626 Refactor DataClassMembersGenerator.kt for better work with LazyIr
^KT-49428
2021-11-03 07:22:28 +00:00
Mads Ager 6622846bc1 [JVM IR] Do not put destructuring params or underscores in LVT.
Putting them in the local variable table means that the debugger
needs to have special handling for parameters with specific names.
That forces us to generate mangled names for these.

Instead of also implementing the name mangling for FIR, this
change gets rid of the parameters from the LVT instead.
2021-11-02 15:13:14 +03:00
Georgy Bronnikov 534beb8553 IR: Test for toSkip(this) in T.resolveFakeOverride()
^KT-49371 Fixed
2021-10-29 12:13:57 +03:00
Roman Artemev d809e260cb [KLIB] Support DefinitelyNotNull type in KLIB
- add proto message
 - serialize/deserialize
2021-10-28 18:03:11 +03:00
Roman Artemev 29728efbf7 [PSI2IR] Support DefinitelyNotNull type translation in Psi2Ir 2021-10-28 18:03:11 +03:00
Roman Artemev 101afded69 [IR] Introduce IrDefinitelyNotNullType in IR
- support it in render
 - support in IR copy
 - KEEP-268
2021-10-28 18:03:09 +03:00
Sergej Jaskiewicz a367b91aa1 [IR] [Refactoring] Add toString and String::plus to IrBuiltins
Also use `OperatorNameConventions` constants instead of magic strings
2021-10-28 08:35:11 +00:00
Ivan Kochurkin 15d23f2a72 [FIR2IR] Fix applying of equals intrinsics 2021-10-25 21:21:39 +03:00
Dmitry Petrov eec16b83c6 Minor: reformat and fix warnings 2021-10-23 11:21:23 +03:00
Artem Kobzar 3dbf996ec6 fix(KT-49225): remove unnecessery boxing. 2021-10-21 06:38:42 +00:00
Anton Bannykh 546ce501cb [JS IR] run IC box tests 2021-10-15 20:14:51 +03:00
Dmitry Petrov af18b10da9 JVM_IR KT-49203 generate stubs for not found classes 2021-10-15 12:15:49 +03:00
Pavel Kunyavskiy e4a4cd3e16 [K/N] Transform constant varargs to ConstantValue 2021-10-14 11:22:25 +00:00
Pavel Kunyavskiy bf3c343ced Introduce new ir nodes for constant values 2021-10-14 11:22:21 +00:00
Svyatoslav Kuzmich 5affd9d2f9 Visit declaration reference when visiting member access 2021-10-12 23:01:00 +03:00
Svyatoslav Kuzmich a6afb7cb41 [JS IR][Wasm] Preload (Suspend)FunctionN needed in lowerings
This reverts commit 15d178d850d15675ee39cbd833d13f4c8aed83ff.
2021-10-12 08:42:01 +03:00
Svyatoslav Kuzmich 3bce0cc055 [Wasm] Support coroutines
- Reuse JS IR Suspend function lowering
  - Fix types
  - Disable reinterpretCast-based optimization for inline
    classes
- Add basic support to Wasm stdlib
- Explicitly transform suspend functions into regular functions
  with continuations
- Clean suspend function handling from JS IR codegen
2021-10-12 08:42:01 +03:00
Georgy Bronnikov a9ce25cf33 JVM_IR: only serialize inline functions themselves with -Xserialize-ir=inline 2021-10-11 11:53:30 +03:00
Dmitry Petrov 146f0f4904 JVM_IR KT-41214 emit PermittedSubclasses on JDK17+ 2021-10-09 17:07:35 +03:00
Svyatoslav Kuzmich 1ed2748334 [Wasm] Generate [K][Suspend]FunctionN on demand and support big arity 2021-10-08 07:24:41 +03:00
Roman Artemev e6de812788 [IR] Implement checker for friendship of modules in fake override builder
- pass corresponding information to FO builder
 - implement check
 - fix KT-47192 and KT-48673
2021-10-07 16:00:49 +03:00
Dmitry Petrov 3d64c91375 PSI2IR KT-49053 skip fake overrides with unresolved types in signature 2021-10-06 16:23:08 +03:00
Roman Artemev ba759fb61b [IR] Fix compatibility mode
- pass corresponding flag to mangler
 - properly handle local declarations in field initializers
 - fix KT-48912
2021-10-06 03:47:20 +03:00
Alexander Udalov 4da4719246 IR: slightly optimize IdSignature calculation in SymbolTable
Do not compute IdSignature for descriptor a second time when adding a
new symbol. Instead, pass the calculated signature to the lambda in
declare/declareIfNotExists/referenced, and use it in `reference*`
methods.
2021-10-05 12:18:06 +02:00
Alexander Udalov 1c735948d1 IR: cleanup SymbolTable
Extract duplicated code, remove unused methods and unneeded OptIn.

Also, check original for descriptors only in case the symbol is not
computed yet. Checking it on every access is not needed.
2021-10-05 12:16:24 +02:00
Alexander Udalov eb28d662d4 IR: use HashMap instead of LinkedHashMap in SymbolTable
It's not important for these maps to be linked hash maps because they
are not iterated over.
2021-10-05 12:16:24 +02:00
Igor Chevdar 0cece79856 [K/N][IR][codegen] Use LazyIr for cached libraries
It's not that simple because we still need inline functions bodies
and classes fields which aren't present in Lazy IR. To overcome this,
save additional binary info for a cached library and then use it when needed
2021-10-05 10:47:52 +05:00
Roman Artemev a1b223e33d [JS IR] Set proper statement origin for bound receiver save 2021-10-01 23:02:09 +03:00
Victor Petukhov 0cb56be14f Have "in type" for java fields to be able to check that type in assignment positions (against rhs' type)
^KT-46727 Fixed
2021-09-30 20:08:52 +03:00
Pavel Kunyavskiy 773c82ae48 Refactor AnnotationImplementationLowering
- Replaced UNDEFINED_OFFSET with SYNTHETIC_OFFSET, it's required by
  Native backend codegen
- Fixed missing overridden symbols
- Enforce adding fakeoverrides for members not overridden by backend
- Support more points for platform customisation
2021-09-23 06:59:32 +00:00
Kristoffer Andersen 247cbffbac [EE-IR] Fragment Compiler Entrypoint in IR Backend
This commit introduces a new entrypoint for the IR backend, and starts
the work of accomodating the evaluator in psi2ir.

The evaluator expects a certain class and method structure of the
compiled fragment, but PSI is only supplied for the actual fragment.

So, to that end, this commit introduces a new "front end" of psi2ir
that "synthesizes" the module, class and method structure around the
fragment before calling into the existing psi2ir pipeline to obtain
the IR for the fragment.

The primary complication so far is handling the captured variables of
the fragment: they are mapped to parameters of the method surrounding
the fragment, and passed as arguments on evaluation. Hence, the IR
translation of the fragment needs to remap captured variables to the
appropriate parameter, in essentially all places they can be referred
to in the fragment (and hence in psi2ir). This commit introduces a
decorated symbol table that intercepts symbol look-ups and remaps as
appropriate.

Other cases that dispatches based on descriptor (see
`CallGenerator.kt`) needs other metadata to generate correct code.

It also introduces a shim in DeserializedContainerSource in the psi2ir
pipeline to facilitate facade class generation for the code that is
being debugged (which are generated as "external ir declarations").

Finally, in passing we resolve a small leftover from previous
refactoring that left an asssertion re. allowing IR to _assign_ to
parameters of methods.
2021-09-21 18:18:30 +02:00
Igor Chevdar 3a4e8e7a61 [K/N][IR] Used .isFakeOverride instead of a special origin 2021-09-18 19:46:09 +05:00
Nikolay Lunyak e571de5942 [FIR] Fix dumpKotlinLike 2021-09-11 22:05:38 +03:00
pyos 23420ecf7a IR: do not infer array element types for non-annotation constants
While annotations restrict the set of allowed types to a few final
built-ins, in arbitrary constants we can have array elements that are
some subtype of the array's element type.

 #KT-48671 Fixed
2021-09-10 21:55:15 +02:00
Mikhail Glukhikh 457a6f4e9d IR: copy anonymous initializer annotations properly #KT-48687 Fixed 2021-09-09 22:14:48 +03:00
Igor Laevsky d99473fe4d WASM: Canonicalize catches without finally blocks 2021-09-08 19:56:35 +03:00
Leonid Startsev 6f954462d6 Implement proper contract for generated java.lang.Annotation.hashCode()
#KT-48606 Fixed
2021-09-08 14:41:25 +00:00
Alexander Udalov a06fc20680 JVM IR: erase parameter default value when copying it to bridge
#KT-48391 Fixed
2021-09-03 15:00:44 +02:00
Georgy Bronnikov 22a6dc0320 JVM_IR: lock IrLazySymbolTable ops 2021-09-01 17:28:21 +03:00
Georgy Bronnikov 570e20696c IR: use synchronized access when creating initial signature stub 2021-09-01 17:28:11 +03:00
Dmitriy Novozhilov 7e6e0a3dd6 Remove all type system-specific inheritors of TypeCheckerState 2021-08-26 10:08:51 +03:00