๐ŸŽฎ Unity Study/Unity

[Unity] IL2CPP, Mono, JIT

ibelieveinme 2023. 4. 17. 13:20
728x90

C# vs C++

: GC ์žˆ์Œ ์—†์Œ ์ฐจ์ด. C#์— GC(Garbage Collector)๊ฐ€ ์ƒ๊ฒจ์„œ ์ƒ์‚ฐ์„ฑ์ด ๋” ์ข‹๋‹ค.

 

Mono, IL2CPP, Burst

: ์ฝ”๋“œ๋ฅผ ์‹คํ–‰๊ฐ€๋Šฅํ•œ ํ˜•ํƒœ๋กœ ๋ฐ”๊ฟ”์ฃผ๋Š” ์ปดํŒŒ์ผ๋Ÿฌ์ธ Scripting Backend์˜ ์ข…๋ฅ˜

Mono๋Š” IL2CPP ๋ณด๋‹ค ๋น ๋ฅด๊ณ  ํ”Œ๋žซํผ์— ๋…๋ฆฝ์ ์ž„. IL2CPP๊ฐ€ ๋” ๋ณด์•ˆ์„ฑ์ด ๋†’๊ณ  Android/iOS ํ˜ธํ™˜๊ฐ€๋Šฅ.

cf) Unity ์ž์ฒด ์—”์ง„์€ C++์ด๊ณ  Script ๋Š” C#์œผ๋กœ ์ž‘์„ฑํ•˜๋Š” ๊ตฌ์กฐ.

 

Mono

: Mono๋Š” JIT(Just-In-Time) ์ปดํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ณ  ๋Ÿฐํƒ€์ž„ ์‹œ์ ์— ์š”์ฒญ์‹œ ์ฝ”๋“œ๋ฅผ ์ปดํŒŒ์ผ ํ•จ

: 64bit ์ง€์› ์•ˆํ•จ.

 

IL2CPP

: IL2CPP๋Š” AOT(Ahead-of-Time) ์ปดํŒŒ์ผ์„ ์‚ฌ์šฉํ•˜๊ณ  ์‹คํ–‰ ์ „์— ์ „์ฒด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ์ปดํŒŒ์ผ ํ•จ.

: iOS ๋Š” 64bit ๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„  64bit ๋ฅผ ์ง€์›ํ•˜๋Š” IL2CPP ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ๋งŒ ํ•œ๋‹ค.

 

 

* C#: .Net ํ”„๋ ˆ์ž„์›Œํฌ์—์„œ ์‚ฌ์šฉํ•˜๋ ค๊ณ  C++์—์„œ ํŒŒ์ƒ๋œ ๊ฒƒ.

          C++ ๋ฉ”๋ชจ๋ฆฌ ๊ด€๋ฆฌ์˜ ์–ด๋ ค์›€์„ Garbage Collector๋กœ ํ•ด๊ฒฐํ–ˆ๋‹ค.

 

         C#์„ Android/iOS์—์„œ ๋Œ๋ฆด ์ˆ˜ ์žˆ๋Š” ์ด์œ ๋Š” mono ํ”„๋ ˆ์ž„์›Œํฌ ๋•๋ถ„.

         (์ฆ‰, Mono Framework๋ฅผ ๋„์›Œ์•ผ ๋Œ๋ฆด ์ˆ˜ ์žˆ๋Š” ๊ฒƒ)

         C#์„ IL(.Net Assembly)์ด๋ผ๋Š” ์–ธ์–ด๋กœ ๋ณ€๊ฒฝํ•œ ๋’ค Mono Framework์—์„œ ๋Œ๋ฆฌ๋Š” ๊ฒƒ์ด๋‹ค.

         ์ด๊ฑธ JIT(Just In Time) ๋ฐฉ์‹์ด๋ผ๊ณ  ๋ถ€๋ฆ„. ๊ทธ๋•Œ ๊ทธ๋•Œ ์ปดํŒŒ์ผ~

 

         IL์€ ์‚ฌ๋žŒ์ด ์ฝ์„ ์ˆ˜ ์žˆ๋Š” ๊ธฐ๊ณ„์–ด๋„ ์•„๋‹Œ ์–ด์…ˆ๋ธ”๋ฆฌ์–ด๋„ ์•„๋‹Œ ์ค‘๊ฐ„์–ธ์–ด์ด๋‹ค.

         Call By Value(struct, int, char, bool, ...)์™€ Call By Reference(Class, string, array, ...)๋ฅผ ์ž๋™์œผ๋กœ ์ ์šฉํ•ด์ค€๋‹ค.

 

* IL2CPP: IL์„ CPP๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๊ฒƒ.

                  C++๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด Andorid(NDK)/iOS(Object-C) ๋‘˜๋‹ค ๋Œ์•„๊ฐˆ ์ˆ˜ ์žˆ๋‹ค.

                  ์ฐธ๊ณ ๋กœ Unity ๋‚ด๋ถ€๋Š” CPP๋กœ ๋˜์–ด ์žˆ์Œ.

 

* IL2CPP Code Generation

Faster runtime: ๊ธฐ์กด๋ฐฉ์‹ ๊ทธ๋Œ€๋กœ ์‹น ํ’€์–ด์•ผ ํ•ด์„œ ์ฝ”๋“œ๊ฐ€ ๊ธธ์–ด์ง.

Faster(smaller) builds: ํฌ์ธํ„ฐ๋กœ ํ•œ๊ฒน ๋” ์‹ธ์„œ ์•ˆ ํ’€์–ด๋„ ๋ผ์„œ ์ฝ”๋“œ๊ฐ€ ์ค„์–ด๋“ฌ.  Runtime ์„ฑ๋Šฅ์€ ์ข€ ๋–จ์–ด์ง.

Conversion Time๊ณผ Code Size ๋น„๊ตํ•œ ์ฐจํŠธ

 

* ์ฐธ๊ณ ์˜์ƒ

https://www.youtube.com/watch?v=-9X965jXrn8 

 

728x90