From 3535263419c214448d90781c698dc70f95528e75 Mon Sep 17 00:00:00 2001 From: kobalicek Date: Wed, 24 Jun 2020 22:51:04 +0200 Subject: [PATCH] Added ASMJIT_API to BaseEmitter::_emitOpArray() + other minor changes --- src/asmjit/core/codeholder.cpp | 6 +++-- src/asmjit/core/emitter.h | 2 +- src/asmjit/core/zonelist.h | 48 +++++++++++++++++----------------- 3 files changed, 29 insertions(+), 27 deletions(-) diff --git a/src/asmjit/core/codeholder.cpp b/src/asmjit/core/codeholder.cpp index 8711e38..69032e8 100644 --- a/src/asmjit/core/codeholder.cpp +++ b/src/asmjit/core/codeholder.cpp @@ -351,7 +351,9 @@ Error CodeHolder::growBuffer(CodeBuffer* cb, size_t n) noexcept { Error CodeHolder::reserveBuffer(CodeBuffer* cb, size_t n) noexcept { size_t capacity = cb->capacity(); - if (n <= capacity) return kErrorOk; + + if (n <= capacity) + return kErrorOk; if (cb->isFixed()) return DebugUtils::errored(kErrorTooLarge); @@ -405,7 +407,7 @@ Section* CodeHolder::sectionByName(const char* name, size_t nameSize) const noex // This could be also put in a hash-table similarly like we do with labels, // however it's questionable as the number of sections should be pretty low // in general. Create an issue if this becomes a problem. - if (ASMJIT_UNLIKELY(nameSize <= Globals::kMaxSectionNameSize)) { + if (nameSize <= Globals::kMaxSectionNameSize) { for (Section* section : _sections) if (memcmp(section->_name.str, name, nameSize) == 0 && section->_name.str[nameSize] == '\0') return section; diff --git a/src/asmjit/core/emitter.h b/src/asmjit/core/emitter.h index 0fd09f7..6da602e 100644 --- a/src/asmjit/core/emitter.h +++ b/src/asmjit/core/emitter.h @@ -561,7 +561,7 @@ public: //! Emits an instruction - all 6 operands must be defined. virtual Error _emit(uint32_t instId, const Operand_& o0, const Operand_& o1, const Operand_& o2, const Operand_* oExt) = 0; //! Emits instruction having operands stored in array. - virtual Error _emitOpArray(uint32_t instId, const Operand_* operands, size_t opCount); + ASMJIT_API virtual Error _emitOpArray(uint32_t instId, const Operand_* operands, size_t opCount); //! \endcond //! \} diff --git a/src/asmjit/core/zonelist.h b/src/asmjit/core/zonelist.h index bc726de..d7fb1dd 100644 --- a/src/asmjit/core/zonelist.h +++ b/src/asmjit/core/zonelist.h @@ -76,20 +76,20 @@ class ZoneList { public: ASMJIT_NONCOPYABLE(ZoneList) - NodeT* _bounds[Globals::kLinkCount]; + NodeT* _nodes[Globals::kLinkCount]; //! \name Construction & Destruction //! \{ inline ZoneList() noexcept - : _bounds { nullptr, nullptr } {} + : _nodes { nullptr, nullptr } {} inline ZoneList(ZoneList&& other) noexcept - : _bounds { other._bounds[0], other._bounds[1] } {} + : _nodes { other._nodes[0], other._nodes[1] } {} inline void reset() noexcept { - _bounds[0] = nullptr; - _bounds[1] = nullptr; + _nodes[0] = nullptr; + _nodes[1] = nullptr; } //! \} @@ -97,9 +97,9 @@ public: //! \name Accessors //! \{ - inline bool empty() const noexcept { return _bounds[0] == nullptr; } - inline NodeT* first() const noexcept { return _bounds[Globals::kLinkFirst]; } - inline NodeT* last() const noexcept { return _bounds[Globals::kLinkLast]; } + inline bool empty() const noexcept { return _nodes[0] == nullptr; } + inline NodeT* first() const noexcept { return _nodes[Globals::kLinkFirst]; } + inline NodeT* last() const noexcept { return _nodes[Globals::kLinkLast]; } //! \} @@ -107,23 +107,23 @@ public: //! \{ inline void swap(ZoneList& other) noexcept { - std::swap(_bounds[0], other._bounds[0]); - std::swap(_bounds[1], other._bounds[1]); + std::swap(_nodes[0], other._nodes[0]); + std::swap(_nodes[1], other._nodes[1]); } - // Can be used to both prepend and append. + // Can be used to both append and prepend. inline void _addNode(NodeT* node, size_t dir) noexcept { - NodeT* prev = _bounds[dir]; + NodeT* prev = _nodes[dir]; node->_listNodes[!dir] = prev; - _bounds[dir] = node; + _nodes[dir] = node; if (prev) prev->_listNodes[dir] = node; else - _bounds[!dir] = node; + _nodes[!dir] = node; } - // Can be used to both prepend and append. + // Can be used to both append and prepend. inline void _insertNode(NodeT* ref, NodeT* node, size_t dir) noexcept { ASMJIT_ASSERT(ref != nullptr); @@ -134,7 +134,7 @@ public: if (next) next->_listNodes[!dir] = node; else - _bounds[dir] = node; + _nodes[dir] = node; node->_listNodes[!dir] = prev; node->_listNodes[ dir] = next; @@ -150,8 +150,8 @@ public: NodeT* prev = node->prev(); NodeT* next = node->next(); - if (prev) { prev->_listNodes[1] = next; node->_listNodes[0] = nullptr; } else { _bounds[0] = next; } - if (next) { next->_listNodes[0] = prev; node->_listNodes[1] = nullptr; } else { _bounds[1] = prev; } + if (prev) { prev->_listNodes[1] = next; node->_listNodes[0] = nullptr; } else { _nodes[0] = next; } + if (next) { next->_listNodes[0] = prev; node->_listNodes[1] = nullptr; } else { _nodes[1] = prev; } node->_listNodes[0] = nullptr; node->_listNodes[1] = nullptr; @@ -160,36 +160,36 @@ public: } inline NodeT* popFirst() noexcept { - NodeT* node = _bounds[0]; + NodeT* node = _nodes[0]; ASMJIT_ASSERT(node != nullptr); NodeT* next = node->next(); - _bounds[0] = next; + _nodes[0] = next; if (next) { next->_listNodes[0] = nullptr; node->_listNodes[1] = nullptr; } else { - _bounds[1] = nullptr; + _nodes[1] = nullptr; } return node; } inline NodeT* pop() noexcept { - NodeT* node = _bounds[1]; + NodeT* node = _nodes[1]; ASMJIT_ASSERT(node != nullptr); NodeT* prev = node->prev(); - _bounds[1] = prev; + _nodes[1] = prev; if (prev) { prev->_listNodes[1] = nullptr; node->_listNodes[0] = nullptr; } else { - _bounds[0] = nullptr; + _nodes[0] = nullptr; } return node;