Open jintemp opened 3 years ago
In my understanding, for example, Unity's IL2CPP is based on Mono (which implements the BCL interface), so there is no InterlnalCall problem。windows .NET Framework or donet is not pure
Looking forward to your reply
In my first inspiration for IL2C's idea: "Why does it required a lot of cost in this case? What different between C language and C# (or CIL)? And/or why couldn't use .NET on embedded bare-metal environment mostly cases?" :
public static void Main(string[] args)
{
var a = 1;
var b = 2;
var r = a + b;
Console.WriteLine(r);
}
We can understand the theme easier, because it has translation problem, overheads and the runtime costs. And has some topics:
For example, many tiny system can built with platform dependent C compiler. The C compiler has runtime code fragments we know 'strlen()', 'malloc()' and etc. We can write in C code:
public static int Main(string[] args)
{
string p = "ABCDEFG";
int r = p.Length; // IL: get_Length(p);
Console.WriteLine("{0}", r);
return 0;
}
instead:
int main(int argc, char* argv[])
{
const char* p = "ABCDEFG";
const int r = strlen(p);
printf("%d\n", r);
return 0;
}
We can translate naturally both C and C# code. (In this example doesn't include discussion in corner cases, may be you know different string encoding and string formatting features)
So we can simplicity replace from Length
property to strlen
function if these semantics are equals.
If it's true, the translation cost (includes additional interoperability fragments) can be minimize or makes zero by directed calling strlen(p)
code fragment.
(And it's reducing code footprints because many other implicitly linked native independent libraries shared these codes.)
Curently, IL2C focuses how to dodge these problems. You know it has many lacks of implementations, includes `System.String.LastIndexOf', because I have no free times now at IL2C prgression :)
Thank you for your answer,Agree with your idea and have studied several IL2CPP details, including Unity's IL2CPP。Use scenarios, in micro systems, using C# to write logic code,Enjoy the convenience of a high-level language, with IL2C, less memory and less code。Hope it goes on and on
I am very curious about how the InternalCall of the.net Framework handles, for example, the conversion of System.String LastIndexOf to C is not implemented。What is the main function of IL2C,There are similar products available now, https://github.com/anydream/il2cpp (The problem of Internalcall has been abandoned)