From a1039484e45ecfae61c5639d72f99ef963ed8620 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Tue, 16 Jan 2018 22:35:39 +0100 Subject: [PATCH 1/9] changes to make JS both x86 and PPC by using JS_CODEGEN_PPC_OSX and JS_CODEGEN_X86 --- js/src/configure.in | 8 +++++-- .../irregexp/NativeRegExpMacroAssembler.cpp | 2 ++ js/src/jit/BaselineIC.cpp | 2 +- js/src/jit/CodeGenerator.cpp | 2 ++ js/src/jit/MacroAssembler.cpp | 24 +++++++++++++++++++ js/src/jit/MacroAssembler.h | 8 +++++++ js/src/vm/TypedArrayCommon.h | 4 ++-- 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/js/src/configure.in b/js/src/configure.in index 1b279f00b..d3f337638 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -3161,13 +3161,17 @@ elif test "$CPU_ARCH" = "mips32"; then elif test "$CPU_ARCH" = "mips64"; then AC_DEFINE(JS_CODEGEN_MIPS64) JS_CODEGEN_MIPS64=1 +elif test "$CPU_ARCH" = "ppc"; then + AC_DEFINE(JS_CODEGEN_PPC_OSX) + JS_CODEGEN_PPC_OSX=1 +elif test "$CPU_ARCH" = "ppc64"; then + AC_DEFINE(JS_CODEGEN_PPC_OSX) + JS_CODEGEN_PPC_OSX=1 fi dnl Hey, Mozilla, bite me. dnl Eventually we will expunge the old JS_CPU_PPC_OSX. dnl -AC_DEFINE(JS_CODEGEN_PPC_OSX) -JS_CODEGEN_PPC_OSX=1 AC_SUBST(JS_CODEGEN_PPC_OSX) AC_SUBST(JS_CPU_PPC_OSX) diff --git a/js/src/irregexp/NativeRegExpMacroAssembler.cpp b/js/src/irregexp/NativeRegExpMacroAssembler.cpp index f1a40e10f..15b0aa754 100644 --- a/js/src/irregexp/NativeRegExpMacroAssembler.cpp +++ b/js/src/irregexp/NativeRegExpMacroAssembler.cpp @@ -315,7 +315,9 @@ NativeRegExpMacroAssembler::GenerateCode(JSContext* cx, bool match_only) masm.jump(&start_label_); // Exit code: +#if defined(JS_CODEGEN_PPC_OSX) BufferOffset bo_exit1, bo_exit2; +#endif if (success_label_.used()) { MOZ_ASSERT(num_saved_registers_ > 0); diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index f9c1fa476..d00641521 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -2542,7 +2542,7 @@ ICGetElem_Arguments::Compiler::generateStubCode(MacroAssembler& masm) AllocatableGeneralRegisterSet regs(availableGeneralRegs(2)); Register scratchReg = regs.takeAny(); -#if(0) +#ifndef JS_CODEGEN_PPC_OSX // Guard on input being an arguments object. masm.branchTestObject(Assembler::NotEqual, R0, &failure); Register objReg = masm.extractObject(R0, ExtractTemp0); diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 14af91f26..25d5035be 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -1029,7 +1029,9 @@ CodeGenerator::visitValueToString(LValueToString* lir) StoreRegisterTo(output)); Label done; +#ifdef JS_CODEGEN_PPC_OSX BufferOffset bo_done1, bo_done2, bo_done3, bo_done4, bo_done5, bo_done6; +#endif Register tag = masm.splitTagForTest(input); const JSAtomState& names = GetJitContext()->runtime->names(); diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp index 39d1bd8f2..48e2619f0 100644 --- a/js/src/jit/MacroAssembler.cpp +++ b/js/src/jit/MacroAssembler.cpp @@ -310,20 +310,40 @@ MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T& src, AnyRegi load8ZeroExtend(src, dest.gpr()); break; case Scalar::Int16: +#if defined(JS_CODEGEN_PPC_OSX) load16SignExtendSwapped(src, dest.gpr()); +#elif defined(JS_CODEGEN_X86) + load16SignExtend(src, dest.gpr()); +#endif break; case Scalar::Uint16: +#if defined(JS_CODEGEN_PPC_OSX) load16ZeroExtendSwapped(src, dest.gpr()); +#elif defined(JS_CODEGEN_X86) + load16ZeroExtend(src, dest.gpr()); +#endif break; case Scalar::Int32: +#if defined(JS_CODEGEN_PPC_OSX) load32ByteSwapped(src, dest.gpr()); +#elif defined(JS_CODEGEN_X86) + load32Byte(src, dest.gpr()); +#endif break; case Scalar::Uint32: if (dest.isFloat()) { +#if defined(JS_CODEGEN_PPC_OSX) load32ByteSwapped(src, temp); +#elif defined(JS_CODEGEN_X86) + load32Byte(src, temp); +#endif convertUInt32ToDouble(temp, dest.fpu()); } else { +#if defined(JS_CODEGEN_PPC_OSX) load32ByteSwapped(src, dest.gpr()); +#elif defined(JS_CODEGEN_X86) + load32Byte(src, temp); +#endif // Bail out if the value doesn't fit into a signed int32 value. This // is what allows MLoadUnboxedScalar to have a type() of @@ -491,7 +511,11 @@ MacroAssembler::loadFromTypedArray(Scalar::Type arrayType, const T& src, const V break; case Scalar::Uint32: // Don't clobber dest when we could fail, instead use temp. +#if defined(JS_CODEGEN_PPC_OSX) load32ByteSwapped(src, temp); +#elif defined(JS_CODEGEN_X86) + load32(src, temp); +#endif if (allowDouble) { // If the value fits in an int32, store an int32 type tag. // Else, convert the value to double and box it. diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index c1822ad94..efff5d929 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -1109,11 +1109,19 @@ private: break; case Scalar::Int16: case Scalar::Uint16: +#if defined(JS_CODEGEN_PPC_OSX) store16Swapped(value, dest); +#elif defined(JS_CODEGEN_X86) + store16(value, dest); +#endif break; case Scalar::Int32: case Scalar::Uint32: +#if defined(JS_CODEGEN_PPC_OSX) store32ByteSwapped(value, dest); +#elif defined(JS_CODEGEN_X86) + store32(value, dest); +#endif break; default: MOZ_CRASH("Invalid typed array type"); diff --git a/js/src/vm/TypedArrayCommon.h b/js/src/vm/TypedArrayCommon.h index d835cd647..ced5c4c27 100644 --- a/js/src/vm/TypedArrayCommon.h +++ b/js/src/vm/TypedArrayCommon.h @@ -126,7 +126,7 @@ IsAnyTypedArrayClass(const Class* clasp) class SharedOps { public: -#if(0) +#ifndef JS_CODEGEN_PPC_OSX template static T load(SharedMem addr) { return js::jit::AtomicOperations::loadSafeWhenRacy(addr); @@ -214,7 +214,7 @@ class SharedOps class UnsharedOps { public: -#if(0) +#ifndef JS_CODEGEN_PPC_OSX template static T load(SharedMem addr) { return *addr.unwrapUnshared(); From e4d110b8b2f6c1b693a3f44b965ba5e235f9a12e Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Tue, 16 Jan 2018 22:44:02 +0100 Subject: [PATCH 2/9] replacement methods for 10.4 SDK --- webapprt/mac/webapprt.mm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webapprt/mac/webapprt.mm b/webapprt/mac/webapprt.mm index 479bb67a0..59b0e12a4 100644 --- a/webapprt/mac/webapprt.mm +++ b/webapprt/mac/webapprt.mm @@ -188,13 +188,22 @@ main(int argc, char **argv) } } +#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) + [fileClerk removeFileAtPath: myWebRTPath handler:nil]; +#else [fileClerk removeItemAtPath: myWebRTPath error: &errorDesc]; +#endif if (errorDesc != nil) { NSLog(@"failed to unlink old binary file at path: %@ with error: %@", myWebRTPath, errorDesc); @throw MakeException(@"Unable To Update", @"Failed preparation for Web Runtime update"); } +#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4) + [fileClerk copyPath: newWebRTPath toPath: myWebRTPath handler:nil]; +#else [fileClerk copyItemAtPath: newWebRTPath toPath: myWebRTPath error: &errorDesc]; +#endif + [fileClerk release]; if (errorDesc != nil) { NSLog(@"failed to copy new webrt file: %@", errorDesc); From a7afb75f2673e699369f82e2c009b4363a1ef110 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Tue, 30 Jan 2018 22:31:18 +0100 Subject: [PATCH 3/9] intel 32bit mozcfg file --- intel-Yonah.mozcfg | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 intel-Yonah.mozcfg diff --git a/intel-Yonah.mozcfg b/intel-Yonah.mozcfg new file mode 100644 index 000000000..022b30849 --- /dev/null +++ b/intel-Yonah.mozcfg @@ -0,0 +1,24 @@ +. $topsrcdir/browser/config/mozconfig +export CC="/opt/local/bin/gcc-mp-4.8 -flax-vector-conversions -O3 -m32 -march=pentium-m -read_only_relocs suppress -mdynamic-no-pic" +export CXX="/opt/local/bin/g++-mp-4.8 -flax-vector-conversions -fpermissive -O3 -m32 -march=pentium-m -read_only_relocs suppress -mdynamic-no-pic" +mk_add_options MOZ_OBJDIR=@TOPSRCDIR@/obj-ff-dbg +mk_add_options MOZ_MAKE_FLAGS="-s -j2" +mk_add_options AUTOCONF=autoconf213 +ac_add_options --disable-tests +ac_add_options --disable-static +ac_add_options --enable-optimize +ac_add_options --disable-cpp-exceptions +ac_add_options --disable-debug +ac_add_options --disable-crashreporter +ac_add_options --enable-printing +ac_add_options --enable-prebinding +ac_add_options --enable-macos-target=10.4 +ac_add_options --enable-chrome-format=jar +ac_add_options --with-macos-sdk=/Developer/SDKs/MacOSX10.4u.sdk +ac_add_options --enable-strip +ac_add_options --enable-install-strip +ac_add_options --with-distribution-id=com.floodgap +ac_add_options --enable-webrtc + +ac_add_options --disable-ion +ac_add_options --disable-ctypes From 8e5ca58fab673dc6ddb46006098400ce7dda0347 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Tue, 30 Jan 2018 22:53:55 +0100 Subject: [PATCH 4/9] disable SKIA, we don't use it on either x86 nor PPC for now --- configure.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.in b/configure.in index 44c6c879d..70f4e4b87 100644 --- a/configure.in +++ b/configure.in @@ -8136,6 +8136,9 @@ else MOZ_ENABLE_SKIA= fi +dnl force disabling of SKIA totally for FFF, to be optionally re-enabled later +MOZ_ENABLE_SKIA= + MOZ_ARG_ENABLE_BOOL(skia, [ --enable-skia Enable use of Skia], MOZ_ENABLE_SKIA=1, From 74793a8c76bfc48b2f6c8bb10ace09f9efbf78d0 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Tue, 30 Jan 2018 22:56:14 +0100 Subject: [PATCH 5/9] set linker options only on PPC, not needed on x86 --- browser/app/moz.build | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/app/moz.build b/browser/app/moz.build index b9367e6f3..c1210995e 100644 --- a/browser/app/moz.build +++ b/browser/app/moz.build @@ -71,7 +71,9 @@ if CONFIG['MOZ_LINKER']: if CONFIG['HAVE_CLOCK_MONOTONIC']: OS_LIBS += CONFIG['REALTIME_LIBS'] -OS_LIBS += ['-Wl,-stack_size,0x40000000,-stack_addr,0xf0000000'] +# we build only on Darwin anyway +if CONFIG['OS_ARCH'] == 'Darwin' and CONFIG['CPU_TYPE'] == 'ppc': + OS_LIBS += ['-Wl,-stack_size,0x40000000,-stack_addr,0xf0000000'] if CONFIG['GNU_CXX']: CXXFLAGS += ['-Wshadow'] From 7ba58cf7fa47eb80e879b215d0741ce30838eb17 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Fri, 2 Feb 2018 10:03:08 +0100 Subject: [PATCH 6/9] tweak AVX for intel gcc build --- security/nss/lib/freebl/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/security/nss/lib/freebl/Makefile b/security/nss/lib/freebl/Makefile index ab0b1e571..5f7bc77c7 100644 --- a/security/nss/lib/freebl/Makefile +++ b/security/nss/lib/freebl/Makefile @@ -187,10 +187,11 @@ endif ifeq ($(OS_TARGET),Darwin) ifeq ($(CPU_ARCH),x86) - ASFILES = mpi_sse2.s +# Disable SSE2 since it causes assembler and linker issues +# ASFILES = mpi_sse2.s DEFINES += -DMP_USE_UINT_DIGIT - DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE - DEFINES += -DMP_ASSEMBLY_DIV_2DX1D +# DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_ASSEMBLY_SQUARE +# DEFINES += -DMP_ASSEMBLY_DIV_2DX1D endif endif # Darwin From dc3e34a505de0f741848c597a8371d26792175fd Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Mon, 5 Feb 2018 21:15:52 +0100 Subject: [PATCH 7/9] and Little Endian paths to GetFont Table and FindTagInTableDir --- gfx/thebes/gfxMacPlatformFontList.mm | 33 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 75abc38af..b7db1b014 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -481,14 +481,14 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) ByteCount dataLength = 0; if (!mIsDataUserFont || mIsLocalUserFont) TryGlobalFontTableCache(); - + // See if we already know how long the table is. This saves a potentially // expensive call to ATSGetFontTable() to simply get the length. // Essentially a hardcoded form of FindTagInTableDir; see below. if (MOZ_LIKELY(mFontTableDirSize > 0)) { - // XXX: This assumes big endian (warning Intel) + uint32_t aTagHE = aTag; #ifndef __ppc__ -#warning needs GetFontTable fast path needs little endian version + aTagHE = __builtin_bswap32(aTag); #endif #ifdef DEBUG_X @@ -500,19 +500,23 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) uint32_t i; uint32_t *wtable = (reinterpret_cast( mFontTableDir.Elements())); + for (i=3; i<(mFontTableDirSize/4); i+=4) { // Skip header #ifdef DEBUG_X char tag[5] = { table[j], table[j+1], table[j+2], table[j+3], '\0' }; - fprintf(stderr, "%s ", tag); // remember: big endian + fprintf(stderr, "%s ", tag); // remember: host endian j += 16; #endif - // ASSUME THAT aTag is already big endian - if(wtable[i] == aTag) { -#ifdef DEBUG_X - fprintf(stderr, "MATCH: length %i\n", wtable[i+3]); -#endif + // ASSUME THAT aTag is in host endianness + if(wtable[i] == aTagHE) { dataLength = (ByteCount)wtable[i+3]; +#ifndef __ppc__ + dataLength = __builtin_bswap32(dataLength); +#endif +#ifdef DEBUG_X + fprintf(stderr, "FF MATCH: length %u\n", dataLength); +#endif break; } } @@ -532,7 +536,7 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) CFMutableDataRef dataRef = ::CFDataCreateMutable(kCFAllocatorDefault, dataLength); if (!dataRef) return nullptr; - + ::CFDataIncreaseLength(dataRef, dataLength); // paranoia if(MOZ_UNLIKELY(::ATSFontGetTable(fontRef, aTag, 0, dataLength, ::CFDataGetMutableBytePtr(dataRef), @@ -540,7 +544,7 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) ::CFRelease(dataRef); return nullptr; } - + return hb_blob_create((const char*)::CFDataGetBytePtr(dataRef), ::CFDataGetLength(dataRef), HB_MEMORY_MODE_READONLY, @@ -559,6 +563,11 @@ static bool FindTagInTableDir(FallibleTArray& table, // corresponding to the tag, checksum, offset and length, with a // 96 bit header (three 32-bit words). One day we could even write // an AltiVec version ... + // aTableTag is expected to be Big Endian order +#ifndef __ppc__ + aTableTag = __builtin_bswap32(aTableTag); +#endif + #ifdef DEBUG_X fprintf(stderr, "Tables: "); uint32_t j = 12; @@ -571,7 +580,7 @@ static bool FindTagInTableDir(FallibleTArray& table, fprintf(stderr, "%s ", tag); // remember: big endian j+=16; #endif - // ASSUME THAT aTableTag is already big endian + // ASSUME THAT aTableTag is already big endian (we converted it in case) if(wtable[i] == aTableTag) { #ifdef DEBUG_X fprintf(stderr, "MATCH\n"); From 23cdfbc71e45a21634e95e80cc53b137c35c9506 Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Sun, 18 Feb 2018 22:05:33 +0100 Subject: [PATCH 8/9] whitespace cleanup --- gfx/thebes/gfxMacPlatformFontList.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index b7db1b014..ab3543b2e 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -481,7 +481,7 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) ByteCount dataLength = 0; if (!mIsDataUserFont || mIsLocalUserFont) TryGlobalFontTableCache(); - + // See if we already know how long the table is. This saves a potentially // expensive call to ATSGetFontTable() to simply get the length. // Essentially a hardcoded form of FindTagInTableDir; see below. From 644b97d52a00bb5ecbae9829ab2153ddcad94fbc Mon Sep 17 00:00:00 2001 From: Riccardo Mottola Date: Mon, 19 Feb 2018 12:48:05 +0100 Subject: [PATCH 9/9] whitespace removal --- gfx/thebes/gfxMacPlatformFontList.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index ab3543b2e..2fba75bdc 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -479,9 +479,9 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) if (fontRef == kInvalidFont) return nullptr; ByteCount dataLength = 0; - + if (!mIsDataUserFont || mIsLocalUserFont) TryGlobalFontTableCache(); - + // See if we already know how long the table is. This saves a potentially // expensive call to ATSGetFontTable() to simply get the length. // Essentially a hardcoded form of FindTagInTableDir; see below. @@ -536,7 +536,7 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) CFMutableDataRef dataRef = ::CFDataCreateMutable(kCFAllocatorDefault, dataLength); if (!dataRef) return nullptr; - + ::CFDataIncreaseLength(dataRef, dataLength); // paranoia if(MOZ_UNLIKELY(::ATSFontGetTable(fontRef, aTag, 0, dataLength, ::CFDataGetMutableBytePtr(dataRef), @@ -544,7 +544,7 @@ MacOSFontEntry::GetFontTable(uint32_t aTag) ::CFRelease(dataRef); return nullptr; } - + return hb_blob_create((const char*)::CFDataGetBytePtr(dataRef), ::CFDataGetLength(dataRef), HB_MEMORY_MODE_READONLY,