From 6f38d1baa1d6c735ae12b571dd341cd431f6ba73 Mon Sep 17 00:00:00 2001 From: degasus Date: Wed, 15 Jul 2015 08:53:05 +0200 Subject: CodeBlock: Add a shared IsAlmostFull function This function shall keep care about the low watermark of code space. If we ran out of space, the JITs shall clear their block cache. --- Source/Core/Common/CodeBlock.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Source/Core/Common/CodeBlock.h') diff --git a/Source/Core/Common/CodeBlock.h b/Source/Core/Common/CodeBlock.h index 972fc707d6..5699fc5385 100644 --- a/Source/Core/Common/CodeBlock.h +++ b/Source/Core/Common/CodeBlock.h @@ -72,5 +72,11 @@ public: { return region_size - (T::GetCodePtr() - region); } + + bool IsAlmostFull() const + { + // This should be bigger than the biggest block ever. + return GetSpaceLeft() < 0x10000; + } }; -- cgit v1.2.3 From d5c99a5b48a6cce702a1aa1e2b105ffe558d9ac9 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Fri, 7 Aug 2015 22:08:57 -0500 Subject: Add support for a CodeBlock holding a child. This is required to make sure two code spaces are relatively close to one another. In this case I need the AArch64 JIT codespace and its farcode space to be within 128MB of one another for branches. --- Source/Core/Common/CodeBlock.h | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'Source/Core/Common/CodeBlock.h') diff --git a/Source/Core/Common/CodeBlock.h b/Source/Core/Common/CodeBlock.h index 5699fc5385..865c4513ca 100644 --- a/Source/Core/Common/CodeBlock.h +++ b/Source/Core/Common/CodeBlock.h @@ -22,9 +22,19 @@ private: protected: u8 *region; size_t region_size; + size_t parent_region_size; + + bool m_has_child; + bool m_is_child; + CodeBlock* m_child; public: - CodeBlock() : region(nullptr), region_size(0) {} + CodeBlock() + : region(nullptr), region_size(0), parent_region_size(0), + m_has_child(false), m_is_child(false), m_child(nullptr) + { + } + virtual ~CodeBlock() { if (region) FreeCodeSpace(); } // Call this before you generate any code. @@ -49,6 +59,12 @@ public: FreeMemoryPages(region, region_size); region = nullptr; region_size = 0; + parent_region_size = 0; + if (m_has_child) + { + m_child->region = nullptr; + m_child->region_size = 0; + } } bool IsInSpace(u8 *ptr) const @@ -70,7 +86,7 @@ public: size_t GetSpaceLeft() const { - return region_size - (T::GetCodePtr() - region); + return (m_has_child ? parent_region_size : region_size) - (T::GetCodePtr() - region); } bool IsAlmostFull() const @@ -78,5 +94,16 @@ public: // This should be bigger than the biggest block ever. return GetSpaceLeft() < 0x10000; } + void AddChildCodeSpace(CodeBlock* child, size_t size) + { + _assert_msg_(DYNA_REC, !m_has_child, "Already have a child! Can't have another!"); + m_child = child; + m_has_child = true; + m_child->m_is_child = true; + u8* child_region = region + region_size - size; + m_child->region = child_region; + m_child->region_size = size; + m_child->ResetCodePtr(); + parent_region_size = region_size - size; + } }; - -- cgit v1.2.3 From 63c9fdd0746f1ad85d60e3c0b4a5f460ffb0457d Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Sat, 12 Sep 2015 01:24:47 +0200 Subject: VertexLoaderX64: fix 2GB warnings Unlike the CPU JIT, the vertex loader JIT already emits position-independent code, so all we need to do is disable the warning. --- Source/Core/Common/CodeBlock.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Source/Core/Common/CodeBlock.h') diff --git a/Source/Core/Common/CodeBlock.h b/Source/Core/Common/CodeBlock.h index 865c4513ca..5a7df9b87f 100644 --- a/Source/Core/Common/CodeBlock.h +++ b/Source/Core/Common/CodeBlock.h @@ -38,10 +38,10 @@ public: virtual ~CodeBlock() { if (region) FreeCodeSpace(); } // Call this before you generate any code. - void AllocCodeSpace(int size) + void AllocCodeSpace(int size, bool need_low = true) { region_size = size; - region = (u8*)AllocateExecutableMemory(region_size); + region = (u8*)AllocateExecutableMemory(region_size, need_low); T::SetCodePtr(region); } -- cgit v1.2.3 From 1d42db24398f7d94a6c9c641225d8088d203a3ea Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 26 Sep 2015 16:13:54 -0400 Subject: Common: Move NonCopyable to its own header --- Source/Core/Common/CodeBlock.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/Common/CodeBlock.h') diff --git a/Source/Core/Common/CodeBlock.h b/Source/Core/Common/CodeBlock.h index 5a7df9b87f..864dac5e63 100644 --- a/Source/Core/Common/CodeBlock.h +++ b/Source/Core/Common/CodeBlock.h @@ -6,6 +6,7 @@ #include "Common/Common.h" #include "Common/MemoryUtil.h" +#include "Common/NonCopyable.h" // Everything that needs to generate code should inherit from this. // You get memory management for free, plus, you can use all emitter functions without -- cgit v1.2.3 From 19ac565e0dafccd3728b58a0d92cdc0cb74e4be0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 26 Sep 2015 16:39:47 -0400 Subject: Common: Move asserts to their own header --- Source/Core/Common/CodeBlock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Source/Core/Common/CodeBlock.h') diff --git a/Source/Core/Common/CodeBlock.h b/Source/Core/Common/CodeBlock.h index 864dac5e63..8f02f08336 100644 --- a/Source/Core/Common/CodeBlock.h +++ b/Source/Core/Common/CodeBlock.h @@ -4,7 +4,7 @@ #pragma once -#include "Common/Common.h" +#include "Common/Assert.h" #include "Common/MemoryUtil.h" #include "Common/NonCopyable.h" -- cgit v1.2.3