Error BaseContext::removeUnreachableCode() { PodList<BaseNode*>::Link* link = _unreachableList.getFirst(); BaseNode* stop = getStop(); while (link != NULL) { BaseNode* node = link->getValue(); if (node != NULL && node->getPrev() != NULL) { // Locate all unreachable nodes. BaseNode* first = node; do { if (node->isFetched()) break; node = node->getNext(); } while (node != stop); // Remove. if (node != first) { BaseNode* last = (node != NULL) ? node->getPrev() : getCompiler()->getLastNode(); getCompiler()->removeNodes(first, last); } } link = link->getNext(); } return kErrorOk; }
Error BaseContext::compile(FuncNode* func) { BaseNode* end = func->getEnd(); BaseNode* stop = end->getNext(); _func = func; _stop = stop; _extraBlock = end; ASMJIT_PROPAGATE_ERROR(fetch()); ASMJIT_PROPAGATE_ERROR(removeUnreachableCode()); ASMJIT_PROPAGATE_ERROR(analyze()); if (_compiler->hasLogger()) ASMJIT_PROPAGATE_ERROR(annotate()); ASMJIT_PROPAGATE_ERROR(translate()); // We alter the compiler cursor, because it doesn't make sense to reference // it after compilation - some nodes may disappear and it's forbidden to add // new code after the compilation is done. _compiler->_setCursor(NULL); return kErrorOk; }