|
From: Arno P. <ar...@pu...> - 2011-09-20 10:20:20
|
On 9/19/11 11:19 PM, Shai wrote:
> Hi,
> I'm running into quite a few issues in the generated code from XML VM.
> Our existing code base is huge and doesn't depend on Android/iPhone
> API's, we use native methods where appropriate but most of the work is
> in Java.
>
> For hello world apps things are starting to work as expected but I'm
> running into some hard difficulties when implementing elaborate
> functionality. The biggest problem I'm facing right now is a bad pointer
> in this code:
> {
> XMLVM_MEMCPY(curThread_w23657aaac46b1c17->fields.java_lang_Thread.xmlvmExceptionEnv_,
> local_env_w23657aaac46b1c17, sizeof(XMLVM_JMP_BUF)); goto label5; };
I can't help you with the information you've provided. We have
successfully cross-compiled complex applications but of course I can't
rule out that there are still issues with the C code generation. Can you
distill a small, self-contained example that would allow me to debug this?
> The debugger is claiming that curThread is 0x1. I would investigate this
> but I'm not sure where to start, I enabled null pointer exception checks
> but that didn't help. I couldn't find the code to enable array boundary
> checks, some of our code really needs that since race conditions could
> trigger a failure and constantly synchronizing is impractical for our
> code which is very performance sensitive. BTW Shouldn't such checks be
> on by default? I understand the cost but since quite allot of third
> party code expects this to work for Java...
We have a #define for NPE checks but no runtime checks for array bounds.
If your code depends on this, it might be a clue why things don't work.
Adding array bound checks shouldn't be that difficult.
> Another issue I'm facing is when I select the IDE option to modernize
> the project to LLVM things stop working. I'm guessing its related to
> endianess of math functions? Moving to LLVM would be huge both because
> of the performance boost on ARM and because of the MUCH shorter compile
> time.
No idea. What do you mean with "stop working"? It doesn't compile or the
executable crashes?
> I also tried to get java.util.Calendar working without much luck, it has
> too many red dependencies in IBM specific system functions to get
> working. I don't need the entire API and can easily implement it
> natively however I was wondering, can I replace a "System" class with my
> own? E.g. can I just write a java.util.Calendar/GregorianCalendar class
> and have it take precedence over the classes that are generated from the
> Harmony bytecode?
> I'm guessing that I can obviously just change the redclass list to
> remove Calendar entirely and just build a class of my own but I'd rather
> not change XMLVM since I only need a subset of calendar and probably
> won't be able to reimplement calendar in a generic enough way for
> everyone's needs.
We call those "proxy classes": classes in src/xmlvm2c/lib/proxies have
precedence over the original Harmony version. You should grab the
original version from the Harmony sources and then modify it to what you
need. You can add a native method and then run "ant gen-c-wrappers"
which will put a skeleton for the native method in src/xmlvm2c/lib/native
Arno
|