mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56:42 +00:00
Add raiseException helper to RuntimeManager [#81563132]
This commit is contained in:
parent
31c9dd3fcf
commit
ac38bf9ac1
4 changed files with 15 additions and 8 deletions
|
|
@ -101,11 +101,7 @@ GasMeter::GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager)
|
||||||
m_builder.CreateCondBr(isOutOfGas, outOfGasBB, updateBB);
|
m_builder.CreateCondBr(isOutOfGas, outOfGasBB, updateBB);
|
||||||
|
|
||||||
m_builder.SetInsertPoint(outOfGasBB);
|
m_builder.SetInsertPoint(outOfGasBB);
|
||||||
|
_runtimeManager.raiseException(ReturnCode::OutOfGas);
|
||||||
//auto longjmpFunc = llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::eh_sjlj_longjmp);
|
|
||||||
llvm::Type* args[] = {Type::BytePtr, m_builder.getInt32Ty()};
|
|
||||||
auto longjmpNative = llvm::Function::Create(llvm::FunctionType::get(Type::Void, args, false), llvm::Function::ExternalLinkage, "longjmp", module);
|
|
||||||
m_builder.CreateCall2(longjmpNative, m_runtimeManager.getJmpBuf(), Constant::get(ReturnCode::OutOfGas));
|
|
||||||
m_builder.CreateUnreachable();
|
m_builder.CreateUnreachable();
|
||||||
|
|
||||||
m_builder.SetInsertPoint(updateBB);
|
m_builder.SetInsertPoint(updateBB);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace jit
|
||||||
{
|
{
|
||||||
class RuntimeManager;
|
class RuntimeManager;
|
||||||
|
|
||||||
class GasMeter : public CompilerHelper
|
class GasMeter : public CompilerHelper // TODO: Use RuntimeHelper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager);
|
GasMeter(llvm::IRBuilder<>& _builder, RuntimeManager& _runtimeManager);
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,8 @@ bytesConstRef Runtime::getReturnData() const
|
||||||
RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_builder)
|
RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_builder)
|
||||||
{
|
{
|
||||||
m_dataPtr = new llvm::GlobalVariable(*getModule(), Type::RuntimePtr, false, llvm::GlobalVariable::PrivateLinkage, llvm::UndefValue::get(Type::RuntimePtr), "rt");
|
m_dataPtr = new llvm::GlobalVariable(*getModule(), Type::RuntimePtr, false, llvm::GlobalVariable::PrivateLinkage, llvm::UndefValue::get(Type::RuntimePtr), "rt");
|
||||||
|
llvm::Type* args[] = {Type::BytePtr, m_builder.getInt32Ty()};
|
||||||
|
m_longjmp = llvm::Function::Create(llvm::FunctionType::get(Type::Void, args, false), llvm::Function::ExternalLinkage, "longjmp", getModule());
|
||||||
|
|
||||||
// Export data
|
// Export data
|
||||||
auto mainFunc = getMainFunction();
|
auto mainFunc = getMainFunction();
|
||||||
|
|
@ -149,6 +151,11 @@ void RuntimeManager::registerReturnData(llvm::Value* _offset, llvm::Value* _size
|
||||||
set(RuntimeData::ReturnDataSize, _size);
|
set(RuntimeData::ReturnDataSize, _size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RuntimeManager::raiseException(ReturnCode _returnCode)
|
||||||
|
{
|
||||||
|
m_builder.CreateCall2(m_longjmp, getJmpBuf(), Constant::get(_returnCode));
|
||||||
|
}
|
||||||
|
|
||||||
llvm::Value* RuntimeManager::get(Instruction _inst)
|
llvm::Value* RuntimeManager::get(Instruction _inst)
|
||||||
{
|
{
|
||||||
switch (_inst)
|
switch (_inst)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "CompilerHelper.h"
|
#include "CompilerHelper.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "Type.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
@ -99,16 +100,19 @@ public:
|
||||||
llvm::Value* getGas(); // TODO: Remove
|
llvm::Value* getGas(); // TODO: Remove
|
||||||
llvm::Value* getCallData();
|
llvm::Value* getCallData();
|
||||||
llvm::Value* getCode();
|
llvm::Value* getCode();
|
||||||
llvm::Value* getJmpBuf();
|
|
||||||
void setGas(llvm::Value* _gas);
|
void setGas(llvm::Value* _gas);
|
||||||
|
|
||||||
void registerReturnData(llvm::Value* _index, llvm::Value* _size);
|
void registerReturnData(llvm::Value* _index, llvm::Value* _size);
|
||||||
|
|
||||||
|
void raiseException(ReturnCode _returnCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
llvm::Value* getPtr(RuntimeData::Index _index);
|
llvm::Value* getPtr(RuntimeData::Index _index);
|
||||||
void set(RuntimeData::Index _index, llvm::Value* _value);
|
void set(RuntimeData::Index _index, llvm::Value* _value);
|
||||||
|
llvm::Value* getJmpBuf();
|
||||||
|
|
||||||
llvm::GlobalVariable* m_dataPtr;
|
llvm::GlobalVariable* m_dataPtr = nullptr;
|
||||||
|
llvm::Function* m_longjmp = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue