Skip to main content

Need information about stacks in vm

1 reply [Last post]
Joined: 2005-09-22

Recently I saw Mark Lam's blog entry ( ) on stacks in CDC vm. I was wondering how java and native stacks are provided in CLDC version of phoneME.
Does the native stack is shared between vm and native methods ?
And who manages native stacks , is it responsibilit of OS or of the CLDC VM ?

Thanks & Regards,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-10-20


CLDC VM also distinguishes native and Java stacks.
It uses single native stack provided by OS which is shared between VM itself and native methods. This stack is controlled by OS.

For execution of Java code VM allocates Java stacks in Java Heap (one stack per Java thread). These stacks are managed by the Virtual Machine. They can be dynamically resized and relocated across Java Heap just like other heap objects.

The layout of Java stack is defined in Frame.hpp and Frame_.hpp.
To print the contents of Java stack use pss() debug function or call System.getProperty("__debug.only.pss") directly from Java. They print even more information when +PrintLongFrames and +PrintExtraLongFrames run-time flags are on.

Good luck,