Skip to content

Commit

Permalink
Revert "debug pring"
Browse files Browse the repository at this point in the history
This reverts commit 0f69a50.
  • Loading branch information
sunny2022da committed Feb 19, 2024
1 parent dbb3cd1 commit 06021b8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 44 deletions.
1 change: 0 additions & 1 deletion core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (
}()
}

log.Warn("Interpreter Run (gasps)", "ContractAddr", contract.Address(), "CodeAddress", contract.CodeAddr, "Code", common.Bytes2Hex(contract.Code))
// The Interpreter main run loop (contextual). This loop runs until either an
// explicit STOP, RETURN or SELFDESTRUCT is executed, an error occurred during
// the execution of one of the operations or until the done flag is set by the
Expand Down
43 changes: 0 additions & 43 deletions core/vm/opcodeProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ func GenOrLoadOptimizedCode(address common.Address, code []byte, codeHash common
//TODO - dav: - make following in one func.
//todo - dav: if cache number > 5. clear. maybe instead reinstall at setcallcode().
err = codeCache.UpdateCodeCache(address, processedCode, codeHash)

log.Warn("GenerateOptimizedCode (gasps)", "address", address.Hex())
log.Warn("GenerateOptimizedCode (gasps)", "orgStr", codeToString(code))
log.Warn("GenerateOptimizedCode (gasps)", "optStr", codeToString(processedCode))

if err != nil {
log.Error("Not update code cache", "err", err)
}
Expand Down Expand Up @@ -109,9 +104,6 @@ func doCodeFusion(code []byte) ([]byte, error) {
// ShlAndSub is actually worked like pushed an uint256,
// todo-dav: replace with push32.
op := ShlAndSub

log.Warn("Optimize Code (gasps)", "code", op.String())

fusedCode[cur] = byte(op)
codeCache := compiler.GetOpCodeCacheInstance()
codeCache.CacheShlAndSubMap(x, y, z, val)
Expand All @@ -135,7 +127,6 @@ func doCodeFusion(code []byte) ([]byte, error) {
code4 := OpCode(fusedCode[cur+4])
if code0 == AND && code1 == SWAP1 && code2 == POP && code3 == SWAP2 && code4 == SWAP1 {
op := AndSwap1PopSwap2Swap1
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
fusedCode[cur+2] = byte(Nop)
Expand All @@ -147,7 +138,6 @@ func doCodeFusion(code []byte) ([]byte, error) {
// Test zero and Jump. target offset at code[2-3]
if code0 == ISZERO && code1 == PUSH2 && code4 == JUMPI {
op := JumpIfZero
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
fusedCode[cur+4] = byte(Nop)
Expand All @@ -174,7 +164,6 @@ func doCodeFusion(code []byte) ([]byte, error) {
code3 := OpCode(fusedCode[cur+3])
if code0 == SWAP2 && code1 == SWAP1 && code2 == POP && code3 == JUMP {
op := Swap2Swap1PopJump
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
fusedCode[cur+2] = byte(Nop)
Expand All @@ -184,7 +173,6 @@ func doCodeFusion(code []byte) ([]byte, error) {

if code0 == SWAP1 && code1 == POP && code2 == SWAP2 && code3 == SWAP1 {
op := Swap1PopSwap2Swap1
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
fusedCode[cur+2] = byte(Nop)
Expand All @@ -194,7 +182,6 @@ func doCodeFusion(code []byte) ([]byte, error) {

if code0 == POP && code1 == SWAP2 && code2 == SWAP1 && code3 == POP {
op := PopSwap2Swap1Pop
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
fusedCode[cur+2] = byte(Nop)
Expand All @@ -204,23 +191,20 @@ func doCodeFusion(code []byte) ([]byte, error) {
// push and jump
if code0 == PUSH2 && code3 == JUMP {
op := Push2Jump
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+3] = byte(Nop)
skipToNext = true
}

if code0 == PUSH2 && code3 == JUMPI {
op := Push2JumpI
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+3] = byte(Nop)
skipToNext = true
}

if code0 == PUSH1 && code2 == PUSH1 {
op := Push1Push1
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+2] = byte(Nop)
skipToNext = true
Expand All @@ -239,22 +223,19 @@ func doCodeFusion(code []byte) ([]byte, error) {
if code0 == PUSH1 {
if code2 == ADD {
op := Push1Add
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+2] = byte(Nop)
skipToNext = true
}
if code2 == SHL {
op := Push1Shl
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+2] = byte(Nop)
skipToNext = true
}

if code2 == DUP1 {
op := Push1Dup1
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+2] = byte(Nop)
skipToNext = true
Expand All @@ -273,46 +254,40 @@ func doCodeFusion(code []byte) ([]byte, error) {

if code0 == SWAP1 && code1 == POP {
op := Swap1Pop
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
skipToNext = true
}
if code0 == POP && code1 == JUMP {
op := PopJump
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
skipToNext = true
}

if code0 == POP && code1 == POP {
op := Pop2
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
skipToNext = true
}

if code0 == SWAP2 && code1 == SWAP1 {
op := Swap2Swap1
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
skipToNext = true
}

if code0 == SWAP2 && code1 == POP {
op := Swap2Pop
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
skipToNext = true
}

if code0 == DUP2 && code1 == LT {
op := Dup2LT
log.Warn("Optimize Code (gasps)", "code", op.String())
fusedCode[cur] = byte(op)
fusedCode[cur+1] = byte(Nop)
skipToNext = true
Expand Down Expand Up @@ -364,21 +339,3 @@ func calculateSkipSteps(code []byte, cur int) (skip bool, steps int) {
}
return skip, steps
}

func codeToString(code []byte) string {
length := len(code)
codeStr := ""
for i := 0; i < length; i++ {
cur := i
opcode := OpCode(code[i])
codeStr += opcode.String() + " "

skip, steps := calculateSkipSteps(code, cur)
if skip {
i += steps
continue
}

}
return codeStr
}

0 comments on commit 06021b8

Please sign in to comment.