From owner-svn-ports-head@freebsd.org Sat Jul 22 02:28:27 2017 Return-Path: Delivered-To: svn-ports-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95167C7C69B; Sat, 22 Jul 2017 02:28:27 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C37B6741B; Sat, 22 Jul 2017 02:28:27 +0000 (UTC) (envelope-from jbeich@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6M2SQWG052909; Sat, 22 Jul 2017 02:28:26 GMT (envelope-from jbeich@FreeBSD.org) Received: (from jbeich@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6M2SQSr052905; Sat, 22 Jul 2017 02:28:26 GMT (envelope-from jbeich@FreeBSD.org) Message-Id: <201707220228.v6M2SQSr052905@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jbeich set sender to jbeich@FreeBSD.org using -f From: Jan Beich Date: Sat, 22 Jul 2017 02:28:26 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r446352 - in head/emulators: ppsspp ppsspp/files rpcs3 rpcs3/files X-SVN-Group: ports-head X-SVN-Commit-Author: jbeich X-SVN-Commit-Paths: in head/emulators: ppsspp ppsspp/files rpcs3 rpcs3/files X-SVN-Commit-Revision: 446352 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree for head List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Jul 2017 02:28:27 -0000 Author: jbeich Date: Sat Jul 22 02:28:26 2017 New Revision: 446352 URL: https://svnweb.freebsd.org/changeset/ports/446352 Log: emulators/{ppsspp,rpcs3}: switch to MAP_32BIT This may slightly improve JIT stability. MFH: 2017Q3 Modified: head/emulators/ppsspp/Makefile (contents, props changed) head/emulators/ppsspp/files/patch-Common_MemoryUtil.cpp (contents, props changed) head/emulators/rpcs3/Makefile (contents, props changed) head/emulators/rpcs3/files/patch-Utilities_JIT.cpp (contents, props changed) Modified: head/emulators/ppsspp/Makefile ============================================================================== --- head/emulators/ppsspp/Makefile Sat Jul 22 01:51:44 2017 (r446351) +++ head/emulators/ppsspp/Makefile Sat Jul 22 02:28:26 2017 (r446352) @@ -3,7 +3,7 @@ PORTNAME= ppsspp DISTVERSIONPREFIX= v DISTVERSION?= 1.4.2 -PORTREVISION?= 0 +PORTREVISION?= 1 CATEGORIES= emulators # XXX Get from Debian once #697821 lands MASTER_SITES= https://bazaar.launchpad.net/~sergio-br2/${PORTNAME}/debian-sdl/download/5/${PORTNAME}.1-20140802045408-dd26dik367ztj5xg-8/:manpage Modified: head/emulators/ppsspp/files/patch-Common_MemoryUtil.cpp ============================================================================== --- head/emulators/ppsspp/files/patch-Common_MemoryUtil.cpp Sat Jul 22 01:51:44 2017 (r446351) +++ head/emulators/ppsspp/files/patch-Common_MemoryUtil.cpp Sat Jul 22 02:28:26 2017 (r446352) @@ -1,35 +1,31 @@ ---- Common/MemoryUtil.cpp.orig 2015-11-19 15:07:48 UTC +https://github.com/hrydgard/ppsspp/pull/9857 + +--- Common/MemoryUtil.cpp.orig 2017-05-27 09:58:05 UTC +++ Common/MemoryUtil.cpp -@@ -32,6 +32,10 @@ - #include +@@ -154,7 +154,7 @@ void *AllocateExecutableMemory(size_t size) { + } + #else + static char *map_hint = 0; +-#if defined(_M_X64) ++#if defined(_M_X64) && !defined(MAP_32BIT) + // Try to request one that is close to our memory location if we're in high memory. + // We use a dummy global variable to give us a good location to start from. + if (!map_hint) { +@@ -176,7 +176,7 @@ void *AllocateExecutableMemory(size_t size) { + void* ptr = mmap(map_hint, size, prot, + MAP_ANON | MAP_PRIVATE + #if defined(_M_X64) && defined(MAP_32BIT) +- | ((uintptr_t) map_hint == 0 ? MAP_32BIT : 0) ++ | MAP_32BIT #endif + , -1, 0); -+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -+#include -+#endif -+ - #ifndef _WIN32 - #include - #endif -@@ -149,6 +153,21 @@ void *AllocateExecutableMemory(size_t si - map_hint = (char*)round_page(&hint_location) - 0x20000000; // 0.5gb lower than our approximate location - else - map_hint = (char*)0x20000000; // 0.5GB mark in memory -+ -+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -+ // XXX Fix maximum data segment size (data + BSS + heap) to 256 MB. -+ // This allows avoiding calling mmap(2) with MAP_FIXED. -+ // On FreeBSD, without lowering this limit, calling mmap(2) -+ // without MAP_FIXED will result in getting an address just -+ // beyond maximum data segment size which will be far beyond -+ // the desired 2 GB. -+ struct rlimit limit; -+ limit.rlim_cur = 0x10000000; // 256 MB -+ limit.rlim_max = 0x10000000; -+ if(setrlimit(RLIMIT_DATA, &limit) != 0) { -+ PanicAlert("Failed to lower maximum data segment size"); -+ } -+#endif +@@ -193,7 +193,7 @@ void *AllocateExecutableMemory(size_t size) { + ERROR_LOG(MEMMAP, "Failed to allocate executable memory (%d)", (int)size); + PanicAlert("Failed to allocate executable memory\n%s", GetLastErrorMsg()); } - else if ((uintptr_t) map_hint > 0xFFFFFFFFULL) - { +-#if defined(_M_X64) && !defined(_WIN32) ++#if defined(_M_X64) && !defined(MAP_32BIT) && !defined(_WIN32) + else if ((uintptr_t)map_hint <= 0xFFFFFFFF) { + // Round up if we're below 32-bit mark, probably allocating sequentially. + map_hint += round_page(size); Modified: head/emulators/rpcs3/Makefile ============================================================================== --- head/emulators/rpcs3/Makefile Sat Jul 22 01:51:44 2017 (r446351) +++ head/emulators/rpcs3/Makefile Sat Jul 22 02:28:26 2017 (r446352) @@ -3,6 +3,7 @@ PORTNAME= rpcs3 DISTVERSIONPREFIX= v DISTVERSION= 0.0.3 +PORTREVISION= 1 CATEGORIES= emulators MAINTAINER= jbeich@FreeBSD.org Modified: head/emulators/rpcs3/files/patch-Utilities_JIT.cpp ============================================================================== --- head/emulators/rpcs3/files/patch-Utilities_JIT.cpp Sat Jul 22 01:51:44 2017 (r446351) +++ head/emulators/rpcs3/files/patch-Utilities_JIT.cpp Sat Jul 22 02:28:26 2017 (r446352) @@ -1,35 +1,33 @@ ---- Utilities/JIT.cpp.orig 2017-07-10 15:42:02 UTC +FreeBSD ignores address hints with default RLIMIT_DATA + +--- Utilities/JIT.cpp.orig 2017-07-20 15:05:34 UTC +++ Utilities/JIT.cpp -@@ -31,6 +31,10 @@ +@@ -30,6 +30,8 @@ + + #ifdef _WIN32 #include ++#else ++#include #endif -+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -+#include -+#endif -+ #include "JIT.h" - - // Memory manager mutex -@@ -45,6 +49,21 @@ static void* const s_memory = []() -> void* - llvm::InitializeNativeTarget(); +@@ -47,6 +49,11 @@ static void* const s_memory = []() -> void* llvm::InitializeNativeTargetAsmPrinter(); LLVMLinkInMCJIT(); -+ -+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -+ // XXX Fix maximum data segment size (data + BSS + heap) to 256 MB. -+ // This allows avoiding calling mmap(2) with MAP_FIXED. -+ // On FreeBSD, without lowering this limit, calling mmap(2) -+ // without MAP_FIXED will result in getting an address just -+ // beyond maximum data segment size which will be far beyond -+ // the desired 2 GB. -+ struct rlimit limit; -+ limit.rlim_cur = 0x10000000; // 256 MB -+ limit.rlim_max = 0x10000000; -+ if(setrlimit(RLIMIT_DATA, &limit) != 0) { -+ LOG_ERROR(GENERAL, "LLVM: Failed to lower maximum data segment size"); -+ } -+#endif ++#ifdef MAP_32BIT ++ auto ptr = ::mmap(nullptr, s_memory_size, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_32BIT, -1, 0); ++ if (ptr != MAP_FAILED) ++ return ptr; ++#else for (u64 addr = 0x10000000; addr <= 0x80000000 - s_memory_size; addr += 0x1000000) { + if (auto ptr = utils::memory_reserve(s_memory_size, (void*)addr)) +@@ -54,6 +61,7 @@ static void* const s_memory = []() -> void* + return ptr; + } + } ++#endif + + return utils::memory_reserve(s_memory_size); + }();