Status: New
Owner: ----

New issue 2597 by [email protected]: v8 doesn't detect ARM CPU features properly in Android sandboxed services.
http://code.google.com/p/v8/issues/detail?id=2597

On ARM, the code in src/platform-linux.cc tries to parse /proc/cpuinfo directly to detect which features the target device's CPU supports.

Unfortunately, when this code runs inside a Chromium renderer process, it won't be able to open /proc/cpuinfo at all, and thus will fail to detect any useful CPU feature, including VFP and NEON.

The reason for this is that renderer processes are run inside Android services that have the "android:isolatedProcess" attribute [1], which adds extra sandboxing to the process (e.g. it is unable to access the filesystem, including /proc).

It is possible to solve this specific problem by using the NDK's "cpufeatures" helper library, because Chrome ensures that the right features mask is passed (from the browser process) to each renderer process when it starts.

This bug is to track the issue. I plan to provide a fix that would amount to the following:

  1/ Add a conditional macro test corresponding to the Chromium on Android
     compilation case (e.g. CHROMIUM_ON_ANDROID)

  2/ Add the following to the source file:

        #ifdef CHROMIUM_ON_ANDROID
        #include <cpu-features.h>
        #endif

        ...

        bool OS::ArmCpuHasFeature(CpuFeature feature) {
          const struct {
            CPUFeature feature;
            uint64_t   mask;
          } features[] = {
            { VFP2,  ANDROID_CPU_ARM_FEATURE_VFPv2 },
            { VFP3,  ANDROID_CPU_ARM_FEATURE_VFPv3 },
            { ARMv7, ANDROID_CPU_ARM_FEATURE_ARMv7 },
            { SUDIV, ANDROID_CPU_ARM_FEATURE_IDIV_ARM |
                     ANDROID_CPU_ARM_FEATURE_IDIV_THUMB },
            { VFP32DREGS, ANDROID_CPU_ARM_FEATURE_VFP_D32 },
          };
          uint64_t cpu_features = android_getCpuFeatures();
          for (size_t i = 0;
               i < sizeof(features)/sizeof(features[0]);
               ++i) {
            if (features[i].feature == feature)
              return (cpu_features & features[i].mask) != 0;
          }
          return false;
        }

Note that cpu-features doesn't return the implementer name for now. I'll add this to the library first, so OS::GetCpuImplementer() can be implemented properly as well.

A similar issue exists for MIPS. cpu-features doesn't report the "FPU" feature yet, I'll add this too.

[1] See http://developer.android.com/guide/topics/manifest/service-element.html

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to