[Webkit-unassigned] [Bug 29076] Detect VFP at runtime in generic ARM port on Linux

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 9 01:21:07 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=29076





--- Comment #2 from Mark Rowe (bdash) <mrowe at apple.com>  2009-09-09 01:21:07 PDT ---
(From update of attachment 39252)
Does this code all need to live in the .h file?  It doesn't seem as though it
needs to be inlined and given the fact that it's likely to become more #if'd in
the future it would seem better placed in a .cpp file.

> diff --git a/JavaScriptCore/assembler/MacroAssemblerARM.h b/JavaScriptCore/assembler/MacroAssemblerARM.h
> index 1a4290d..36cee92 100644
> --- a/JavaScriptCore/assembler/MacroAssemblerARM.h
> +++ b/JavaScriptCore/assembler/MacroAssemblerARM.h
> @@ -35,10 +35,23 @@
>  #include "ARMAssembler.h"
>  #include "AbstractMacroAssembler.h"
>  
> +#if PLATFORM(LINUX)
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <fcntl.h>
> +#include <unistd.h>
> +#include <elf.h>
> +#endif
> +
>  namespace JSC {
>  
>  class MacroAssemblerARM : public AbstractMacroAssembler<ARMAssembler> {
>  public:
> +    MacroAssemblerARM()
> +        : m_isVFPPresent(isVFPPresent())
> +    {
> +    }
> +
>      enum Condition {
>          Equal = ARMAssembler::EQ,
>          NotEqual = ARMAssembler::NE,
> @@ -637,8 +650,7 @@ public:
>      // Floating point operators
>      bool supportsFloatingPoint() const
>      {
> -        // FIXME: should be a dynamic test: VFP, FPA, or nothing
> -        return false;
> +        return m_isVFPPresent;
>      }
>  
>      bool supportsFloatingPointTruncate() const
> @@ -793,6 +805,29 @@ private:
>          ARMAssembler::relinkCall(call.dataLocation(), destination.executableAddress());
>      }
>  
> +    bool isVFPPresent()
> +    {
> +#if PLATFORM(LINUX)
> +        bool has_VFP = false;
> +        int fd = open("/proc/self/auxv", O_RDONLY);
> +        if (fd > 0) {
> +            Elf32_auxv_t aux;
> +            while(read(fd, &aux, sizeof(Elf32_auxv_t))) {
> +                if (aux.a_type == AT_HWCAP) {
> +                    has_VFP = (aux.a_un.a_val & 64) != 0;
> +                    break;
> +                }
> +            }
> +            close(fd);
> +        }
> +        return has_VFP;


This will open /proc/self/auxv and perform this check again each time a
MacroAssemblerARM instance is created.  Since the presence of VFP isn't
something that will change during the lifetime of a process it seems that we
should calculate this just the once.

> +#else
> +        /* Disable by default.  */
> +        return false;
> +#endif
> +    }
> +
> +    const bool m_isVFPPresent;

It seems a bit odd to store this in a member variable given that the value
cannot differ between instances.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list