Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

SIMD #4201

Closed
wants to merge 51 commits into from
Closed

SIMD #4201

Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d239486
Fix STATICCALL giving stipend
chfast Jun 23, 2017
6702b18
redesignd stack use to minimize impact of simd on remainer of code, i…
gcolvin Jun 26, 2017
f372161
fuzzHelper wants 615 opcodes
gcolvin Jun 26, 2017
18bc1c8
Update fuzzHelper.cpp
gcolvin Jun 26, 2017
cbe4b17
Fix STATICCALL forwarding call value
chfast Jun 26, 2017
5bca159
update tests
winsvega Jun 23, 2017
f17ed62
snark: Add ECADD and ECMUL benchmark tests
chfast Jun 20, 2017
8a68de6
Fix clang build issue
chfast Jun 26, 2017
e232db4
Update tests to include two new tests about staticcall not inheriting…
pirapira Jun 26, 2017
631c875
Merge branch 'develop' into fix-staticcall
pirapira Jun 26, 2017
e2c2a0a
Merge pull request #4178 from ethereum/snark-benchmarks
pirapira Jun 26, 2017
53be05a
Update tests
pirapira Jun 26, 2017
1809582
Update tests
pirapira Jun 27, 2017
5ad949e
Merge pull request #4200 from ethereum/fix-staticcall
winsvega Jun 27, 2017
7d0fae1
redesignd stack use to minimize impact of simd on remainer of code, i…
gcolvin Jun 26, 2017
cdf9b02
fuzzHelper wants 615 opcodes
gcolvin Jun 26, 2017
65cf38b
Andrei's suggestions
gcolvin Jun 28, 2017
30b996c
conflicts
gcolvin Jun 28, 2017
a4fcfc9
commit now or comments later
gcolvin Jun 28, 2017
b4bacee
more of Andrei's suggestions, more cleanup, get it all compiling again
gcolvin Jun 30, 2017
05a1e2e
redesignd stack use to minimize impact of simd on remainer of code, i…
gcolvin Jun 26, 2017
59250cc
fuzzHelper wants 615 opcodes
gcolvin Jun 26, 2017
77769e8
more of Andrei's suggestions, more cleanup, get it all compiling again
gcolvin Jun 30, 2017
7d2c989
get instruction configuration cleaned up and working on windows, othe…
gcolvin Jul 3, 2017
7136b98
conflicts
gcolvin Jul 3, 2017
d7cc1e9
conflicts still
gcolvin Jul 4, 2017
0e0d45d
construct in place rather than assign where destination is trash, oth…
gcolvin Jul 5, 2017
bbfeb5d
Check names of GeneralStateTest test fillers against filenames
pirapira Jun 30, 2017
45dbc24
EVMJIT: STATICCALL
chfast Jun 23, 2017
b242a2c
Fix Boost build on Gentoo
chfast Jul 3, 2017
d2201dd
travis_wait 80
winsvega Jul 3, 2017
4405261
travis_wait on `brew install llvm`, which takes more than 10 minutes
pirapira Jul 4, 2017
a860a9d
eth: Drop old interactive mode
chfast Jul 4, 2017
25e009e
logs: Simplify log output handling
chfast Jul 4, 2017
e17b1a5
common: Remove SpinLock class
chfast Jul 4, 2017
d14407e
eth: Remove obsolete command line options
chfast Jul 4, 2017
efb99c0
trace to logChannel in State and DB
winsvega Jun 27, 2017
4011184
general blockchain tests
winsvega Jun 27, 2017
0f3f057
bcExample
winsvega Jun 28, 2017
939832c
more debuginfo
winsvega Jun 30, 2017
4bfa739
bcForgedTest
winsvega Jun 30, 2017
47afcf2
fix style
winsvega Jul 2, 2017
883c8b4
fix GasPricer tests
winsvega Jul 3, 2017
bf1d1dd
limit mining threads to 1 for testeth
winsvega Jul 4, 2017
63fe8ba
fix style issues
winsvega Jul 4, 2017
7f78291
correct --fillchain option for new blockchain fillers
winsvega Jul 4, 2017
c9b3bfe
fixes and style update
winsvega Jul 5, 2017
e803179
change throw 1; to exit(1)
winsvega Jul 5, 2017
9e487a6
still trying to force github to accept push
gcolvin Jul 5, 2017
67ab2a7
yes, still trying to force github to accept push
gcolvin Jul 5, 2017
d2c2e80
why am I still messing with this branch?
gcolvin Jul 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libevm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set(SOURCES
VM.cpp
VMOpt.cpp
VMCalls.cpp
VMSIMD.cpp
VMValidate.cpp
VMFactory.cpp
)
Expand Down
322 changes: 307 additions & 15 deletions libevm/VM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/

#include <libethereum/ExtVM.h>
#include "VMConfig.h"
Expand Down Expand Up @@ -115,6 +113,22 @@ void VM::adjustStack(unsigned _removed, unsigned _added)
#endif
}

void VM::sstoreGas()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe name it updateGasForSstore

{
if (m_ext->staticCall)
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

@gcolvin gcolvin Jun 27, 2017

Choose a reason for hiding this comment

The 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)
{
Expand Down Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's VM::xoor and VM::xxor , shoudn't the latter be called here?
Also where's the case for XOOR ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong. Seems xor is now a keyword, so I called the function xoor, and it needs a case to call it too.

}
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are ON_OP() and updateIOGas not called for XPUT, XGET, XSWIZZLE, XSHUFFLE ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably because I forgot. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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)
{
Expand Down Expand Up @@ -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();

Expand Down
Loading