Fix Object::IsSoftReference

Also changed -Xzygote to default boot.art and log arguments

Finally Makefile work:
- separate out test dependencies
- changed zygote with art to work by replacing libdvm with libart[d]
- changed Makefile defines to name and error check their arguments
  This was to fix bug in generating ART_TARGET_EXECUTABLES
  where we used $(1) when we meant $(3)

Change-Id: I7ef6008eff1fe99b59d151b6793e8fd8ea5304d4
diff --git a/build/Android.executable.mk b/build/Android.executable.mk
index 3311b99..7619f74 100644
--- a/build/Android.executable.mk
+++ b/build/Android.executable.mk
@@ -22,50 +22,69 @@
 # $(3): target or host
 # $(4): ndebug or debug
 define build-art-executable
+  ifneq ($(3),target)
+    ifneq ($(3),host)
+      $$(error expected target or host for argument 3, received $(3))
+    endif
+  endif
+  ifneq ($(4),ndebug)
+    ifneq ($(4),debug)
+      $$(error expected ndebug or debug for argument 4, received $(4))
+    endif
+  endif
+
+  art_executable := $(1)
+  art_source := $(2)
+  art_target_or_host := $(3)
+  art_ndebug_or_debug := $(4)
+
   include $(CLEAR_VARS)
-  ifeq ($(3),target)
+  ifeq ($$(art_target_or_host),target)
     include external/stlport/libstlport.mk
   endif
+
   LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-  ifeq ($(4),ndebug)
-    LOCAL_MODULE := $(1)
-  else
-    LOCAL_MODULE := $(1)d
-  endif
   LOCAL_MODULE_TAGS := optional
-  LOCAL_SRC_FILES := $(2)
-  ifeq ($(3),target)
-    LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
-  else
-    LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
+  LOCAL_SRC_FILES := $$(art_source)
+  LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
+  LOCAL_SHARED_LIBRARIES := libnativehelper
+
+  ifeq ($$(art_ndebug_or_debug),ndebug)
+    LOCAL_MODULE := $$(art_executable)
+  else #debug
+    LOCAL_MODULE := $$(art_executable)d
   endif
-  ifeq ($(4),debug)
-    ifeq ($(3),target)
+
+  ifeq ($(art_target_or_host),target)
+    LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
+    ifeq ($$(art_ndebug_or_debug),debug)
       LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
-    else
+    endif
+  else # host
+    LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
+    ifeq ($$(art_ndebug_or_debug),debug)
       LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
     endif
   endif
-  LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
-  LOCAL_SHARED_LIBRARIES := libnativehelper
-  ifeq ($(4),ndebug)
+
+  ifeq ($$(art_ndebug_or_debug),ndebug)
     LOCAL_SHARED_LIBRARIES += libart
-  else
+  else # debug
     LOCAL_SHARED_LIBRARIES += libartd
   endif
-  ifeq ($(3),target)
+
+  ifeq ($$(art_target_or_host),target)
     LOCAL_SHARED_LIBRARIES += libstlport
   endif
-  ifeq ($(3),target)
+
+  ifeq ($$(art_target_or_host),target)
     include $(BUILD_EXECUTABLE)
-  else
+    ART_TARGET_EXECUTABLES := $(ART_TARGET_EXECUTABLES) $(TARGET_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
+  else # host
     include $(BUILD_HOST_EXECUTABLE)
+    ART_HOST_EXECUTABLES := $(ART_HOST_EXECUTABLES) $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
   endif
-  ifeq ($(1),target)
-    ART_TARGET_EXECUTABLES += $(TARGET_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
-  else
-    ART_HOST_EXECUTABLES += $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
-  endif
+
 endef
 
 ifeq ($(ART_BUILD_TARGET_NDEBUG),true)
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index e35758d..92443be 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -18,37 +18,43 @@
 ART_TARGET_TEST_EXECUTABLES :=
 
 # $(1): target or host
-# $(2): file name with .cc or .cc.arm extension
+# $(2): file name
 define build-art-test
+  ifneq ($(1),target)
+    ifneq ($(1),host)
+      $$(error expected target or host for argument 1, received $(1))
+    endif
+  endif
+
+  art_target_or_host := $(1)
+  art_gtest_filename := $(2)
+
   include $(CLEAR_VARS)
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
     include external/stlport/libstlport.mk
   endif
+
   LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-  LOCAL_MODULE := $(notdir $(basename $(2:%.arm=%)))
+  LOCAL_MODULE := $(notdir $(basename $$(art_gtest_filename)))
   LOCAL_MODULE_TAGS := tests
-  LOCAL_SRC_FILES := $(2)
+  LOCAL_SRC_FILES := $$(art_gtest_filename)
   LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
   LOCAL_SHARED_LIBRARIES := libarttest libartd
-  ifeq ($(1),target)
+
+  ifeq ($$(art_target_or_host),target)
     LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
     LOCAL_SHARED_LIBRARIES += libdl libicuuc libicui18n libnativehelper libstlport libz
     LOCAL_STATIC_LIBRARIES := libgtest libgtest_main
-  else
+    include $(BUILD_EXECUTABLE)
+    ART_TARGET_TEST_EXECUTABLES += $(TARGET_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
+  else # host
     LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
     LOCAL_SHARED_LIBRARIES += libicuuc-host libicui18n-host libnativehelper libz-host
     LOCAL_WHOLE_STATIC_LIBRARIES := libgtest_main_host
-  endif
-  ifeq ($(1),target)
-    include $(BUILD_EXECUTABLE)
-  else
     include $(BUILD_HOST_EXECUTABLE)
-  endif
-  ifeq ($(1),target)
-    ART_TARGET_TEST_EXECUTABLES += $(TARGET_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
-  else
     ART_HOST_TEST_EXECUTABLES += $(HOST_OUT_EXECUTABLES)/$$(LOCAL_MODULE)
   endif
+
 endef
 
 ifeq ($(ART_BUILD_TARGET),true)
diff --git a/build/Android.libart.mk b/build/Android.libart.mk
index b58d8e8..6c33512 100644
--- a/build/Android.libart.mk
+++ b/build/Android.libart.mk
@@ -17,47 +17,62 @@
 # $(1): target or host
 # $(2): ndebug or debug
 define build-libart
+  ifneq ($(1),target)
+    ifneq ($(1),host)
+      $$(error expected target or host for argument 1, received $(1))
+    endif
+  endif
+  ifneq ($(2),ndebug)
+    ifneq ($(2),debug)
+      $$(error expected ndebug or debug for argument 2, received $(2))
+    endif
+  endif
+
+  art_target_or_host := $(1)
+  art_ndebug_or_debug := $(2)
+
   include $(CLEAR_VARS)
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
     include external/stlport/libstlport.mk
   endif
   LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
-  ifeq ($(2),ndebug)
+  ifeq ($$(art_ndebug_or_debug),ndebug)
     LOCAL_MODULE := libart
-  else
+  else # debug
     LOCAL_MODULE := libartd
   endif
+
   LOCAL_MODULE_TAGS := optional
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
     LOCAL_SRC_FILES := $(LIBART_TARGET_SRC_FILES)
-  else
+  else # host
     LOCAL_SRC_FILES := $(LIBART_HOST_SRC_FILES)
   endif
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
     LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
-  else
+  else # host
     LOCAL_CFLAGS := $(ART_HOST_CFLAGS)
   endif
-  ifeq ($(2),debug)
-    ifeq ($(1),target)
+  ifeq ($$(art_ndebug_or_debug),debug)
+    ifeq ($$(art_target_or_host),target)
       LOCAL_CFLAGS += $(ART_TARGET_DEBUG_CFLAGS)
-    else
+    else # host
       LOCAL_CFLAGS += $(ART_HOST_DEBUG_CFLAGS)
       LOCAL_STATIC_LIBRARIES := libgtest_host
     endif
   endif
   LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
   LOCAL_SHARED_LIBRARIES := liblog libnativehelper
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
     LOCAL_SHARED_LIBRARIES += libcutils libstlport libz libdl
-  else
+  else # host
     LOCAL_SHARED_LIBRARIES += libz-host
     LOCAL_LDLIBS := -ldl -lpthread -lrt
   endif
   LOCAL_STATIC_LIBRARIES += libdex
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
     include $(BUILD_SHARED_LIBRARY)
-  else
+  else # host
     include $(BUILD_HOST_SHARED_LIBRARY)
   endif
 endef
diff --git a/build/Android.libarttest.mk b/build/Android.libarttest.mk
index 823f78e..86927c3 100644
--- a/build/Android.libarttest.mk
+++ b/build/Android.libarttest.mk
@@ -16,27 +16,33 @@
 
 # $(1): target or host
 define build-libarttest
+  ifneq ($(1),target)
+    ifneq ($(1),host)
+      $$(error expected target or host for argument 1, received $(1))
+    endif
+  endif
+
+  art_target_or_host := $(1)
+
   include $(CLEAR_VARS)
-  ifeq ($(1),target)
+  ifeq ($$(art_target_or_host),target)
    include external/stlport/libstlport.mk
   endif
+
   LOCAL_CPP_EXTENSION := $(ART_CPP_EXTENSION)
   LOCAL_MODULE := libarttest
   LOCAL_MODULE_TAGS := tests
   LOCAL_SRC_FILES := $(LIBARTTEST_COMMON_SRC_FILES)
   LOCAL_SHARED_LIBRARIES := libartd
-  ifeq ($(1),target)
+  LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
+  ifeq ($$(art_target_or_host),target)
     LOCAL_CFLAGS := $(ART_TARGET_CFLAGS) $(ART_TARGET_DEBUG_CFLAGS)
     LOCAL_SHARED_LIBRARIES += libdl libstlport
     LOCAL_STATIC_LIBRARIES := libgtest
-  else
+    include $(BUILD_SHARED_LIBRARY)
+  else # host
     LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
     LOCAL_LDLIBS := -ldl -lrt -lpthread
-  endif
-  LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
-  ifeq ($(1),target)
-    include $(BUILD_SHARED_LIBRARY)
-  else
     include $(BUILD_HOST_SHARED_LIBRARY)
   endif
 endef