Size: a a a

Kotlin Community

2019 December 06

i

iseki in Kotlin Community
Yeah. How does it works? This is my question. Maybe some MetaData?
источник

KZ

Konstantin Zolotov in Kotlin Community
iseki
I want to know how kotlin inline function works without source code. Looks kotlin can inlining function which compiled and without source code.
Basically, inline means "take body of this function and put in call place"
источник

AT

Alexey Tkachenko in Kotlin Community
Konstantin Zolotov
Basically, inline means "take body of this function and put in call place"
and “function body” is a set of bytecode instructions on this stage
источник

AM

Andrew Mikhaylov in Kotlin Community
Of course, with additional processing like replacing returns with corresponding value usage at call site, processing non-local returns and type reification if requested.
источник

i

iseki in Kotlin Community
emmm. If kotlin compiler analysis byte code on compile time... The Kotlin/js ?
источник

i

iseki in Kotlin Community
Analysis js code at compile time?
источник

AT

Alexey Tkachenko in Kotlin Community
in case of js the compiler obviously has a source code, isn't it?
источник

i

iseki in Kotlin Community
Sorry that I have a poor English...
источник

i

iseki in Kotlin Community
Alexey Tkachenko
in case of js the compiler obviously has a source code, isn't it?
😳
источник

QH

Quantum Harmonizer in Kotlin Community
Alexey Tkachenko
in case of js the compiler obviously has a source code, isn't it?
I don't think so.
источник

AT

Alexey Tkachenko in Kotlin Community
Quantum Harmonizer
I don't think so.
could you explain why it might be?
источник

AM

Andrew Mikhaylov in Kotlin Community
That's an interesing question. I guess with the new Frontend IR this should be a deal of frontend compiler and shouldn't actually concern platform-related backends. As for how it's done right now, I'm not sure as I didn't check that. But knwoing that even main IR is a recent feature, previously the only artifacts compiler had were platform output (JS, JVM bytecode, etc) and Kotlin-specific metadata, compiler has to transform the former to inline actual function.

Once again, these are solely my speculations.
источник

QH

Quantum Harmonizer in Kotlin Community
Alexey Tkachenko
could you explain why it might be?
The sources are not always available.
источник

AT

Alexey Tkachenko in Kotlin Community
You mean Kotlin/JS sources are also compiled into bytecode?
источник

VP

Vladimir Petrakovich in Kotlin Community
Minified JS after DCE is far from "source" code 😄
источник

QH

Quantum Harmonizer in Kotlin Community
Alexey Tkachenko
You mean Kotlin/JS sources are also compiled into bytecode?
KtJS 'bytecode' is JS.
источник

AM

Andrew Mikhaylov in Kotlin Community
Vladimir Petrakovich
Minified JS after DCE is far from "source" code 😄
But that's still JS source code. :)
источник

AT

Alexey Tkachenko in Kotlin Community
Vladimir Petrakovich
Minified JS after DCE is far from "source" code 😄
for human of course, but not for compiler
источник

VP

Vladimir Petrakovich in Kotlin Community
It's rather a poor man bytecode for V8
источник

VB

Viacheslav Blinov in Kotlin Community
Alexey Tkachenko
You mean Kotlin/JS sources are also compiled into bytecode?
I would assume there is some sort of IR in between KtJs sources and JS output anyway
источник