Zygote: Restrict slave mountspace so Dalvik apps can mount system-wide volumes

Android 4.2 implements multi-user storage using per-process mount
namespaces.  Originally, everything under "/" (the entire filesystem
hierarchy) is marked as a recursive-slave mountspace for all zygote
instances.  This is done so that user-storage sandbox mounts under
/storage/emulated are hidden from other apps and users.

Unfortunately this means that any Dalvik app (actually, any program whose
clone/fork ancestry includes a Dalvik zygote, which is everything except
services spawned directly from init) cannot mount system-wide volumes.
Thus, apps like CifsManager are effectively broken in Android 4.2, since
its cifs mounts are only visible to the CifsManager app itself.  All other
apps see empty mountpoints instead of the mounted volume.  Furthermore,
Linux provides no provision for a process to "escape" a recursive-slave
mountspace in versions prior to Linux 3.8 (setns syscall).

Here, we restrict the slave mountspace to /storage (and, due to a possible
kernel bug, /mnt/shell/emulated) so that Dalvik apps can mount system-wide
volumes elsewhere (with appropriate permission, as in earlier versions of
Android), while retaining full multi-user storage compatibility.

This change requires that a tmpfs volume is mounted as /storage in init.rc.
If this volume is unavailable, then Zygote falls back to the previous
behavior of marking the entire filesystem hierarchy as slave.  It also
implicitly requires that EMULATED_STORAGE_TARGET is path-prefixed by (part
of the subhierarchy of) ANDROID_STORAGE, which is the typical case.

Change-Id: Ic4c227fe7ef1b82bc600c52a85117ba03ae86329
debug: allow ability to hide GC freed lines in logcat

use setprop dalvik.vm.debug.alloc 0 to disable these noisy logs...

Change-Id: I8692b941901b43d33ea9ee30c288a47b6a3be3b1
DexOpt anything in /system on /cache

Allow system property to disable use of /cache for dexfiles.

(manually cherry-picked commit 15d27bbe10e307136e081bedb7cf25131896f1cb)

Change-Id: I110cab87e572dbf8e08d6b8e6681ccad6ee1733a
JIT: Allow use of cbz/cbnz for conditional branch gen.

Optimize conditional branch generation when comparing
with zero for ARM JIT. When possible use cbz/cbnz
instead of cmp+beq/cmp+bne.

This improves performance for usecases involving
code execution in Dalvik.

Change-Id: Iffd455d9cbb3ef0b1f87caafdae1b72ba3f0d2fc
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
JIT: Combine shift & sub for monitor unlock.

Optimize monitor unlock for ARM Thumb2 JIT.
Monitor unlock performs a logical shift left
and sub, replace it with a sub capable of
performing the shift in the same instruction.

This improves performance for usecases involving code
executing in Dalvik.

Change-Id: Iaf062d750c3bc941926f3c3b8a64dc9c7984a477
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
JIT: Use rsb and shift in easy multiply.

For easy multiplication using reverse subtract (when
lit is 2^n-1) use the barrel shifter for rsb.

This improves arithmetic performance for code executing
in Dalvik. E.g String.hashCode.

Change-Id: Ifb086dcec344b30fd3e392ac21d508b43e820cdc
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
JIT: Hoist loop load operations above loop.

Hoists Dalvik frame load operations outside of loops, when possible.
This improves performance in most loops, and is noticable in many
applications.

Change-Id: Ibe42b509b50a13f19758fd923f31d703e33a51c6
Signed-off-by: Henrik Smiding <henrik.smiding@stericsson.com>
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
JIT: Combine add with shift.

Optimize logical shift for ARM JIT.
Whenever logical shift is followed by an add,
try to replace it with an add capable of performing
the shift in the same instruction.

This improves performance for usecases
involving code executing in Dalvik.

Change-Id: I3cb807b6d6ef4b053a19e2703676a93a930eb963
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
JIT: Combine add with shift and offset for array load & store.

Optimize long and double array load / store for ARM JIT.
Array load / store performs a logical shift left and add,
replace it with add capable of performing shift in the
same instruction.
Array load / store performs an add instead of using offset
for vldr/vstr. Replace the add and vldr/vstr with a vldr/vstr
that is capable of handling offset.

This improves performance for usecases involving long and double
array code execution in Dalvik. E.g WindowOrientation.

Change-Id: I90220c349ab936cdba1987139ccdf4dc31d7bbb0
Signed-off-by: Patrik Ryd <patrik.ryd@stericsson.com>
Add barriers for proper observation sequence.

Change-Id: I5c2ef043920fe60c92304cd2c8a857a805b6e9af
GC triggering performance optimizations

Copy the correct starting heap size at process init.
Interfaces to set GC/managed heap parameters.

Change-Id: I454b1985a3225d7dbdea9c5d4e6f0c9f5e24352e
Excessive JNI: Dump HPROF dump.

This change would dump the heap memory status before we abort the
VM because of excessive JNI refs.

Change-Id: Iaf43ee0f2f40fc007e231dd10d1c6c6d95284896
Added missing <include sys/resource.h> for gcc-4.7.1

Patch Set 2: Added gcc version check as suggested by jeagoss

Change-Id: I7743d5fab8d026e12ad9e9ef4d4fbabe0a9bded7
ThumbVFP.cpp:231:10: error: variable 'wide' set but not used [-Werror=unused-but-set-variable]

Change-Id: If6828c8cf8c2c4ab28567f6e39126e537d0020c1