Commit Graph

5222 Commits

Author SHA1 Message Date
Roman Artemev a0d67cb2e3 [JS IR] Support throwing linkage error in JS IR BE
- lower it into runtime API call
2021-11-19 01:16:37 +03:00
Roman Artemev 53a65f818f [KLIB] Support partially linked klibs in Ir linker
Now it's possible to compile against klib even if in there are
references to declarations from other klibs which are no longer existed

 - add switch flag to turn on/off that mode
 - pass switch flag from JS CLI to JS Linker
2021-11-19 01:16:35 +03:00
Roman Artemev 650b04b4dd [JS IR] Make assert checks no unbound symbols left conditional 2021-11-19 01:16:34 +03:00
Roman Artemev e4585730d6 [IR] Add platform-agnostic builtin to throw linkage error 2021-11-19 01:16:33 +03:00
Roman Artemev 8381badcc4 [KLIB] Make IrModuleDeserializer constructor nullable 2021-11-19 01:16:30 +03:00
Roman Artemev 918ed1f077 [KLIB] Refactored IrSymbolDeserializer.kt
- extract function which creates a new symbols in linker
2021-11-19 01:16:29 +03:00
Roman Artemev df9d039c03 [KLIB] Don't use module descriptor to compute library in error reporter 2021-11-19 01:16:28 +03:00
Anton Bannykh 75368a2c06 [JS IR] tie together IC code in tests and K2JsIrCompiler 2021-11-19 00:39:37 +03:00
Anton Bannykh ff02ea5840 [JS IR] advance stage in regular mode when needed 2021-11-19 00:39:32 +03:00
Anton Bannykh 7d7dd3fe97 [JS IR] better tags + bare parameter names 2021-11-19 00:39:29 +03:00
Anton Bannykh f9e62f8ffa [JS IR] expose currentStage via the stageController
Otherwise the signatures for the declarations, created in lowerings,
will be miscalculated.
2021-11-19 00:39:24 +03:00
Anton Bannykh f413d7fd75 [JS IR] make using the original parameter names possible 2021-11-19 00:39:18 +03:00
Anton Bannykh e342ade00a [JS IR] fix inline graph tracker for file-local signatures 2021-11-19 00:39:15 +03:00
Anton Bannykh 56e1c4e38f [JS IR] IrFactory which saves signatures for declarations created in BE 2021-11-19 00:39:12 +03:00
Anton Bannykh e972ad9855 [JS IR] improved missing body reporting for inliner 2021-11-19 00:39:03 +03:00
Anton Bannykh 953089a4b9 [JS IR] suport SuspendN.invoke functions 2021-11-19 00:38:51 +03:00
Anton Bannykh 1ae042edc3 [JS IR] make old Ir2Js pass all tests 2021-11-19 00:38:46 +03:00
Anton Bannykh 3c859138d1 [JS IR] support source maps in new Ir2Js 2021-11-19 00:38:33 +03:00
Anton Bannykh a7d8c34927 [JS IR] support generateScriptModule 2021-11-19 00:38:30 +03:00
Anton Bannykh 0506d422a3 [JS IR] support per-module in the new Ir2JS 2021-11-19 00:38:27 +03:00
Anton Bannykh 1f55dc73d2 [JS IR] don't inline property accessors across files 2021-11-19 00:38:24 +03:00
Anton Bannykh 03b9caa439 [JS IR] export external declarations 2021-11-19 00:38:15 +03:00
Anton Bannykh ee8351b9c9 [JS IR] remove unused property 2021-11-19 00:38:11 +03:00
Anton Bannykh 0b0ed5241c [JS IR] remove unused method 2021-11-19 00:38:09 +03:00
Anton Bannykh 3617c1388c [JS IR] improve the hacky fix 2021-11-19 00:38:06 +03:00
Anton Bannykh 46a23c70df [JS IR] hacky fix for local variables name binding 2021-11-19 00:38:03 +03:00
Anton Bannykh e4c668462c [JS IR] fix field namer 2021-11-19 00:38:00 +03:00
Anton Bannykh 5100cb058f [JS IR] local var clashes 2021-11-19 00:37:55 +03:00
Anton Bannykh 05e8bfcd2a [JS IR] split fqn-ish JsNames before resolving temporary names 2021-11-19 00:37:45 +03:00
Anton Bannykh a5d9cb0cc6 [JS IR] copy class models 2021-11-19 00:37:40 +03:00
Dmitriy Novozhilov 93378b1a04 [FE 1.0] Resolve private constructors of sealed classes same as for regular classes
^KT-44866
^KT-49729
2021-11-18 13:54:05 +03:00
Artem Kobzar d5dd35cb20 feat(@JsExport for interfaces): add ability to export interfaces in TypeScript. 2021-11-18 10:07:38 +00:00
Svyatoslav Kuzmich f833fc4bcb [Wasm] Default parameter values for external functions
+ import top-level external functions wrapped in lambdas
2021-11-17 19:28:14 +00:00
Dmitry Petrov 30ceb49442 JVM_IR KT-48945 generate special bridge with unsubstituted signature 2021-11-17 17:44:01 +03:00
Alexander Udalov a7fef487c1 JVM IR: fix support of cyclic module dependencies
Previous episode was at 987a3460 (KT-45915).

Apparently, it's not enough to run psi2ir for all modules, and then
backend for all modules. If there are several modules in the chunk, IR
in any one of them can reference IR of any other one after psi2ir.

So we would end up in a situation where we're running codegen for the
first module, but the second module is completely unlowered. This would
break some assumptions in the codegen, for example in KT-49575, codegen
would see a reference to a top-level function from another module, and
would fail because the function has no containing class (since file
facades have not been generated yet!), and thus must be an intrinsic,
yet no such intrinsic is known to the codegen.

The solution is to run lowerings first on all modules, and then run
codegen on all modules. The kind of error explained above shouldn't be
possible anymore, because lowerings have to deal both with lowered and
unlowered code from other files all the time, so lowerings can't assume
that reference from other module is lowered either (or unlowered).

The code is not very nice, but hopefully it can be improved as soon as
we get rid of the old JVM backend (and maybe later with the migration to
FIR too).

 #KT-49575 Fixed
2021-11-16 20:20:20 +01:00
Alexander Udalov 5012aeba7c JVM IR: move codegen out of the main phases
This is needed in order to be able to invoke lowerings and codegen
separately, for cyclically dependent modules (KT-49575).

A side effect is that the two codegen phases are no longer configurable
via the phaser, i.e. absent in the -Xlist-phases and can't be disabled
or made verbose.
2021-11-16 20:20:19 +01:00
Alexander Udalov f701f04326 JVM IR: move jvmPhases to backend.jvm.entrypoint
This will be used for two purposes:
1) call lowerings and codegen separately from
   KotlinToJVMBytecodeCompiler to support cyclical module dependencies
   (KT-49575)
2) split lowerings and codegen into separate modules
2021-11-16 20:20:19 +01:00
Artem Kobzar af924fd3d1 feat: add implicit export support for Kotlin/JS 2021-11-16 16:59:18 +00:00
Alexander Udalov 850d76f6bf Remove error on annotated types as arguments to typeOf
Instead, document that `KType.annotations` returns an empty list for
types created with `typeOf`. Annotations might be supported in the
future.

 #KT-49573 Fixed
 #KT-29919
2021-11-16 15:02:50 +01: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
Igor Yakovlev ee7f4c7278 [WASM] Implementation typeOf support 2021-11-15 19:53:48 +03:00
Igor Yakovlev ce360bb10b [WASM] Implementation of Class references 2021-11-15 19:53:46 +03:00
Igor Yakovlev d9f2bd7963 Revert "[Wasm][Temporary] Stubs for typeOf and ::class constructs"
This reverts commit 8dc81b6c57.
2021-11-15 19:53:45 +03:00
Igor Laevsky c7cfa97748 [Wasm] Implement Any::hashCode() 2021-11-15 18:26:46 +03:00
Steven Schäfer a6dae0b37b JVM IR: Fix value class mangling in SAM wrappers from different modules
KT-49659
2021-11-14 21:52:39 +01: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
Artem Kobzar 7aa8de55a5 fix(use strict): move global this polyfill after "use strict" pragma. 2021-11-12 15:59:27 +00:00
Svyatoslav Kuzmich 08362e8b38 [Wasm] Support defineExternally 2021-11-12 18:44:46 +03:00
Svyatoslav Kuzmich 5098bc0c70 [Wasm][Minor] Rename method 2021-11-12 18:44:46 +03:00