Error CodeGen::setError(Error error, const char* message) { if (error == kErrorOk) { _error = kErrorOk; return kErrorOk; } if (message == NULL) { #if !defined(ASMJIT_DISABLE_NAMES) message = ErrorUtil::asString(error); #else static const char noMessage[] = ""; message = noMessage; #endif // ASMJIT_DISABLE_NAMES } // Error handler is called before logger so logging can be skipped if error // has been handled. ErrorHandler* handler = _errorHandler; ASMJIT_TLOG("[ERROR] %s %s\n", message, !handler ? "(Possibly unhandled?)" : ""); if (handler != NULL && handler->handleError(error, message)) return error; #if !defined(ASMJIT_DISABLE_LOGGER) Logger* logger = _logger; if (logger != NULL) { logger->logFormat(kLoggerStyleComment, "*** ERROR: %s (%u).\n", message, static_cast<unsigned int>(error)); } #endif // !ASMJIT_DISABLE_LOGGER // The handler->handleError() function may throw an exception or longjmp() // to terminate the execution of setError(). This is the reason why we have // delayed changing the _error member until now. _error = error; return error; }
Error Context::removeUnreachableCode() { Compiler* compiler = getCompiler(); PodList<HLNode*>::Link* link = _unreachableList.getFirst(); HLNode* stop = getStop(); while (link != NULL) { HLNode* node = link->getValue(); if (node != NULL && node->getPrev() != NULL && node != stop) { // Locate all unreachable nodes. HLNode* first = node; do { if (node->isFetched()) break; node = node->getNext(); } while (node != stop); // Remove unreachable nodes that are neither informative nor directives. if (node != first) { HLNode* end = node; node = first; do { HLNode* next = node->getNext(); if (!node->isInformative() && node->getType() != kHLNodeTypeAlign) { ASMJIT_TLOG("[%05d] Unreachable\n", node->getFlowId()); compiler->removeNode(node); } node = next; } while (node != end); } } link = link->getNext(); } return kErrorOk; }