views:

594

answers:

4

When you compile windows application in .NET you can set "Platform Target" to be x86 or x64. This would optimize your code to a specific architecture of the processor and allow to escape IL. Does anyone know if there's something that would allow to achieve the same result for Windows Mobile application? I'm only interested in running my application on ARM architecture.

+1  A: 

I don't believe specifying the platform target does optimise the generated IL for the given architecture. Instead, it says, "I only run on the specified architecture, because I contain P/Invoke calls specific to that architecture." At least, that's my understanding of it. It means that when running on an x64 machine, an executable can run under the 32 bit version of the CLR for compatibility.

How this fits in with the compact framework (which I assume is your actual platform?) I'm not sure.

Jon Skeet
I don't think that's true. I've compiled windows/web applications as x64 applications, and even if you have symbols available, and you attach debugger, a lot of times, you will get a message that debugger can't get the value of the variable, because code is optimized.
Ilya Volodin
http://social.microsoft.com/Forums/en-US/netfxbcl/thread/0705a4a3-49bf-4295-8932-ac6466172f8b
Ilya Volodin
Hmm... I'm not entirely sure I trust that. It's the JIT's job to optimise to the current architecture (given that it knows it!) rather than the C# compiler's. Your argument will be very convincing if you can show it changing the generated IL.
Jon Skeet
+1  A: 

Use Mono's Ahead-of-Time (AOT) compilation. That's how they got UNITY scripting onto the iPhone which is an ARM platform. It will probably take some labour to get it up and running on Windows Mobile since, afaik, noone has done that particular platform port yet but the compiler etc should already be there.

You can see Miguel de Icaza's presentation of it at MS PDC here.

David Holm
A: 

x86 or x64 doesn't optimize the IL - that's the job of the JITter that runs on the deployed machine. x86 or x64 just marks a bitness flag.

Of course, in the desktop framework you can NGEN your MSIL to a particular CPU - but IIRC, the lack of a native image will just revert to JIT compilation. Besides that, though, I don't think NGEN is available for .NET CF anyway.

I'm not sure why you'd need to restrict to ARM processors, but a P/Invoke to GetSystemInfo will return a SYSTEM_INFO structure with the processor type in it. That could prevent your app continuing on !ARM, but not really from running.

Edit: Re-reading this question, I noticed that besides he C# and .NET tag, there's really no indication that you only want a managed solution. If you're willing to go unmanaged, you can obviously just compile down to ARM.

Mark Brackett
+1  A: 

If you want to create ARM based application on Windows Mobile based devices install .NET Compact Framework. You’ll have a new “Smart device” project type in your VS for that.

I don’t know if there is JIT for any other ARM platform WM, there is also .NET Micro Framework but I can’t tell you anything about that, maybe this will solve your questions?

michael