aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encodingexec.go
diff options
context:
space:
mode:
Diffstat (limited to 'prog/encodingexec.go')
-rw-r--r--prog/encodingexec.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/prog/encodingexec.go b/prog/encodingexec.go
index b5573f60f..ae885d3b1 100644
--- a/prog/encodingexec.go
+++ b/prog/encodingexec.go
@@ -193,16 +193,15 @@ func (p *Prog) SerializeForExec(buffer []byte) (int, error) {
return len(buffer) - len(w.buf), nil
}
-func (target *Target) PhysicalAddr(arg Arg) uint64 {
- a, ok := arg.(*PointerArg)
- if !ok {
- panic("physicalAddr: bad arg kind")
+func (target *Target) PhysicalAddr(arg *PointerArg) uint64 {
+ if arg.Res == nil && arg.PagesNum == 0 {
+ return 0
}
- addr := a.PageIndex*target.PageSize + target.DataOffset
- if a.PageOffset >= 0 {
- addr += uint64(a.PageOffset)
+ addr := arg.PageIndex*target.PageSize + target.DataOffset
+ if arg.PageOffset >= 0 {
+ addr += uint64(arg.PageOffset)
} else {
- addr += target.PageSize - uint64(-a.PageOffset)
+ addr += target.PageSize - uint64(-arg.PageOffset)
}
return addr
}
@@ -256,7 +255,7 @@ func (w *execContext) writeArg(arg Arg) {
w.write(a.OpAdd)
}
case *PointerArg:
- w.writeConstArg(a.Size(), w.target.PhysicalAddr(arg), 0, 0, 0, false)
+ w.writeConstArg(a.Size(), w.target.PhysicalAddr(a), 0, 0, 0, false)
case *DataArg:
data := a.Data()
w.write(execArgData)