This repository was archived by the owner on Oct 28, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-14
lines changed
Expand file tree Collapse file tree 1 file changed +17
-14
lines changed Original file line number Diff line number Diff line change @@ -635,11 +635,7 @@ void VM::interpretCases()
635635 if (m_SP[0 ] >= 256 )
636636 m_SPP[0 ] = 0 ;
637637 else
638- {
639- // / This workarounds a bug in Boost...
640- u256 mask = (u256 (1 ) << (256 - m_SP[0 ])) - 1 ;
641- m_SPP[0 ] = (m_SP[1 ] & mask) << m_SP[0 ];
642- }
638+ m_SPP[0 ] = m_SP[1 ] << unsigned (m_SP[0 ]);
643639 }
644640 NEXT
645641
@@ -651,8 +647,7 @@ void VM::interpretCases()
651647 if (m_SP[0 ] >= 256 )
652648 m_SPP[0 ] = 0 ;
653649 else
654- // / TODO: confirm shift >= 256 results in 0 on Boost
655- m_SPP[0 ] = m_SP[1 ] >> m_SP[0 ];
650+ m_SPP[0 ] = m_SP[1 ] >> unsigned (m_SP[0 ]);
656651 }
657652 NEXT
658653
@@ -661,17 +656,25 @@ void VM::interpretCases()
661656 ON_OP ();
662657 updateIOGas ();
663658
664- s256 value = u2s (m_SP[1 ]);
665- u256 shift = m_SP[0 ];
666- if (shift >= 256 )
659+ static u256 const hibit = u256 (1 ) << 255 ;
660+ static u256 const allbits =
661+ u256 (" 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" );
662+
663+ u256 shiftee = m_SP[1 ];
664+ if (m_SP[0 ] >= 256 )
667665 {
668- if (value >= 0 )
669- m_SPP[0 ] = 0 ;
666+ if (shiftee & hibit )
667+ m_SPP[0 ] = allbits ;
670668 else
671- m_SPP[0 ] = s2u (- 1 ) ;
669+ m_SPP[0 ] = 0 ;
672670 }
673671 else
674- m_SPP[0 ] = s2u (divWorkaround (value, exp256 (2 , shift)));
672+ {
673+ unsigned amount = unsigned (m_SP[0 ]);
674+ m_SPP[0 ] = shiftee >> amount;
675+ if (shiftee & hibit)
676+ m_SPP[0 ] |= allbits << (256 - amount);
677+ }
675678 }
676679 NEXT
677680#endif
You can’t perform that action at this time.
0 commit comments