source: CIVL/notes/notes.txt@ 793cfc2

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since 793cfc2 was 0e2797d, checked in by Stephen Siegel <siegel@…>, 13 years ago

Working on heap stuff.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@162 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 2.1 KB
Line 
1
2For implementing malloc:
3
4Add sizeof expression in model.
5
6During model building, count the malloc statements.
7Every time you come to a malloc call, create a new system
8function:
9
10T* __malloc__i($heap *h, int size);
11
12where T is obtained from the cast wrapping the malloc
13and i is the counter.
14Add this to the model and use this in the translation.
15Maybe even create a special class for it extending
16FunctionCall.
17
18Complete the $heap type:
19 For each i, you have the static CIVL type T_i and the
20 __malloc__ function. Compute the most general symbolic
21 type t_i by translating t_i and using incomplete types
22 for arrays. Store t_i in the malloc call object.
23 let $heap be the symbolic type which is the tuple type
24
25 [array of array of t1,
26 array of array of t2,
27 array of array of t3, ...]
28
29Initial value:
30
31 [array of length 0, array of length 0, ...]
32
33Semantics:
34 to execute a __malloc__i:
35 let h be the result of evaluating the heap argument. *h is a tuple.
36 (*h).i is a concrete array. Let l be its concrete length.
37 create a new symbolic constant whose name is a function of
38 the pid, dynamic scope id, heap variable ID, index i, and
39 l. The type of this new symbolic constant is array of t_i
40 of length arg/sizeof(t+i), where arg is the result of evaluating
41 the size argument. Check that it evenly divides, and log
42 an error if it might not. Now append this symbolic constant
43 to the concrete array. [Really need a method in SARL to do this.]
44 Anyway, since it is concrete, get its sequence and append on to that.
45 Return the reference with tree:
46 - ref to heap (h)
47 - tuple component ref (i)
48 - array element reference (l)
49 - array element reference (0)
50 which is a reference to the first element of the newly allocated
51 array.
52
53
54free: sets the value in the heap array to some symbolic constant
55UNDEFINED of type array of t_i.
56
57Canonicalization: map
58 Ref[h,i,l,0] -> Ref[h,i,l',0]
59 H_p_s_v_i_l -> H_p_s_v_i_l' (symbolic constants)
60
61
62
63---
64
65
66Think about moving more stuff into model factory, like pointer value
67manipulation
68
69better printing of model
70
71better printing of states during execution
Note: See TracBrowser for help on using the repository browser.