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