Squashed 'evmjit/' changes from 334deeb..533531b
533531b Create helper/external functions on demand (env_balance for now)
e12fa12 Suicide rework
ae6e709 Disalbe bswap constant folding
ec30ce4 Object cache
5be8c59 Byte swap for constants
3df5a12 Do not compile LLVM module if machine code available in memory
2b31cba Memory manager cleanup
6a22491 Clean up ExecutionEngine
28a0623 Clean up ExecutionEngine
de02425 Clean up ExecutionEngine
ece7fe7 Clean up ExecutionEngine
fe90c6f Clean up ExecutionEngine
9d9e73a Using one ExecutionEngine to cache compiled contracts
713b33e Remove global private memory pointers
f8ffdfa Remove global privite pointers to runtime instance and runtime data
6643af5 Use code hash as main function name
e3245e1 Remove addtional cost param from commitCostBlock(). Count additional cost manually. [#81461534]
90cb4a7 More aggresive gas counting optimization: do not commit cost before LOG. [#81461534]
5d5259e Do not auto-commit cost block
c5de54d More aggresive gas counting optimization: do not commit cost before SSTORE.
c5ebca6 More aggresive gas counting optimization: do not commit cost before memory access.
69930b9 Use sub "no-wrap"
6acbfe0 Remove unused function
eaed9c3 Read push data using llvm::APInt
30f0a7a Type usage and other cleanups
4254b3f Fix memory copy [Delivers #84703344]
43e08ea Handle create/call depth limit in CREATE instruction
20190b1 Add -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS needed by LLVM (reverted from commit 66d5a2b5cdf1361dcf0205b191dd12be090ed224)
75fa672 Fix compilation with LLVM pre-3.5 (Ubuntu 14.04) (reverted from commit 6094aa30add22d56bee145bbb4a7d440c08db5c8)
6094aa3 Fix compilation with LLVM pre-3.5 (Ubuntu 14.04)
66d5a2b Add -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS needed by LLVM
1b49024 Workaround for Ubuntu broken LLVM package (llvm-3.5-dev does not have correct cmake files)
ed63ced Disable rtti for Cache as LLVM has not rtti
232f9fe Refactor cmake files
8287c60 Own cached objects
6543cc4 Execution Engine cleanups (reverted from commit bd85efa299e661228a1ac6283b5fad14e09f88d9)
98b265b Merge commit '2332595c9c0d315dc9ecde22d236ae477b931863' into develop
2b83b75 Object cache wit memory leaks
de22a0a Execution Engine cleanups
2332595 Change the name of a module to some hash (for caching)
bd85efa Execution Engine cleanups
b37ce8e Gas counting for CREATE instruction
0a64245 Fix checking memory requirements with size 0
a492760 Using llvm::ExecutionEngine::getFunctionAddress() instead of getPointerToFunction(). Cleanups.
dd63bb3 Remove TODO comment
8f3edbc Disable cache. It's broken.
49bd78b SHA3 gas cost updated
76d30b8 Count additional gas cost for memory copies. Some GasMeter improvments.
077cf7b Count additional cost for EXP exponent
c2699b3 Comment about MCJIT and caching pointers to entry functions
91cd37e Remove logs
47d92e9 Remove dummy int argument in entry function
2e1c90f Change the way entry function is called.
4a9d08d Change the way entry function is called.
70279f8 Changes in setjmps
dbf8174 Update usage of ExtVMFace
dc4bc0e Jit can handle call stack up to 1024
45fb3f5 Move some data from stack to JitVM object to save stack space.
6e318f8 Check current call depth
70348d9 Fix cache key and do not compile to LLVM module when it is not needed
da02a18 Cache key is contract code. Does not work
7c9cf6e Trying to cache compiled contracts with pointer to code as a key (it's not a good idea)
2a7111c ExecBundle - all information needed to execute a JIT-compiled contracts
b3a1734 Disable JIT logs
b1b94de Opcodes update
c9f5694 CMakeLists.txt cleanup (in progress)
63d6997 added missing <csetjmp>
b07f25d Detect endianness without boost help
b176574 Remove usage of boost::lexical_cast
5f4c1c7 Fix evmcc compilation - provide fake runtime data
e3ccc03 Fix MSVC warning
9452da9 Merge remote-tracking branch 'origin/develop' into develop
2fd2446 Simplify ExecutionEngine interface. It is possible to pass raw code instead of LLVM module.
46d1926 fixed gcc warnings (missing field initializers, unused functions)
bd40486 Moving ext_calldataload helper function to evmjit library (does not depend on Env)
2b9b530 Cleanups
c6fcdbc Arith performace tests
adb5a68 A bit of work in evmcc. Not ready yet.
b987258 A TODO comment
5362d50 SDIV & SMOD fixed
58d2bfb External code access in Env reimplemented
4366542 LOGs reimplemented
63719d2 env_call updated
69dae9a env_create updated
6f84f3d Rename sload, sstore & sha3 Env functions
408fda8 Old code removed
116ce60 Remove Env* param from env_sha3 function (not needed)
4fc4e76 Change the way memory is passed to sha3 Env function
cc6bb83 Simplify JIT logs
259d1d2 Old files removed
ddfe85b Update VM gas counter after execution
2b4430e Change Env functions first argument type to opaque Env*
969f1b5 The way runtime data is passed to jit'ed contract changed
b8e0ad1 Fix exporting Env callback symbols
7db676c Client side Env updated
a0d0f85 JIT VM updated
3298e10 Remove mock declaration
49b82cd Move EXP implementation from Ext to Arith256
8672c4b Updating Ext interface
bb6e603 Updating ExecutionEngine interface
0509b3b Changing Runtime interface
aa77158 Separate runtime classes
68648a2 Separating EVM JIT from CPP client (WIP)
99c7113 CMake scripts
5f61bdc Starting cmake scripts
dc82664 C Interface draft 1
94e41d8 correct calculation of LOG cost
fdd5275 fixed bug in implementation of LOG
30eea6e Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
f72cced resolved circular dependency between libevm and libevmjit
c2c96e6 Merge remote-tracking branch 'origin/develop-evmcc' into develop-evmcc
bf6a4d4 output gas updated in vmPerformanceTest.json
d77ee40 EVM code updated in vmPerformanceTests
3517bfc fixed libevmjit dependencies in cmake files
f7d6554 Move mock of ExtVMFace to evmcc tool
89e6d2f made _ext a mandatory arg of Runtime::run()
aa7fc79 libevmface -> libevmcore: updated cmake files
320bdf5 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
86334f5 Handle bytecode as bytes
2bd4d6c Update Instruction.h location
c907c71 codegen for LOG instructions [Delivers #81700490]
cdcbb6b removed references to Memory::dump()
47e654c Merge branch 'develop' into develop-evmcc
7305fb3 fixed bug in llvm ir computing required memory size
4b4265c Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
ae9f57f (1) Handling evmcc options with boost::program_options. (2) Writing out .ll and .bc files
cb87052 unused var removed
9a0f9d3 1) JUMP/I semantics updated. 2) Members of BasicBlock::LocalStack pulled out to BasicBlock
c91c5df Rename BNOT -> NOT, NOT -> ISZERO
29432be Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
ee0e2d3 added struct for compiler options
172fc1c Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
8f7b5d6 removed *.orig file
6f99869 code cleanup and coding-standardization
3fc508f Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
a44a7ab Use llvm.longjmp intrinsic for longjmp [Delivers #81792986]
b6b4f5f Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
8ee32d9 Coding style: use "o_" prefix for output function arguments
40561b1 code cleanup & coding-standardization
aaaf543 Rename Type::i256 -> Type::Word
b5abb70 Use common builder in GasMeter and Memory
33cc50d Empty lines removal
72398d2 Handle unsigned integer overflow in Memory::require() [Delivers #81773288]
350b004 Change Constant::get to support negative values
272c568 Remove Memory::require(size) interface [#81773288]
273b0f6 Deprecate Memory::require(size) function. Risk of unsigned integer overflow.
439561a Use readPushData() in basic block analysis
bfb9660 Use readPushData() in instruction compilation
1008c70 Create dedicated function for pushdata reading
4ff7ba0 Fix u256 to APInt conversion
65af01c removed accidentally added *.orig file
d32daf6 New performance tests [Delivers #81578852]
895d0aa Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
7760b31 Cleaning up warnings and build dependencies [#81588646]
2d6aa46 CMakeLists updated, should now build without LLVM when EVMJIT is not enabled [#81588646]
43093d6 Fix MSIZE and memory resize step [Delivers #81777708]
85f67a5 Improve PUSH compilation
2bbbf6c Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
3725432 Fix case where JUMPI is the last instruction
2524c72 Codegen for SIGNEXTEND [Delivers #81700414]
007641a SIGEXTEND: first try [#81700414]
d778640 Fix BNOT instruction [Delivers #81700198]
dd75da2 BNOT instruction [Delivers #81700198]
e4a77c1 Increase refund counter if deleting a storage item [Delivers #81575908]
22e4d16 Remove old code
af0530b Got rid of some gcc warnings
c6cf723 Fix u256 to APInt conversion
e6b4761 Allow creating LLVM constants directly from u256
33f1253 Update gas counting for SSTORE, no refunding yet [#81575908]
e24c9c2 Improve Compiler code formatting
f06445f Improve VM code formatting
c03d36a Improve Ext code formatting
bc1ef19 Improve GasMeter code formatting
3212b2b Improve ExecutionEngine code formatting
de67937 Improve BasicBlock code formatting
64513d5 Improve Memory code formatting
3ee33cc Improve code formatting
1e8a091 Improve Arith256 code formatting
211d3c0 Change #include setjmp
fa6d4c6 Improve Stack code formatting
7e3a9f4 Remove done FIXME tasks
ce889fc Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
4c9fed9 turned on stack optimization by default in jit compiler
664de37 json test file for performance testing
89d4a1c Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
887bac9 Use clog for JIT logs
6e8d1ce added inlcude of setjmp.h required for jmp_buf type
ac478d2 added dependency on libethereum to evmcc
a3871e5 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
cecf567 MULMOD/ADDMOD implemented in separate functions [FIXES #80566276]
65eaa13 Remove global Runtime pointer
25ccd49 Changed semantics of JUMPDEST so that *the next* instruction is a jump destination
6bf994d 1. Indenting spaces converted to tabs 2. Options changed: -G --> -g
4684c6f Using call helper
2493ef5 Call helper
6da6f3d Handle bad instructions (BadInstruction exception) [#81563132]
ac38bf9 Add raiseException helper to RuntimeManager [#81563132]
31c9dd3 Ignore opOp callback silently
5a923d6 Ignore opOp callback silently
c7ba567 Merge branch 'develop' into develop-evmcc
0da6823 Fix EXTCODECOPY
0eb8311 Restore correct memory access in Ext functions
05bbe53 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
d5ddbfa Added missing changes [#79450108]
6a16efa Get Runtime pointer from main function argument if available
e273299 Change some runtime names
fd7b6da Move return data reference to Runtime [#81470252]
6d428d8 Fix ReturnData::Index::_size
64e3748 Move jmpbuf to Runtime [#81470252]
68ca696 256-bit arithmetic implemented via calls to boost::multiprecision library. [#79450108]
4bcd092 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
a90ebe6 Print compilation/execution times
734dd31 Using RuntimeData pointer in ext functions [#81470252]
a076ced Old bswap intrinsic removed
3cba473 Moving CODE data from Ext to Runtime [#81470252]
83b24b6 Moving CALLDATA data from Ext to Runtime [#81470252]
916f5ab Group instructions that access runtime data [#81470252]
088a4ef Moving the rest word-size data from Ext to Runtime [#81470252]
bfe1216 Moving ORIGIN, CALLER & CALLVALUE data from Ext to Runtime [#81470252]
5c1e344 Add name to data indices [#81470252]
399cf28 Moving ADDRESS data from Ext to Runtime [#81470252]
2b898fc Introducing RuntimeHelper - a compiler helper that depends on runtime data [#81470252]
9ca2663 Use Type::RuntimePtr instead of RuntimeData::getType->getPointerTo()
3670e32 Access stack structure through runtime structure [#81470252]
693c4b3 Add Type::RuntimePtr predefined LLVM type
c388a81 Access memory structure through runtime structure [#81470252]
b579c70 Place current gas counter value in RuntimeData
097b7ae Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
8da55ff Export runtime data to global variable in main function
a60843e Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
547ca38 Propagation of values between basic blocks' local stacks [#80895676]
6c2a120 Introducing RuntimeData struct - a data that will be provided to running program
6580a9b Visual Studio build fix
0dae894 new test cases
d281396 Refactored local stack [#81180320]
d41828f added option to set initial gas
fc7a46b Change the way VMs are created (mostly for tracking where are created)
dcb739e Better assert condition
16de530 Try not to use JIT in any interactive mode
48108f5 Implement VMFace with jit::VM
701d99e Fixed the order in which phi nodes are created (was incorrect) [#80895676]
aaf0f7d Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
044e838 Fixed bug in phi node rewriting [#80895676]
170ca15 Null gas in case of out-of-gas exception [Delivers #81118624]
54c636a Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
f28f8cc Add support for Big Endian architectures [Delivers #79877740]
0757523 Use Endianness in Ext [#79877740]
920ea2e Comment: storage uses native endianness [#79877740]
05741c2 Handle endianness for CALLDATALOAD correctly [#79877740]
5a8ba36 added assert in linkBasicBlocks()
8909c15 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
080cf20 Handling pop() from the empty EVM stack. [#80895676]
49b0769 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
d95083a Remove unreachable basic blocks before "linking"
a6ce4ba Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
1cf3549 minor changes in the compiler driver
a4416e5 Remove unreachable basic blocks before "linking"
c4eb835 added missing CMakeLists.txt
937fbaa Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
0a9e0f5 Propagation of values between basic blocks (and the stack): initial implementation (probably buggy, but simple cases work). [#80895676]
8ba533f Merge branch 'develop' into develop-evmcc
c7eac0d Fix SHA3 instruction :)
5db2038 Handle endianness of MSTORE & MLOAD [#79877740]
51fc9ad Fix compiling empty bytecode
c97ca24 Throw exception if EVM program is not jitable instead of terminating to make tests going
150162e Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
f83e23a Another round of fixing ExtVM interface
54e0824 Updated cmake files after moving the jit compiler to a lib.
58c5a4f Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
607458b BYTE reimplementation
afe0254 Endianness handler
b13f1ac Check if pushed item is a word
b01a75a Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
52ba848 Add support for direct jump outside the code - terminates with STOP
6c3af96 Limit debug output
de8deab Fix for invalid jump table basic block
0febd6a Do not try to add additional cost (call instruction) to cost-block
f31f3bc Using gas provided by test engine and fix for creating fake ExtVMFace.
dfac5a0 Using ExtVM provided by test engine
f0928f5 Tests moved to test/ folder
dd6fbda Fix not allocated arg8 for CALL
15714ce Fix GasMeter not nulling cost call
0f4c8eb VM execution wrapper with similar interface as libevm/VM
9105fb1 Merge branch 'develop' into develop-evmcc
7df24fa Move JIT compiler project to library
34afb85 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
f062fd0 Dumping CFG to .dot: showing indirect jumps with dashed lines
dcafa47 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
72a6fe4 InsertPointGuard definition moved to CompilerHelper.h
8eea475 Get IR module from IR builder on demand
f233122 Added dumping of CFG to a .dot file [Delivers #80816506]
c83739e Get IR module from IR builder
5e13d59 Introducing CompilerHelper - a base class for... compiler helper classes like Memory, GasMeter, etc.
bb51b34 Cleanup block terminator generation
1463897 Basic block compilation in separated function
e094ba9 Placing IRBuilder in Compiler class (for future refactoring)
5586ff5 Some changes about final/stop block
07f6bbf Removing unnecessary `dev` name prefixes
11bf67b Eliminating some `using namespace`
a2da7c9 Change namespace from `evmcc` to `dev::eth::jit`
f1ea6c9 Macros grouping PUSH, DUP and SWAP switch cases
a36a432 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
67ee0b6 Unused rt_exit() function removed
ec2013d Working longjmp solution
00a872e * codegen for CODECALL * fixes for EXTCODECOPY
59a392c Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
564a593 Codegen for EXTCODESIZE & EXTCODECOPY [Delivers #80644732]
9007b74 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
7fcf24d Trying to implement "exceptions" with longjmp (does not work on Windows 64bit at least)
727691f Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
e22238f Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
c57de78 Use longjmp to return OutOfGas code from main function (WIP)
dbb3e81 Try to throw an OutOfGas exception when out of gas. The exception cannot be handled.
04d6ffb Some LLVM function attribute fun
e11a9bb Change a bit the implementation of GAS instruction (fix)
00e5afc Change a bit the implementation of GAS instruction
0d679f0 Count gas cost for SSTORE instruction
df93292 Codegen for CODECOPY. [Delivers #80644732]
1c70f3d Prealloc memory and count gas for CALL instruction
d56f60f Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
7d67476 Prealloc memory and count gas for SHA3 and CREATE instructions
42b14ae Fixes in CALLDATACOPY [Delivers #80644732]
9d9e160 InsertPointGuard helper class for IRBuilder
7203120 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
0d97405 Initial implementation for CALLDATACOPY [Delivers #80644732]
82cba7a Use mem.require in mload, mstore & mstore8
0931289 Convenient Memory::require() overload
ab556c6 Private mem.require function that preallocates memory and counts gas fee
01ca987 Give back an amount of gas not used by CALL instructions
fb87a0b Count gas for CALL instructions
07131e4 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
475b85d Fixes in inline asm in some jump tests.
7494fdb Use Constant::get() interface to create LLVM constants
f95999c Allocate memory and count gas for RETURN instruction
7a89751 Change the way compiled program returns
8fb6de0 Define constants and return codes
6caff31 Implemented ADDMOD, MULMOD and GAS [Delivers #80566276]
9b3c446 Codegen for GAS
3a25969 Report error if static-analysed stack is too small
0c259cd Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
a2a496e test cases for JUMPS/phi nodes
6131cca Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
8a52283 Do not check gas cost of value 0
efe23ad Do not commit gas costs on JUMPDEST instruction
7c78ecb Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
293f0de Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
9bdfd59 Change basic block linking order to get better results (still not perfect)
56a17a0 test cases for JUMP
e4cf741 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
6e2bcef Implemented indirect JUMPI and fixes for JUMPs to invalid PCs
2c3d0cc test cases for JUMP(I)
d5f7de4 Always commit cost blocks
39ba3ae Use external counter for gas (external linkage global variable)
4eb65a8 Fix block cost counting (counter not reset)
5470faf Count gas for additional memory
d6e6a5f MSIZE test
0128f09 Wrong resize condition fixed
4f87144 mload function added as implementation of MLOAD
5f1ea8f store8 function added as implementation of MSTORE8
f5a0975 Use mem.store as implementation of MSTORE
f825a60 Generate mem.store function and dependencies (currently unused)
7a7d4e3 Fix for finding jumpTableBlock
d6915b4 Renames & comments
ad43b92 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
fd7069e Indirect jump: jump table generated in separate bblock.
09a5899 Fix stack swap or dup not generating PHI nodes
973e0a2 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
52d1ceb test cases for jumps
5dd3037 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
cfb226b Group gas counting into block of instructions called cost-block.
dab29a9 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
6778940 test cases for JUMP
2b36803 Implementing JUMP/JUMPDEST (work in progress)
e42217d Disable gas checking for now (does not work and makes IR code hard to read)
04cf0cf Generate gas checking function
97644d6 Cleanup LLVM types usage
b7f31af Cleanup LLVM types usage
28d6dd7 Decrement global gas value by instruction step cost
d3f59f6 Introducing GasMeter
7f88487 EXP instruction.
dafa5bc Make the Stack an integral part of BasicBlock
58c5950 JUMP test in assembly
bb19540 Cleanup Compiler
b273b86 Provide end instruction to basic block
16ea3bf Improve basic blocks linking implementation
7a3f3f9 Remove external stack
1cbb9d5 Stack cleanups
a338b88 Cleanups: move basic block linking to separated function
577438e Correct the order of basic blocks
e52d421 Link basic blocks with phi functions
0961908 Introducing BasicBlock class.
cc51bfd Pop entry state of basic block from external stack, push exit state to external stack.
33e36ce Basic stack implementation for basic block. Values on stack are not preserved between basic blocks (jumps)
3cba3a2 SHA3 instruction
f230c82 SUICIDE instruction
3f57858 CALL instruction. Still needs gas counting and callback support.
3942b2e CREATE instruction. Still needs some work with ExtVM interface.
a1a195b Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
f075b7b - fixes for RETURN and STOP - codegen for SLT, SGT, EQ and NEG
b519b73 Stack functions simplified
7bee86a Runtime class that inits and keeps stack, memory and ExtVM interface
320add0 BYTE instruction implementation (with bug on BYTE 0)
710b734 TODO: implement BYTE
48897f4 Bitwise operators: AND, OR, XOR
c002d9b PC instructions
20cd698 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
09a9f10 Block Information instructions: PREVHASH, COINBASE, TIMESTAMP, NUMBER, DIFFICULTY, GASLIMIT
9289508 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
48d4294 - implemented LT, GT - new tests for jumps and comparisons
954300f Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
fbe97fd BALANCE
8b625fa fixed implementation of NOT
fa76d7a fixes for JUMP/JUMPI (generating final basic block) implementation of NOT
ad2c4c4 fixed implementation of JUMPI (cond casted to bool)
1d17da1 Added Module* constructor argument to Memory and Ext.
b730bdc Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
0b8ba6d initial implementation of JUMP/JUMPI (untested)
edf192b Print returned memory to standard output
d073af7 Merge branch 'develop-evmcc' of https://github.com/imapp-pl/ethereum into develop-evmcc
748ee0f Implementing RETURN and STOP instructions
eea755c fixed bug in memory handling
e1abb20 Merge branch 'develop-evmcc' of github.com:imapp-pl/ethereum into develop-evmcc
00f9939 Implemented MLOAD, MSTORE, MSTORE8 and MSIZE
b9cda13 Push call data on stack - CALLDATALOAD
fcde2f3 Accessing Ext static data: CALLER, ORIGIN, CALLVALUE, CALLDATASIZE, GASPRICE
ac795c4 Send Ext static data to running contract. ADDRESS instruction
9ba6a7c Improve stack binary interface
8cd4326 Set/get values in Ext store - SSTORE & SLOAD
0013656 added ethcore to libs required by evmcc
15b9452 Merge branch 'develop-evmcc' of git@github.com:imapp-pl/ethereum.git into develop-evmcc
68f15f9 initial implementation of memory
f3a347b Starting ExtVM binary interface
78b188c Fix stack set/get bad function signature
58e03d5 Basic arithmetic, limited precision for MUL, DIV and MOD.
e53c0a4 SWAP* instructions
3e01d18 POP and DUP* instructions
4266ce5 PUSH instruction implementation
d8430db Output compilation (option -c) result to standard output by default
e8ff67c Stack interface and implementation
bbc3aa4 evmcc's CMakeLists updated: * added std=c++14 for gcc (required for std::make_unique) * added required llvm libnames
dfa141a Staring with Stack helper
f124be6 Implementation of ExecutionEngine with LLVM MCJIT
e33fdea Remove public LLVM dependency in Compiler
507ba06 ExecutionEngine stub and -i program option for interpreting EVM Code
f5eda1f Moving Compiler to separated files
REVERT: 334deeb Initial commit
git-subtree-dir: evmjit
git-subtree-split: 533531bd07cb2d95f3fa017231484e91196d87a6
10 years ago
|
|
|
|
|
|
|
#include "RuntimeManager.h"
|
|
|
|
|
|
|
|
#include <llvm/IR/GlobalVariable.h>
|
|
|
|
#include <llvm/IR/Function.h>
|
|
|
|
#include <llvm/IR/IntrinsicInst.h>
|
|
|
|
|
|
|
|
#include "RuntimeData.h"
|
|
|
|
#include "Instruction.h"
|
|
|
|
|
|
|
|
namespace dev
|
|
|
|
{
|
|
|
|
namespace eth
|
|
|
|
{
|
|
|
|
namespace jit
|
|
|
|
{
|
|
|
|
|
|
|
|
llvm::StructType* RuntimeManager::getRuntimeDataType()
|
|
|
|
{
|
|
|
|
static llvm::StructType* type = nullptr;
|
|
|
|
if (!type)
|
|
|
|
{
|
|
|
|
llvm::Type* elems[] =
|
|
|
|
{
|
|
|
|
llvm::ArrayType::get(Type::Word, RuntimeData::_size), // i256[]
|
|
|
|
Type::BytePtr, // callData
|
|
|
|
Type::BytePtr // code
|
|
|
|
};
|
|
|
|
type = llvm::StructType::create(elems, "RuntimeData");
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::StructType* RuntimeManager::getRuntimeType()
|
|
|
|
{
|
|
|
|
static llvm::StructType* type = nullptr;
|
|
|
|
if (!type)
|
|
|
|
{
|
|
|
|
llvm::Type* elems[] =
|
|
|
|
{
|
|
|
|
Type::RuntimeDataPtr, // data
|
|
|
|
Type::EnvPtr, // Env*
|
|
|
|
Type::BytePtr, // jmpbuf
|
|
|
|
Type::BytePtr, // memory data
|
|
|
|
Type::Word, // memory size
|
|
|
|
};
|
|
|
|
type = llvm::StructType::create(elems, "Runtime");
|
|
|
|
}
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
|
|
|
llvm::Twine getName(RuntimeData::Index _index)
|
|
|
|
{
|
|
|
|
switch (_index)
|
|
|
|
{
|
|
|
|
default: return "data";
|
|
|
|
case RuntimeData::Gas: return "gas";
|
|
|
|
case RuntimeData::Address: return "address";
|
|
|
|
case RuntimeData::Caller: return "caller";
|
|
|
|
case RuntimeData::Origin: return "origin";
|
|
|
|
case RuntimeData::CallValue: return "callvalue";
|
|
|
|
case RuntimeData::CallDataSize: return "calldatasize";
|
|
|
|
case RuntimeData::GasPrice: return "gasprice";
|
|
|
|
case RuntimeData::CoinBase: return "coinbase";
|
|
|
|
case RuntimeData::TimeStamp: return "timestamp";
|
|
|
|
case RuntimeData::Number: return "number";
|
|
|
|
case RuntimeData::Difficulty: return "difficulty";
|
|
|
|
case RuntimeData::GasLimit: return "gaslimit";
|
|
|
|
case RuntimeData::CodeSize: return "codesize";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RuntimeManager::RuntimeManager(llvm::IRBuilder<>& _builder): CompilerHelper(_builder)
|
|
|
|
{
|
|
|
|
m_longjmp = llvm::Intrinsic::getDeclaration(getModule(), llvm::Intrinsic::longjmp);
|
|
|
|
|
|
|
|
// Unpack data
|
|
|
|
auto rtPtr = getRuntimePtr();
|
|
|
|
m_dataPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(rtPtr, 0), "data");
|
|
|
|
assert(m_dataPtr->getType() == Type::RuntimeDataPtr);
|
|
|
|
m_envPtr = m_builder.CreateLoad(m_builder.CreateStructGEP(rtPtr, 1), "env");
|
|
|
|
assert(m_envPtr->getType() == Type::EnvPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getRuntimePtr()
|
|
|
|
{
|
|
|
|
// Expect first argument of a function to be a pointer to Runtime
|
|
|
|
auto func = m_builder.GetInsertBlock()->getParent();
|
|
|
|
auto rtPtr = &func->getArgumentList().front();
|
|
|
|
assert(rtPtr->getType() == Type::RuntimePtr);
|
|
|
|
return rtPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getDataPtr()
|
|
|
|
{
|
|
|
|
if (getMainFunction())
|
|
|
|
return m_dataPtr;
|
|
|
|
|
|
|
|
auto rtPtr = getRuntimePtr();
|
|
|
|
return m_builder.CreateLoad(m_builder.CreateStructGEP(rtPtr, 0), "data");
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getEnvPtr()
|
|
|
|
{
|
|
|
|
assert(getMainFunction()); // Available only in main function
|
|
|
|
return m_envPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getPtr(RuntimeData::Index _index)
|
|
|
|
{
|
|
|
|
llvm::Value* idxList[] = {m_builder.getInt32(0), m_builder.getInt32(0), m_builder.getInt32(_index)};
|
|
|
|
return m_builder.CreateInBoundsGEP(getDataPtr(), idxList, getName(_index) + "Ptr");
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::get(RuntimeData::Index _index)
|
|
|
|
{
|
|
|
|
return m_builder.CreateLoad(getPtr(_index), getName(_index));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuntimeManager::set(RuntimeData::Index _index, llvm::Value* _value)
|
|
|
|
{
|
|
|
|
m_builder.CreateStore(_value, getPtr(_index));
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuntimeManager::registerReturnData(llvm::Value* _offset, llvm::Value* _size)
|
|
|
|
{
|
|
|
|
set(RuntimeData::ReturnDataOffset, _offset);
|
|
|
|
set(RuntimeData::ReturnDataSize, _size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuntimeManager::registerSuicide(llvm::Value* _balanceAddress)
|
|
|
|
{
|
|
|
|
set(RuntimeData::SuicideDestAddress, _balanceAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuntimeManager::raiseException(ReturnCode _returnCode)
|
|
|
|
{
|
|
|
|
m_builder.CreateCall2(m_longjmp, getJmpBuf(), Constant::get(_returnCode));
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::get(Instruction _inst)
|
|
|
|
{
|
|
|
|
switch (_inst)
|
|
|
|
{
|
|
|
|
default: assert(false); return nullptr;
|
|
|
|
case Instruction::GAS: return get(RuntimeData::Gas);
|
|
|
|
case Instruction::ADDRESS: return get(RuntimeData::Address);
|
|
|
|
case Instruction::CALLER: return get(RuntimeData::Caller);
|
|
|
|
case Instruction::ORIGIN: return get(RuntimeData::Origin);
|
|
|
|
case Instruction::CALLVALUE: return get(RuntimeData::CallValue);
|
|
|
|
case Instruction::CALLDATASIZE: return get(RuntimeData::CallDataSize);
|
|
|
|
case Instruction::GASPRICE: return get(RuntimeData::GasPrice);
|
|
|
|
case Instruction::COINBASE: return get(RuntimeData::CoinBase);
|
|
|
|
case Instruction::TIMESTAMP: return get(RuntimeData::TimeStamp);
|
|
|
|
case Instruction::NUMBER: return get(RuntimeData::Number);
|
|
|
|
case Instruction::DIFFICULTY: return get(RuntimeData::Difficulty);
|
|
|
|
case Instruction::GASLIMIT: return get(RuntimeData::GasLimit);
|
|
|
|
case Instruction::CODESIZE: return get(RuntimeData::CodeSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getCallData()
|
|
|
|
{
|
|
|
|
auto ptr = getBuilder().CreateStructGEP(getDataPtr(), 1, "calldataPtr");
|
|
|
|
return getBuilder().CreateLoad(ptr, "calldata");
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getCode()
|
|
|
|
{
|
|
|
|
auto ptr = getBuilder().CreateStructGEP(getDataPtr(), 2, "codePtr");
|
|
|
|
return getBuilder().CreateLoad(ptr, "code");
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getJmpBuf()
|
|
|
|
{
|
|
|
|
auto ptr = getBuilder().CreateStructGEP(getRuntimePtr(), 2, "jmpbufPtr");
|
|
|
|
return getBuilder().CreateLoad(ptr, "jmpbuf");
|
|
|
|
}
|
|
|
|
|
|
|
|
llvm::Value* RuntimeManager::getGas()
|
|
|
|
{
|
|
|
|
return get(RuntimeData::Gas);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RuntimeManager::setGas(llvm::Value* _gas)
|
|
|
|
{
|
|
|
|
llvm::Value* idxList[] = {m_builder.getInt32(0), m_builder.getInt32(0), m_builder.getInt32(RuntimeData::Gas)};
|
|
|
|
auto ptr = m_builder.CreateInBoundsGEP(getDataPtr(), idxList, "gasPtr");
|
|
|
|
m_builder.CreateStore(_gas, ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|