Skip to content

Commit

Permalink
no-cc
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Feb 25, 2024
1 parent 14ea77b commit 1484131
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 194 deletions.
170 changes: 0 additions & 170 deletions core/opcodeCompiler/compiler/OpCodeCache.go

This file was deleted.

39 changes: 22 additions & 17 deletions core/opcodeCompiler/compiler/opcodeProcessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package compiler
import (
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/holiman/uint256"
"runtime"
"sync"
)
Expand All @@ -20,8 +18,8 @@ var opcodeProcessor *OpcodeProcessor
const taskChannelSize = 1024 * 1024

type OpcodeProcessor struct {
enabled bool
codeCache *OpCodeCache
enabled bool
//codeCache *OpCodeCache
taskChannel chan optimizeTask
}

Expand All @@ -47,8 +45,8 @@ type optimizeTask struct {
func GetOpcodeProcessorInstance() *OpcodeProcessor {
initOnce.Do(func() {
opcodeProcessor = &OpcodeProcessor{
enabled: false,
codeCache: nil,
enabled: false,
//codeCache: nil,
taskChannel: make(chan optimizeTask, taskChannelSize),
}
// start task processors.
Expand All @@ -66,23 +64,25 @@ func (p *OpcodeProcessor) EnableOptimization() {
return
}
p.enabled = true
p.codeCache = getOpCodeCacheInstance()
//p.codeCache = getOpCodeCacheInstance()
}

func (p *OpcodeProcessor) DisableOptimization() {
p.enabled = false
}

// Producer functions
func (p *OpcodeProcessor) LoadOptimizedCode(address common.Address, hash common.Hash) OptCode {
if !p.enabled {
func (p *OpcodeProcessor) LoadOptimizedCode(address common.Address, hash common.Hash) []byte {
/*if !p.enabled {
return nil
}
/* Try load from cache */
// Try load from cache
codeCache := p.codeCache
processedCode := codeCache.GetCachedCode(address, hash)
return processedCode
*/
return nil
}

func (p *OpcodeProcessor) GenOrLoadOptimizedCode(address common.Address, code []byte, hash common.Hash) {
Expand Down Expand Up @@ -113,14 +113,18 @@ func (p *OpcodeProcessor) taskProcessor() {
}

func (p *OpcodeProcessor) handleOptimizationTask(task optimizeTask) {
switch task.taskType {
case generate:
p.TryGenerateOptimizedCode(task.addr, task.rawCode, task.codeHash)
case flush:
p.DeleteCodeCache(task.addr, task.codeHash)
}
/*
switch task.taskType {
case generate:
p.TryGenerateOptimizedCode(task.addr, task.rawCode, task.codeHash)
case flush:
p.DeleteCodeCache(task.addr, task.codeHash)
}
*/
}

/*
// GenOrRewriteOptimizedCode generate the optimized code and refresh the codecache.
func (p *OpcodeProcessor) GenOrRewriteOptimizedCode(address common.Address, code []byte, hash common.Hash) (OptCode, error) {
if !p.enabled {
Expand All @@ -143,7 +147,7 @@ func (p *OpcodeProcessor) TryGenerateOptimizedCode(address common.Address, code
if !p.enabled {
return nil, false, ErrOptiDisabled
}
/* Try load from cache */
// Try load from cache
codeCache := p.codeCache
processedCode := codeCache.GetCachedCode(address, hash)
hit := false
Expand Down Expand Up @@ -454,3 +458,4 @@ func calculateSkipSteps(code []byte, cur int) (skip bool, steps int) {
}
return skip, steps
}
*/
10 changes: 3 additions & 7 deletions core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package vm

import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/opcodeCompiler/compiler"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
Expand Down Expand Up @@ -936,12 +935,9 @@ func opShlAndSub(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) (
y := scope.Contract.Code[*pc+2]
z := scope.Contract.Code[*pc+3]

result := compiler.GetOpcodeProcessorInstance().GetValFromShlAndSubMap(x, y, z)
if result != nil {
result = uint256.NewInt(uint64(y))
result.Lsh(result, uint(z))
result.Sub(result, uint256.NewInt(uint64(x)))
}
result := uint256.NewInt(uint64(y))
result.Lsh(result, uint(z))
result.Sub(result, uint256.NewInt(uint64(x)))

scope.Stack.push(result)
*pc += 7
Expand Down

0 comments on commit 1484131

Please sign in to comment.