@@ -442,42 +442,42 @@ func BenchmarkSimpleLoop(b *testing.B) {
442442 // Call identity, and pop return value
443443 staticCallIdentity := p .
444444 StaticCall (nil , 0x4 , 0 , 0 , 0 , 0 ).
445- Op (vm .POP ).Jump (lbl ).Bytecode () // pop return value and jump to label
445+ Op (vm .POP ).Jump (lbl ).Bytes () // pop return value and jump to label
446446
447447 p , lbl = program .New ().Jumpdest ()
448448 callIdentity := p .
449449 Call (nil , 0x4 , 0 , 0 , 0 , 0 , 0 ).
450- Op (vm .POP ).Jump (lbl ).Bytecode () // pop return value and jump to label
450+ Op (vm .POP ).Jump (lbl ).Bytes () // pop return value and jump to label
451451
452452 p , lbl = program .New ().Jumpdest ()
453453 callInexistant := p .
454454 Call (nil , 0xff , 0 , 0 , 0 , 0 , 0 ).
455- Op (vm .POP ).Jump (lbl ).Bytecode () // pop return value and jump to label
455+ Op (vm .POP ).Jump (lbl ).Bytes () // pop return value and jump to label
456456
457457 p , lbl = program .New ().Jumpdest ()
458458 callEOA := p .
459459 Call (nil , 0xE0 , 0 , 0 , 0 , 0 , 0 ). // call addr of EOA
460- Op (vm .POP ).Jump (lbl ).Bytecode () // pop return value and jump to label
460+ Op (vm .POP ).Jump (lbl ).Bytes () // pop return value and jump to label
461461
462462 p , lbl = program .New ().Jumpdest ()
463463 // Push as if we were making call, then pop it off again, and loop
464464 loopingCode := p .Push (0 ).
465465 Ops (vm .DUP1 , vm .DUP1 , vm .DUP1 ).
466466 Push (0x4 ).
467467 Ops (vm .GAS , vm .POP , vm .POP , vm .POP , vm .POP , vm .POP , vm .POP ).
468- Jump (lbl ).Bytecode ()
468+ Jump (lbl ).Bytes ()
469469
470470 p , lbl = program .New ().Jumpdest ()
471471 loopingCode2 := p .
472472 Push (0x01020304 ).Push (uint64 (0x0102030405 )).
473473 Ops (vm .POP , vm .POP ).
474474 Op (vm .PUSH6 ).Append (make ([]byte , 6 )).Op (vm .JUMP ). // Jumpdest zero expressed in 6 bytes
475- Bytecode ()
475+ Bytes ()
476476
477477 p , lbl = program .New ().Jumpdest ()
478478 callRevertingContractWithInput := p .
479479 Call (nil , 0xee , 0 , 0 , 0x20 , 0x0 , 0x0 ).
480- Op (vm .POP ).Jump (lbl ).Bytecode () // pop return value and jump to label
480+ Op (vm .POP ).Jump (lbl ).Bytes () // pop return value and jump to label
481481
482482 //tracer := logger.NewJSONLogger(nil, os.Stdout)
483483 //Execute(loopingCode, nil, &Config{
@@ -716,104 +716,49 @@ func TestRuntimeJSTracer(t *testing.T) {
716716 this.exits++;
717717 this.gasUsed = res.getGasUsed();
718718 }}` }
719+ initcode := program .New ().Return (0 , 0 ).Bytes ()
719720 tests := []struct {
720721 code []byte
721722 // One result per tracer
722723 results []string
723724 }{
724- {
725- // CREATE
726- code : []byte {
727- // Store initcode in memory at 0x00 (5 bytes left-padded to 32 bytes)
728- byte (vm .PUSH5 ),
729- // Init code: PUSH1 0, PUSH1 0, RETURN (3 steps)
730- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .RETURN ),
731- byte (vm .PUSH1 ), 0 ,
732- byte (vm .MSTORE ),
733- // length, offset, value
734- byte (vm .PUSH1 ), 5 , byte (vm .PUSH1 ), 27 , byte (vm .PUSH1 ), 0 ,
735- byte (vm .CREATE ),
736- byte (vm .POP ),
737- },
725+ { // CREATE
726+ code : program .New ().MstorePadded (initcode , 0 ).
727+ Push (len (initcode )). // length
728+ Push (32 - len (initcode )). // offset
729+ Push (0 ). // value
730+ Op (vm .CREATE ).
731+ Op (vm .POP ).Bytes (),
738732 results : []string {`"1,1,952853,6,12"` , `"1,1,952853,6,0"` },
739733 },
740- {
741- // CREATE2
742- code : []byte {
743- // Store initcode in memory at 0x00 (5 bytes left-padded to 32 bytes)
744- byte (vm .PUSH5 ),
745- // Init code: PUSH1 0, PUSH1 0, RETURN (3 steps)
746- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .RETURN ),
747- byte (vm .PUSH1 ), 0 ,
748- byte (vm .MSTORE ),
749- // salt, length, offset, value
750- byte (vm .PUSH1 ), 1 , byte (vm .PUSH1 ), 5 , byte (vm .PUSH1 ), 27 , byte (vm .PUSH1 ), 0 ,
751- byte (vm .CREATE2 ),
752- byte (vm .POP ),
753- },
734+ { // CREATE2
735+ code : program .New ().MstorePadded (initcode , 0 ).
736+ Push (1 ). // salt
737+ Push (len (initcode )). // length
738+ Push (32 - len (initcode )). // offset
739+ Push (0 ). // value
740+ Op (vm .CREATE2 ).
741+ Op (vm .POP ).Bytes (),
754742 results : []string {`"1,1,952844,6,13"` , `"1,1,952844,6,0"` },
755743 },
756- {
757- // CALL
758- code : []byte {
759- // outsize, outoffset, insize, inoffset
760- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 ,
761- byte (vm .PUSH1 ), 0 , // value
762- byte (vm .PUSH1 ), 0xbb , //address
763- byte (vm .GAS ), // gas
764- byte (vm .CALL ),
765- byte (vm .POP ),
766- },
744+ { // CALL
745+ code : program .New ().Call (nil , 0xbb , 0 , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
767746 results : []string {`"1,1,981796,6,13"` , `"1,1,981796,6,0"` },
768747 },
769- {
770- // CALLCODE
771- code : []byte {
772- // outsize, outoffset, insize, inoffset
773- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 ,
774- byte (vm .PUSH1 ), 0 , // value
775- byte (vm .PUSH1 ), 0xcc , //address
776- byte (vm .GAS ), // gas
777- byte (vm .CALLCODE ),
778- byte (vm .POP ),
779- },
748+ { // CALLCODE
749+ code : program .New ().CallCode (nil , 0xcc , 0 , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
780750 results : []string {`"1,1,981796,6,13"` , `"1,1,981796,6,0"` },
781751 },
782- {
783- // STATICCALL
784- code : []byte {
785- // outsize, outoffset, insize, inoffset
786- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 ,
787- byte (vm .PUSH1 ), 0xdd , //address
788- byte (vm .GAS ), // gas
789- byte (vm .STATICCALL ),
790- byte (vm .POP ),
791- },
752+ { // STATICCALL
753+ code : program .New ().StaticCall (nil , 0xdd , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
792754 results : []string {`"1,1,981799,6,12"` , `"1,1,981799,6,0"` },
793755 },
794- {
795- // DELEGATECALL
796- code : []byte {
797- // outsize, outoffset, insize, inoffset
798- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 ,
799- byte (vm .PUSH1 ), 0xee , //address
800- byte (vm .GAS ), // gas
801- byte (vm .DELEGATECALL ),
802- byte (vm .POP ),
803- },
756+ { // DELEGATECALL
757+ code : program .New ().DelegateCall (nil , 0xee , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
804758 results : []string {`"1,1,981799,6,12"` , `"1,1,981799,6,0"` },
805759 },
806- {
807- // CALL self-destructing contract
808- code : []byte {
809- // outsize, outoffset, insize, inoffset
810- byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 , byte (vm .PUSH1 ), 0 ,
811- byte (vm .PUSH1 ), 0 , // value
812- byte (vm .PUSH1 ), 0xff , //address
813- byte (vm .GAS ), // gas
814- byte (vm .CALL ),
815- byte (vm .POP ),
816- },
760+ { // CALL self-destructing contract
761+ code : program .New ().Call (nil , 0xff , 0 , 0 , 0 , 0 , 0 ).Op (vm .POP ).Bytes (),
817762 results : []string {`"2,2,0,5003,12"` , `"2,2,0,5003,0"` },
818763 },
819764 }
@@ -896,16 +841,8 @@ func TestJSTracerCreateTx(t *testing.T) {
896841
897842func BenchmarkTracerStepVsCallFrame (b * testing.B ) {
898843 // Simply pushes and pops some values in a loop
899- code := []byte {
900- byte (vm .JUMPDEST ),
901- byte (vm .PUSH1 ), 0 ,
902- byte (vm .PUSH1 ), 0 ,
903- byte (vm .POP ),
904- byte (vm .POP ),
905- byte (vm .PUSH1 ), 0 , // jumpdestination
906- byte (vm .JUMP ),
907- }
908-
844+ p , lbl := program .New ().Jumpdest ()
845+ code := p .Push (0 ).Push (0 ).Ops (vm .POP , vm .POP ).Jump (lbl ).Bytes ()
909846 stepTracer := `
910847 {
911848 step: function() {},
0 commit comments