Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
dev::eth::VM Class Reference

#include <VM.h>

Inheritance diagram for dev::eth::VM:
[legend]
Collaboration diagram for dev::eth::VM:
[legend]

Public Member Functions

virtual owning_bytes_ref exec (u256 &io_gas, ExtVMFace &_ext, OnOpFunc const &_onOp) overridefinal
 VM implementation. More...
 
bytes const & memory () const
 
u256s stack () const
 
- Public Member Functions inherited from dev::eth::VMFace
 VMFace ()=default
 
virtual ~VMFace ()=default
 
 VMFace (VMFace const &)=delete
 
VMFaceoperator= (VMFace const &)=delete
 

Private Types

typedef void(VM::* MemFnPtr) ()
 

Private Member Functions

void copyCode (int)
 
ptrdiff_t stackSize ()
 
void initEntry ()
 
void optimize ()
 
void interpretCases ()
 
void caseCreate ()
 
bool caseCallSetup (CallParameters *, bytesRef &o_output)
 
void caseCall ()
 
void copyDataToMemory (bytesConstRef _data, u256 *&m_SP)
 
uint64_t memNeed (u256 _offset, u256 _size)
 
void throwOutOfGas ()
 
void throwBadInstruction ()
 
void throwBadJumpDestination ()
 
void throwBadStack (unsigned _size, unsigned _n, unsigned _d)
 
void reportStackUse ()
 
int64_t verifyJumpDest (u256 const &_dest, bool _throw=true)
 
int poolConstant (const u256 &)
 
void onOperation ()
 
void checkStack (unsigned _n, unsigned _d)
 
uint64_t gasForMem (u512 _size)
 
void updateIOGas ()
 
void updateGas ()
 
void updateMem ()
 
void logGasMem ()
 
void fetchInstruction ()
 
uint64_t decodeJumpDest (const byte *const _code, uint64_t &_pc)
 
uint64_t decodeJumpvDest (const byte *const _code, uint64_t &_pc, u256 *&_sp)
 
template<class T >
uint64_t toInt63 (T v)
 

Static Private Member Functions

static void initMetrics ()
 
static u256 exp256 (u256 _base, u256 _exponent)
 

Private Attributes

u256io_gas = 0
 
uint64_t m_io_gas = 0
 
ExtVMFacem_ext = 0
 
OnOpFunc m_onOp
 
const void *const * c_jumpTable = 0
 
bool m_caseInit = false
 
MemFnPtr m_bounce = 0
 
MemFnPtr m_onFail = 0
 
uint64_t m_nSteps = 0
 
EVMSchedule const * m_schedule = nullptr
 
owning_bytes_ref m_output
 
bytes m_mem
 
bytes m_codeSpace
 
bytem_code = nullptr
 
u256 m_stackSpace [1025]
 
u256m_stack = m_stackSpace + 1
 
u256 m_pool [256]
 
Instruction m_OP
 
uint64_t m_PC = 0
 
u256m_SP = m_stack - 1
 
uint64_t m_runGas = 0
 
uint64_t m_newMemSize = 0
 
uint64_t m_copyMemSize = 0
 
std::vector< uint64_t > m_beginSubs
 
std::vector< uint64_t > m_jumpDests
 

Static Private Attributes

static std::array< InstructionMetric, 256 > c_metrics
 

Detailed Description

Definition at line 60 of file VM.h.

Member Typedef Documentation

typedef void(VM::* dev::eth::VM::MemFnPtr) ()
private

Definition at line 88 of file VM.h.

Member Function Documentation

void VM::caseCall ( )
private

Definition at line 130 of file VMCalls.cpp.

Here is the call graph for this function:

bool VM::caseCallSetup ( CallParameters callParams,
bytesRef o_output 
)
private

Definition at line 151 of file VMCalls.cpp.

Here is the call graph for this function:

void VM::caseCreate ( )
private

Definition at line 99 of file VMCalls.cpp.

void VM::checkStack ( unsigned  _n,
unsigned  _d 
)
private

Definition at line 91 of file VM.cpp.

void VM::copyCode ( int  _extraBytes)
private

Definition at line 52 of file VMOpt.cpp.

void VM::copyDataToMemory ( bytesConstRef  _data,
u256 *&  m_SP 
)
private

Definition at line 28 of file VMCalls.cpp.

Here is the call graph for this function:

uint64_t VM::decodeJumpDest ( const byte *const  _code,
uint64_t &  _pc 
)
private

Definition at line 50 of file VM.cpp.

uint64_t VM::decodeJumpvDest ( const byte *const  _code,
uint64_t &  _pc,
u256 *&  _sp 
)
private

Definition at line 60 of file VM.cpp.

owning_bytes_ref VM::exec ( u256 io_gas,
ExtVMFace _ext,
OnOpFunc const &  _onOp 
)
finaloverridevirtual

VM implementation.

Implements dev::eth::VMFace.

Definition at line 163 of file VM.cpp.

Here is the call graph for this function:

u256 VM::exp256 ( u256  _base,
u256  _exponent 
)
staticprivate

Definition at line 273 of file VMOpt.cpp.

void VM::fetchInstruction ( )
private

Definition at line 137 of file VM.cpp.

uint64_t VM::gasForMem ( u512  _size)
private

Definition at line 99 of file VM.cpp.

void VM::initEntry ( )
private

Definition at line 258 of file VMOpt.cpp.

Here is the call graph for this function:

void VM::initMetrics ( )
staticprivate

Definition at line 36 of file VMOpt.cpp.

Here is the call graph for this function:

void VM::interpretCases ( )
private

Definition at line 194 of file VM.cpp.

Here is the call graph for this function:

void VM::logGasMem ( )
private

Definition at line 129 of file VM.cpp.

uint64_t VM::memNeed ( u256  _offset,
u256  _size 
)
private

Definition at line 30 of file VM.cpp.

bytes const& dev::eth::VM::memory ( ) const
inline

Definition at line 71 of file VM.h.

Here is the caller graph for this function:

void VM::onOperation ( )
private

Definition at line 83 of file VM.cpp.

void VM::optimize ( )
private

Definition at line 64 of file VMOpt.cpp.

Here is the call graph for this function:

int dev::eth::VM::poolConstant ( const u256 )
private
void VM::reportStackUse ( )
private

Definition at line 26 of file VMOpt.cpp.

u256s dev::eth::VM::stack ( ) const
inline

Definition at line 72 of file VM.h.

Here is the call graph for this function:

Here is the caller graph for this function:

ptrdiff_t dev::eth::VM::stackSize ( )
inlineprivate

Definition at line 107 of file VM.h.

void VM::throwBadInstruction ( )
private

Definition at line 51 of file VMCalls.cpp.

void VM::throwBadJumpDestination ( )
private

Definition at line 56 of file VMCalls.cpp.

void VM::throwBadStack ( unsigned  _size,
unsigned  _n,
unsigned  _d 
)
private

Definition at line 61 of file VMCalls.cpp.

void VM::throwOutOfGas ( )
private

Definition at line 46 of file VMCalls.cpp.

template<class T >
uint64_t dev::eth::VM::toInt63 ( T  v)
inlineprivate

Definition at line 174 of file VM.h.

void VM::updateGas ( )
private

Definition at line 112 of file VM.cpp.

void VM::updateIOGas ( )
private

Definition at line 105 of file VM.cpp.

void VM::updateMem ( )
private

Definition at line 121 of file VM.cpp.

int64_t VM::verifyJumpDest ( u256 const &  _dest,
bool  _throw = true 
)
private

Definition at line 77 of file VMCalls.cpp.

Member Data Documentation

const void* const* dev::eth::VM::c_jumpTable = 0
private

Definition at line 85 of file VM.h.

std::array< InstructionMetric, 256 > VM::c_metrics
staticprivate

Definition at line 81 of file VM.h.

u256* dev::eth::VM::io_gas = 0
private

Definition at line 76 of file VM.h.

std::vector<uint64_t> dev::eth::VM::m_beginSubs
private

Definition at line 156 of file VM.h.

MemFnPtr dev::eth::VM::m_bounce = 0
private

Definition at line 89 of file VM.h.

bool dev::eth::VM::m_caseInit = false
private

Definition at line 86 of file VM.h.

byte* dev::eth::VM::m_code = nullptr
private

Definition at line 102 of file VM.h.

bytes dev::eth::VM::m_codeSpace
private

Definition at line 101 of file VM.h.

uint64_t dev::eth::VM::m_copyMemSize = 0
private

Definition at line 132 of file VM.h.

ExtVMFace* dev::eth::VM::m_ext = 0
private

Definition at line 78 of file VM.h.

uint64_t dev::eth::VM::m_io_gas = 0
private

Definition at line 77 of file VM.h.

std::vector<uint64_t> dev::eth::VM::m_jumpDests
private

Definition at line 157 of file VM.h.

bytes dev::eth::VM::m_mem
private

Definition at line 98 of file VM.h.

uint64_t dev::eth::VM::m_newMemSize = 0
private

Definition at line 131 of file VM.h.

uint64_t dev::eth::VM::m_nSteps = 0
private

Definition at line 91 of file VM.h.

MemFnPtr dev::eth::VM::m_onFail = 0
private

Definition at line 90 of file VM.h.

OnOpFunc dev::eth::VM::m_onOp
private

Definition at line 79 of file VM.h.

Instruction dev::eth::VM::m_OP
private

Definition at line 122 of file VM.h.

owning_bytes_ref dev::eth::VM::m_output
private

Definition at line 95 of file VM.h.

uint64_t dev::eth::VM::m_PC = 0
private

Definition at line 123 of file VM.h.

u256 dev::eth::VM::m_pool[256]
private

Definition at line 119 of file VM.h.

uint64_t dev::eth::VM::m_runGas = 0
private

Definition at line 130 of file VM.h.

EVMSchedule const* dev::eth::VM::m_schedule = nullptr
private

Definition at line 92 of file VM.h.

u256* dev::eth::VM::m_SP = m_stack - 1
private

Definition at line 124 of file VM.h.

u256* dev::eth::VM::m_stack = m_stackSpace + 1
private

Definition at line 106 of file VM.h.

u256 dev::eth::VM::m_stackSpace[1025]
private

Definition at line 105 of file VM.h.


The documentation for this class was generated from the following files: