dalvik: update and optimize from master and Linaro

export setThreadName() and add NULL check

Set Processes comm name to package name

When debugging audit logs, it is often helpful to
have the packages name. Bear in mind that the
package name is the right most chars up to
TASK_COMM_LEN. Although a possibility of truncation
exists, it can be useful for narrowing down the
possibilities.

Dalvik: DMB Optimisation

Replaces use of 'dmb' and 'dmb st' with inner-shareable versions.
This should improve performance in certain cases without harming
correctness.

Dalvik: DMB Optimisations for TracingJIT

Makes DMB domain ISH or ISHST instead of the implicit System.
ISH (Inner Shareable) should be sufficient for all cores/clusters,
but is not sufficient for GPU or other memory-mapped peripherals

Fix "dalvikvm -help".

Showing the help because we were asked to isn't an error.
Showing the help because the command line made no sense is.

Bug: https://code.google.com/p/android/issues/detail?id=60009

Dalvik: Ensure that the array length complies with the final specifier

JSR-133, which Android 4 should comply with, "final" fields should be
visible to all threads at the time the constructor exits, regardless of
synchronization. This behaviour should also apply to the array lengths
as they are regarded as equivalent in behaviour to "final" fields.
Non-final fields require explicit synchronization in Java for them to be
accessed correctly.

The Dalvik VM in Android ensures constructors for ordinary object behave
properly by inserting a memory barrier ("DMB") on their return if the
object's class has a "final" field.

The issue, however, is that while Dalivk inserts a barrier in
constructors, it doesn't during array create. A barrier ought to be
inserted in order to ensure an array's length is visible when the array
itself can be observed by other threads.

In order for Dalvik to be correct in respect to JSR-133 and the ARM
memory model, it should be modified to have a memory barrier after an
array is allocated and initialized, before it is visible to other
threads.

Signed-off-by: Stuart Monteith <Stuart.Monteith@arm.com>
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>

Fix that getClasses() method returns protected classes

In publicOnly condition, Dalvik_java_lang_Class_getDeclaredClasses()
returns non-public(protected) declared class.
It is not match with documentation and the result of host java vm.
Protected inner declared class is generated as ‘public’ class via host javac.
But, has ‘protected’ constructor.
This fix add check constructor’s modifier to decide whether public or not.
Related issue: http://code.google.com/p/android/issues/detail?id=60394

Reject dex files that attempt to use unspecified class access flags

Move verification of class access flags to libdex

Use RETURN_PTR(NULL) instead of RETURN_VOID in newNonMovableArray.

RETURN_VOID doesn't set the return value. This means that we are
returning random garbage when the allocation doesn't succeed.

Bug: 11971220

Change-Id: I3eec5f259c7437e7f2bcf1b66afe93618dd64e8e