On Wed, Jun 24, 2009 at 11:54 AM, Marek
Urbaniak<[email protected]> wrote:
> I have a question regarding Google I/O 2008 presentation about Dalvik
> internals. One thing is not completely clear to me: implicit labeling
> (slide #21). It is listed as one reason why memory is saved in Dex
> format. Could anyone explain, what exactly does it mean in this
> context?

As an example first of *explicit* labeling, if you look inside a
.class file, you will find that many parts of it are represented as
tagged attributes, where the tag identifies the attribute, say, as a
method body, a default field value, a line number table, etc. Those
attribute tags are generally two-byte references to constant pool
entries for string constants, and though two bytes may not sound like
much, they add up. Similarly, each entry in the constant pool for a
.class is preceded by a byte identifying its type, and these also add
up.

In the dex format, on the other hand, in representing the vast
majority of data, such labeling is omitted, because the format itself
implies the type of data being represented. Bytecode arrays are known
to be bytecode arrays because they are pointed at from a known offset
in a method structure; and that method structure is known to be a
method structure, since it is referred to at the right point in a
class definition structure; and that class definition structure is
known to be a class definition structure, because it is within the
class definition array pointed at by the dex file header. It's all
implicit; no tagging required.

The dex format does provide an "escape valve" for arbitrary tagged
data in the form of annotations. Dex annotations are used to represent
annotations as written in the original source code, but they are also
used for a couple of things that are represented as tagged attributes
in .class files. For example, metadata about inner classes is
represented in dex files using the annotation mechanism.

You can refer to the dex format spec for more details, under
<dalvik/docs> in the source.

Cheers,

-dan

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/android-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to