Added ASMJIT_API to BaseEmitter::_emitOpArray() + other minor changes

This commit is contained in:
kobalicek
2020-06-24 22:51:04 +02:00
parent 5bd643058a
commit 3535263419
3 changed files with 29 additions and 27 deletions

View File

@@ -351,7 +351,9 @@ Error CodeHolder::growBuffer(CodeBuffer* cb, size_t n) noexcept {
Error CodeHolder::reserveBuffer(CodeBuffer* cb, size_t n) noexcept { Error CodeHolder::reserveBuffer(CodeBuffer* cb, size_t n) noexcept {
size_t capacity = cb->capacity(); size_t capacity = cb->capacity();
if (n <= capacity) return kErrorOk;
if (n <= capacity)
return kErrorOk;
if (cb->isFixed()) if (cb->isFixed())
return DebugUtils::errored(kErrorTooLarge); 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, // 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 // however it's questionable as the number of sections should be pretty low
// in general. Create an issue if this becomes a problem. // in general. Create an issue if this becomes a problem.
if (ASMJIT_UNLIKELY(nameSize <= Globals::kMaxSectionNameSize)) { if (nameSize <= Globals::kMaxSectionNameSize) {
for (Section* section : _sections) for (Section* section : _sections)
if (memcmp(section->_name.str, name, nameSize) == 0 && section->_name.str[nameSize] == '\0') if (memcmp(section->_name.str, name, nameSize) == 0 && section->_name.str[nameSize] == '\0')
return section; return section;

View File

@@ -561,7 +561,7 @@ public:
//! Emits an instruction - all 6 operands must be defined. //! 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; 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. //! 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 //! \endcond
//! \} //! \}

View File

@@ -76,20 +76,20 @@ class ZoneList {
public: public:
ASMJIT_NONCOPYABLE(ZoneList) ASMJIT_NONCOPYABLE(ZoneList)
NodeT* _bounds[Globals::kLinkCount]; NodeT* _nodes[Globals::kLinkCount];
//! \name Construction & Destruction //! \name Construction & Destruction
//! \{ //! \{
inline ZoneList() noexcept inline ZoneList() noexcept
: _bounds { nullptr, nullptr } {} : _nodes { nullptr, nullptr } {}
inline ZoneList(ZoneList&& other) noexcept inline ZoneList(ZoneList&& other) noexcept
: _bounds { other._bounds[0], other._bounds[1] } {} : _nodes { other._nodes[0], other._nodes[1] } {}
inline void reset() noexcept { inline void reset() noexcept {
_bounds[0] = nullptr; _nodes[0] = nullptr;
_bounds[1] = nullptr; _nodes[1] = nullptr;
} }
//! \} //! \}
@@ -97,9 +97,9 @@ public:
//! \name Accessors //! \name Accessors
//! \{ //! \{
inline bool empty() const noexcept { return _bounds[0] == nullptr; } inline bool empty() const noexcept { return _nodes[0] == nullptr; }
inline NodeT* first() const noexcept { return _bounds[Globals::kLinkFirst]; } inline NodeT* first() const noexcept { return _nodes[Globals::kLinkFirst]; }
inline NodeT* last() const noexcept { return _bounds[Globals::kLinkLast]; } inline NodeT* last() const noexcept { return _nodes[Globals::kLinkLast]; }
//! \} //! \}
@@ -107,23 +107,23 @@ public:
//! \{ //! \{
inline void swap(ZoneList& other) noexcept { inline void swap(ZoneList& other) noexcept {
std::swap(_bounds[0], other._bounds[0]); std::swap(_nodes[0], other._nodes[0]);
std::swap(_bounds[1], other._bounds[1]); 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 { inline void _addNode(NodeT* node, size_t dir) noexcept {
NodeT* prev = _bounds[dir]; NodeT* prev = _nodes[dir];
node->_listNodes[!dir] = prev; node->_listNodes[!dir] = prev;
_bounds[dir] = node; _nodes[dir] = node;
if (prev) if (prev)
prev->_listNodes[dir] = node; prev->_listNodes[dir] = node;
else 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 { inline void _insertNode(NodeT* ref, NodeT* node, size_t dir) noexcept {
ASMJIT_ASSERT(ref != nullptr); ASMJIT_ASSERT(ref != nullptr);
@@ -134,7 +134,7 @@ public:
if (next) if (next)
next->_listNodes[!dir] = node; next->_listNodes[!dir] = node;
else else
_bounds[dir] = node; _nodes[dir] = node;
node->_listNodes[!dir] = prev; node->_listNodes[!dir] = prev;
node->_listNodes[ dir] = next; node->_listNodes[ dir] = next;
@@ -150,8 +150,8 @@ public:
NodeT* prev = node->prev(); NodeT* prev = node->prev();
NodeT* next = node->next(); NodeT* next = node->next();
if (prev) { prev->_listNodes[1] = next; node->_listNodes[0] = nullptr; } else { _bounds[0] = next; } 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 { _bounds[1] = prev; } if (next) { next->_listNodes[0] = prev; node->_listNodes[1] = nullptr; } else { _nodes[1] = prev; }
node->_listNodes[0] = nullptr; node->_listNodes[0] = nullptr;
node->_listNodes[1] = nullptr; node->_listNodes[1] = nullptr;
@@ -160,36 +160,36 @@ public:
} }
inline NodeT* popFirst() noexcept { inline NodeT* popFirst() noexcept {
NodeT* node = _bounds[0]; NodeT* node = _nodes[0];
ASMJIT_ASSERT(node != nullptr); ASMJIT_ASSERT(node != nullptr);
NodeT* next = node->next(); NodeT* next = node->next();
_bounds[0] = next; _nodes[0] = next;
if (next) { if (next) {
next->_listNodes[0] = nullptr; next->_listNodes[0] = nullptr;
node->_listNodes[1] = nullptr; node->_listNodes[1] = nullptr;
} }
else { else {
_bounds[1] = nullptr; _nodes[1] = nullptr;
} }
return node; return node;
} }
inline NodeT* pop() noexcept { inline NodeT* pop() noexcept {
NodeT* node = _bounds[1]; NodeT* node = _nodes[1];
ASMJIT_ASSERT(node != nullptr); ASMJIT_ASSERT(node != nullptr);
NodeT* prev = node->prev(); NodeT* prev = node->prev();
_bounds[1] = prev; _nodes[1] = prev;
if (prev) { if (prev) {
prev->_listNodes[1] = nullptr; prev->_listNodes[1] = nullptr;
node->_listNodes[0] = nullptr; node->_listNodes[0] = nullptr;
} }
else { else {
_bounds[0] = nullptr; _nodes[0] = nullptr;
} }
return node; return node;