aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorJeffrey Wilcke <jeffrey@ethereum.org>2017-03-01 18:52:57 +0800
committerJeffrey Wilcke <jeffrey@ethereum.org>2017-03-01 18:52:57 +0800
commitf30733c806561a97900613517dade377bf57528c (patch)
treedc1ed9f155400721f8c9948d2f757b13e52a1164 /cmd
parentbf4155846cf1adaf03e6395a93ce911f315acdbf (diff)
downloadgo-tangerine-f30733c806561a97900613517dade377bf57528c.tar
go-tangerine-f30733c806561a97900613517dade377bf57528c.tar.gz
go-tangerine-f30733c806561a97900613517dade377bf57528c.tar.bz2
go-tangerine-f30733c806561a97900613517dade377bf57528c.tar.lz
go-tangerine-f30733c806561a97900613517dade377bf57528c.tar.xz
go-tangerine-f30733c806561a97900613517dade377bf57528c.tar.zst
go-tangerine-f30733c806561a97900613517dade377bf57528c.zip
cmd/evm: removed -sysstat and moved content to -debug flag
Added the ability to directly compile and run ethereum assembly using the evm utility: `evm run <file>`. This is equivalant to `evm compile <file> | evm run`.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/evm/main.go5
-rw-r--r--cmd/evm/runner.go33
2 files changed, 21 insertions, 17 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index 5ce45b9ca..2e7d98557 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -66,10 +66,6 @@ var (
Name: "input",
Usage: "input for the EVM",
}
- SysStatFlag = cli.BoolFlag{
- Name: "sysstat",
- Usage: "display system stats",
- }
VerbosityFlag = cli.IntFlag{
Name: "verbosity",
Usage: "sets the verbosity level",
@@ -89,7 +85,6 @@ func init() {
CreateFlag,
DebugFlag,
VerbosityFlag,
- SysStatFlag,
CodeFlag,
CodeFileFlag,
GasFlag,
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index 8a71a92f7..6ef9230f4 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -25,6 +25,7 @@ import (
goruntime "runtime"
+ "github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/state"
@@ -61,7 +62,18 @@ func runCmd(ctx *cli.Context) error {
ret []byte
err error
)
- if ctx.GlobalString(CodeFlag.Name) != "" {
+ if fn := ctx.Args().First(); len(fn) > 0 {
+ src, err := ioutil.ReadFile(fn)
+ if err != nil {
+ return err
+ }
+
+ bin, err := compiler.Compile(fn, src, false)
+ if err != nil {
+ return err
+ }
+ code = common.Hex2Bytes(bin)
+ } else if ctx.GlobalString(CodeFlag.Name) != "" {
code = common.Hex2Bytes(ctx.GlobalString(CodeFlag.Name))
} else {
var hexcode []byte
@@ -106,7 +118,7 @@ func runCmd(ctx *cli.Context) error {
ret, err = runtime.Call(receiver, common.Hex2Bytes(ctx.GlobalString(InputFlag.Name)), &runtimeConfig)
}
- vmdone := time.Since(tstart)
+ execTime := time.Since(tstart)
if ctx.GlobalBool(DumpFlag.Name) {
statedb.Commit(true)
@@ -118,19 +130,16 @@ func runCmd(ctx *cli.Context) error {
vm.WriteTrace(os.Stderr, logger.StructLogs())
fmt.Fprintln(os.Stderr, "#### LOGS ####")
vm.WriteLogs(os.Stderr, statedb.Logs())
- }
- if ctx.GlobalBool(SysStatFlag.Name) {
var mem goruntime.MemStats
goruntime.ReadMemStats(&mem)
- fmt.Printf("vm took %v\n", vmdone)
- fmt.Printf(`alloc: %d
-tot alloc: %d
-no. malloc: %d
-heap alloc: %d
-heap objs: %d
-num gc: %d
-`, mem.Alloc, mem.TotalAlloc, mem.Mallocs, mem.HeapAlloc, mem.HeapObjects, mem.NumGC)
+ fmt.Fprintf(os.Stderr, `evm execution time: %v
+heap objects: %d
+allocations: %d
+total allocations: %d
+GC calls: %d
+
+`, execTime, mem.HeapObjects, mem.Alloc, mem.TotalAlloc, mem.NumGC)
}
fmt.Printf("0x%x", ret)