Moving from libdvm to libart (1 of 5)

Change-Id: I6541802c5f403a4ba4424818084b94bebe71dfca
diff --git a/Android.mk b/Android.mk
index 6bbceb9..b614da5 100644
--- a/Android.mk
+++ b/Android.mk
@@ -67,11 +67,6 @@
 ART_HOST_TEST_DEPENDENCIES   := $(ART_HOST_DEPENDENCIES)   $(ART_TEST_OAT_FILES)
 ART_TARGET_TEST_DEPENDENCIES := $(ART_TARGET_DEPENDENCIES) $(ART_TEST_OAT_FILES)
 
-ART_TARGET_TEST_DEPENDENCIES += $(TARGET_OUT_EXECUTABLES)/oat_process $(TARGET_OUT_EXECUTABLES)/oat_processd
-
-# Switch this to "oat_process" to run an optimized build.
-OAT_PROCESS=oat_processd
-
 ########################################################################
 # host test targets
 
@@ -123,7 +118,7 @@
 	@echo test-art-target-run-test-002 PASSED
 
 ########################################################################
-# oat_process test targets
+# oat test targets
 
 # $(1): jar or apk name
 define art-cache-oat
@@ -137,14 +132,13 @@
   ART_CACHE_OATS += $(call art-cache-oat,$(1))
 endef
 
-.PHONY: test-art-target-oat-process
-test-art-target-oat-process: test-art-target-oat-process-am # test-art-target-oat-process-Calculator
-
+# for test-art-target-am
 $(eval $(call build-art-cache-oat,system/framework/am.jar))
+
+# for test-art-target-Calculator
 $(eval $(call build-art-cache-oat,system/app/Calculator.apk))
 
-
-# WORKING for zygote-art
+# for zygote-art
 ifeq ($(TARGET_PRODUCT),mysid)
 
 $(eval $(call build-art-cache-oat,system/app/ApplicationsProvider.apk))
@@ -369,34 +363,16 @@
 
 endif
 
-.PHONY: test-art-target-oat-process-am
-test-art-target-oat-process-am: $(call art-cache-oat,system/framework/am.jar) test-art-target-sync
-	adb remount
-	adb sync
-	adb shell sh -c "export CLASSPATH=/system/framework/am.jar && $(OAT_PROCESS) /system/bin/app_process /system/bin com.android.commands.am.Am start http://android.com && touch $(ART_TEST_DIR)/test-art-target-process-am"
+.PHONY: test-art-target-am
+test-art-target-am: $(call art-cache-oat,system/framework/am.jar) test-art-target-sync
+	adb shell sh -c "am start http://android.com && touch $(ART_TEST_DIR)/test-art-target-process-am"
 	$(hide) (adb pull $(ART_TEST_DIR)/test-art-target-process-am /tmp/ && echo test-art-target-process-am PASSED) || echo test-art-target-process-am FAILED
 	$(hide) rm /tmp/test-art-target-process-am
 
-.PHONY: test-art-target-oat-process-Calculator
-# Note that using this instead of "adb shell am start" make sure that the /data/art-cache is up-to-date
-test-art-target-oat-process-Calculator: $(call art-cache-oat,system/app/Calculator.oat) $(call art-cache-oat,system/framework/am.jar) test-art-target-sync
-	mkdir -p $(ART_CACHE_OUT)
-	unzip $(TARGET_OUT_APPS)/Calculator.apk classes.dex -d $(TARGET_OUT_DATA)/art-cache
-	mv $(TARGET_OUT_DATA)/art-cache/classes.dex $(ART_CACHE_OUT)/system@app@Calculator.apk@classes.dex.`unzip -lv $(TARGET_OUT_APPS)/Calculator.apk classes.dex | grep classes.dex | sed -E 's/.* ([0-9a-f]+)  classes.dex/\1/'` # note this is extracting the crc32 that is needed as the file extension
-	adb remount
-	adb sync
-	if [ "`adb shell getprop wrap.com.android.calculator2 | tr -d '\r'`" = "$(OAT_PROCESS)" ]; then \
-	  echo wrap.com.android.calculator2 already set; \
-	  adb shell start; \
-	else \
-	  echo Setting wrap.com.android.calculator2 and restarting runtime; \
-	  adb shell setprop wrap.com.android.calculator2 "$(OAT_PROCESS)"; \
-	  adb shell stop; \
-	  adb shell start; \
-	  sleep 30; \
-	fi
+.PHONY: test-art-target-Calculator
+test-art-target-Calculator: $(call art-cache-oat,system/app/Calculator.oat) $(call art-cache-oat,system/framework/am.jar) test-art-target-sync
 	adb shell kill `adb shell ps | fgrep com.android.calculator2 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
-	adb shell sh -c "export CLASSPATH=/system/framework/am.jar && $(OAT_PROCESS) /system/bin/app_process /system/bin com.android.commands.am.Am start -a android.intent.action.MAIN -n com.android.calculator2/.Calculator && touch $(ART_TEST_DIR)/test-art-target-process-Calculator"
+	adb shell sh -c "am start -a android.intent.action.MAIN -n com.android.calculator2/.Calculator && touch $(ART_TEST_DIR)/test-art-target-process-Calculator"
 	$(hide) (adb pull $(ART_TEST_DIR)/test-art-target-process-Calculator /tmp/ && echo test-art-target-process-Calculator PASSED) || echo test-art-target-process-Calculator FAILED
 	$(hide) rm /tmp/test-art-target-process-Calculator
 
@@ -405,7 +381,6 @@
 #
 # zygote-artd will change to use art to boot the device with a debug build
 # zygote-art will change to use art to boot the device with a production build
-# zygote-dalvik will restore to booting with dalvik
 #
 # zygote-artd-target-sync will just push a new artd in place of dvm
 # zygote-art-target-sync will just push a new art in place of dvm
@@ -414,8 +389,6 @@
 define define-zygote-art-targets
 .PHONY: zygote-art$(1)-target-sync
 zygote-art$(1)-target-sync: $(ART_TARGET_DEPENDENCIES) $(TARGET_BOOT_OAT) $(ART_CACHE_OATS)
-	cp $(TARGET_OUT_SHARED_LIBRARIES)/libart$(1).so $(TARGET_OUT_SHARED_LIBRARIES)/libdvm.so
-	cp $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libart$(1).so $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libdvm.so
 	cp $(TARGET_OUT_EXECUTABLES)/oatopt$(1) $(TARGET_OUT_EXECUTABLES)/dexopt
 	cp $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/oatopt$(1) $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/dexopt
 	mkdir -p $(TARGET_OUT_DATA)/property
@@ -426,7 +399,6 @@
 .PHONY: zygote-art$(1)
 zygote-art$(1): zygote-art$(1)-target-sync
 	sed -e 's/--start-system-server/--start-system-server --no-preload/' -e 's/art-cache 0771/art-cache 0777/' < system/core/rootdir/init.rc > $(ANDROID_PRODUCT_OUT)/root/init.rc
-	adb shell rm -f $(ART_CACHE_DIR)
 	rm -f $(ANDROID_PRODUCT_OUT)/boot.img
 	unset ONE_SHOT_MAKEFILE && $(MAKE) showcommands bootimage
 	adb reboot bootloader
@@ -437,23 +409,6 @@
 $(eval $(call define-zygote-art-targets,d))
 $(eval $(call define-zygote-art-targets,))
 
-.PHONY: zygote-dalvik
-zygote-dalvik:
-	cp $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libdvm.so $(TARGET_OUT_SHARED_LIBRARIES)/libdvm.so
-	cp $(call intermediates-dir-for,SHARED_LIBRARIES,libdvm)/LINKED/libdvm.so $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/libdvm.so
-	cp $(call intermediates-dir-for,EXECUTABLES,dexopt)/dexopt $(TARGET_OUT_EXECUTABLES)/dexopt
-	cp $(call intermediates-dir-for,EXECUTABLES,dexopt)/LINKED/dexopt $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/dexopt
-	rm -f $(TARGET_OUT_DATA)/property/persist.sys.strictmode.disable
-	adb shell rm /data/property/persist.sys.strictmode.disable
-	adb remount
-	adb sync
-	cp system/core/rootdir/init.rc $(ANDROID_PRODUCT_OUT)/root/init.rc
-	rm -f $(ANDROID_PRODUCT_OUT)/boot.img
-	unset ONE_SHOT_MAKEFILE && $(MAKE) showcommands bootimage
-	adb reboot bootloader
-	fastboot flash boot $(ANDROID_PRODUCT_OUT)/boot.img
-	fastboot reboot
-
 ########################################################################
 # oatdump targets
 
diff --git a/build/Android.gtest.mk b/build/Android.gtest.mk
index 4ea6f9a..8f26997 100644
--- a/build/Android.gtest.mk
+++ b/build/Android.gtest.mk
@@ -75,7 +75,7 @@
 ART_TARGET_TEST_TARGETS += $$(art_gtest_target)
 else
 .PHONY: $$(art_gtest_target)
-$$(art_gtest_target): $$(art_gtest_exe)
+$$(art_gtest_target): $$(art_gtest_exe) $(ART_HOST_TEST_DEPENDENCIES)
 	$$<
 	@echo $$@ PASSED
 
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index 0995356..a87de97 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -66,8 +66,8 @@
 # The full system boot classpath
 TARGET_BOOT_JARS := $(subst :, ,$(DEXPREOPT_BOOT_JARS))
 TARGET_BOOT_DEX := $(foreach jar,$(TARGET_BOOT_JARS),$(TARGET_OUT_JAVA_LIBRARIES)/$(jar).jar)
-TARGET_BOOT_OAT := $(ART_CACHE_OUT)/boot.oat
-TARGET_BOOT_IMG := $(ART_CACHE_OUT)/boot.art
+TARGET_BOOT_OAT := $(TARGET_OUT_JAVA_LIBRARIES)/boot.oat
+TARGET_BOOT_IMG := $(TARGET_OUT_JAVA_LIBRARIES)/boot.art
 
 $(TARGET_BOOT_OAT): $(TARGET_BOOT_DEX) $(DEX2OAT_DEPENDENCY)
 	@echo "target dex2oat: $@ ($?)"
@@ -75,3 +75,9 @@
 	$(hide) $(DEX2OAT) --runtime-arg -Xms256m --runtime-arg -Xmx256m --image-classes=$(PRELOADED_CLASSES) $(addprefix --dex-file=,$(filter-out $(DEX2OAT),$^)) --oat=$@ --image=$(TARGET_BOOT_IMG) --base=$(IMG_TARGET_BASE_ADDRESS) --host-prefix=$(PRODUCT_OUT)
 
 $(TARGET_BOOT_IMG): $(TARGET_BOOT_OAT)
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := boot.art
+LOCAL_MODULE_TAGS := optional
+LOCAL_ADDITIONAL_DEPENDENCIES := $(TARGET_BOOT_IMG)
+include $(BUILD_PHONY_PACKAGE)
diff --git a/build/Android.oattest.mk b/build/Android.oattest.mk
index bb6695e..f982fe3 100644
--- a/build/Android.oattest.mk
+++ b/build/Android.oattest.mk
@@ -40,6 +40,7 @@
 define build-art-oat
 $(2): $(1) $(3) $(DEX2OAT_DEPENDENCY)
 	@echo "target dex2oat: $$@ ($$?)"
+	@mkdir -p $$(dir $$@)
 	$(hide) $(DEX2OAT) --runtime-arg -Xms64m --runtime-arg -Xmx64m --boot-image=$(3) $(addprefix --dex-file=,$$<) --oat=$$@ --host-prefix=$(PRODUCT_OUT)
 endef
 
diff --git a/oat_process/Android.mk b/oat_process/Android.mk
deleted file mode 100644
index 0ebb052..0000000
--- a/oat_process/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-local_src_files:= \
-	app_main.cpp
-
-local_shared_libraries := \
-	libcutils \
-	libutils \
-	libbinder \
-	libstlport
-
-include $(CLEAR_VARS)
-include external/stlport/libstlport.mk
-LOCAL_MODULE:= oat_process
-LOCAL_MODULE_TAGS:= optional
-LOCAL_SRC_FILES:= $(local_src_files)
-LOCAL_SHARED_LIBRARIES := liboat_runtime libart $(local_shared_libraries)
-LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
-LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
-include $(BUILD_EXECUTABLE)
-
-include $(CLEAR_VARS)
-include external/stlport/libstlport.mk
-LOCAL_MODULE_TAGS:= optional
-LOCAL_MODULE:= oat_processd
-LOCAL_SRC_FILES:= $(local_src_files)
-LOCAL_SHARED_LIBRARIES := liboat_runtimed libartd $(local_shared_libraries)
-LOCAL_C_INCLUDES += $(ART_C_INCLUDES)
-LOCAL_CFLAGS := $(ART_TARGET_CFLAGS)
-include $(BUILD_EXECUTABLE)
diff --git a/oat_process/MODULE_LICENSE_APACHE2 b/oat_process/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/oat_process/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/oat_process/NOTICE b/oat_process/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/oat_process/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
-   Copyright (c) 2005-2008, The Android Open Source Project
-
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
-
-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-
diff --git a/oat_process/app_main.cpp b/oat_process/app_main.cpp
deleted file mode 100644
index cc9d095..0000000
--- a/oat_process/app_main.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * Main entry of app process.
- *
- * Starts the interpreted runtime, then starts up the application.
- *
- */
-
-#define LOG_TAG "appproc"
-
-#include "stringprintf.h"
-#include "logging.h"
-
-#include <binder/IPCThreadState.h>
-#include <binder/ProcessState.h>
-#include <utils/Log.h>
-#include <cutils/process_name.h>
-#include <cutils/memory.h>
-#include <android_runtime/AndroidRuntime.h>
-
-#include <stdio.h>
-#include <unistd.h>
-
-namespace android {
-
-void app_usage()
-{
-    fprintf(stderr,
-        "Usage: oat_process [java-options] cmd-dir start-class-name [options]\n");
-}
-
-class AppRuntime : public AndroidRuntime
-{
-public:
-    AppRuntime()
-        : mParentDir(NULL)
-        , mClassName(NULL)
-        , mClass(NULL)
-        , mArgC(0)
-        , mArgV(NULL)
-    {
-    }
-
-#if 0
-    // this appears to be unused
-    const char* getParentDir() const
-    {
-        return mParentDir;
-    }
-#endif
-
-    const char* getClassName() const
-    {
-        return mClassName;
-    }
-
-    virtual void onVmCreated(JNIEnv* env)
-    {
-        if (mClassName == NULL) {
-            return; // Zygote. Nothing to do here.
-        }
-
-        /*
-         * This is a little awkward because the JNI FindClass call uses the
-         * class loader associated with the native method we're executing in.
-         * If called in onStarted (from RuntimeInit.finishInit because we're
-         * launching "am", for example), FindClass would see that we're calling
-         * from a boot class' native method, and so wouldn't look for the class
-         * we're trying to look up in CLASSPATH. Unfortunately it needs to,
-         * because the "am" classes are not boot classes.
-         *
-         * The easiest fix is to call FindClass here, early on before we start
-         * executing boot class Java code and thereby deny ourselves access to
-         * non-boot classes.
-         */
-        char* slashClassName = toSlashClassName(mClassName);
-        mClass = env->FindClass(slashClassName);
-        if (mClass == NULL) {
-            LOG(FATAL) << "Could not find class: " << mClassName;
-        }
-        free(slashClassName);
-
-        mClass = reinterpret_cast<jclass>(env->NewGlobalRef(mClass));
-    }
-
-    virtual void onStarted()
-    {
-        sp<ProcessState> proc = ProcessState::self();
-        ALOGV("App process: starting thread pool.\n");
-        proc->startThreadPool();
-
-        AndroidRuntime* ar = AndroidRuntime::getRuntime();
-        ar->callMain(mClassName, mClass, mArgC, mArgV);
-
-        IPCThreadState::self()->stopProcess();
-    }
-
-    virtual void onZygoteInit()
-    {
-        sp<ProcessState> proc = ProcessState::self();
-        ALOGV("App process: starting thread pool.\n");
-        proc->startThreadPool();
-    }
-
-    virtual void onExit(int code)
-    {
-        if (mClassName == NULL) {
-            // if zygote
-            IPCThreadState::self()->stopProcess();
-        }
-
-        AndroidRuntime::onExit(code);
-    }
-
-
-    const char* mParentDir;
-    const char* mClassName;
-    jclass mClass;
-    int mArgC;
-    const char* const* mArgV;
-};
-
-}
-
-using namespace android;
-
-/*
- * sets argv0 to as much of newArgv0 as will fit
- */
-static void setArgv0(const char *argv0, const char *newArgv0)
-{
-    strlcpy(const_cast<char *>(argv0), newArgv0, strlen(argv0));
-}
-
-int main(int argc, const char* argv[])
-{
-    // These are global variables in ProcessState.cpp
-    mArgC = argc;
-    mArgV = argv;
-
-    mArgLen = 0;
-    for (int i=0; i<argc; i++) {
-        mArgLen += strlen(argv[i]) + 1;
-    }
-    mArgLen--;
-
-    AppRuntime runtime;
-    const char* argv0 = argv[0];
-
-    // Process command line arguments
-    // ignore argv[0]
-    argc--;
-    argv++;
-
-    // ignore /system/bin/app_process when invoked via WrapperInit
-    if (strcmp(argv[0], "/system/bin/app_process") == 0) {
-        LOG(INFO) << "Removing /system/bin/app_process argument";
-        argc--;
-        argv++;
-        for (int i = 0; i < argc; i++) {
-            LOG(INFO) << StringPrintf("argv[%d]=%s", i, argv[i]);
-        }
-    }
-
-    // TODO: remove when we default the boot image
-    int oatArgc = argc + 1;
-    const char* oatArgv[oatArgc];
-    if (strcmp(argv[0], "-Ximage:/data/art-cache/boot.art") != 0) {
-        LOG(INFO) << "Adding image arguments";
-        oatArgv[0] = "-Ximage:/data/art-cache/boot.art";
-        memcpy(oatArgv + (oatArgc - argc), argv, argc * sizeof(*argv));
-        argv = oatArgv;
-        argc = oatArgc;
-        for (int i = 0; i < argc; i++) {
-            LOG(INFO) << StringPrintf("argv[%d]=%s", i, argv[i]);
-        }
-    }
-
-    // TODO: remove the heap arguments when implicit garbage collection enabled
-    LOG(INFO) << "Adding heap arguments";
-    int heapArgc = argc + 2;
-    const char* heapArgv[heapArgc];
-    heapArgv[0] = "-Xms64m";
-    heapArgv[1] = "-Xmx64m";
-    memcpy(heapArgv + (heapArgc - argc), argv, argc * sizeof(*argv));
-    argv = heapArgv;
-    argc = heapArgc;
-    for (int i = 0; i < argc; i++) {
-        LOG(INFO) << StringPrintf("argv[%d]=%s", i, argv[i]);
-    }
-
-    // TODO: change the system default to not perform preloading
-    LOG(INFO) << "Disabling preloading";
-    for (int i = 0; i < argc; i++) {
-        if (strcmp(argv[i], "preload") == 0) {
-            argv[i] = "nopreload";
-            break;
-        }
-    }
-    for (int i = 0; i < argc; i++) {
-        LOG(INFO) << StringPrintf("argv[%d]=%s", i, argv[i]);
-    }
-
-    // Everything up to '--' or first non '-' arg goes to the vm
-
-    int i = runtime.addVmArguments(argc, argv);
-
-    // Parse runtime arguments.  Stop at first unrecognized option.
-    bool zygote = false;
-    bool startSystemServer = false;
-    bool noPreload = false;
-    bool application = false;
-    const char* parentDir = NULL;
-    const char* niceName = NULL;
-    const char* className = NULL;
-    while (i < argc) {
-        const char* arg = argv[i++];
-        if (!parentDir) {
-            parentDir = arg;
-        } else if (strcmp(arg, "--zygote") == 0) {
-            zygote = true;
-            niceName = "zygote";
-        } else if (strcmp(arg, "--start-system-server") == 0) {
-            startSystemServer = true;
-        } else if (strcmp(arg, "--no-preload") == 0) {
-            noPreload = true;
-        } else if (strcmp(arg, "--application") == 0) {
-            application = true;
-        } else if (strncmp(arg, "--nice-name=", 12) == 0) {
-            niceName = arg + 12;
-        } else {
-            className = arg;
-            break;
-        }
-    }
-
-    if (niceName && *niceName) {
-        setArgv0(argv0, niceName);
-        set_process_name(niceName);
-    }
-
-    runtime.mParentDir = parentDir;
-
-    if (zygote) {
-        std::string options;
-        if (startSystemServer) {
-            options += "start-system-server ";
-        }
-        if (noPreload) {
-            options += "no-preload ";
-        }
-        runtime.start("com.android.internal.os.ZygoteInit", options.c_str());
-    } else if (className) {
-        // Remainder of args get passed to startup class main()
-        runtime.mClassName = className;
-        runtime.mArgC = argc - i;
-        runtime.mArgV = argv + i;
-        runtime.start("com.android.internal.os.RuntimeInit",
-                application ? "application" : "tool");
-    } else {
-        fprintf(stderr, "Error: no class name or --zygote supplied.\n");
-        app_usage();
-        LOG(FATAL) << "oat_process: no class name or --zygote supplied.";
-        return 10;
-    }
-}
diff --git a/oat_runtime/Android.mk b/oat_runtime/Android.mk
deleted file mode 100644
index ccf5146..0000000
--- a/oat_runtime/Android.mk
+++ /dev/null
@@ -1,260 +0,0 @@
-LOCAL_PATH:= $(call my-dir)/../../frameworks/base/core/jni
-
-local_cflags += -DHAVE_CONFIG_H -DKHTML_NO_EXCEPTIONS -DGKWQ_NO_JAVA
-local_cflags += -DNO_SUPPORT_JS_BINDING -DQT_NO_WHEELEVENT -DKHTML_NO_XBL
-local_cflags += -U__APPLE__
-
-ifeq ($(TARGET_ARCH), arm)
-	local_cflags += -DPACKED="__attribute__ ((packed))"
-else
-	local_cflags += -DPACKED=""
-endif
-
-ifeq ($(WITH_JIT),true)
-	local_cflags += -DWITH_JIT
-endif
-
-ifneq ($(USE_CUSTOM_RUNTIME_HEAP_MAX),)
-  local_cflags += -DCUSTOM_RUNTIME_HEAP_MAX=$(USE_CUSTOM_RUNTIME_HEAP_MAX)
-endif
-
-ifeq ($(USE_OPENGL_RENDERER),true)
-	local_cflags += -DUSE_OPENGL_RENDERER
-endif
-
-local_cflags += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
-
-local_src_files:= \
-	ActivityManager.cpp \
-	AndroidRuntime.cpp \
-	Time.cpp \
-	com_android_internal_content_NativeLibraryHelper.cpp \
-	com_google_android_gles_jni_EGLImpl.cpp \
-	com_google_android_gles_jni_GLImpl.cpp.arm \
-	android_app_NativeActivity.cpp \
-	android_opengl_GLES10.cpp \
-	android_opengl_GLES10Ext.cpp \
-	android_opengl_GLES11.cpp \
-	android_opengl_GLES11Ext.cpp \
-	android_opengl_GLES20.cpp \
-	android_database_CursorWindow.cpp \
-	android_database_SQLiteCompiledSql.cpp \
-	android_database_SQLiteDebug.cpp \
-	android_database_SQLiteDatabase.cpp \
-	android_database_SQLiteProgram.cpp \
-	android_database_SQLiteQuery.cpp \
-	android_database_SQLiteStatement.cpp \
-	android_emoji_EmojiFactory.cpp \
-	android_view_Display.cpp \
-	android_view_Surface.cpp \
-	android_view_TextureView.cpp \
-	android_view_InputChannel.cpp \
-	android_view_InputQueue.cpp \
-	android_view_KeyEvent.cpp \
-	android_view_KeyCharacterMap.cpp \
-	android_view_HardwareRenderer.cpp \
-	android_view_GLES20Canvas.cpp \
-	android_view_MotionEvent.cpp \
-	android_view_PointerIcon.cpp \
-	android_view_VelocityTracker.cpp \
-	android_text_AndroidCharacter.cpp \
-	android_text_AndroidBidi.cpp \
-	android_os_Debug.cpp \
-	android_os_FileUtils.cpp \
-	android_os_MemoryFile.cpp \
-	android_os_MessageQueue.cpp \
-	android_os_ParcelFileDescriptor.cpp \
-	android_os_Power.cpp \
-	android_os_StatFs.cpp \
-	android_os_SystemClock.cpp \
-	android_os_SystemProperties.cpp \
-	android_os_UEventObserver.cpp \
-	android_net_LocalSocketImpl.cpp \
-	android_net_NetUtils.cpp \
-	android_net_TrafficStats.cpp \
-	android_net_wifi_Wifi.cpp \
-	android_nio_utils.cpp \
-	android_nfc_NdefMessage.cpp \
-	android_nfc_NdefRecord.cpp \
-	android_text_format_Time.cpp \
-	android_util_AssetManager.cpp \
-	android_util_Binder.cpp \
-	android_util_EventLog.cpp \
-	android_util_Log.cpp \
-	android_util_FloatMath.cpp \
-	android_util_Process.cpp \
-	android_util_StringBlock.cpp \
-	android_util_XmlBlock.cpp \
-	android/graphics/AutoDecodeCancel.cpp \
-	android/graphics/Bitmap.cpp \
-	android/graphics/BitmapFactory.cpp \
-	android/graphics/Camera.cpp \
-	android/graphics/Canvas.cpp \
-	android/graphics/ColorFilter.cpp \
-	android/graphics/DrawFilter.cpp \
-	android/graphics/CreateJavaOutputStreamAdaptor.cpp \
-	android/graphics/Graphics.cpp \
-	android/graphics/HarfbuzzSkia.cpp \
-	android/graphics/Interpolator.cpp \
-	android/graphics/LayerRasterizer.cpp \
-	android/graphics/MaskFilter.cpp \
-	android/graphics/Matrix.cpp \
-	android/graphics/Movie.cpp \
-	android/graphics/NinePatch.cpp \
-	android/graphics/NinePatchImpl.cpp \
-	android/graphics/NinePatchPeeker.cpp \
-	android/graphics/Paint.cpp \
-	android/graphics/Path.cpp \
-	android/graphics/PathMeasure.cpp \
-	android/graphics/PathEffect.cpp \
-	android_graphics_PixelFormat.cpp \
-	android/graphics/Picture.cpp \
-	android/graphics/PorterDuff.cpp \
-	android/graphics/BitmapRegionDecoder.cpp \
-	android/graphics/Rasterizer.cpp \
-	android/graphics/Region.cpp \
-	android/graphics/Shader.cpp \
-	android/graphics/SurfaceTexture.cpp \
-	android/graphics/TextLayout.cpp \
-	android/graphics/TextLayoutCache.cpp \
-	android/graphics/Typeface.cpp \
-	android/graphics/Utils.cpp \
-	android/graphics/Xfermode.cpp \
-	android/graphics/YuvToJpegEncoder.cpp \
-	android_media_AudioRecord.cpp \
-	android_media_AudioSystem.cpp \
-	android_media_AudioTrack.cpp \
-	android_media_JetPlayer.cpp \
-	android_media_ToneGenerator.cpp \
-	android_hardware_Camera.cpp \
-	android_hardware_SensorManager.cpp \
-	android_hardware_UsbDevice.cpp \
-	android_hardware_UsbDeviceConnection.cpp \
-	android_hardware_UsbRequest.cpp \
-	android_debug_JNITest.cpp \
-	android_util_FileObserver.cpp \
-	android/opengl/poly_clip.cpp.arm \
-	android/opengl/util.cpp.arm \
-	android_bluetooth_HeadsetBase.cpp \
-	android_bluetooth_common.cpp \
-	android_bluetooth_BluetoothAudioGateway.cpp \
-	android_bluetooth_BluetoothSocket.cpp \
-	android_bluetooth_c.c \
-	android_server_BluetoothService.cpp \
-	android_server_BluetoothEventLoop.cpp \
-	android_server_BluetoothA2dpService.cpp \
-	android_server_NetworkManagementSocketTagger.cpp \
-	android_server_Watchdog.cpp \
-	android_ddm_DdmHandleNativeHeap.cpp \
-	com_android_internal_os_ZygoteInit.cpp \
-	android_backup_BackupDataInput.cpp \
-	android_backup_BackupDataOutput.cpp \
-	android_backup_FileBackupHelperBase.cpp \
-	android_backup_BackupHelperDispatcher.cpp \
-	android_app_backup_FullBackup.cpp \
-	android_content_res_ObbScanner.cpp \
-	android_content_res_Configuration.cpp \
-    android_animation_PropertyValuesHolder.cpp
-
-local_c_includes += \
-	$(LOCAL_PATH)/android/graphics \
-	$(LOCAL_PATH)/../../libs/hwui \
-	$(LOCAL_PATH)/../../opengl/libs \
-	$(call include-path-for, bluedroid) \
-	$(call include-path-for, libhardware)/hardware \
-	$(call include-path-for, libhardware_legacy)/hardware_legacy \
-	$(LOCAL_PATH)/../../include/ui \
-	$(LOCAL_PATH)/../../include/utils \
-	external/skia/include/core \
-	external/skia/include/effects \
-	external/skia/include/images \
-	external/skia/src/ports \
-	external/skia/include/utils \
-	external/sqlite/dist \
-	external/sqlite/android \
-	external/expat/lib \
-	external/openssl/include \
-	external/tremor/Tremor \
-	external/icu4c/i18n \
-	external/icu4c/common \
-	external/jpeg \
-	external/harfbuzz/contrib \
-	external/harfbuzz/src \
-	external/zlib \
-	frameworks/opt/emoji \
-	libcore/libnativehelper/include
-
-local_shared_libraries := \
-	libexpat \
-	libnativehelper \
-	libcutils \
-	libutils \
-	libbinder \
-	libnetutils \
-	libui \
-	libgui \
-	libcamera_client \
-	libskia \
-	libsqlite \
-	libEGL \
-	libGLESv1_CM \
-	libGLESv2 \
-	libETC1 \
-	libhardware \
-	libhardware_legacy \
-	libsonivox \
-	libcrypto \
-	libssl \
-	libicuuc \
-	libicui18n \
-	libmedia \
-	libwpa_client \
-	libjpeg \
-	libnfc_ndef \
-	libusbhost \
-	libharfbuzz \
-	libz \
-
-ifeq ($(USE_OPENGL_RENDERER),true)
-	local_shared_libraries += libhwui
-endif
-
-ifeq ($(BOARD_HAVE_BLUETOOTH),true)
-local_c_includes += \
-	external/dbus \
-	system/bluetooth/bluez-clean-headers
-local_cflags += -DHAVE_BLUETOOTH
-local_shared_libraries += libbluedroid libdbus
-endif
-
-local_shared_libraries += \
-	libdl
-# we need to access the private Bionic header
-# <bionic_tls.h> in com_google_android_gles_jni_GLImpl.cpp
-local_cflags += -I$(LOCAL_PATH)/../../../../bionic/libc/private
-
-local_ldlibs += -lpthread -ldl
-
-ifeq ($(WITH_MALLOC_LEAK_CHECK),true)
-	local_cflags += -DMALLOC_LEAK_CHECK
-endif
-
-include $(CLEAR_VARS)
-LOCAL_CFLAGS := $(local_cflags)
-LOCAL_SRC_FILES := $(local_src_files)
-LOCAL_C_INCLUDES := $(local_c_includes)
-LOCAL_SHARED_LIBRARIES := libart $(local_shared_libraries)
-LOCAL_LDLIBS := $(local_ldlibs)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE:= liboat_runtime
-include $(BUILD_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-LOCAL_CFLAGS := $(local_cflags)
-LOCAL_SRC_FILES := $(local_src_files)
-LOCAL_C_INCLUDES := $(local_c_includes)
-LOCAL_SHARED_LIBRARIES := libartd $(local_shared_libraries)
-LOCAL_LDLIBS := $(local_ldlibs)
-LOCAL_MODULE_TAGS := optional
-LOCAL_MODULE:= liboat_runtimed
-include $(BUILD_SHARED_LIBRARY)
diff --git a/src/class_linker.cc b/src/class_linker.cc
index d59323b..caf2876 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -556,34 +556,41 @@
 const OatFile* ClassLinker::GenerateOatFile(const std::string& filename) {
   std::string oat_filename(GetArtCacheFilenameOrDie(OatFile::DexFilenameToOatFilename(filename)));
 
+  std::string dex2oat_string("/system/bin/dex2oat");
+#ifndef NDEBUG
+  dex2oat_string += 'd';
+#endif
+  const char* dex2oat = dex2oat_string.c_str();
+
+  const char* class_path = Runtime::Current()->GetClassPath().c_str();
+
+  std::string boot_image_option_string("--boot-image=");
+  boot_image_option_string += Heap::GetSpaces()[0]->GetImageFilename();
+  const char* boot_image_option = boot_image_option_string.c_str();
+
+  std::string dex_file_option_string("--dex-file=");
+  dex_file_option_string += filename;
+  const char* dex_file_option = dex_file_option_string.c_str();
+
+  std::string oat_file_option_string("--oat=");
+  oat_file_option_string += oat_filename;
+  const char* oat_file_option = oat_file_option_string.c_str();
+
   // fork and exec dex2oat
   pid_t pid = fork();
   if (pid == 0) {
-    std::string boot_image_option("--boot-image=");
-    boot_image_option += Heap::GetSpaces()[0]->GetImageFilename();
-
-    std::string dex_file_option("--dex-file=");
-    dex_file_option += filename;
-
-    std::string oat_file_option("--oat=");
-    oat_file_option += oat_filename;
-
-    std::string dex2oat("/system/bin/dex2oat");
-#ifndef NDEBUG
-    dex2oat += 'd';
-#endif
-
-    execl(dex2oat.c_str(), dex2oat.c_str(),
+    // no allocation allowed between fork and exec
+    execl(dex2oat, dex2oat,
           "--runtime-arg", "-Xms64m",
           "--runtime-arg", "-Xmx64m",
           "--runtime-arg", "-classpath",
-          "--runtime-arg", Runtime::Current()->GetClassPath().c_str(),
-          boot_image_option.c_str(),
-          dex_file_option.c_str(),
-          oat_file_option.c_str(),
+          "--runtime-arg", class_path,
+          boot_image_option,
+          dex_file_option,
+          oat_file_option,
           NULL);
 
-    PLOG(FATAL) << "execl(dex2oatd) failed";
+    PLOG(FATAL) << "execl(" << dex2oat << ") failed";
     return NULL;
   } else {
     // wait for dex2oat to finish
@@ -594,7 +601,7 @@
       return NULL;
     }
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
-      LOG(ERROR) << "dex2oatd failed with dex-file=" << filename;
+      LOG(ERROR) << dex2oat << " failed with dex-file=" << filename;
       return NULL;
     }
   }
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index da07dbd..ab63a48 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -33,11 +33,11 @@
           "\n");
   fprintf(stderr,
           "  --oat=<file.oat>: specifies the required oat filename.\n"
-          "      Example: --oat=/data/art-cache/boot.oat\n"
+          "      Example: --oat=/system/framework/boot.oat\n"
           "\n");
   fprintf(stderr,
           "  --image=<file.art>: specifies the output image filename.\n"
-          "      Example: --image=/data/art-cache/boot.art\n"
+          "      Example: --image=/system/framework/boot.art\n"
           "\n");
   fprintf(stderr,
           "  --image-classes=<classname-file>: specifies classes to include in an image.\n"
@@ -49,8 +49,8 @@
           "\n");
   fprintf(stderr,
           "  --boot-image=<file.art>: provide the image file for the boot class path.\n"
-          "      Example: --boot-image=/data/art-cache/boot.art\n"
-          "      Default: <host-prefix>/data/art-cache/boot.art\n"
+          "      Example: --boot-image=/system/framework/boot.art\n"
+          "      Default: <host-prefix>/system/framework/boot.art\n"
           "\n");
   fprintf(stderr,
           "  --host-prefix may be used to translate host paths to target paths during\n"
diff --git a/src/oatdump.cc b/src/oatdump.cc
index 2006827..3b204c0 100644
--- a/src/oatdump.cc
+++ b/src/oatdump.cc
@@ -23,20 +23,20 @@
 static void usage() {
   fprintf(stderr,
           "Usage: oatdump [options] ...\n"
-          "    Example: oatdump --image=$ANDROID_PRODUCT_OUT/data/art-cache/boot.art --host-prefix=$ANDROID_PRODUCT_OUT\n"
-          "    Example: adb shell oatdump --image=/data/art-cache/boot.art\n"
+          "    Example: oatdump --image=$ANDROID_PRODUCT_OUT/system/framework/boot.art --host-prefix=$ANDROID_PRODUCT_OUT\n"
+          "    Example: adb shell oatdump --image=/system/framework/boot.art\n"
           "\n");
   fprintf(stderr,
           "  --oat=<file.oat>: specifies an input oat filename.\n"
-          "      Example: --image=/data/art-cache/boot.oat\n"
+          "      Example: --image=/system/framework/boot.oat\n"
           "\n");
   fprintf(stderr,
           "  --image=<file.art>: specifies an input image filename.\n"
-          "      Example: --image=/data/art-cache/boot.art\n"
+          "      Example: --image=/system/framework/boot.art\n"
           "\n");
   fprintf(stderr,
           "  --boot-image=<file.art>: provide the image file for the boot class path.\n"
-          "      Example: --boot-image=/data/art-cache/boot.art\n"
+          "      Example: --boot-image=/system/framework/boot.art\n"
           "\n");
   fprintf(stderr,
           "  --host-prefix may be used to translate host paths to target paths during\n"
diff --git a/src/runtime.cc b/src/runtime.cc
index ad86e05..cfb1b29 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -394,7 +394,7 @@
   }
 
   if (!compiler && parsed->images_.empty()) {
-    parsed->images_.push_back("/data/art-cache/boot.art");
+    parsed->images_.push_back("/system/framework/boot.art");
   }
   if (parsed->heap_growth_limit_ == 0) {
     parsed->heap_growth_limit_ = parsed->heap_maximum_size_;
diff --git a/src/runtime.h b/src/runtime.h
index b5e6954..7f5f6f6 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -221,7 +221,7 @@
 
   // The host prefix is used during cross compilation. It is removed
   // from the start of host paths such as:
-  //    $ANDROID_PRODUCT_OUT/data/art-cache/boot.oat
+  //    $ANDROID_PRODUCT_OUT/system/framework/boot.oat
   // to produce target paths such as
   //    /system/framework/boot.oat
   // Similarly it is prepended to target paths to arrive back at a