1
2
3
4
5 package ssa
6
7 import (
8 "cmd/internal/obj"
9 "sort"
10 )
11
12
13
14 type Cache struct {
15
16 values [2000]Value
17 blocks [200]Block
18 locs [2000]Location
19
20
21
22 stackAllocState *stackAllocState
23
24 domblockstore []ID
25 scrSparseSet []*sparseSet
26 scrSparseMap []*sparseMap
27 scrPoset []*poset
28
29
30 deadcode struct {
31 liveOrderStmts []*Value
32 live []bool
33 q []*Value
34 }
35
36 regallocValues []valState
37
38 ValueToProgAfter []*obj.Prog
39 debugState debugState
40
41 Liveness interface{}
42 }
43
44 func (c *Cache) Reset() {
45 nv := sort.Search(len(c.values), func(i int) bool { return c.values[i].ID == 0 })
46 xv := c.values[:nv]
47 for i := range xv {
48 xv[i] = Value{}
49 }
50 nb := sort.Search(len(c.blocks), func(i int) bool { return c.blocks[i].ID == 0 })
51 xb := c.blocks[:nb]
52 for i := range xb {
53 xb[i] = Block{}
54 }
55 nl := sort.Search(len(c.locs), func(i int) bool { return c.locs[i] == nil })
56 xl := c.locs[:nl]
57 for i := range xl {
58 xl[i] = nil
59 }
60
61
62
63 for i := range c.regallocValues {
64 c.regallocValues[i] = valState{}
65 }
66
67
68
69 c.deadcode.liveOrderStmts = c.deadcode.liveOrderStmts[:cap(c.deadcode.liveOrderStmts)]
70 no := sort.Search(len(c.deadcode.liveOrderStmts), func(i int) bool { return c.deadcode.liveOrderStmts[i] == nil })
71 xo := c.deadcode.liveOrderStmts[:no]
72 for i := range xo {
73 xo[i] = nil
74 }
75 c.deadcode.q = c.deadcode.q[:cap(c.deadcode.q)]
76 nq := sort.Search(len(c.deadcode.q), func(i int) bool { return c.deadcode.q[i] == nil })
77 xq := c.deadcode.q[:nq]
78 for i := range xq {
79 xq[i] = nil
80 }
81 }
82
View as plain text