Browse Source

Change JIT return codes, use negative values for errors

cl-refactor
Paweł Bylica 10 years ago
parent
commit
06048c51a6
  1. 18
      libevmjit/Common.h
  2. 6
      libevmjit/Stack.cpp

18
libevmjit/Common.h

@ -22,14 +22,16 @@ enum class ReturnCode
Return = 1, Return = 1,
Suicide = 2, Suicide = 2,
BadJumpDestination = 101, OutOfGas = -1,
OutOfGas = 102, BadJumpDestination = -2,
StackTooSmall = 103, StackTooSmall = -3,
BadInstruction = 104, BadInstruction = -4,
LLVMConfigError = 201, LLVMConfigError = -5,
LLVMCompileError = 202, LLVMCompileError = -6,
LLVMLinkError = 203, LLVMLinkError = -7,
UnexpectedException = -8,
}; };
/// Representation of 256-bit value binary compatible with LLVM i256 /// Representation of 256-bit value binary compatible with LLVM i256

6
libevmjit/Stack.cpp

@ -73,7 +73,7 @@ extern "C"
{ {
auto& stack = _rt->getStack(); auto& stack = _rt->getStack();
if (stack.size() < _count) if (stack.size() < _count)
longjmp(_rt->getJmpBuf(), static_cast<uint64_t>(ReturnCode::StackTooSmall)); longjmp(_rt->getJmpBuf(), static_cast<int>(ReturnCode::StackTooSmall));
stack.erase(stack.end() - _count, stack.end()); stack.erase(stack.end() - _count, stack.end());
} }
@ -92,7 +92,7 @@ extern "C"
auto& stack = _rt->getStack(); auto& stack = _rt->getStack();
// TODO: encode _index and stack size in the return code // TODO: encode _index and stack size in the return code
if (stack.size() <= _index) if (stack.size() <= _index)
longjmp(_rt->getJmpBuf(), static_cast<uint64_t>(ReturnCode::StackTooSmall)); longjmp(_rt->getJmpBuf(), static_cast<int>(ReturnCode::StackTooSmall));
*o_ret = *(stack.rbegin() + _index); *o_ret = *(stack.rbegin() + _index);
} }
@ -102,7 +102,7 @@ extern "C"
auto& stack = _rt->getStack(); auto& stack = _rt->getStack();
// TODO: encode _index and stack size in the return code // TODO: encode _index and stack size in the return code
if (stack.size() <= _index) if (stack.size() <= _index)
longjmp(_rt->getJmpBuf(), static_cast<uint64_t>(ReturnCode::StackTooSmall)); longjmp(_rt->getJmpBuf(), static_cast<int>(ReturnCode::StackTooSmall));
*(stack.rbegin() + _index) = *_word; *(stack.rbegin() + _index) = *_word;
} }

Loading…
Cancel
Save