@@ -148,7 +148,7 @@ uint64_t VM::gasForMem(intx::uint512 const& _size)
148148void VM::updateIOGas ()
149149{
150150 if (m_io_gas < m_runGas)
151- throwOutOfGas () ;
151+ throw EVMC_OUT_OF_GAS ;
152152 m_io_gas -= m_runGas;
153153}
154154
@@ -158,7 +158,7 @@ void VM::updateGas()
158158 m_runGas += toInt63 (gasForMem (m_newMemSize) - gasForMem (m_mem.size ()));
159159 m_runGas += (VMSchedule::copyGas * ((m_copyMemSize + 31 ) / 32 ));
160160 if (m_io_gas < m_runGas)
161- throwOutOfGas () ;
161+ throw EVMC_OUT_OF_GAS ;
162162}
163163
164164void VM::updateMem (uint64_t _newMem)
@@ -239,9 +239,9 @@ void VM::interpretCases()
239239 {
240240 ON_OP ();
241241 if (m_rev < EVMC_CONSTANTINOPLE)
242- throwBadInstruction () ;
242+ throw EVMC_BAD_JUMP_DESTINATION ;
243243 if (m_message->flags & EVMC_STATIC)
244- throwDisallowedStateChange () ;
244+ throw EVMC_STATIC_MODE_VIOLATION ;
245245
246246 m_bounce = &VM::caseCreate;
247247 }
@@ -251,7 +251,7 @@ void VM::interpretCases()
251251 {
252252 ON_OP ();
253253 if (m_message->flags & EVMC_STATIC)
254- throwDisallowedStateChange () ;
254+ throw EVMC_STATIC_MODE_VIOLATION ;
255255
256256 m_bounce = &VM::caseCreate;
257257 }
@@ -264,11 +264,11 @@ void VM::interpretCases()
264264 {
265265 ON_OP ();
266266 if (m_OP == Instruction::DELEGATECALL && m_rev < EVMC_HOMESTEAD)
267- throwBadInstruction () ;
267+ throw EVMC_UNDEFINED_INSTRUCTION ;
268268 if (m_OP == Instruction::STATICCALL && m_rev < EVMC_BYZANTIUM)
269- throwBadInstruction () ;
269+ throw EVMC_UNDEFINED_INSTRUCTION ;
270270 if (m_OP == Instruction::CALL && m_message->flags & EVMC_STATIC && m_SP[2 ] != 0 )
271- throwDisallowedStateChange () ;
271+ throw EVMC_STATIC_MODE_VIOLATION ;
272272 m_bounce = &VM::caseCall;
273273 }
274274 BREAK
@@ -291,22 +291,24 @@ void VM::interpretCases()
291291 {
292292 // Pre-byzantium
293293 if (m_rev < EVMC_BYZANTIUM)
294- throwBadInstruction () ;
294+ throw EVMC_UNDEFINED_INSTRUCTION ;
295295
296296 ON_OP ();
297297 m_copyMemSize = 0 ;
298298 updateMem (memNeed (m_SP[0 ], m_SP[1 ]));
299299 updateIOGas ();
300300
301- throwRevertInstruction (static_cast <uint64_t >(m_SP[0 ]), static_cast <uint64_t >(m_SP[1 ]));
301+ m_output = owning_bytes_ref{
302+ std::move (m_mem), static_cast <uint64_t >(m_SP[0 ]), static_cast <uint64_t >(m_SP[1 ])};
303+ throw EVMC_REVERT;
302304 }
303305 BREAK;
304306
305307 CASE (SELFDESTRUCT)
306308 {
307309 ON_OP ();
308310 if (m_message->flags & EVMC_STATIC)
309- throwDisallowedStateChange () ;
311+ throw EVMC_STATIC_MODE_VIOLATION ;
310312
311313 auto const destination = intx::be::trunc<evmc::address>(m_SP[0 ]);
312314
@@ -393,7 +395,7 @@ void VM::interpretCases()
393395 {
394396 ON_OP ();
395397 if (m_message->flags & EVMC_STATIC)
396- throwDisallowedStateChange () ;
398+ throw EVMC_STATIC_MODE_VIOLATION ;
397399
398400 logGasMem ();
399401 updateIOGas ();
@@ -410,7 +412,7 @@ void VM::interpretCases()
410412 {
411413 ON_OP ();
412414 if (m_message->flags & EVMC_STATIC)
413- throwDisallowedStateChange () ;
415+ throw EVMC_STATIC_MODE_VIOLATION ;
414416
415417 logGasMem ();
416418 updateIOGas ();
@@ -430,7 +432,7 @@ void VM::interpretCases()
430432 {
431433 ON_OP ();
432434 if (m_message->flags & EVMC_STATIC)
433- throwDisallowedStateChange () ;
435+ throw EVMC_STATIC_MODE_VIOLATION ;
434436
435437 logGasMem ();
436438 updateIOGas ();
@@ -451,7 +453,7 @@ void VM::interpretCases()
451453 {
452454 ON_OP ();
453455 if (m_message->flags & EVMC_STATIC)
454- throwDisallowedStateChange () ;
456+ throw EVMC_STATIC_MODE_VIOLATION ;
455457
456458 logGasMem ();
457459 updateIOGas ();
@@ -472,7 +474,7 @@ void VM::interpretCases()
472474 {
473475 ON_OP ();
474476 if (m_message->flags & EVMC_STATIC)
475- throwDisallowedStateChange () ;
477+ throw EVMC_STATIC_MODE_VIOLATION ;
476478
477479 logGasMem ();
478480 updateIOGas ();
@@ -681,7 +683,7 @@ void VM::interpretCases()
681683 {
682684 // Pre-constantinople
683685 if (m_rev < EVMC_CONSTANTINOPLE)
684- throwBadInstruction () ;
686+ throw EVMC_UNDEFINED_INSTRUCTION ;
685687
686688 ON_OP ();
687689 updateIOGas ();
@@ -697,7 +699,7 @@ void VM::interpretCases()
697699 {
698700 // Pre-constantinople
699701 if (m_rev < EVMC_CONSTANTINOPLE)
700- throwBadInstruction () ;
702+ throw EVMC_UNDEFINED_INSTRUCTION ;
701703
702704 ON_OP ();
703705 updateIOGas ();
@@ -713,7 +715,7 @@ void VM::interpretCases()
713715 {
714716 // Pre-constantinople
715717 if (m_rev < EVMC_CONSTANTINOPLE)
716- throwBadInstruction () ;
718+ throw EVMC_UNDEFINED_INSTRUCTION ;
717719
718720 ON_OP ();
719721 updateIOGas ();
@@ -781,7 +783,7 @@ void VM::interpretCases()
781783 CASE (JUMPTO) CASE (JUMPIF) CASE (JUMPV) CASE (JUMPSUB) CASE (JUMPSUBV) CASE (RETURNSUB)
782784 CASE (BEGINSUB) CASE (BEGINDATA) CASE (GETLOCAL) CASE (PUTLOCAL)
783785 {
784- throwBadInstruction () ;
786+ throw EVMC_UNDEFINED_INSTRUCTION ;
785787 }
786788 CONTINUE
787789
@@ -817,7 +819,7 @@ void VM::interpretCases()
817819 CASE (XPUT)
818820 CASE (XGET)
819821 CASE (XSWIZZLE)
820- CASE (XSHUFFLE) { throwBadInstruction () ; }
822+ CASE (XSHUFFLE) { throw EVMC_UNDEFINED_INSTRUCTION ; }
821823 CONTINUE
822824
823825 CASE (ADDRESS)
@@ -905,7 +907,7 @@ void VM::interpretCases()
905907 CASE (RETURNDATASIZE)
906908 {
907909 if (m_rev < EVMC_BYZANTIUM)
908- throwBadInstruction () ;
910+ throw EVMC_UNDEFINED_INSTRUCTION ;
909911
910912 ON_OP ();
911913 updateIOGas ();
@@ -950,10 +952,10 @@ void VM::interpretCases()
950952 {
951953 ON_OP ();
952954 if (m_rev < EVMC_BYZANTIUM)
953- throwBadInstruction () ;
955+ throw EVMC_UNDEFINED_INSTRUCTION ;
954956 intx::uint512 const endOfAccess = intx::uint512 (m_SP[1 ]) + intx::uint512 (m_SP[2 ]);
955957 if (m_returnData.size () < endOfAccess)
956- throwBufferOverrun () ;
958+ throw EVMC_INVALID_MEMORY_ACCESS ;
957959
958960 m_copyMemSize = toInt63 (m_SP[2 ]);
959961 updateMem (memNeed (m_SP[0 ], m_SP[2 ]));
@@ -967,7 +969,7 @@ void VM::interpretCases()
967969 {
968970 ON_OP ();
969971 if (m_rev < EVMC_CONSTANTINOPLE)
970- throwBadInstruction () ;
972+ throw EVMC_UNDEFINED_INSTRUCTION ;
971973
972974 updateIOGas ();
973975
@@ -1091,7 +1093,7 @@ void VM::interpretCases()
10911093 ON_OP ();
10921094
10931095 if (m_rev < EVMC_ISTANBUL)
1094- throwBadInstruction () ;
1096+ throw EVMC_UNDEFINED_INSTRUCTION ;
10951097
10961098 updateIOGas ();
10971099
@@ -1104,7 +1106,7 @@ void VM::interpretCases()
11041106 ON_OP ();
11051107
11061108 if (m_rev < EVMC_ISTANBUL)
1107- throwBadInstruction () ;
1109+ throw EVMC_UNDEFINED_INSTRUCTION ;
11081110
11091111 updateIOGas ();
11101112
@@ -1138,7 +1140,7 @@ void VM::interpretCases()
11381140 m_SPP[0 ] = m_pool[off];
11391141 TRACE_VAL (2 , " Retrieved pooled const" , m_SPP[0 ]);
11401142#else
1141- throwBadInstruction () ;
1143+ throw EVMC_UNDEFINED_INSTRUCTION ;
11421144#endif
11431145 }
11441146 CONTINUE
@@ -1225,7 +1227,7 @@ void VM::interpretCases()
12251227
12261228 m_PC = uint64_t (m_SP[0 ]);
12271229#else
1228- throwBadInstruction () ;
1230+ throw EVMC_UNDEFINED_INSTRUCTION ;
12291231#endif
12301232 }
12311233 CONTINUE
@@ -1241,7 +1243,7 @@ void VM::interpretCases()
12411243 else
12421244 ++m_PC;
12431245#else
1244- throwBadInstruction () ;
1246+ throw EVMC_UNDEFINED_INSTRUCTION ;
12451247#endif
12461248 }
12471249 CONTINUE
@@ -1304,10 +1306,10 @@ void VM::interpretCases()
13041306 {
13051307 ON_OP ();
13061308 if (m_message->flags & EVMC_STATIC)
1307- throwDisallowedStateChange () ;
1309+ throw EVMC_STATIC_MODE_VIOLATION ;
13081310
13091311 if (m_rev >= EVMC_ISTANBUL && m_io_gas <= VMSchedule::callStipend)
1310- throwOutOfGas () ;
1312+ throw EVMC_OUT_OF_GAS ;
13111313
13121314 auto const key = intx::be::store<evmc_uint256be>(m_SP[0 ]);
13131315 auto const value = intx::be::store<evmc_uint256be>(m_SP[1 ]);
@@ -1373,9 +1375,9 @@ void VM::interpretCases()
13731375 CASE (INVALID) DEFAULT
13741376 {
13751377 if (m_OP == Instruction::INVALID)
1376- throwInvalidInstruction () ;
1378+ throw EVMC_INVALID_INSTRUCTION ;
13771379 else
1378- throwBadInstruction () ;
1380+ throw EVMC_UNDEFINED_INSTRUCTION ;
13791381 }
13801382 }
13811383 WHILE_CASES
0 commit comments