summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-01-29 09:25:26 -0800
committerOri Bernstein <ori@eigenstate.org>2019-01-29 09:25:26 -0800
commit8d7247af269b3b0ef283f3b01f31980f686ae217 (patch)
tree8e68189b020b24eab5604c3afe328e427e017004
parent9b864a2bc7fbdae40704708a6893e6f29ad48397 (diff)
downloadmc-8d7247af269b3b0ef283f3b01f31980f686ae217.tar.gz
Remove pointless call overhead and casting.
-rw-r--r--lib/std/varargs.myr49
1 files changed, 16 insertions, 33 deletions
diff --git a/lib/std/varargs.myr b/lib/std/varargs.myr
index 6f5aa30..90c2945 100644
--- a/lib/std/varargs.myr
+++ b/lib/std/varargs.myr
@@ -14,7 +14,7 @@ pkg std =
;;
type valist = struct
- args : byte#
+ args : intptr
tc : typecursor
;;
@@ -28,7 +28,7 @@ type valist = struct
* force varargs onto the stack regardless.
*/
const vastart = {args
- var tc, a, ip
+ var tc, a
/*
pull out the args. These are on the stacks like so:
@@ -47,8 +47,7 @@ const vastart = {args
*/
tc = typeenc(args)
- ip = (args : intptr) + sizeof(byte#)
- a = (ip : byte#)
+ a = (args : intptr) + sizeof(byte#)
-> [.args = a, .tc = tc]
}
@@ -68,32 +67,28 @@ const vaenter = {ap
}
const cursoralign = {arg, ty
- var ti, align, p
+ var ti, align
ti = typeinfo(ty)
/* apply the alignment to the arg pointer */
align = (ti.align : intptr)
- p = (arg : intptr)
- p = (p + align - 1) & ~(align - 1)
- -> (p : byte#)
+ -> (arg + align - 1) & ~(align - 1)
}
const vaenterunion = {ap, elt
- var sub, ti, p, align
+ var sub, ti, align
ti = typeinfo(tcpeek(&ap.tc))
align = (ti.align : intptr)
- p = (ap.args : intptr)
- p = (p + align - 1) & ~(align - 1)
- ap.args = (p : byte#)
+ ap.args = (ap.args + align - 1) & ~(align - 1)
match typedesc(vatype(ap))
| `Tyunion nc:
for var i = 0; i < elt; i++
ncnext(&nc)
;;
(_, sub) = ncnext(&nc)
- -> [.args=addp(ap.args, 4), .tc=typeenccursor(sub)]
+ -> [.args=ap.args + 4, .tc=typeenccursor(sub)]
| t: std.die("type is not a union\n")
;;
}
@@ -103,56 +98,44 @@ const vatype = {ap
}
const vabytes = {ap
- var sl
- var ti, align, sz
- var p
+ var sl, ti, align, p
ti = typeinfo(tcpeek(&ap.tc))
/* apply the alignment to the arg pointer */
align = (ti.align : intptr)
- p = (ap.args : intptr)
- p = (p + align - 1) & ~(align - 1)
- ap.args = (p : byte#)
+ p = (ap.args + align - 1) & ~(align - 1)
- sl = ap.args[:ti.size]
+ sl = (ap.args : byte#)[:ti.size]
tcnext(&ap.tc)
- sz = (ti.size : intptr)
- ap.args = ((p : intptr) + sz : byte#)
+ ap.args = p + (ti.size : intptr)
-> sl
}
generic vanext = {ap -> @a
- var ti
- var align
- var p
+ var ti, align, p
ti = typeinfo(tcpeek(&ap.tc))
/* apply the alignment to the arg pointer */
align = (ti.align : intptr)
- p = (ap.args : intptr)
- p = (p + align - 1) & ~(align - 1)
+ p = (ap.args + align - 1) & ~(align - 1)
/* TODO: check for type mismatch */
tcnext(&ap.tc)
/* only move on after we read through the value */
- ap.args = ((p : intptr) + sizeof(@a) : byte#)
+ ap.args = p + sizeof(@a)
-> (p : @a#)#
}
-const addp = {p, k
- -> ((p : intptr) + k : byte#)
-}
-
const sliceptr = {pp
var p
p = (pp : intptr)
p = (p + 0x7) & ~0x7
- -> (p : byte##)#
+ -> (p : intptr#)#
}
const slicelen = {pp