-
Notifications
You must be signed in to change notification settings - Fork 2.2k
SIMD #4201
SIMD #4201
Changes from 3 commits
d239486
6702b18
f372161
18bc1c8
cbe4b17
5bca159
f17ed62
8a68de6
e232db4
631c875
e2c2a0a
53be05a
1809582
5ad949e
7d0fae1
cdf9b02
65cf38b
30b996c
a4fcfc9
b4bacee
05a1e2e
59250cc
77769e8
7d2c989
7136b98
d7cc1e9
0e0d45d
bbfeb5d
45dbc24
b242a2c
d2201dd
4405261
a860a9d
25e009e
e17b1a5
d14407e
efb99c0
4011184
0f3f057
939832c
4bfa739
47afcf2
883c8b4
bf1d1dd
63fe8ba
7f78291
c9b3bfe
e803179
9e487a6
67ab2a7
d2c2e80
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ set(SOURCES | |
VM.cpp | ||
VMOpt.cpp | ||
VMCalls.cpp | ||
VMSIMD.cpp | ||
VMValidate.cpp | ||
VMFactory.cpp | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,6 @@ | |
You should have received a copy of the GNU General Public License | ||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
/** @file VM.cpp | ||
*/ | ||
|
||
#include <libethereum/ExtVM.h> | ||
#include "VMConfig.h" | ||
|
@@ -115,6 +113,22 @@ void VM::adjustStack(unsigned _removed, unsigned _added) | |
#endif | ||
} | ||
|
||
void VM::sstoreGas() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe name it |
||
{ | ||
if (m_ext->staticCall) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better leave this check out of the function updating the gas, it't not related to gas in any way There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I copied the existing code in SSTORE exactly. Could move this one piece to SSTORE and to XSTORE? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I should, it's included as a preamble to lots of functions that way. Somebody slipped them in while I wasn't looking ;) |
||
throwDisallowedStateChange(); | ||
|
||
if (!m_ext->store(m_SP[0]) && m_SP[1]) | ||
m_runGas = toInt63(m_schedule->sstoreSetGas); | ||
else if (m_ext->store(m_SP[0]) && !m_SP[1]) | ||
{ | ||
m_runGas = toInt63(m_schedule->sstoreResetGas); | ||
m_ext->sub.refunds += m_schedule->sstoreRefundGas; | ||
} | ||
else | ||
m_runGas = toInt63(m_schedule->sstoreResetGas); | ||
} | ||
|
||
|
||
uint64_t VM::gasForMem(u512 _size) | ||
{ | ||
|
@@ -643,7 +657,296 @@ void VM::interpretCases() | |
number &= mask; | ||
} | ||
} | ||
NEXT | ||
NEXT | ||
|
||
#if EIP_616 | ||
|
||
CASE(XADD) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
uint8_t nt = m_code[++m_PC]; | ||
xadd(nt); | ||
++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XMUL) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xmul(m_code[++m_PC]); ++m_PC; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better put each statement on the separate line for readability and easier debugging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created one function for advancing the PC and fetching the simd type. |
||
} | ||
CONTINUE | ||
|
||
CASE(XSUB) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsub(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XDIV) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xdiv(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSDIV) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsdiv(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XMOD) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xmod(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSMOD) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsmod(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XLT) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xlt(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XGT) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xgt(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSLT) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xslt(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSGT) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsgt(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XEQ) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xeq(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XISZERO) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xzero(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XAND) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xand(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XXOR) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xoor(m_code[++m_PC]); ++m_PC; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think xoor is a typo and only one of them is needed, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong. Seems |
||
} | ||
CONTINUE | ||
|
||
CASE(XNOT) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xnot(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSHL) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xshl(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSHR) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xshr(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSAR) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsar(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XROL) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xrol(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XROR) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xror(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XMLOAD) | ||
{ | ||
updateMem(toInt63(m_SP[0]) + 32); | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xmload(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XMSTORE) | ||
{ | ||
updateMem(toInt63(m_SP[0]) + 32); | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xmstore(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSLOAD) | ||
{ | ||
m_runGas = toInt63(m_schedule->sloadGas); | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsload(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSSTORE) | ||
{ | ||
sstoreGas(); | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xsstore(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XVTOWIDE) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xvtowide(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XWIDETOV) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xwidetov(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XPUSH) | ||
{ | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
xpush(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XPUT) | ||
{ | ||
uint8_t b = ++m_PC; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably because I forgot. Thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh - ON_OP() just because I forgot. The rest because they have complicated gas functions I haven't written yet. |
||
uint8_t c = ++m_PC; | ||
xput(m_code[b], m_code[c]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XGET) | ||
{ | ||
uint8_t b = ++m_PC; | ||
uint8_t c = ++m_PC; | ||
xget(m_code[b], m_code[c]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSWIZZLE) | ||
{ | ||
xswizzle(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
|
||
CASE(XSHUFFLE) | ||
{ | ||
xshuffle(m_code[++m_PC]); ++m_PC; | ||
} | ||
CONTINUE | ||
#endif | ||
|
||
CASE(ADDRESS) | ||
{ | ||
|
@@ -1140,18 +1443,7 @@ void VM::interpretCases() | |
|
||
CASE(SSTORE) | ||
{ | ||
if (m_ext->staticCall) | ||
throwDisallowedStateChange(); | ||
|
||
if (!m_ext->store(m_SP[0]) && m_SP[1]) | ||
m_runGas = toInt63(m_schedule->sstoreSetGas); | ||
else if (m_ext->store(m_SP[0]) && !m_SP[1]) | ||
{ | ||
m_runGas = toInt63(m_schedule->sstoreResetGas); | ||
m_ext->sub.refunds += m_schedule->sstoreRefundGas; | ||
} | ||
else | ||
m_runGas = toInt63(m_schedule->sstoreResetGas); | ||
sstoreGas(); | ||
ON_OP(); | ||
updateIOGas(); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we agreed on keeping these @file directives in the files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think (could be wrong) Pawel asked me to remove them. I took a lot out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chriseth ?