Blame SOURCES/enddianness.patch

3de678
From f66d410f3ba767efb91c6b9545d373267cd975f2 Mon Sep 17 00:00:00 2001
3de678
From: rpm-build <rpm-build>
3de678
Date: Sat, 7 Sep 2019 20:43:40 +0200
3de678
Subject: [PATCH] enddianness.patch
3de678
3de678
Bug 1488552 - Ensure proper running on 64-bit and 32-bit BE platforms.
3de678
---
3de678
 js/src/gc/Marking-inl.h       | 16 ++++++++++++++++
3de678
 js/src/gc/RelocationOverlay.h | 13 ++++++++++++-
3de678
 js/src/jsfriendapi.h          |  8 ++++++++
3de678
 js/src/vm/StringType.h        | 13 +++++++++++++
3de678
 4 files changed, 49 insertions(+), 1 deletion(-)
3de678
3de678
Index: firefox-60.9.0/js/src/gc/Marking-inl.h
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/gc/Marking-inl.h	2019-09-01 15:09:17.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/gc/Marking-inl.h	2019-12-09 11:42:31.024301901 +0100
3de678
@@ -82,12 +82,28 @@
3de678
   MOZ_ASSERT(!isForwarded());
3de678
   // The location of magic_ is important because it must never be valid to see
3de678
   // the value Relocated there in a GC thing that has not been moved.
3de678
+#if MOZ_LITTLE_ENDIAN || JS_BITS_PER_WORD == 32
3de678
+  // On 32-bit, the magic_ aliases with whatever comes after the first
3de678
+  // pointer; on little-endian 64-bit, the magic_ aliases with the
3de678
+  // 32 most significant bits of the pointer, which are the second half.
3de678
   static_assert(offsetof(RelocationOverlay, magic_) ==
3de678
                     offsetof(JSObject, group_) + sizeof(uint32_t),
3de678
                 "RelocationOverlay::magic_ is in the wrong location");
3de678
   static_assert(offsetof(RelocationOverlay, magic_) ==
3de678
                     offsetof(js::Shape, base_) + sizeof(uint32_t),
3de678
                 "RelocationOverlay::magic_ is in the wrong location");
3de678
+#elif JS_BITS_PER_WORD == 64
3de678
+  // On big-endian 64-bit, the magic_ aliases with the 32 most
3de678
+  // significant bits of the pointer, but now that's the first half.
3de678
+  static_assert(offsetof(RelocationOverlay, magic_) ==
3de678
+                    offsetof(JSObject, group_),
3de678
+                "RelocationOverlay::magic_ is in the wrong location");
3de678
+  static_assert(offsetof(RelocationOverlay, magic_) ==
3de678
+                    offsetof(js::Shape, base_),
3de678
+                "RelocationOverlay::magic_ is in the wrong location");
3de678
+#else
3de678
+#  error "Unknown endianness or word size"
3de678
+#endif
3de678
   static_assert(
3de678
       offsetof(RelocationOverlay, magic_) == offsetof(JSString, d.u1.length),
3de678
       "RelocationOverlay::magic_ is in the wrong location");
3de678
Index: firefox-60.9.0/js/src/gc/RelocationOverlay.h
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/gc/RelocationOverlay.h	2019-09-01 15:09:17.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/gc/RelocationOverlay.h	2019-12-09 11:42:31.024301901 +0100
3de678
@@ -33,14 +33,25 @@
3de678
   /* See comment in js/public/HeapAPI.h. */
3de678
   static const uint32_t Relocated = js::gc::Relocated;
3de678
 
3de678
+#if MOZ_LITTLE_ENDIAN || JS_BITS_PER_WORD == 32
3de678
   /*
3de678
-   * Keep the low 32 bits untouched. Use them to distinguish strings from
3de678
+   * Keep the first 32 bits untouched. Use them to distinguish strings from
3de678
    * objects in the nursery.
3de678
    */
3de678
   uint32_t preserve_;
3de678
 
3de678
   /* Set to Relocated when moved. */
3de678
   uint32_t magic_;
3de678
+#elif JS_BITS_PER_WORD == 64
3de678
+  /*
3de678
+   * On big-endian, we need to reorder to keep preserve_ lined up with the
3de678
+   * low 32 bits of the aligned group_ pointer in JSObject.
3de678
+   */
3de678
+  uint32_t magic_;
3de678
+  uint32_t preserve_;
3de678
+#else
3de678
+#  error "Unknown endianness or word size"
3de678
+#endif
3de678
 
3de678
   /* The location |this| was moved to. */
3de678
   Cell* newLocation_;
3de678
Index: firefox-60.9.0/js/src/jsfriendapi.h
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/jsfriendapi.h	2019-09-01 15:09:18.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/jsfriendapi.h	2019-12-09 11:42:31.024301901 +0100
3de678
@@ -9,6 +9,7 @@
3de678
 
3de678
 #include "mozilla/Atomics.h"
3de678
 #include "mozilla/Casting.h"
3de678
+#include "mozilla/EndianUtils.h"
3de678
 #include "mozilla/Maybe.h"
3de678
 #include "mozilla/MemoryReporting.h"
3de678
 #include "mozilla/UniquePtr.h"
3de678
@@ -609,8 +610,15 @@
3de678
   static const uint32_t LATIN1_CHARS_BIT = JS_BIT(6);
3de678
   static const uint32_t EXTERNAL_FLAGS = LINEAR_BIT | NON_ATOM_BIT | JS_BIT(5);
3de678
   static const uint32_t TYPE_FLAGS_MASK = JS_BIT(6) - 1;
3de678
+#if MOZ_LITTLE_ENDIAN || JS_BITS_PER_WORD == 32
3de678
   uint32_t flags;
3de678
   uint32_t length;
3de678
+#elif JS_BITS_PER_WORD == 64
3de678
+  uint32_t length;
3de678
+  uint32_t flags;
3de678
+#else
3de678
+#  error "Unknown endianness or word size"
3de678
+#endif
3de678
   union {
3de678
     const JS::Latin1Char* nonInlineCharsLatin1;
3de678
     const char16_t* nonInlineCharsTwoByte;
3de678
Index: firefox-60.9.0/js/src/vm/StringType.h
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/vm/StringType.h	2019-09-01 15:09:39.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/vm/StringType.h	2019-12-09 11:42:31.028301901 +0100
3de678
@@ -7,6 +7,7 @@
3de678
 #ifndef vm_StringType_h
3de678
 #define vm_StringType_h
3de678
 
3de678
+#include "mozilla/EndianUtils.h"
3de678
 #include "mozilla/MemoryReporting.h"
3de678
 #include "mozilla/PodOperations.h"
3de678
 #include "mozilla/Range.h"
3de678
@@ -168,8 +169,20 @@
3de678
   struct Data {
3de678
     union {
3de678
       struct {
3de678
+#if MOZ_LITTLE_ENDIAN || JS_BITS_PER_WORD == 32
3de678
         uint32_t flags;  /* JSString */
3de678
         uint32_t length; /* JSString */
3de678
+#elif JS_BITS_PER_WORD == 64
3de678
+        /*
3de678
+         * On big-endian, we need to reorder to keep flags lined up
3de678
+         * with the low 32 bits of the aligned group_ pointer in
3de678
+         * JSObject.
3de678
+         */
3de678
+        uint32_t length; /* JSString */
3de678
+        uint32_t flags;  /* JSString */
3de678
+#else
3de678
+#  error "Unknown endianness or word size"
3de678
+#endif
3de678
       };
3de678
       uintptr_t flattenData; /* JSRope (temporary while flattening) */
3de678
     } u1;
3de678
Index: firefox-60.9.0/js/src/js-config.h.in
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/js-config.h.in	2019-09-01 15:09:18.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/js-config.h.in	2019-12-09 11:43:13.052302975 +0100
3de678
@@ -38,6 +38,13 @@
3de678
 /* Define to 1 if SpiderMonkey should include ctypes support.  */
3de678
 #undef JS_HAS_CTYPES
3de678
 
3de678
+/* Define to 1 if SpiderMonkey should include trace logging support. */
3de678
+#undef JS_TRACE_LOGGING
3de678
+
3de678
+/* Define to 1 if SpiderMonkey should include a breakpoint function for
3de678
+ * artificial OOMs. */
3de678
+#undef JS_OOM_BREAKPOINT
3de678
+
3de678
 /* Define to 1 if SpiderMonkey should support the ability to perform
3de678
    entirely too much GC.  */
3de678
 #undef JS_GC_ZEAL
3de678
@@ -48,12 +55,25 @@
3de678
 /* Define to 1 to perform extra assertions and heap poisoning. */
3de678
 #undef JS_CRASH_DIAGNOSTICS
3de678
 
3de678
+/* Define to 1 if SpiderMonkey is compiled with support for private values at
3de678
+ * odd-numbered memory addresses. */
3de678
+#undef JS_UNALIGNED_PRIVATE_VALUES
3de678
+
3de678
 /* Define to 1 if SpiderMonkey is in NUNBOX32 mode. */
3de678
 #undef JS_NUNBOX32
3de678
 
3de678
 /* Define to 1 if SpiderMonkey is in PUNBOX64 mode. */
3de678
 #undef JS_PUNBOX64
3de678
 
3de678
+/* Define exactly one of these to 1 to indicate JIT code generation mode. */
3de678
+#undef JS_CODEGEN_NONE
3de678
+#undef JS_CODEGEN_ARM
3de678
+#undef JS_CODEGEN_ARM64
3de678
+#undef JS_CODEGEN_MIPS32
3de678
+#undef JS_CODEGEN_MIPS64
3de678
+#undef JS_CODEGEN_X86
3de678
+#undef JS_CODEGEN_X64
3de678
+
3de678
 /* MOZILLA JSAPI version number components */
3de678
 #undef MOZJS_MAJOR_VERSION
3de678
 #undef MOZJS_MINOR_VERSION
3de678
Index: firefox-60.9.0/js/src/jsapi.cpp
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/jsapi.cpp	2019-09-01 15:09:18.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/jsapi.cpp	2019-12-09 11:43:13.052302975 +0100
3de678
@@ -115,6 +115,14 @@
3de678
 #define JS_ADDRESSOF_VA_LIST(ap) (&(ap))
3de678
 #endif
3de678
 
3de678
+// See preprocessor definition of JS_BITS_PER_WORD in jstypes.h; make sure
3de678
+// JS_64BIT (used internally) agrees with it
3de678
+#ifdef JS_64BIT
3de678
+static_assert(JS_BITS_PER_WORD == 64, "values must be in sync");
3de678
+#else
3de678
+static_assert(JS_BITS_PER_WORD == 32, "values must be in sync");
3de678
+#endif
3de678
+
3de678
 JS_PUBLIC_API bool JS::CallArgs::requireAtLeast(JSContext* cx,
3de678
                                                 const char* fnname,
3de678
                                                 unsigned required) const {
3de678
Index: firefox-60.9.0/js/src/jstypes.h
3de678
===================================================================
3de678
--- firefox-60.9.0.orig/js/src/jstypes.h	2019-09-01 15:09:18.000000000 +0200
3de678
+++ firefox-60.9.0/js/src/jstypes.h	2019-12-09 11:43:13.052302975 +0100
3de678
@@ -141,12 +141,17 @@
3de678
 #define JS_BITS_PER_BYTE 8
3de678
 #define JS_BITS_PER_BYTE_LOG2 3
3de678
 
3de678
-#if defined(JS_64BIT)
3de678
+#if (defined(__SIZEOF_POINTER__) && __SIZEOF_POINTER__ == 8) || \
3de678
+    (defined(UINTPTR_MAX) && UINTPTR_MAX == 0xFFFFFFFFFFFFFFFFu)
3de678
 #define JS_BITS_PER_WORD 64
3de678
 #else
3de678
 #define JS_BITS_PER_WORD 32
3de678
 #endif
3de678
 
3de678
+static_assert(sizeof(void*) == 8 ? JS_BITS_PER_WORD == 64
3de678
+                                 : JS_BITS_PER_WORD == 32,
3de678
+              "preprocessor and compiler must agree");
3de678
+
3de678
 /***********************************************************************
3de678
 ** MACROS:      JS_FUNC_TO_DATA_PTR
3de678
 **              JS_DATA_TO_FUNC_PTR
3de678