Build SM GCC 4.8.

Thanks GNOME.
dalvik: Fix for broswer-crashing bug

This applies the fix proposed by Olivier Cozette in
https://code.google.com/p/android/issues/detail?id=37561
and fixes our bug:
https://bugs.launchpad.net/linaro-android/+bug/978060

An alternative fix has been applied since, leaving this one in
as a comment for reference

Change-Id: I54336c83650c1628fd1bb689148bc1dd8843d7c6
Signed-off-by: Jon Medhurst <tixy@linaro.org>
Dalvik: Better compatibility with different compilers

This fixes building with clang, and possibly future versions of gcc:
- Don't error out on unused functions generated by gen-mterp.py
  even when we're using -Werror
- Eliminate some dead code (Word/kWordSize definition) clang warns about
- Add a return statement to a switch path causing a possible code path
  with uninitialized variables (if the compiler doesn't know what
  dvmAbort() is)
- Initialize a variable

Change-Id: I9a3c0a1ad4dce10445e2251e491f18511413ca50
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
dalvik/vm: Dalvik startup with a low memory footprint

Initialize concurrentStartBytes and createMspace using HEAP_MIN_FREE.
This helps save Android framework memory after boot.

This is for low memory targets only(<=512MB RAM & hdpi resolution)
Also, set TARGET_ARCH_LOWMEM in the BoardConfig.mk file of a device
for this patch to take effect.

Change-Id: Ia1dec6e89ef8285f1e12644bcdc6ca17a15e37a2

Conflicts:
	vm/Android.mk
Add -Wno-unused-but-set-variable to the Dalvik project.

This is to meet long term goal that we don't suppress any warnings in
the global makefile.

BUG: 10495043
Change-Id: I1eece42a9f2c43b614cfbeb1397c8071fb3db04a
(cherry picked from commit 0c4625a4e1464544625723b013b3febb1cc9359e)
[PATCH] Basic KSM Support

Be sure to add '#define MADV_MERGEABLE 12' to
bionic/libc/include/sys/mman.h so we can have a central place for this

parse the process memory map and inform madvise common HEAP/Stack
regions on fork from zygote

These then can be used by the kernel KSM module to re-join (copy on write)
pages between the various dalvik processes.

As is on a fully loaded system you can expect ~12MB to be indicated to be
scanned by KSM.. of this 10-15% will be saved; as such a recommend a very
slow scan until as any logic to stop scanning while sleeping will require
another process and remove all memory savings provided by this logic.

To activate on a KSM kernel (2min for full scan of ~16m and 1%CPU):

echo 4000 > /sys/kernel/mm/ksm/sleep_millisecs
echo 128 > /sys/kernel/mm/ksm/pages_to_scan
echo 1 > /sys/kernel/mm/ksm/run

Newer kernels only require the last line.

In future additional memory regions and kernel logic may improve this.

Change-Id: I271cbee74a1f02a89c34c6ee9006a4ea81360154
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.
vm: fix extraneous parentheses warnings

Summary:
This warning is treated as an error with clang and -Werror.
Fixes the following:
  equality comparison with extraneous parentheses

Test Plan: verify

Reviewers: randall.rushing, synergy

Reviewed By: synergy

Differential Revision: http://review.codefirex.com/D598
Small tweak
Add interface for updating process state.

Used only in ART. Stub function added to Dalvik.

Bug: 8981901
Change-Id: Icc4d3c73c7959bae97d43752f3b4c5e146b7cb1f
Remove some ARMv5 cruft.

Change-Id: I95dcfd9dff8db25b9419b8ef862e3b9b70927a0c
Remove the sole reference to __ARM_HAVE_BLX.

Every ARM processor we run on has blx.

Change-Id: I633984d208d8a1995b9595521352e0b16413837c
Fix libutils dependencies for dexdump & dexlist.

We should always use a libutils SHARED_LIBRARY on the target &
a STATIC_LIBRARY on the host.

(cherry picked from commit 2ac78805e1b4d80308c5c4a48a997abc3a2ac37b)

Change-Id: I06c9b8f0cf663e00da0eeba54c893d8eec1d8a9f
Dalvik: Add sdiv support in the interpreter

This patch adds hardware divide support in the interpreter side of
dalvik. This operation is supported on new armv7 cpus such as A15 or A7.

Opcodes added:
    OP_DIV_INT
    OP_DIV_INT_2ADDR
    OP_DIV_INT_LIT16
    OP_DIV_INT_LIT8
    OP_REM_INT
    OP_REM_INT_2ADDR
    OP_REM_INT_LIT16
    OP_REM_INT_LIT8

Change-Id: Ib1ec5856d957feadd90807fe53ec34cc0e1fd4a2
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Dalvik: Add hardware support for OP_LONG_TO_DOUBLE in the interpreter

The following patch adds hardware vfp support for OP_LONG_TO_DOUBLE
in the interpreter. Previously this opcode was implemented using one of
gcc's builtin helpers.

Change-Id: I7713aa03c0b0bed8df592710dd50ab3d13d4bd9b
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Dalvik: Add sdiv support in the JIT

This patch adds hardware divide support in the JIT side of dalvik.
This operation is supported on new armv7 cpus such as A15 or A7.

The following opcodes are enabled and will generate code based using
SDIV instruction:

        OP_DIV_INT
        OP_DIV_INT_2ADDR
        OP_REM_INT
        OP_REM_INT_2ADDR
        OP_DIV_INT_LIT16
        OP_DIV_INT_LIT8
        OP_REM_INT_LIT16
        OP_REM_INT_LIT8

Change-Id: I2b2f9f337f13b5c794df951c4929b6ca0ad583c4
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>

Conflicts:
	vm/compiler/codegen/arm/Thumb2/Factory.cpp
Dalvik: Add hardware vfp support for OP_LONG_TO_DOUBLE in JIT

The following patch adds hardware vfp support for OP_LONG_TO_DOUBLE
in the JIT. Previously this opcode was implemented using one of gcc's
builtin helpers.

Change-Id: I3c88b2a527dea99dcefdb34be6695e75993da73e
Signed-off-by: Serban Constantinescu <serban.constantinescu@arm.com>
Dalvik: Better compatibility with different compilers

This fixes building with clang 3.4, and possibly future versions of gcc:
- Don't error out on unused functions generated by gen-mterp.py even
  when we're using -Werror
- Eliminate some dead code (Word/kWordSize definition) clang warns about

In order to avoid the need for -Wno-error=unused-function, gen-mterp.py
would have to be a lot smarter than it currently is.

Currently, it copies all code from header.cpp and then adds CPU specific
routines.

The code in header.cpp defines all sorts of functions that may or may
not be used by the CPU specific routines, depending on whether or not
the CPU specific bits have a better implementation available.

To fix this without -Wno-error=unused-functions, gen-mterp.py would have
to actually read the CPU specific bits and based on that throw out parts
of header.cpp that aren't needed.

This seems to be too much effort to just avoid having a couple of unused
functions in the code that can be thrown out at compile time anyway,
especially since this is in dalvik which will likely not see another
major revision.

Change-Id: I2874c6f05186721636518e422b0f39a3d8e731cd
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Don't implicitly cast NULL to a bool

The code is wrong and causes an error when building with clang 3.4
(-Werror,-Wnull-conversion)

Change-Id: If03aa782fa25337802ff906a0d06071fbda93e26
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>
Don't implicitly cast NULL to a bool

The code is wrong and causes an error when building with clang 3.4
(-Werror,-Wnull-conversion)

Change-Id: I223649ebcebf6f5df4b1024651bf07e85288f0b8
Signed-off-by: Bernhard Rosenkränzer <Bernhard.Rosenkranzer@linaro.org>