public static void main(String argv[]) {
    try {
      Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "ZygoteInit");
      RuntimeInit.enableDdms();
      // Start profiling the zygote initialization.
      SamplingProfilerIntegration.start();

      boolean startSystemServer = false;
      String socketName = "zygote";
      String abiList = null;
      for (int i = 1; i < argv.length; i++) {
        if ("start-system-server".equals(argv[i])) {
          startSystemServer = true;
        } else if (argv[i].startsWith(ABI_LIST_ARG)) {
          abiList = argv[i].substring(ABI_LIST_ARG.length());
        } else if (argv[i].startsWith(SOCKET_NAME_ARG)) {
          socketName = argv[i].substring(SOCKET_NAME_ARG.length());
        } else {
          throw new RuntimeException("Unknown command line argument: " + argv[i]);
        }
      }

      if (abiList == null) {
        throw new RuntimeException("No ABI list supplied.");
      }

      registerZygoteSocket(socketName);
      Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "ZygotePreload");
      EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_START, SystemClock.uptimeMillis());
      preload();
      EventLog.writeEvent(LOG_BOOT_PROGRESS_PRELOAD_END, SystemClock.uptimeMillis());
      Trace.traceEnd(Trace.TRACE_TAG_DALVIK);

      // Finish profiling the zygote initialization.
      SamplingProfilerIntegration.writeZygoteSnapshot();

      // Do an initial gc to clean up after startup
      Trace.traceBegin(Trace.TRACE_TAG_DALVIK, "PostZygoteInitGC");
      gcAndFinalize();
      Trace.traceEnd(Trace.TRACE_TAG_DALVIK);

      Trace.traceEnd(Trace.TRACE_TAG_DALVIK);

      // Disable tracing so that forked processes do not inherit stale tracing tags from
      // Zygote.
      Trace.setTracingEnabled(false);

      if (startSystemServer) {
        startSystemServer(abiList, socketName);
      }

      Log.i(TAG, "Accepting command socket connections");
      runSelectLoop(abiList);

      closeServerSocket();
    } catch (MethodAndArgsCaller caller) {
      caller.run();
    } catch (RuntimeException ex) {
      Log.e(TAG, "Zygote died with exception", ex);
      closeServerSocket();
      throw ex;
    }
  }