From 06048c51a63003d6367e341d9a0a75976d0136d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 26 Jan 2015 17:58:29 +0100 Subject: [PATCH] Change JIT return codes, use negative values for errors --- libevmjit/Common.h | 18 ++++++++++-------- libevmjit/Stack.cpp | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/libevmjit/Common.h b/libevmjit/Common.h index d0c582236..175cd1bcd 100644 --- a/libevmjit/Common.h +++ b/libevmjit/Common.h @@ -22,14 +22,16 @@ enum class ReturnCode Return = 1, Suicide = 2, - BadJumpDestination = 101, - OutOfGas = 102, - StackTooSmall = 103, - BadInstruction = 104, - - LLVMConfigError = 201, - LLVMCompileError = 202, - LLVMLinkError = 203, + OutOfGas = -1, + BadJumpDestination = -2, + StackTooSmall = -3, + BadInstruction = -4, + + LLVMConfigError = -5, + LLVMCompileError = -6, + LLVMLinkError = -7, + + UnexpectedException = -8, }; /// Representation of 256-bit value binary compatible with LLVM i256 diff --git a/libevmjit/Stack.cpp b/libevmjit/Stack.cpp index 2382b9361..44f1c21c1 100644 --- a/libevmjit/Stack.cpp +++ b/libevmjit/Stack.cpp @@ -73,7 +73,7 @@ extern "C" { auto& stack = _rt->getStack(); if (stack.size() < _count) - longjmp(_rt->getJmpBuf(), static_cast(ReturnCode::StackTooSmall)); + longjmp(_rt->getJmpBuf(), static_cast(ReturnCode::StackTooSmall)); stack.erase(stack.end() - _count, stack.end()); } @@ -92,7 +92,7 @@ extern "C" auto& stack = _rt->getStack(); // TODO: encode _index and stack size in the return code if (stack.size() <= _index) - longjmp(_rt->getJmpBuf(), static_cast(ReturnCode::StackTooSmall)); + longjmp(_rt->getJmpBuf(), static_cast(ReturnCode::StackTooSmall)); *o_ret = *(stack.rbegin() + _index); } @@ -102,7 +102,7 @@ extern "C" auto& stack = _rt->getStack(); // TODO: encode _index and stack size in the return code if (stack.size() <= _index) - longjmp(_rt->getJmpBuf(), static_cast(ReturnCode::StackTooSmall)); + longjmp(_rt->getJmpBuf(), static_cast(ReturnCode::StackTooSmall)); *(stack.rbegin() + _index) = *_word; }