diff options
| author | Andreas Gampe <agampe@google.com> | 2015-04-04 04:23:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-04 04:23:12 +0000 |
| commit | f8cb672f121495e4f80b96a14140180f71e770fe (patch) | |
| tree | c54c96078efe4914a9ff8617ebf7a0edec8b8cdc | |
| parent | efcbaec14135c42f81e2a8f645584cf7cf542a02 (diff) | |
| parent | 605cca1a985be74c00582853ee2c84b086cfade8 (diff) | |
| download | frameworks_base-f8cb672f121495e4f80b96a14140180f71e770fe.zip frameworks_base-f8cb672f121495e4f80b96a14140180f71e770fe.tar.gz frameworks_base-f8cb672f121495e4f80b96a14140180f71e770fe.tar.bz2 | |
Merge "Frameworks/base: Pass variant and feature-set to runtime"
| -rw-r--r-- | core/jni/AndroidRuntime.cpp | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index b44adcb..d826303 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -536,7 +536,6 @@ bool AndroidRuntime::parseCompilerRuntimeOption(const char* property, */ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) { - int result = -1; JavaVMInitArgs initArgs; char propBuf[PROPERTY_VALUE_MAX]; char stackTraceFileBuf[sizeof("-Xstacktracefile:")-1 + PROPERTY_VALUE_MAX]; @@ -561,6 +560,10 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) char dex2oatImageCompilerFilterBuf[sizeof("--compiler-filter=")-1 + PROPERTY_VALUE_MAX]; char dex2oatThreadsBuf[sizeof("-j")-1 + PROPERTY_VALUE_MAX]; char dex2oatThreadsImageBuf[sizeof("-j")-1 + PROPERTY_VALUE_MAX]; + char dex2oat_isa_variant_key[PROPERTY_KEY_MAX]; + char dex2oat_isa_variant[sizeof("--instruction-set-variant=") -1 + PROPERTY_VALUE_MAX]; + char dex2oat_isa_features_key[PROPERTY_KEY_MAX]; + char dex2oat_isa_features[sizeof("--instruction-set-features=") -1 + PROPERTY_VALUE_MAX]; char dex2oatFlagsBuf[PROPERTY_VALUE_MAX]; char dex2oatImageFlagsBuf[PROPERTY_VALUE_MAX]; char extraOptsBuf[PROPERTY_VALUE_MAX]; @@ -701,7 +704,7 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) if (!hasFile("/system/etc/preloaded-classes")) { ALOGE("Missing preloaded-classes file, /system/etc/preloaded-classes not found: %s\n", strerror(errno)); - goto bail; + return -1; } addOption("-Ximage-compiler-option"); addOption("--image-classes=/system/etc/preloaded-classes"); @@ -738,6 +741,43 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) parseCompilerOption("dalvik.vm.dex2oat-threads", dex2oatThreadsBuf, "-j", "-Xcompiler-option"); parseCompilerOption("dalvik.vm.image-dex2oat-threads", dex2oatThreadsImageBuf, "-j", "-Ximage-compiler-option"); + + // The runtime will compile a boot image, when necessary, not using installd. Thus, we need to + // pass the instruction-set-features/variant as an image-compiler-option. + // TODO: Find a better way for the instruction-set. +#if defined(__arm__) + constexpr const char* instruction_set = "arm"; +#elif defined(__aarch64__) + constexpr const char* instruction_set = "arm64"; +#elif defined(__mips__) && !defined(__LP64__) + constexpr const char* instruction_set = "mips"; +#elif defined(__mips__) && defined(__LP64__) + constexpr const char* instruction_set = "mips64"; +#elif defined(__i386__) + constexpr const char* instruction_set = "x86"; +#elif defined(__x86_64__) + constexpr const char* instruction_set = "x86_64"; +#else + constexpr const char* instruction_set = "unknown"; +#endif + // Note: it is OK to reuse the buffer, as the values are exactly the same between + // * compiler-option, used for runtime compilation (DexClassLoader) + // * image-compiler-option, used for boot-image compilation on device + + // Copy the variant. + sprintf(dex2oat_isa_variant_key, "dalvik.vm.isa.%s.variant", instruction_set); + parseCompilerOption(dex2oat_isa_variant_key, dex2oat_isa_variant, + "--instruction-set-variant=", "-Ximage-compiler-option"); + parseCompilerOption(dex2oat_isa_variant_key, dex2oat_isa_variant, + "--instruction-set-variant=", "-Xcompiler-option"); + // Copy the features. + sprintf(dex2oat_isa_features_key, "dalvik.vm.isa.%s.features", instruction_set); + parseCompilerOption(dex2oat_isa_features_key, dex2oat_isa_features, + "--instruction-set-features=", "-Ximage-compiler-option"); + parseCompilerOption(dex2oat_isa_features_key, dex2oat_isa_features, + "--instruction-set-features=", "-Xcompiler-option"); + + property_get("dalvik.vm.dex2oat-flags", dex2oatFlagsBuf, ""); parseExtraOpts(dex2oatFlagsBuf, "-Xcompiler-option"); @@ -834,13 +874,10 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) */ if (JNI_CreateJavaVM(pJavaVM, pEnv, &initArgs) < 0) { ALOGE("JNI_CreateJavaVM failed\n"); - goto bail; + return -1; } - result = 0; - -bail: - return result; + return 0; } char* AndroidRuntime::toSlashClassName(const char* className) |
